diff pyink/domview.py @ 1328:407f321f0d7c

Add a svg:use after transform a group to a component
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 31 Jan 2011 12:47:49 +0800
parents ab281ec3eeec
children 5da64f67d00d
line wrap: on
line diff
--- a/pyink/domview.py	Sun Jan 30 23:04:06 2011 +0800
+++ b/pyink/domview.py	Mon Jan 31 12:47:49 2011 +0800
@@ -502,6 +502,25 @@
         layer_group = self._get_group_of_component_layer(comp_name, 0)
         layer_group.appendChild(group)
         pass
+
+    ## \brief Create a link to a component.
+    #
+    # \param parent_group is where the link will be pliaced in.
+    # \return link node.
+    #
+    def link_to_component(self, comp_name, parent_group):
+        layers_group = self._get_layers_group_of_component(comp_name)
+        
+        use_node = self._doc.createElement('svg:use')
+        layers_group_id = layers_group.getAttribute('id')
+        use_node.setAttribute('xlink:href', '#' + layers_group_id)
+        use_node_id = self.new_id()
+        use_node.setAttribute('id', use_node_id)
+        use_node.setAttribute('use_component', 'true')
+
+        parent_group.appendChild(use_node)
+        
+        return use_node
     pass