comparison pyink/domview.py @ 1246:42c4874c8d1e

Move _duplicate_group to domview_ui. - domview_ui.copy_key_group() replaces MBScene._duplicate_group().
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 19:44:15 +0800
parents b241f9768833
children 45e9566ea5c0
comparison
equal deleted inserted replaced
1245:ccbf0c5d01d1 1246:42c4874c8d1e
291 pass 291 pass
292 pass 292 pass
293 pass 293 pass
294 294
295 295
296 ## \brief Iterator to travel a sub-tree of DOM.
297 #
298 def _DOM_iterator(node):
299 nodes = [node]
300 while nodes:
301 node = nodes.pop(0)
302 child = node.firstChild()
303 while child:
304 nodes.append(child)
305 child = child.next()
306 pass
307 yield node
308 pass
309 pass
310
311
296 ## \brief This layer provide a data view to the DOM-tree. 312 ## \brief This layer provide a data view to the DOM-tree.
297 # 313 #
298 # This class maintains layers information, and provides functions to create, 314 # This class maintains layers information, and provides functions to create,
299 # change and destroy scene node and scene group. A scene node is a 'ns0:scene' 315 # change and destroy scene node and scene group. A scene node is a 'ns0:scene'
300 # in 'ns0:scenes' tag. A scene group is respective 'svg:g' for a scene. 316 # in 'ns0:scenes' tag. A scene group is respective 'svg:g' for a scene.
588 pass 604 pass
589 pass 605 pass
590 606
591 def get_max_frame(self): 607 def get_max_frame(self):
592 return self._maxframe 608 return self._maxframe
609
610 ## \brief Copy children of a group.
611 #
612 # Duplicate children of a group, and append them to another group.
613 #
614 def copy_group_children(self, src_group, dst_group):
615 # Search for the duplicated group
616 doc = self._doc
617
618 dup_group = src_group.duplicate(doc)
619 for child in dup_group.childList():
620 dup_group.removeChild(child) # prvent from crash
621 dst_group.appendChild(child)
622 pass
623
624 old_nodes = _DOM_iterator(src_group)
625 new_nodes = _DOM_iterator(dst_group)
626 for old_node in old_nodes:
627 old_node_id = old_node.getAttribute('id')
628 new_node = new_nodes.next()
629 new_node.setAttribute('ns0:duplicate-src', old_node_id)
630 pass
631 pass
593 pass 632 pass
594 633