summaryrefslogtreecommitdiff
path: root/lib/stitch_plan
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2021-03-14 09:38:36 +0100
committerGitHub <noreply@github.com>2021-03-14 09:38:36 +0100
commit21614c7c3ae46fbfa229755916aec433faba0c95 (patch)
tree8a676049b49ba83890f320ab219b7b96aedc9aac /lib/stitch_plan
parent3dd767917d8e604bf4a1f3b41c5c4fc506fa2b96 (diff)
add lock stitches select box (#1076)
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/stitch_plan')
-rw-r--r--lib/stitch_plan/stitch.py23
-rw-r--r--lib/stitch_plan/stitch_plan.py2
-rw-r--r--lib/stitch_plan/ties.py7
3 files changed, 18 insertions, 14 deletions
diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py
index ccbea12e..6e1e4090 100644
--- a/lib/stitch_plan/stitch.py
+++ b/lib/stitch_plan/stitch.py
@@ -2,7 +2,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
@@ -10,6 +10,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
@@ -19,18 +20,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 de66cb10..fc725371 100644
--- a/lib/stitch_plan/stitch_plan.py
+++ b/lib/stitch_plan/stitch_plan.py
@@ -40,7 +40,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 5acf16e6..916f9822 100644
--- a/lib/stitch_plan/ties.py
+++ b/lib/stitch_plan/ties.py
@@ -31,11 +31,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[0].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):