summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2022-11-22 09:50:21 +0100
committerGitHub <noreply@github.com>2022-11-22 09:50:21 +0100
commit4c845df846889e50016bcc0a7d56df5d01102fdf (patch)
tree7ccf6213f5b8ee5303e805ed9740aaa83645b2f2 /lib
parent8d0e80e5f10cc05cc3b14b1b8061c8e6aa6a2fef (diff)
small zigzag warning (#1891)
Diffstat (limited to 'lib')
-rw-r--r--lib/elements/stroke.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index ce973c0e..2854adaf 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -39,6 +39,14 @@ class MultipleGuideLineWarning(ValidationWarning):
]
+class SmallZigZagWarning(ValidationWarning):
+ name = _("Small ZigZag")
+ description = _("This zig zag stitch has a stroke width smaller than 0.5 units.")
+ steps_to_solve = [
+ _("Set your stroke to be dashed to indicate running stitch. Any kind of dash will work.")
+ ]
+
+
class Stroke(EmbroideryElement):
element_name = _("Stroke")
@@ -481,6 +489,15 @@ class Stroke(EmbroideryElement):
return guide_lines['satin'][0]
return guide_lines['stroke'][0]
+ def _representative_point(self):
+ # if we just take the center of a line string we could end up on some point far away from the actual line
+ try:
+ coords = list(self.shape.coords)
+ except NotImplementedError:
+ # linear rings to not have a coordinate sequence
+ coords = list(self.shape.exterior.coords)
+ return coords[int(len(coords)/2)]
+
def validation_warnings(self):
if self.stroke_method == 1 and self.skip_start + self.skip_end >= self.line_count:
yield IgnoreSkipValues(self.shape.centroid)
@@ -489,4 +506,8 @@ class Stroke(EmbroideryElement):
if self.stroke_method == 1:
guide_lines = get_marker_elements(self.node, "guide-line", False, True, True)
if sum(len(x) for x in guide_lines.values()) > 1:
- yield MultipleGuideLineWarning(self.shape.centroid)
+ yield MultipleGuideLineWarning(self._representative_point())
+
+ stroke_width, units = parse_length_with_units(self.get_style("stroke-width", "1"))
+ if not self.dashed and stroke_width <= 0.5:
+ yield SmallZigZagWarning(self._representative_point())