changeset 1183:e8446e138427

Move update_scenes_of_dom() to MBScene_dom
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 31 Dec 2010 12:37:30 +0800
parents 8b0e5e8a6b0c
children 05d33f0fbc76
files pyink/MBScene.py
diffstat 1 files changed, 52 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/MBScene.py	Fri Dec 31 12:31:02 2010 +0800
+++ b/pyink/MBScene.py	Fri Dec 31 12:37:30 2010 +0800
@@ -156,6 +156,20 @@
 ## \brief Layer of MBScene to manipulate DOM tree.
 #
 class MBScene_dom(object):
+    def newID(self):
+	while True:
+	    n = 's%d' % int(random.random()*10000)
+			#print "try %s" % n
+	    if self.ID.has_key(n) == False:
+		return n
+	    pass
+	pass
+    
+    def dumpID(self):
+	for a,v in self.ID.items():
+	    pass
+	pass
+    
     def dumpattr(self, n):
 	s = ""
 	for a,v in n.attrib.items():
@@ -275,6 +289,44 @@
 	line.add_keyframe(frame, ns)
 	self.update_scenes_of_dom()
 	pass
+    
+    def add_scene_on_dom(self, frameline, scenes_node):
+	doc = self.document
+	for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
+	    ref = frameline.get_frame_data(start_idx)
+	    tween_type_idx = self._frameline_tween_types.index(tween_type)
+	    tween_type_name = self._tween_type_names[tween_type_idx]
+	    
+	    scene_node = doc.createElement("ns0:scene")
+	    scenes_node.appendChild(scene_node)
+	    scene_node.setAttribute("start", str(start_idx + 1))
+	    if start_idx != stop_idx:
+		scene_node.setAttribute("end", str(stop_idx + 1))
+		pass
+	    scene_node.setAttribute("ref", ref.attribute("id"))
+	    scene_node.setAttribute("type", tween_type_name)
+	    pass
+	pass
+
+    def update_scenes_of_dom(self):
+        doc = self.root
+	rdoc = self.document
+	for node in doc.childList():
+	    if node.name() == 'svg:metadata':
+	        for t in node.childList():
+		    if t.name() == "ns0:scenes":
+		        node.removeChild(t)
+			scenes = rdoc.createElement("ns0:scenes")
+			node.appendChild(scenes)
+			for layer in range(0, len(self._framelines)):
+			    lobj = self._framelines[layer]
+			    self.add_scene_on_dom(lobj, scenes)
+			    pass
+			pass
+		    pass
+		pass
+	    pass
+	pass
     pass
 
 class MBScene(MBScene_dom):
@@ -331,26 +383,6 @@
 	self.window.add(vbox)
 	pass
     
-    def update_scenes_of_dom(self):
-        doc = self.root
-	rdoc = self.document
-	for node in doc.childList():
-	    if node.name() == 'svg:metadata':
-	        for t in node.childList():
-		    if t.name() == "ns0:scenes":
-		        node.removeChild(t)
-			scenes = rdoc.createElement("ns0:scenes")
-			node.appendChild(scenes)
-			for layer in range(0, len(self._framelines)):
-			    lobj = self._framelines[layer]
-			    self.add_scene_on_dom(lobj, scenes)
-			    pass
-			pass
-		    pass
-		pass
-	    pass
-	pass
-    
     def parseScene(self):
 	"""
 	In this function, we will collect all items for the current
@@ -438,20 +470,6 @@
 	    pass
 	pass
     
-    def newID(self):
-	while True:
-	    n = 's%d' % int(random.random()*10000)
-			#print "try %s" % n
-	    if self.ID.has_key(n) == False:
-		return n
-	    pass
-	pass
-    
-    def dumpID(self):
-	for a,v in self.ID.items():
-	    pass
-	pass
-    
     def getLayer(self, layer):
 	for l in self.layers:
 	    if l.node.getAttribute('id') == layer:
@@ -1020,24 +1038,6 @@
 	gtk.main_quit()
 	pass
 
-    def add_scene_on_dom(self, frameline, scenes_node):
-	doc = self.document
-	for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
-	    ref = frameline.get_frame_data(start_idx)
-	    tween_type_idx = self._frameline_tween_types.index(tween_type)
-	    tween_type_name = self._tween_type_names[tween_type_idx]
-	    
-	    scene_node = doc.createElement("ns0:scene")
-	    scenes_node.appendChild(scene_node)
-	    scene_node.setAttribute("start", str(start_idx + 1))
-	    if start_idx != stop_idx:
-		scene_node.setAttribute("end", str(stop_idx + 1))
-		pass
-	    scene_node.setAttribute("ref", ref.attribute("id"))
-	    scene_node.setAttribute("type", tween_type_name)
-	    pass
-	pass
-
     def updateUI(self,node=None,arg=None):
         if self.lockui: return