From 8e70f3d2feaab8a14f775a5ef84002bdab9688f0 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:10:40 +0100 Subject: Add object based min stitch length (#2792) * add object based min stitch length (overwrites global) * add object based minimum jump stitch (overwrites global) * rename patches to stitch_groups --- lib/elements/element.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'lib/elements/element.py') diff --git a/lib/elements/element.py b/lib/elements/element.py index 7145571b..6c2fa15a 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -218,6 +218,28 @@ class EmbroideryElement(object): width = convert_length(width) return width * self.stroke_scale + @property + @param('min_stitch_length_mm', + _('Minimum stitch length'), + tooltip=_('Overwrite global minimum stitch length setting. Shorter stitches than that will be removed.'), + type='float', + default=None, + sort_index=48) + @cache + def min_stitch_length(self): + return self.get_float_param("min_stitch_length_mm") + + @property + @param('min_jump_stitch_length_mm', + _('Minimum jump stitch length'), + tooltip=_('Overwrite global minimum jump stitch length setting. Shorter distances to the next object will have no lock stitches.'), + type='float', + default=None, + sort_index=49) + @cache + def min_jump_stitch_length(self): + return self.get_float_param("min_jump_stitch_length_mm") + @property @param('ties', _('Allow lock stitches'), @@ -472,7 +494,7 @@ class EmbroideryElement(object): return lock_start, lock_end - def to_stitch_groups(self, last_patch): + def to_stitch_groups(self, last_stitch_group): raise NotImplementedError("%s must implement to_stitch_groups()" % self.__class__.__name__) @debug.time @@ -576,6 +598,10 @@ class EmbroideryElement(object): stitch_groups[-1].trim_after = self.has_command("trim") or self.trim_after stitch_groups[-1].stop_after = self.has_command("stop") or self.stop_after + for stitch_group in stitch_groups: + stitch_group.min_jump_stitch_length = self.min_jump_stitch_length + stitch_group.set_minimum_stitch_length(self.min_stitch_length) + self._save_cached_stitch_groups(stitch_groups, previous_stitch) debug.log(f"ending {self.node.get('id')} {self.node.get(INKSCAPE_LABEL)}") -- cgit v1.2.3