Mercurial > MadButterfly
changeset 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 | 2b051e474b0f |
files | pyink/MBScene.py pyink/domview.py pyink/domview_ui.py |
diffstat | 3 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/MBScene.py Sun Jan 30 23:04:06 2011 +0800 +++ b/pyink/MBScene.py Mon Jan 31 12:47:49 2011 +0800 @@ -403,10 +403,19 @@ ## \brief To handle context menu event. # def do_make_component_from_group(self, node): + node_parent_group = node.parent() + comp_name = 'Component ' + node.getAttribute('id') self._domviewui.add_component_from_group(comp_name, node) + + self._domviewui.link_to_component(comp_name, node_parent_group) pass + ## \brief Add menu item to context menu. + # + # This method is called by pyink.pyink_context_menu() to notify the + # creation of context menu for a node. + # def context_menu(self, spitem, menu_factory): node = spitem.repr if node.name() != 'svg:g':
--- 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
--- a/pyink/domview_ui.py Sun Jan 30 23:04:06 2011 +0800 +++ b/pyink/domview_ui.py Mon Jan 31 12:47:49 2011 +0800 @@ -465,6 +465,10 @@ self.add_component(comp_name) self._dom.mv_group_to_component(group, comp_name) pass + + def link_to_component(self, comp_name, parent_group): + link_node = self._dom.link_to_component(comp_name, parent_group) + return link_node pass