comparison pyink/domview.py @ 1288:fb44830c8a81

Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
author wycc
date Sat, 15 Jan 2011 21:06:55 +0800
parents cbcb91b196fa
children 99de83340782
comparison
equal deleted inserted replaced
1287:f6a28f473494 1288:fb44830c8a81
730 # Duplicate children of a group, and append them to another group. 730 # Duplicate children of a group, and append them to another group.
731 # 731 #
732 def copy_group_children(self, src_group, dst_group): 732 def copy_group_children(self, src_group, dst_group):
733 # Search for the duplicated group 733 # Search for the duplicated group
734 doc = self._doc 734 doc = self._doc
735
736 dup_group = src_group.duplicate(doc)
737
738 old_nodes = _DOM_iterator(src_group)
739 new_nodes = _DOM_iterator(dup_group)
740 new_gids = set()
741 for old_node in old_nodes:
742 old_node_id = old_node.getAttribute('id')
743 new_node = new_nodes.next()
744 new_node.setAttribute('ns0:duplicate-src', old_node_id)
745
746 #
747 # Change ID here, or inkscape would insert the node with
748 # the same ID, and change it later to avoid duplication.
749 # But, our event handler would be called before changing
750 # ID. It would confuse our code. We change ID of nodes
751 # before inserting them into the DOM-tree.
752 #
753 gid = self.new_id()
754 while gid in new_gids:
755 gid = self.new_id()
756 pass
757 new_gids.add(gid)
758 new_node.setAttribute('id', gid)
759 pass
760
761 for child in dup_group.childList():
762 dup_group.removeChild(child) # prvent from crash
763 dst_group.appendChild(child)
764 pass
765 pass
766 pass
767
768 ## \brief Link children of a group.
769 #
770 # Clone children of a group, and append them to another group.
771 #
772 def link_group_children(self, src_group, dst_group):
773 # Search for the duplicated group
774 doc = self._doc
735 old_nodes = _DOM_iterator(src_group) 775 old_nodes = _DOM_iterator(src_group)
736 new_gids = set() 776 new_gids = set()
737 for old_node in old_nodes: 777 for old_node in old_nodes:
738 old_node_id = old_node.getAttribute('id') 778 old_node_id = old_node.getAttribute('id')
739 new_node = doc.createElement("svg:use") 779 new_node = doc.createElement("svg:use")
755 new_node.setAttribute('id', gid) 795 new_node.setAttribute('id', gid)
756 dst_group.appendChild(new_node) 796 dst_group.appendChild(new_node)
757 pass 797 pass
758 pass 798 pass
759 pass 799 pass
760