kopia lustrzana https://github.com/inkstitch/inkstitch
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 shapespull/2130/head
rodzic
da1cd33f3b
commit
fd6e43cf00
|
@ -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')
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue