From d713c8649231aee5ffd61df156fee55f90775b03 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Mon, 5 Apr 2021 18:54:09 +0200 Subject: rename transfer params to duplicate params (#1128) --- lib/extensions/__init__.py | 4 ++-- lib/extensions/duplicate_params.py | 49 ++++++++++++++++++++++++++++++++++++++ lib/extensions/transfer_params.py | 49 -------------------------------------- templates/duplicate_params.xml | 15 ++++++++++++ templates/transfer_params.xml | 15 ------------ 5 files changed, 66 insertions(+), 66 deletions(-) create mode 100644 lib/extensions/duplicate_params.py delete mode 100644 lib/extensions/transfer_params.py create mode 100644 templates/duplicate_params.xml delete mode 100644 templates/transfer_params.xml diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index 67e37121..25f835c3 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -10,6 +10,7 @@ from .break_apart import BreakApart from .cleanup import Cleanup from .convert_to_satin import ConvertToSatin from .cut_satin import CutSatin +from .duplicate_params import DuplicateParams from .embroider_settings import EmbroiderSettings from .flip import Flip from .global_commands import GlobalCommands @@ -29,7 +30,6 @@ from .remove_embroidery_settings import RemoveEmbroiderySettings from .reorder import Reorder from .simulator import Simulator from .stitch_plan_preview import StitchPlanPreview -from .transfer_params import TransferParams from .zip import Zip __all__ = extensions = [StitchPlanPreview, @@ -57,5 +57,5 @@ __all__ = extensions = [StitchPlanPreview, ImportThreadlist, Simulator, Reorder, - TransferParams, + DuplicateParams, EmbroiderSettings] diff --git a/lib/extensions/duplicate_params.py b/lib/extensions/duplicate_params.py new file mode 100644 index 00000000..9fcdbf1c --- /dev/null +++ b/lib/extensions/duplicate_params.py @@ -0,0 +1,49 @@ +# Authors: see git history +# +# Copyright (c) 2021 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +import inkex + +from ..i18n import _ +from ..svg.tags import EMBROIDERABLE_TAGS, SVG_GROUP_TAG +from .base import InkstitchExtension + + +class DuplicateParams(InkstitchExtension): + # Transfer inkstitch namespaced attributes from the first selected element to the rest of selection + + def effect(self): + objects = self.get_selected_in_order() + if len(objects) < 2: + inkex.errormsg(_("This function copies Ink/Stitch parameters from the first selected element to the rest of the selection. " + "Please select at least two elements.")) + return + + copy_from = objects[0] + copy_from_attribs = self.get_inkstitch_attributes(copy_from) + + copy_to_selection = objects[1:] + self.copy_to = [] + + # extract copy_to group elements + for element in copy_to_selection: + if element.tag == SVG_GROUP_TAG: + for descendant in element.iterdescendants(EMBROIDERABLE_TAGS): + self.copy_to.append(descendant) + elif element.tag in EMBROIDERABLE_TAGS: + self.copy_to.append(element) + + # remove inkstitch params from copy_to elements + for element in self.copy_to: + copy_to_attribs = self.get_inkstitch_attributes(element) + for attrib in copy_to_attribs: + element.pop(attrib) + + # paste inkstitch params from copy_from element to copy_to elements + for attrib in copy_from_attribs: + for element in self.copy_to: + element.attrib[attrib] = copy_from_attribs[attrib] + + def get_inkstitch_attributes(self, node): + return {k: v for k, v in node.attrib.iteritems() if inkex.NSS['inkstitch'] in k} diff --git a/lib/extensions/transfer_params.py b/lib/extensions/transfer_params.py deleted file mode 100644 index c10393e2..00000000 --- a/lib/extensions/transfer_params.py +++ /dev/null @@ -1,49 +0,0 @@ -# Authors: see git history -# -# Copyright (c) 2021 Authors -# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. - -import inkex - -from ..i18n import _ -from ..svg.tags import EMBROIDERABLE_TAGS, SVG_GROUP_TAG -from .base import InkstitchExtension - - -class TransferParams(InkstitchExtension): - # Transfer inkstitch namespaced attributes from the first selected element to the rest of selection - - def effect(self): - objects = self.get_selected_in_order() - if len(objects) < 2: - inkex.errormsg(_("This function transfers Ink/Stitch parameters from the first selected element to the rest of the selection. " - "Please select at least two elements.")) - return - - copy_from = objects[0] - copy_from_attribs = self.get_inkstitch_attributes(copy_from) - - copy_to_selection = objects[1:] - self.copy_to = [] - - # extract copy_to group elements - for element in copy_to_selection: - if element.tag == SVG_GROUP_TAG: - for descendant in element.iterdescendants(EMBROIDERABLE_TAGS): - self.copy_to.append(descendant) - elif element.tag in EMBROIDERABLE_TAGS: - self.copy_to.append(element) - - # remove inkstitch params from copy_to elements - for element in self.copy_to: - copy_to_attribs = self.get_inkstitch_attributes(element) - for attrib in copy_to_attribs: - element.pop(attrib) - - # paste inkstitch params from copy_from element to copy_to elements - for attrib in copy_from_attribs: - for element in self.copy_to: - element.attrib[attrib] = copy_from_attribs[attrib] - - def get_inkstitch_attributes(self, node): - return {k: v for k, v in node.attrib.iteritems() if inkex.NSS['inkstitch'] in k} diff --git a/templates/duplicate_params.xml b/templates/duplicate_params.xml new file mode 100644 index 00000000..2fc83c52 --- /dev/null +++ b/templates/duplicate_params.xml @@ -0,0 +1,15 @@ + + + {% trans %}Duplicate Params{% endtrans %} + org.inkstitch.duplicate_params.{{ locale }} + duplicate_params + + all + + + + + + diff --git a/templates/transfer_params.xml b/templates/transfer_params.xml deleted file mode 100644 index 7e256cd4..00000000 --- a/templates/transfer_params.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - {% trans %}Transfer Params{% endtrans %} - org.inkstitch.transfer_params.{{ locale }} - transfer_params - - all - - - - - - -- cgit v1.2.3