diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-03-09 18:57:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-09 18:57:55 +0100 |
| commit | fd6e43cf00548f78daf8ae855f691279e3c90a3b (patch) | |
| tree | 44774d59038213fb81e8906e61dfbd309aa17da8 /lib | |
| parent | da1cd33f3b7fa6b85a6cdfcb855dc8a16cf3f92c (diff) | |
Various fixes (#2125)
* add unit info to scale value in ripple stitch
* fix apply threadlist with empty description
* fix satin type ripple with unequal nodes
* fix legacy auto_fill conversion
* inform about too small meander shapes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/elements/element.py | 4 | ||||
| -rw-r--r-- | lib/elements/satin_column.py | 38 | ||||
| -rw-r--r-- | lib/elements/stroke.py | 2 | ||||
| -rw-r--r-- | lib/extensions/apply_threadlist.py | 2 | ||||
| -rw-r--r-- | lib/stitches/meander_fill.py | 14 |
5 files changed, 38 insertions, 22 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py index 51555129..c0b7ee0f 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -74,7 +74,9 @@ class EmbroideryElement(object): # convert legacy fill_method legacy_fill_method = self.get_int_param('fill_method', None) - if legacy_fill_method == 1: + if legacy_fill_method == 0: + self.set_param('fill_method', 'auto_fill') + elif legacy_fill_method == 1: self.set_param('fill_method', 'contour_fill') elif legacy_fill_method == 2: self.set_param('fill_method', 'guided_fill') diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index b5086171..8c39b4d2 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -33,17 +33,6 @@ class TooFewPathsError(ValidationError): ] -class UnequalPointsError(ValidationError): - name = _("Unequal number of points") - description = _("Satin column: There are no rungs and rails have an an unequal number of points.") - steps_to_solve = [ - _('The easiest way to solve this issue is to add one or more rungs. '), - _('Rungs control the stitch direction in satin columns.'), - _('* With the selected object press "P" to activate the pencil tool.'), - _('* Hold "Shift" while drawing the rung.') - ] - - class NotStitchableError(ValidationError): name = _("Not stitchable satin column") description = _("A satin column consists out of two rails and one or more rungs. This satin column may have a different setup.") @@ -56,14 +45,25 @@ class NotStitchableError(ValidationError): rung_message = _("Each rung should intersect both rails once.") +class TooManyIntersectionsError(ValidationError): + name = _("Rungs intersects too many times") + description = _("Satin column: A rung intersects a rail more than once.") + " " + rung_message + + class DanglingRungWarning(ValidationWarning): name = _("Rung doesn't intersect rails") description = _("Satin column: A rung doesn't intersect both rails.") + " " + rung_message -class TooManyIntersectionsError(ValidationError): - name = _("Rungs intersects too many times") - description = _("Satin column: A rung intersects a rail more than once.") + " " + rung_message +class UnequalPointsWarning(ValidationError): + name = _("Unequal number of points") + description = _("Satin column: There are no rungs and rails have an an unequal number of points.") + steps_to_solve = [ + _('The easiest way to solve this issue is to add one or more rungs. '), + _('Rungs control the stitch direction in satin columns.'), + _('* With the selected object press "P" to activate the pencil tool.'), + _('* Hold "Shift" while drawing the rung.') + ] class SatinColumn(EmbroideryElement): @@ -407,10 +407,13 @@ class SatinColumn(EmbroideryElement): def _synthesize_rungs(self): rung_endpoints = [] + # check for unequal length of rails + equal_length = len(self.rails[0]) == len(self.rails[1]) + for rail in self.rails: points = self.strip_control_points(rail) - if len(points) > 2: + if len(points) > 2 or not equal_length: # Don't bother putting rungs at the start and end. points = points[1:-1] else: @@ -513,6 +516,8 @@ class SatinColumn(EmbroideryElement): return sections def validation_warnings(self): + if len(self.csp) == 2 and len(self.rails[0]) != len(self.rails[1]): + yield UnequalPointsWarning(self.flattened_rails[0].interpolate(0.5, normalized=True)) for rung in self.flattened_rungs: for rail in self.flattened_rails: intersection = rung.intersection(rail) @@ -526,9 +531,6 @@ class SatinColumn(EmbroideryElement): 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]): - yield UnequalPointsError(self.flattened_rails[0].interpolate(0.5, normalized=True)) else: for rung in self.flattened_rungs: for rail in self.flattened_rails: diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index 9fe6fee1..8f5a6347 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -285,6 +285,7 @@ class Stroke(EmbroideryElement): _('Starting scale'), tooltip=_('How big the first copy of the line should be, in percent.') + " " + _('Used only for ripple stitch with a guide line.'), type='float', + unit='%', default=100, select_items=[('stroke_method', 1)], sort_index=13) @@ -296,6 +297,7 @@ class Stroke(EmbroideryElement): _('Ending scale'), tooltip=_('How big the last copy of the line should be, in percent.') + " " + _('Used only for ripple stitch with a guide line.'), type='float', + unit='%', default=0.0, select_items=[('stroke_method', 1)], sort_index=14) diff --git a/lib/extensions/apply_threadlist.py b/lib/extensions/apply_threadlist.py index e17b4a3c..a9a49b7a 100644 --- a/lib/extensions/apply_threadlist.py +++ b/lib/extensions/apply_threadlist.py @@ -106,7 +106,7 @@ class ApplyThreadlist(InkstitchExtension): colors = [] threads = pyembroidery.read(path).threadlist for color in threads: - if color.description.startswith("Cut"): + if color.description is not None and color.description.startswith("Cut"): # there is a maximum of 4 needles, we can simply take the last element from the description string colors.append([color.hex_color(), color.description[-1]]) else: diff --git a/lib/stitches/meander_fill.py b/lib/stitches/meander_fill.py index 6043b4bc..0a59da72 100644 --- a/lib/stitches/meander_fill.py +++ b/lib/stitches/meander_fill.py @@ -1,18 +1,21 @@ from itertools import combinations import networkx as nx +from inkex import errormsg from shapely.geometry import MultiPoint, Point from shapely.ops import nearest_points -from .running_stitch import running_stitch from .. import tiles from ..debug import debug +from ..i18n import _ from ..utils.clamp_path import clamp_path_to_polygon -from ..utils.geometry import Point as InkStitchPoint, ensure_geometry_collection +from ..utils.geometry import Point as InkStitchPoint +from ..utils.geometry import ensure_geometry_collection from ..utils.list import poprandom from ..utils.prng import iter_uniform_floats from ..utils.smoothing import smooth_path from ..utils.threading import check_stop_flag +from .running_stitch import running_stitch def meander_fill(fill, shape, shape_index, starting_point, ending_point): @@ -25,6 +28,13 @@ def meander_fill(fill, shape, shape_index, starting_point, ending_point): debug.log_line_strings(lambda: ensure_geometry_collection(shape.boundary).geoms, 'Meander shape') graph = tile.to_graph(shape, fill.meander_scale) + + if not graph: + label = fill.node.label or fill.node.get_id() + errormsg(_('%s: Could not build graph for meander stitching. Try to enlarge your shape or ' + 'scale your meander pattern down.') % label) + return [] + debug.log_graph(graph, 'Meander graph') ensure_connected(graph) start, end = find_starting_and_ending_nodes(graph, shape, starting_point, ending_point) |
