From 8e70f3d2feaab8a14f775a5ef84002bdab9688f0 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:10:40 +0100 Subject: Add object based min stitch length (#2792) * add object based min stitch length (overwrites global) * add object based minimum jump stitch (overwrites global) * rename patches to stitch_groups --- lib/stitch_plan/stitch_group.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/stitch_plan/stitch_group.py') diff --git a/lib/stitch_plan/stitch_group.py b/lib/stitch_plan/stitch_group.py index c85fc5f5..0730101c 100644 --- a/lib/stitch_plan/stitch_group.py +++ b/lib/stitch_plan/stitch_group.py @@ -17,8 +17,17 @@ class StitchGroup: between them by the stitch plan generation code. """ - def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, - lock_stitches=(None, None), force_lock_stitches=False, tags=None): + def __init__( + self, + color=None, + stitches=None, + min_jump_stitch_length=False, + trim_after=False, + stop_after=False, + lock_stitches=(None, None), + force_lock_stitches=False, + tags=None + ): # DANGER: if you add new attributes, you MUST also set their default # values in __new__() below. Otherwise, cached stitch plans can be # loaded and create objects without those properties defined, because @@ -29,6 +38,7 @@ class StitchGroup: self.stop_after = stop_after self.lock_stitches = lock_stitches self.force_lock_stitches = force_lock_stitches + self.min_jump_stitch_length = min_jump_stitch_length self.stitches = [] if stitches: @@ -55,9 +65,13 @@ class StitchGroup: raise TypeError("StitchGroup can only be added to another StitchGroup") def __len__(self): - # This method allows `len(patch)` and `if patch: + # This method allows `len(stitch_group)` and `if stitch_group: return len(self.stitches) + def set_minimum_stitch_length(self, min_stitch_length): + for stitch in self.stitches: + stitch.min_stitch_length = min_stitch_length + def add_stitches(self, stitches, tags=None): for stitch in stitches: self.add_stitch(stitch, tags=tags) @@ -66,7 +80,6 @@ class StitchGroup: if not isinstance(stitch, Stitch): # probably a Point stitch = Stitch(stitch, tags=tags) - self.stitches.append(stitch) def reverse(self): -- cgit v1.2.3