comparison pyink/MBScene.py @ 1146:e14ec6d1a661

CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
author wycc
date Fri, 24 Dec 2010 14:44:07 +0800
parents 8f0ee167c5b2
children 5cfa73d7e80f
comparison
equal deleted inserted replaced
1141:8f0ee167c5b2 1146:e14ec6d1a661
510 i=0 510 i=0
511 511
512 # Check the duplicated scene group and create it if it is not available 512 # Check the duplicated scene group and create it if it is not available
513 try: 513 try:
514 if layer.duplicateGroup: 514 if layer.duplicateGroup:
515 layer.duplicateGroup.parent().removeChild(layer.duplicateGroup) 515 layer.duplicateGroup.setAttribute("style","display:none")
516 layer.duplicateGroup = None
517 except: 516 except:
518 traceback.print_exc() 517 print "*"*40
518 layer.duplicateGroup = self.document.createElement("svg:g")
519 layer.duplicateGroup.setAttribute("inkscape:label","dup")
520 layer.duplicateGroup.setAttribute("sodipodi:insensitive","1")
521 layer.duplicateGroup.setAttribute("style","")
522 layer.layer.node.appendChild(layer.duplicateGroup)
519 pass 523 pass
520 # Create a new group 524 # Create a new group
521 layer.duplicateGroup = None 525 #layer.duplicateGroup = None
522 526
523 527
524 while i < len(layer._keys): 528 while i < len(layer._keys):
525 s = layer._keys[i] 529 s = layer._keys[i]
526 print s.ref.getAttribute("id"),s.idx,s.left_tween,s.right_tween 530 print s.ref.getAttribute("id"),s.idx,s.left_tween,s.right_tween
534 if nth == s.idx + 1: 538 if nth == s.idx + 1:
535 s.ref.setAttribute("style","") 539 s.ref.setAttribute("style","")
536 else: 540 else:
537 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1): 541 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1):
538 if i+2 < len(layer._keys): 542 if i+2 < len(layer._keys):
539 layer.duplicateGroup = self.document.createElement("svg:g") 543 #s.ref.parent().appendChild(layer.duplicateGroup)
540 layer.duplicateGroup.setAttribute("inkscape:label","dup")
541 layer.duplicateGroup.setAttribute("sodipodi:insensitive","1")
542 s.ref.setAttribute("style","display:none") 544 s.ref.setAttribute("style","display:none")
543 s.ref.parent().appendChild(layer.duplicateGroup) 545 layer.duplicateGroup.setAttribute("style","")
544 self.tween.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth) 546 self.tween.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth)
545 else: 547 else:
546 layer.duplicateGroup = s.ref.duplicate(self.document) 548 layer.duplicateGroup.setAttribute("style","")
547 layer.duplicateGroup.setAttribute("style","") 549 #layer.duplicateGroup = s.ref.duplicate(self.document)
548 layer.duplicateGroup.setAttribute("inkscape:label","dup") 550 #layer.duplicateGroup.setAttribute("style","")
549 layer.duplicateGroup.setAttribute("sodipodi:insensitive","1") 551 #layer.duplicateGroup.setAttribute("inkscape:label","dup")
552 #layer.duplicateGroup.setAttribute("sodipodi:insensitive","1")
550 s.ref.setAttribute("style","display:none") 553 s.ref.setAttribute("style","display:none")
551 s.ref.parent().appendChild(layer.duplicateGroup) 554 #s.ref.parent().appendChild(layer.duplicateGroup)
555 pass
552 else: 556 else:
553 s.ref.setAttribute("style","display:none") 557 s.ref.setAttribute("style","display:none")
554 i = i + 2 558 i = i + 2
555 pass 559 pass
556 pass 560 pass
742 orig = t 746 orig = t
743 break 747 break
744 if orig == None: 748 if orig == None:
745 return None 749 return None
746 ns = orig.duplicate(rdoc) 750 ns = orig.duplicate(rdoc)
747 gid = self.last_line.node.label()+self.newID() 751 gid = self.last_line.node.getAttribute('id')+self.newID()
748 self.ID[gid]=1 752 self.ID[gid]=1
749 ns.setAttribute("id",gid) 753 ns.setAttribute("id",gid)
750 ns.setAttribute("inkscape:groupmode","layer") 754 ns.setAttribute("inkscape:groupmode","layer")
751 self.last_line.node.appendChild(ns) 755 self.last_line.node.appendChild(ns)
752 return ns 756 return ns
778 self.lockui = True 782 self.lockui = True
779 self.extendScene() 783 self.extendScene()
780 self.lockui = False 784 self.lockui = False
781 #self.grid.show_all() 785 #self.grid.show_all()
782 pass 786 pass
787
783 def changeObjectLabel(self,w): 788 def changeObjectLabel(self,w):
784 o = self.desktop.selection.list()[0] 789 o = self.desktop.selection.list()[0]
785 o.setAttribute("inkscape:label", self.nameEditor.get_text()) 790 o.setAttribute("inkscape:label", self.nameEditor.get_text())
791
786 def addNameEditor(self,hbox): 792 def addNameEditor(self,hbox):
787 self.nameEditor = gtk.Entry(max=40) 793 self.nameEditor = gtk.Entry(max=40)
788 hbox.pack_start(self.nameEditor,expand=False,fill=False) 794 hbox.pack_start(self.nameEditor,expand=False,fill=False)
789 self.editDone = gtk.Button('Set') 795 self.editDone = gtk.Button('Set')
790 hbox.pack_start(self.editDone,expand=False,fill=False) 796 hbox.pack_start(self.editDone,expand=False,fill=False)
791 self.editDone.connect('clicked', self.changeObjectLabel) 797 self.editDone.connect('clicked', self.changeObjectLabel)
798
799 def doRun(self):
800 """
801 Execute the current animation till the last frame.
802 """
803
792 804
793 def addButtons(self,hbox): 805 def addButtons(self,hbox):
794 #btn = gtk.Button('Edit') 806 #btn = gtk.Button('Edit')
795 #btn.connect('clicked', self.doEditScene) 807 #btn.connect('clicked', self.doEditScene)
796 #hbox.pack_start(btn,expand=False,fill=False) 808 #hbox.pack_start(btn,expand=False,fill=False)
804 btn.connect('clicked', self.doExtendScene) 816 btn.connect('clicked', self.doExtendScene)
805 hbox.pack_start(btn,expand=False,fill=False) 817 hbox.pack_start(btn,expand=False,fill=False)
806 btn=gtk.Button('Duplicate Key') 818 btn=gtk.Button('Duplicate Key')
807 btn.connect('clicked', self.doDuplicateKeyScene) 819 btn.connect('clicked', self.doDuplicateKeyScene)
808 hbox.pack_start(btn,expand=False,fill=False) 820 hbox.pack_start(btn,expand=False,fill=False)
821 btn=gtk.Button('Run')
822 btn.connect('clicked', self.doRun)
823 hbox.pack_start(btn,expand=False,fill=False)
809 self.addNameEditor(hbox) 824 self.addNameEditor(hbox)
810 self.addTweenTypeSelector(hbox) 825 self.addTweenTypeSelector(hbox)
826
811 pass 827 pass
812 def onTweenTypeChange(self,w): 828 def onTweenTypeChange(self,w):
813 n = self.tweenTypeSelector.get_active() 829 n = self.tweenTypeSelector.get_active()
814 if self.last_line == None: 830 if self.last_line == None:
815 return 831 return