diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-05-03 17:18:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-03 17:18:01 +0200 |
| commit | 8a32d0787d234048b648f2956b337ffabff17bf2 (patch) | |
| tree | 32a1f9138ee8a3fb7dbd7bb7a4b3f2e182fdc836 /lib/elements | |
| parent | 9f7083f25c43261033ef236d2f57cfcfba70a059 (diff) | |
expose end_row_spacing and (re)order fill params (#2265)
Diffstat (limited to 'lib/elements')
| -rw-r--r-- | lib/elements/fill_stitch.py | 234 |
1 files changed, 122 insertions, 112 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index ec115ce7..9e2eed45 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -130,7 +130,7 @@ class FillStitch(EmbroideryElement): @property @param('guided_fill_strategy', _('Guided Fill Strategy'), type='dropdown', default=0, - options=[_("Copy"), _("Parallel Offset")], select_items=[('fill_method', 'guided_fill')], sort_index=3, + options=[_("Copy"), _("Parallel Offset")], select_items=[('fill_method', 'guided_fill')], sort_index=10, tooltip=_('Copy (the default) will fill the shape with shifted copies of the line. ' 'Parallel offset will ensure that each line is always a consistent distance from its neighbor. ' 'Sharp corners may be introduced.')) @@ -139,13 +139,13 @@ class FillStitch(EmbroideryElement): @property @param('contour_strategy', _('Contour Fill Strategy'), type='dropdown', default=0, - options=[_("Inner to Outer"), _("Single spiral"), _("Double spiral")], select_items=[('fill_method', 'contour_fill')], sort_index=3) + options=[_("Inner to Outer"), _("Single spiral"), _("Double spiral")], select_items=[('fill_method', 'contour_fill')], sort_index=10) def contour_strategy(self): return self.get_int_param('contour_strategy', 0) @property @param('join_style', _('Join Style'), type='dropdown', default=0, - options=[_("Round"), _("Mitered"), _("Beveled")], select_items=[('fill_method', 'contour_fill')], sort_index=4) + options=[_("Round"), _("Mitered"), _("Beveled")], select_items=[('fill_method', 'contour_fill')], sort_index=11) def join_style(self): return self.get_int_param('join_style', 0) @@ -155,33 +155,18 @@ class FillStitch(EmbroideryElement): type='boolean', default=False, select_items=[('fill_method', 'contour_fill')], - sort_index=5) + sort_index=12) def avoid_self_crossing(self): return self.get_boolean_param('avoid_self_crossing', False) @property - @param('smoothness_mm', _('Smoothness'), - tooltip=_( - 'Smooth the stitch path. Smoothness limits how far the smoothed stitch path ' + - 'is allowed to deviate from the original path. Try low numbers like 0.2. ' + - 'Hint: a lower running stitch tolerance may be needed too.' - ), - type='integer', - unit='mm', - default=0, - select_items=[('fill_method', 'contour_fill'), ('fill_method', 'meander_fill')], - sort_index=5) - def smoothness(self): - return self.get_float_param('smoothness_mm', 0) - - @property - @param('clockwise', _('Clockwise'), type='boolean', default=True, select_items=[('fill_method', 'contour_fill')], sort_index=5) + @param('clockwise', _('Clockwise'), type='boolean', default=True, select_items=[('fill_method', 'contour_fill')], sort_index=13) def clockwise(self): return self.get_boolean_param('clockwise', True) @property @param('meander_pattern', _('Meander Pattern'), type='combo', default=0, - options=sorted(tiles.all_tiles()), select_items=[('fill_method', 'meander_fill')], sort_index=3) + options=sorted(tiles.all_tiles()), select_items=[('fill_method', 'meander_fill')], sort_index=10) def meander_pattern(self): return self.get_param('meander_pattern', min(tiles.all_tiles()).id) @@ -191,7 +176,7 @@ class FillStitch(EmbroideryElement): type='float', unit="degrees", default=0, select_items=[('fill_method', 'meander_fill')], - sort_index=4) + sort_index=11) def meander_angle(self): return math.radians(self.get_float_param('meander_angle', 0)) @@ -203,17 +188,57 @@ class FillStitch(EmbroideryElement): type='float', unit="%", default=100, select_items=[('fill_method', 'meander_fill')], - sort_index=4) + sort_index=12) def meander_scale(self): return np.maximum(self.get_split_float_param('meander_scale_percent', (100, 100)), (1, 1)) / 100 @property + @param('clip', _('Clip path'), + tooltip=_('Constrain stitching to the shape. Useful when smoothing and expand are used.'), + type='boolean', + default=False, + select_items=[('fill_method', 'meander_fill')], + sort_index=13) + def clip(self): + return self.get_boolean_param('clip', False) + + @property + @param('smoothness_mm', _('Smoothness'), + tooltip=_( + 'Smooth the stitch path. Smoothness limits how far the smoothed stitch path ' + + 'is allowed to deviate from the original path. Try low numbers like 0.2. ' + + 'Hint: a lower running stitch tolerance may be needed too.' + ), + type='integer', + unit='mm', + default=0, + select_items=[('fill_method', 'contour_fill'), ('fill_method', 'meander_fill')], + sort_index=14) + def smoothness(self): + return self.get_float_param('smoothness_mm', 0) + + @property + @param('expand_mm', + _('Expand'), + tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes. Negative values contract instead.'), + unit='mm', + type='float', + default=0, + sort_index=20, + select_items=[('fill_method', 'auto_fill'), + ('fill_method', 'guided_fill'), + ('fill_method', 'meander_fill'), + ('fill_method', 'circular_fill')]) + def expand(self): + return self.get_float_param('expand_mm', 0) + + @property @param('angle', _('Angle of lines of stitches'), tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), unit='deg', type='float', - sort_index=6, + sort_index=21, select_items=[('fill_method', 'auto_fill'), ('fill_method', 'legacy_fill')], default=0) @cache @@ -221,43 +246,27 @@ class FillStitch(EmbroideryElement): return math.radians(self.get_float_param('angle', 0)) @property - def color(self): - # SVG spec says the default fill is black - return self.get_style("fill", "#000000") - - @property - @param( - 'skip_last', - _('Skip last stitch in each row'), - tooltip=_('The last stitch in each row is quite close to the first stitch in the next row. ' - 'Skipping it decreases stitch count and density.'), - type='boolean', - sort_index=6, - select_items=[('fill_method', 'auto_fill'), ('fill_method', 'guided_fill'), - ('fill_method', 'legacy_fill')], - default=False) - def skip_last(self): - return self.get_boolean_param("skip_last", False) - - @property - @param( - 'flip', - _('Flip fill (start right-to-left)'), - tooltip=_('The flip option can help you with routing your stitch path. ' - 'When you enable flip, stitching goes from right-to-left instead of left-to-right.'), - type='boolean', - sort_index=7, - select_items=[('fill_method', 'legacy_fill')], - default=False) - def flip(self): - return self.get_boolean_param("flip", False) + @param('max_stitch_length_mm', + _('Maximum fill stitch length'), + tooltip=_( + 'The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), + unit='mm', + sort_index=22, + type='float', + select_items=[('fill_method', 'auto_fill'), + ('fill_method', 'contour_fill'), + ('fill_method', 'guided_fill'), + ('fill_method', 'legacy_fill')], + default=3.0) + def max_stitch_length(self): + return max(self.get_float_param("max_stitch_length_mm", 3.0), 0.1 * PIXELS_PER_MM) @property @param('row_spacing_mm', _('Spacing between rows'), tooltip=_('Distance between rows of stitches.'), unit='mm', - sort_index=6, + sort_index=23, type='float', select_items=[('fill_method', 'auto_fill'), ('fill_method', 'contour_fill'), @@ -269,24 +278,18 @@ class FillStitch(EmbroideryElement): return max(self.get_float_param("row_spacing_mm", 0.25), 0.1 * PIXELS_PER_MM) @property - def end_row_spacing(self): - return self.get_float_param("end_row_spacing_mm") - - @property - @param('max_stitch_length_mm', - _('Maximum fill stitch length'), - tooltip=_( - 'The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), + @param('end_row_spacing_mm', + _('End row spacing'), + tooltip=_('Increases or decreases the row spacing towards the end.'), unit='mm', - sort_index=6, + sort_index=24, type='float', select_items=[('fill_method', 'auto_fill'), - ('fill_method', 'contour_fill'), - ('fill_method', 'guided_fill'), ('fill_method', 'legacy_fill')], - default=3.0) - def max_stitch_length(self): - return max(self.get_float_param("max_stitch_length_mm", 3.0), 0.1 * PIXELS_PER_MM) + default=None) + def end_row_spacing(self): + end_row_spacing = self.get_float_param("end_row_spacing_mm") + return max(end_row_spacing, 0) if end_row_spacing else None @property @param('staggers', @@ -294,13 +297,53 @@ class FillStitch(EmbroideryElement): tooltip=_('Length of the cycle by which successive stitch rows are staggered. ' 'Fractional values are allowed and can have less visible diagonals than integer values.'), type='int', - sort_index=6, + sort_index=25, select_items=[('fill_method', 'auto_fill'), ('fill_method', 'guided_fill'), ('fill_method', 'legacy_fill')], default=4) def staggers(self): return self.get_float_param("staggers", 4) @property + @param( + 'skip_last', + _('Skip last stitch in each row'), + tooltip=_('The last stitch in each row is quite close to the first stitch in the next row. ' + 'Skipping it decreases stitch count and density.'), + type='boolean', + sort_index=26, + select_items=[('fill_method', 'auto_fill'), ('fill_method', 'guided_fill'), + ('fill_method', 'legacy_fill')], + default=False) + def skip_last(self): + return self.get_boolean_param("skip_last", False) + + @property + @param( + 'flip', + _('Flip fill (start right-to-left)'), + tooltip=_('The flip option can help you with routing your stitch path. ' + 'When you enable flip, stitching goes from right-to-left instead of left-to-right.'), + type='boolean', + sort_index=27, + select_items=[('fill_method', 'legacy_fill')], + default=False) + def flip(self): + return self.get_boolean_param("flip", False) + + @property + @param('underpath', + _('Underpath'), + tooltip=_('Travel inside the shape when moving from section to section. Underpath ' + 'stitches avoid traveling in the direction of the row angle so that they ' + 'are not visible. This gives them a jagged appearance.'), + type='boolean', + default=True, + select_items=[('fill_method', 'auto_fill'), ('fill_method', 'guided_fill'), ('fill_method', 'circular_fill')], + sort_index=30) + def underpath(self): + return self.get_boolean_param('underpath', True) + + @property @param('running_stitch_length_mm', _('Running stitch length'), tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section. ' @@ -312,7 +355,7 @@ class FillStitch(EmbroideryElement): ('fill_method', 'guided_fill'), ('fill_method', 'meander_fill'), ('fill_method', 'circular_fill')], - sort_index=6) + sort_index=31) def running_stitch_length(self): return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01) @@ -325,7 +368,7 @@ class FillStitch(EmbroideryElement): unit='mm', type='float', default=0.2, - sort_index=6) + sort_index=32) def running_stitch_tolerance(self): return max(self.get_float_param("running_stitch_tolerance_mm", 0.2), 0.01) @@ -336,7 +379,7 @@ class FillStitch(EmbroideryElement): type='int', default="1", select_items=[('fill_method', 'meander_fill')], - sort_index=7) + sort_index=33) def repeats(self): return max(1, self.get_int_param("repeats", 1)) @@ -350,11 +393,16 @@ class FillStitch(EmbroideryElement): type='str', select_items=[('fill_method', 'meander_fill')], default=0, - sort_index=8) + sort_index=34) def bean_stitch_repeats(self): return self.get_multiple_int_param("bean_stitch_repeats", "0") @property + def color(self): + # SVG spec says the default fill is black + return self.get_style("fill", "#000000") + + @property @param('fill_underlay', _('Underlay'), type='toggle', group=_('Fill Underlay'), default=True) def fill_underlay(self): return self.get_boolean_param("fill_underlay", default=True) @@ -429,44 +477,6 @@ class FillStitch(EmbroideryElement): return self.get_boolean_param("fill_underlay_skip_last", False) @property - @param('expand_mm', - _('Expand'), - tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes. Negative values contract instead.'), - unit='mm', - type='float', - default=0, - sort_index=5, - select_items=[('fill_method', 'auto_fill'), - ('fill_method', 'guided_fill'), - ('fill_method', 'meander_fill'), - ('fill_method', 'circular_fill')]) - def expand(self): - return self.get_float_param('expand_mm', 0) - - @property - @param('clip', _('Clip path'), - tooltip=_('Constrain stitching to the shape. Useful when smoothing and expand are used.'), - type='boolean', - default=False, - select_items=[('fill_method', 'meander_fill')], - sort_index=6) - def clip(self): - return self.get_boolean_param('clip', False) - - @property - @param('underpath', - _('Underpath'), - tooltip=_('Travel inside the shape when moving from section to section. Underpath ' - 'stitches avoid traveling in the direction of the row angle so that they ' - 'are not visible. This gives them a jagged appearance.'), - type='boolean', - default=True, - select_items=[('fill_method', 'auto_fill'), ('fill_method', 'guided_fill'), ('fill_method', 'circular_fill')], - sort_index=6) - def underpath(self): - return self.get_boolean_param('underpath', True) - - @property @param( 'underlay_underpath', _('Underpath'), |
