summaryrefslogtreecommitdiff
path: root/lib/stitch_plan
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitch_plan')
-rw-r--r--lib/stitch_plan/stitch.py26
-rw-r--r--lib/stitch_plan/stitch_group.py4
-rw-r--r--lib/stitch_plan/stitch_plan.py7
-rw-r--r--lib/stitch_plan/ties.py2
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])