diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-12-09 15:05:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-09 15:05:21 +0100 |
| commit | 36f7610cc0844a034ba068b549332cab3ef7b033 (patch) | |
| tree | e63e66d8313df795d26efb42833f103f3554971a /lib/stitch_plan | |
| parent | 41ace3a9e53b52b4271554d7aedd88d533ee5f5e (diff) | |
Force lock stitches option/extension and some typos (#1471)
Diffstat (limited to 'lib/stitch_plan')
| -rw-r--r-- | lib/stitch_plan/stitch.py | 26 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_group.py | 4 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 7 | ||||
| -rw-r--r-- | lib/stitch_plan/ties.py | 2 |
4 files changed, 24 insertions, 15 deletions
diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py index f163d09c..a4c50b60 100644 --- a/lib/stitch_plan/stitch.py +++ b/lib/stitch_plan/stitch.py @@ -10,7 +10,8 @@ from copy import deepcopy class Stitch(Point): """A stitch is a Point with extra information telling how to sew it.""" - def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, tie_modus=0, no_ties=False, tags=None): + def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, + tie_modus=0, force_lock_stitches=False, no_ties=False, tags=None): if isinstance(x, Stitch): # Allow creating a Stitch from another Stitch. Attributes passed as # arguments will override any existing attributes. @@ -28,6 +29,7 @@ class Stitch(Point): self.trim = trim self.stop = stop self.color_change = color_change + self.force_lock_stitches = force_lock_stitches self.tie_modus = tie_modus self.no_ties = no_ties self.tags = set() @@ -35,15 +37,16 @@ class Stitch(Point): self.add_tags(tags or []) def __repr__(self): - return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.x, - self.y, - self.color, - "JUMP" if self.jump else " ", - "TRIM" if self.trim else " ", - "STOP" if self.stop else " ", - "TIE MODUS" if self.tie_modus else " ", - "NO TIES" if self.no_ties else " ", - "COLOR CHANGE" if self.color_change else " ") + return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.x, + self.y, + self.color, + "JUMP" if self.jump else " ", + "TRIM" if self.trim else " ", + "STOP" if self.stop else " ", + "TIE MODUS" if self.tie_modus else " ", + "FORCE LOCK STITCHES" if self.force_lock_stitches else " ", + "NO TIES" if self.no_ties else " ", + "COLOR CHANGE" if self.color_change else " ") def add_tags(self, tags): for tag in tags: @@ -68,7 +71,8 @@ class Stitch(Point): return tag in self.tags def copy(self): - return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.tie_modus, self.no_ties, self.tags) + return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, + self.tie_modus, self.force_lock_stitches, self.no_ties, self.tags) def __json__(self): attributes = dict(vars(self)) diff --git a/lib/stitch_plan/stitch_group.py b/lib/stitch_plan/stitch_group.py index 98d9799e..21beebe1 100644 --- a/lib/stitch_plan/stitch_group.py +++ b/lib/stitch_plan/stitch_group.py @@ -17,11 +17,13 @@ class StitchGroup: between them by the stitch plan generation code. """ - def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, tie_modus=0, stitch_as_is=False, tags=None): + def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, + tie_modus=0, force_lock_stitches=False, stitch_as_is=False, tags=None): self.color = color self.trim_after = trim_after self.stop_after = stop_after self.tie_modus = tie_modus + self.force_lock_stitches = force_lock_stitches self.stitch_as_is = stitch_as_is self.stitches = [] diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 7e7621c1..f6895197 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -42,10 +42,13 @@ def stitch_groups_to_stitch_plan(stitch_groups, collapse_len=None, disable_ties= # always start a color with a JUMP to the first stitch position color_block.add_stitch(stitch_group.stitches[0], jump=True) else: - if len(color_block) and (stitch_group.stitches[0] - color_block.stitches[-1]).length() > collapse_len: + 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) - 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) diff --git a/lib/stitch_plan/ties.py b/lib/stitch_plan/ties.py index c649ee44..a95f9805 100644 --- a/lib/stitch_plan/ties.py +++ b/lib/stitch_plan/ties.py @@ -37,7 +37,7 @@ def add_tie(stitches, tie_path): def add_tie_off(stitches): # tie_modus: 0 = both | 1 = before | 2 = after | 3 = neither - if stitches[-1].tie_modus not in [1, 3]: + if stitches[-1].tie_modus not in [1, 3] or stitches[-1].force_lock_stitches: add_tie(stitches, stitches[-1:-3:-1]) |
