diff options
Diffstat (limited to 'lib/stitch_plan')
| -rw-r--r-- | lib/stitch_plan/stitch.py | 23 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 6 | ||||
| -rw-r--r-- | lib/stitch_plan/ties.py | 7 |
3 files changed, 21 insertions, 15 deletions
diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py index a5938c7b..ae6fa480 100644 --- a/lib/stitch_plan/stitch.py +++ b/lib/stitch_plan/stitch.py @@ -7,7 +7,7 @@ from ..utils.geometry import Point class Stitch(Point): - def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, no_ties=False): + def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, tie_modus=0, no_ties=False): self.x = x self.y = y self.color = color @@ -15,6 +15,7 @@ class Stitch(Point): self.trim = trim self.stop = stop self.color_change = color_change + self.tie_modus = tie_modus self.no_ties = no_ties # Allow creating a Stitch from a Point @@ -24,18 +25,18 @@ class Stitch(Point): self.y = point.y def __repr__(self): - return "Stitch(%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 " ", - "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)" % (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 " ") def copy(self): - return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.no_ties) + return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.tie_modus, self.no_ties) def __json__(self): return vars(self) diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 47e8b203..01463aba 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -19,7 +19,9 @@ def patches_to_stitch_plan(patches, collapse_len=None, disable_ties=False): * adds jump-stitches between patches if necessary """ - collapse_len = (collapse_len or 3.0) * PIXELS_PER_MM + if collapse_len is None: + collapse_len = 3.0 + collapse_len = collapse_len * PIXELS_PER_MM stitch_plan = StitchPlan() color_block = stitch_plan.new_color_block(color=patches[0].color) @@ -45,7 +47,7 @@ def patches_to_stitch_plan(patches, collapse_len=None, disable_ties=False): if len(color_block) and (patch.stitches[0] - color_block.stitches[-1]).length() > collapse_len: color_block.add_stitch(patch.stitches[0], jump=True) - color_block.add_stitches(patch.stitches, no_ties=patch.stitch_as_is) + color_block.add_stitches(stitches=patch.stitches, tie_modus=patch.tie_modus, no_ties=patch.stitch_as_is) if patch.trim_after: color_block.add_stitch(trim=True) diff --git a/lib/stitch_plan/ties.py b/lib/stitch_plan/ties.py index d54b0f0f..c649ee44 100644 --- a/lib/stitch_plan/ties.py +++ b/lib/stitch_plan/ties.py @@ -36,11 +36,14 @@ def add_tie(stitches, tie_path): def add_tie_off(stitches): - add_tie(stitches, stitches[-1:-3:-1]) + # tie_modus: 0 = both | 1 = before | 2 = after | 3 = neither + if stitches[-1].tie_modus not in [1, 3]: + add_tie(stitches, stitches[-1:-3:-1]) def add_tie_in(stitches, upcoming_stitches): - add_tie(stitches, upcoming_stitches) + if stitches[0].tie_modus not in [2, 3]: + add_tie(stitches, upcoming_stitches) def add_ties(stitch_plan): |
