summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Steel <george.steel@gmail.com>2023-01-28 20:20:40 -0500
committerGeorge Steel <george.steel@gmail.com>2023-01-28 20:20:40 -0500
commitc2c256727bc0c6663d553024783941e25448e06c (patch)
tree6b462ba3a76d6219e618eaf03f46ac3070d92f96
parent45496fcd93363659cf3dcebde92d5c86be82dd6c (diff)
parentf2f1fea0cb5d5fe122cc62a338b3b6513528f313 (diff)
Merge branch 'main' of https://github.com/inkstitch/inkstitch into george-steel/fix-running-stitch
-rw-r--r--lib/elements/satin_column.py14
-rw-r--r--lib/extensions/stitch_plan_preview.py14
-rw-r--r--lib/svg/tags.py1
-rw-r--r--templates/stitch_plan_preview.xml2
4 files changed, 22 insertions, 9 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index e935a9d7..be614a04 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -361,7 +361,10 @@ class SatinColumn(EmbroideryElement):
@property
@cache
def csp(self):
- return self.parse_path()
+ paths = self.parse_path()
+ # exclude subpaths which are just a point
+ paths = [path for path in paths if len(path) >= 2]
+ return paths
@property
@cache
@@ -518,8 +521,9 @@ class SatinColumn(EmbroideryElement):
def validation_errors(self):
# The node should have exactly two paths with the same number of points - or it should
# have two rails and at least one rung
-
- if len(self.rails) < 2:
+ if len(self.csp) < 2:
+ yield TooFewPathsError((0, 0))
+ elif len(self.rails) < 2:
yield TooFewPathsError(self.shape.centroid)
elif len(self.csp) == 2:
if len(self.rails[0]) != len(self.rails[1]):
@@ -1015,7 +1019,7 @@ class SatinColumn(EmbroideryElement):
self.zigzag_spacing,
self.pull_compensation_px,
self.pull_compensation_percent/100,
- self.random_width_decrease.any() and self.random_width_increase.any() and self.random_zigzag_spacing,
+ self.random_width_decrease.any() or self.random_width_increase.any() or self.random_zigzag_spacing,
)
# "left" and "right" here are kind of arbitrary designations meaning
@@ -1070,7 +1074,7 @@ class SatinColumn(EmbroideryElement):
offset_px = [0, 0]
if a.distance(pairs[i-1][0]) < min_dist:
offset_px[0] = -inset_px
- if b.distance(pairs[i-1][0]) < min_dist:
+ if b.distance(pairs[i-1][1]) < min_dist:
offset_px[1] = -inset_px
shortened.append(self.offset_points(a, b, offset_px, (0, 0)))
return shortened
diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py
index 571d5040..2468fc84 100644
--- a/lib/extensions/stitch_plan_preview.py
+++ b/lib/extensions/stitch_plan_preview.py
@@ -3,14 +3,14 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-from lxml import etree
-
from inkex import Boolean, Style
+from lxml import etree
from ..stitch_plan import stitch_groups_to_stitch_plan
from ..svg import render_stitch_plan
-from ..svg.tags import (INKSCAPE_GROUPMODE, INKSTITCH_ATTRIBS, SVG_DEFS_TAG,
- SVG_GROUP_TAG, SVG_PATH_TAG)
+from ..svg.tags import (INKSCAPE_GROUPMODE, INKSTITCH_ATTRIBS,
+ SODIPODI_INSENSITIVE, SVG_DEFS_TAG, SVG_GROUP_TAG,
+ SVG_PATH_TAG)
from .base import InkstitchExtension
from .stitch_plan_preview_undo import reset_stitch_plan
@@ -21,6 +21,7 @@ class StitchPlanPreview(InkstitchExtension):
self.arg_parser.add_argument("-s", "--move-to-side", type=Boolean, default=True, dest="move_to_side")
self.arg_parser.add_argument("-v", "--layer-visibility", type=int, default=0, dest="layer_visibility")
self.arg_parser.add_argument("-n", "--needle-points", type=Boolean, default=False, dest="needle_points")
+ self.arg_parser.add_argument("-i", "--insensitive", type=Boolean, default=False, dest="insensitive")
def effect(self):
# delete old stitch plan
@@ -58,6 +59,11 @@ class StitchPlanPreview(InkstitchExtension):
float(style.get('opacity', 1)) > 0.4 and not style.get('display', 'inline') == 'none'):
g.style['opacity'] = 0.4
+ if self.options.insensitive is True:
+ layer.set(SODIPODI_INSENSITIVE, True)
+ else:
+ layer.set(SODIPODI_INSENSITIVE, False)
+
# translate stitch plan to the right side of the canvas
if self.options.move_to_side:
layer.set('transform', 'translate(%s)' % svg.get('viewBox', '0 0 800 0').split(' ')[2])
diff --git a/lib/svg/tags.py b/lib/svg/tags.py
index 0227274c..64f6c2f3 100644
--- a/lib/svg/tags.py
+++ b/lib/svg/tags.py
@@ -40,6 +40,7 @@ XLINK_HREF = inkex.addNS('href', 'xlink')
SODIPODI_NAMEDVIEW = inkex.addNS('namedview', 'sodipodi')
SODIPODI_GUIDE = inkex.addNS('guide', 'sodipodi')
SODIPODI_ROLE = inkex.addNS('role', 'sodipodi')
+SODIPODI_INSENSITIVE = inkex.addNS('insensitive', 'sodipodi')
INKSTITCH_LETTERING = inkex.addNS('lettering', 'inkstitch')
diff --git a/templates/stitch_plan_preview.xml b/templates/stitch_plan_preview.xml
index c78089ee..e7a49522 100644
--- a/templates/stitch_plan_preview.xml
+++ b/templates/stitch_plan_preview.xml
@@ -18,6 +18,8 @@
<option value="2">Lower opacity</option>
</param>
<param name="needle-points" type="boolean" gui-text="Needle points">false</param>
+ <param name="insensitive" type="boolean" gui-text="Lock"
+ gui-description="Make stitch plan insensitive to mouse interactions">false</param>
<spacer />
<script>
{{ command_tag | safe }}