diff options
Diffstat (limited to 'lib/stitch_plan/stitch_plan.py')
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 7e7621c1..4593781a 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -3,9 +3,14 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from .ties import add_ties -from .color_block import ColorBlock +from sys import exit + +from inkex import errormsg + +from ..i18n import _ from ..svg import PIXELS_PER_MM +from .color_block import ColorBlock +from .ties import add_ties def stitch_groups_to_stitch_plan(stitch_groups, collapse_len=None, disable_ties=False): # noqa: C901 @@ -17,6 +22,11 @@ def stitch_groups_to_stitch_plan(stitch_groups, collapse_len=None, disable_ties= * adds jump-stitches between stitch_group if necessary """ + if not stitch_groups: + errormsg(_("There is no selected stitchable element. Please run " + "Extensions > Ink/Stitch > Troubleshoot > Troubleshoot objects in case you have expected a stitchout.")) + exit(1) + if collapse_len is None: collapse_len = 3.0 collapse_len = collapse_len * PIXELS_PER_MM @@ -40,12 +50,15 @@ def stitch_groups_to_stitch_plan(stitch_groups, collapse_len=None, disable_ties= color_block = stitch_plan.new_color_block(color=stitch_group.color) # always start a color with a JUMP to the first stitch position - color_block.add_stitch(stitch_group.stitches[0], jump=True) + color_block.add_stitch(stitch_group.stitches[0], jump=True, tie_modus=stitch_group.tie_modus) else: - if len(color_block) and (stitch_group.stitches[0] - color_block.stitches[-1]).length() > collapse_len: - color_block.add_stitch(stitch_group.stitches[0], jump=True) + if (len(color_block) and + ((stitch_group.stitches[0] - color_block.stitches[-1]).length() > collapse_len or + color_block.stitches[-1].force_lock_stitches)): + color_block.add_stitch(stitch_group.stitches[0], jump=True, tie_modus=stitch_group.tie_modus) - color_block.add_stitches(stitches=stitch_group.stitches, tie_modus=stitch_group.tie_modus, no_ties=stitch_group.stitch_as_is) + color_block.add_stitches(stitches=stitch_group.stitches, tie_modus=stitch_group.tie_modus, + force_lock_stitches=stitch_group.force_lock_stitches, no_ties=stitch_group.stitch_as_is) if stitch_group.trim_after: color_block.add_stitch(trim=True) @@ -110,7 +123,8 @@ class StitchPlan(object): num_stops=self.num_stops, num_trims=self.num_trims, num_stitches=self.num_stitches, - bounding_box=self.bounding_box + bounding_box=self.bounding_box, + estimated_thread=self.estimated_thread ) @property @@ -145,6 +159,11 @@ class StitchPlan(object): return minx, miny, maxx, maxy @property + def estimated_thread(self): + thread_meter = sum(block.estimated_thread for block in self) / PIXELS_PER_MM / 1000 + return round(thread_meter, 2) + + @property def dimensions(self): minx, miny, maxx, maxy = self.bounding_box return (maxx - minx, maxy - miny) |
