comparison pyink/MBScene.py @ 1142:dd6c60c6f41e

Use getAttribute()/spitem instead of .label and DOMtoItem(). - stop use PYSPObject.label, it should be replaced by PYNode.getAttribute(). - stop use MBScene.DOMtoItem() since we have PYNode.spitem.
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 23 Dec 2010 11:04:05 +0800
parents 8f0ee167c5b2
children 257beac7c982
comparison
equal deleted inserted replaced
1141:8f0ee167c5b2 1142:dd6c60c6f41e
370 txt.setAttribute("y","0") 370 txt.setAttribute("y","0")
371 txt.setAttribute("width","100") 371 txt.setAttribute("width","100")
372 txt.setAttribute("height","100") 372 txt.setAttribute("height","100")
373 txt.setAttribute("style","fill:#ff00") 373 txt.setAttribute("style","fill:#ff00")
374 ns.appendChild(txt) 374 ns.appendChild(txt)
375 gid = self.last_line.node.label()+self.newID() 375 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID()
376 self.ID[gid]=1 376 self.ID[gid]=1
377 ns.setAttribute("id",gid) 377 ns.setAttribute("id",gid)
378 ns.setAttribute("inkscape:groupmode","layer") 378 ns.setAttribute("inkscape:groupmode","layer")
379 self.last_line.node.appendChild(ns) 379 self.last_line.node.appendChild(ns)
380 print 'Add key ', x 380 print 'Add key ', x
554 i = i + 2 554 i = i + 2
555 pass 555 pass
556 pass 556 pass
557 pass 557 pass
558 558
559 def DOMtoItem(self,obj):
560 """
561 Find the corresponding PYSPObject object for a DOM object.
562 """
563 return self.DOMtoItem_recursive(self.desktop.doc().root(),obj)
564
565 def DOMtoItem_recursive(self,tree,obj):
566 nodes = tree.childList()
567 for s in nodes:
568 if s.getId() == obj.getAttribute('id'):
569 return s
570 d = self.DOMtoItem_recursive(s,obj)
571 if d != None: return d
572
573
574 def enterGroup(self,obj): 559 def enterGroup(self,obj):
575 for l in self.layers: 560 for l in self.layers:
576 for s in l.node.childList(): 561 for s in l.node.childList():
577 if s.getAttribute('id') == obj.getAttribute("id"): 562 if s.getAttribute('id') == obj.getAttribute("id"):
578 self.desktop.setCurrentLayer(self.DOMtoItem(s)) 563 self.desktop.setCurrentLayer(s.spitem)
579 564
580 def selectSceneObject(self,frameline, nth): 565 def selectSceneObject(self,frameline, nth):
581 i = 0 566 i = 0
582 while i < len(frameline._keys): 567 while i < len(frameline._keys):
583 s = frameline._keys[i] 568 s = frameline._keys[i]
742 orig = t 727 orig = t
743 break 728 break
744 if orig == None: 729 if orig == None:
745 return None 730 return None
746 ns = orig.duplicate(rdoc) 731 ns = orig.duplicate(rdoc)
747 gid = self.last_line.node.label()+self.newID() 732 gid = self.last_line.node.getAttribute("inkscape:label")+self.newID()
748 self.ID[gid]=1 733 self.ID[gid]=1
749 ns.setAttribute("id",gid) 734 ns.setAttribute("id",gid)
750 ns.setAttribute("inkscape:groupmode","layer") 735 ns.setAttribute("inkscape:groupmode","layer")
751 self.last_line.node.appendChild(ns) 736 self.last_line.node.appendChild(ns)
752 return ns 737 return ns