From 4ba3cd708561870a731d9634d9cdd5c18579cac7 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 22 Feb 2019 22:07:15 -0500 Subject: refactor add_commands() out into commands module --- lib/extensions/auto_satin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/extensions/auto_satin.py') diff --git a/lib/extensions/auto_satin.py b/lib/extensions/auto_satin.py index f846ac6b..90d8fe33 100644 --- a/lib/extensions/auto_satin.py +++ b/lib/extensions/auto_satin.py @@ -2,6 +2,7 @@ import sys import inkex +from ..commands import add_commands from ..elements import SatinColumn from ..i18n import _ from ..stitches.auto_satin import auto_satin @@ -97,6 +98,5 @@ class AutoSatin(CommandsExtension): def add_trims(self, new_elements, trim_indices): if self.options.trim and trim_indices: - self.ensure_symbol("trim") for i in trim_indices: - self.add_commands(new_elements[i], ["trim"]) + add_commands(new_elements[i], ["trim"]) -- cgit v1.2.3 From 53a9bd6b31ca3a1f50d41f228e0b598a7d9da8ea Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 25 Feb 2019 19:49:38 -0500 Subject: add trims in stitches.auto_satin --- lib/extensions/auto_satin.py | 52 ++++---------------------------------------- 1 file changed, 4 insertions(+), 48 deletions(-) (limited to 'lib/extensions/auto_satin.py') diff --git a/lib/extensions/auto_satin.py b/lib/extensions/auto_satin.py index 90d8fe33..12588d1e 100644 --- a/lib/extensions/auto_satin.py +++ b/lib/extensions/auto_satin.py @@ -38,22 +38,6 @@ class AutoSatin(CommandsExtension): if command is not None: return command.target_point - def effect(self): - if not self.check_selection(): - return - - if self.options.preserve_order: - # when preservering order, auto_satin() takes care of putting the - # newly-created elements into the existing group nodes in the SVG - # DOM - new_elements, trim_indices = self.auto_satin() - else: - group = self.create_group() - new_elements, trim_indices = self.auto_satin() - self.add_elements(group, new_elements) - - self.add_trims(new_elements, trim_indices) - def check_selection(self): if not self.get_elements(): return @@ -65,38 +49,10 @@ class AutoSatin(CommandsExtension): return True - def create_group(self): - first = self.elements[0].node - parent = first.getparent() - insert_index = parent.index(first) - group = inkex.etree.Element(SVG_GROUP_TAG, { - "transform": get_correction_transform(parent, child=True) - }) - parent.insert(insert_index, group) - - return group + def effect(self): + if not self.check_selection(): + return - def auto_satin(self): starting_point = self.get_starting_point() ending_point = self.get_ending_point() - return auto_satin(self.elements, self.options.preserve_order, starting_point, ending_point) - - def add_elements(self, group, new_elements): - for i, element in enumerate(new_elements): - if isinstance(element, SatinColumn): - element.node.set("id", self.uniqueId("autosatin")) - - # L10N Label for a satin column created by Auto-Route Satin Columns extension - element.node.set(INKSCAPE_LABEL, _("AutoSatin %d") % (i + 1)) - else: - element.node.set("id", self.uniqueId("autosatinrun")) - - # L10N Label for running stitch (underpathing) created by Auto-Route Satin Columns extension - element.node.set(INKSCAPE_LABEL, _("AutoSatin Running Stitch %d") % (i + 1)) - - group.append(element.node) - - def add_trims(self, new_elements, trim_indices): - if self.options.trim and trim_indices: - for i in trim_indices: - add_commands(new_elements[i], ["trim"]) + auto_satin(self.elements, self.options.preserve_order, starting_point, ending_point, self.options.trim) -- cgit v1.2.3 From 602f201cb6236a7cb4a041b84e761aaedc358ab0 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 6 Mar 2019 20:32:51 -0500 Subject: implement trim option for lettering --- lib/extensions/auto_satin.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/extensions/auto_satin.py') diff --git a/lib/extensions/auto_satin.py b/lib/extensions/auto_satin.py index 12588d1e..b7cee83b 100644 --- a/lib/extensions/auto_satin.py +++ b/lib/extensions/auto_satin.py @@ -2,12 +2,8 @@ import sys import inkex -from ..commands import add_commands -from ..elements import SatinColumn from ..i18n import _ from ..stitches.auto_satin import auto_satin -from ..svg import get_correction_transform -from ..svg.tags import SVG_GROUP_TAG, INKSCAPE_LABEL from .commands import CommandsExtension -- cgit v1.2.3