From 9ae97154d689b188c796e5d11820e026ed1f9326 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 12 Dec 2018 20:26:22 -0500 Subject: add option to skip last stitch in fill rows --- lib/elements/auto_fill.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/elements/auto_fill.py') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 65b11fb1..486243ea 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -1,8 +1,10 @@ import math + from shapely import geometry as shgeo + from ..i18n import _ -from ..utils import cache from ..stitches import auto_fill +from ..utils import cache from .element import param, Patch from .fill import Fill @@ -92,6 +94,18 @@ class AutoFill(Fill): def fill_underlay_inset(self): return self.get_float_param('fill_underlay_inset_mm', 0) + @property + @param( + 'fill_underlay_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.'), + group=_('AutoFill Underlay'), + type='boolean', + default=False) + def fill_underlay_skip_last(self): + return self.get_boolean_param("fill_underlay_skip_last", False) + @property @param('expand_mm', _('Expand'), @@ -150,6 +164,7 @@ class AutoFill(Fill): self.fill_underlay_max_stitch_length, self.running_stitch_length, self.staggers, + self.fill_underlay_skip_last, starting_point)) starting_point = stitches[-1] @@ -160,6 +175,7 @@ class AutoFill(Fill): self.max_stitch_length, self.running_stitch_length, self.staggers, + self.skip_last, starting_point, ending_point)) -- cgit v1.2.3 From be7d0af82da95d64261351b6281153db1944c0b4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 15 Feb 2019 20:51:10 -0500 Subject: improve error message when trying to autofill tiny shapes --- lib/elements/auto_fill.py | 56 ++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'lib/elements/auto_fill.py') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 486243ea..55292212 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -1,7 +1,9 @@ import math +import traceback from shapely import geometry as shgeo +from ..exceptions import InkstitchException from ..i18n import _ from ..stitches import auto_fill from ..utils import cache @@ -156,27 +158,41 @@ class AutoFill(Fill): starting_point = self.get_starting_point(last_patch) ending_point = self.get_ending_point() - if self.fill_underlay: - stitches.extend(auto_fill(self.underlay_shape, - self.fill_underlay_angle, - self.fill_underlay_row_spacing, - self.fill_underlay_row_spacing, - self.fill_underlay_max_stitch_length, + try: + if self.fill_underlay: + stitches.extend(auto_fill(self.underlay_shape, + self.fill_underlay_angle, + self.fill_underlay_row_spacing, + self.fill_underlay_row_spacing, + self.fill_underlay_max_stitch_length, + self.running_stitch_length, + self.staggers, + self.fill_underlay_skip_last, + starting_point)) + starting_point = stitches[-1] + + stitches.extend(auto_fill(self.fill_shape, + self.angle, + self.row_spacing, + self.end_row_spacing, + self.max_stitch_length, self.running_stitch_length, self.staggers, - self.fill_underlay_skip_last, - starting_point)) - starting_point = stitches[-1] - - stitches.extend(auto_fill(self.fill_shape, - self.angle, - self.row_spacing, - self.end_row_spacing, - self.max_stitch_length, - self.running_stitch_length, - self.staggers, - self.skip_last, - starting_point, - ending_point)) + self.skip_last, + starting_point, + ending_point)) + except InkstitchException, exc: + # for one of our exceptions, just print the message + self.fatal(_("Unable to autofill: ") + str(exc)) + except Exception, exc: + # for an uncaught exception, give a little more info so that they can create a bug report + message = "" + message += _("Error during autofill! This means that there is a problem with Ink/Stitch.") + message += "\n\n" + message += _("If you'd like to help us make Ink/Stitch better, please paste this whole message into a new issue at: https://github.com/inkstitch/inkstitch/issues/new") + message += "\n\n" + message += traceback.format_exc() + + self.fatal(message) return [Patch(stitches=stitches, color=self.color)] -- cgit v1.2.3 From fa3236372bcee28f4aaa78da47b68c5d7f32cca4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 16 Feb 2019 16:46:16 -0500 Subject: fix style --- lib/elements/auto_fill.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/elements/auto_fill.py') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 55292212..b8d8d15f 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -189,8 +189,9 @@ class AutoFill(Fill): message = "" message += _("Error during autofill! This means that there is a problem with Ink/Stitch.") message += "\n\n" - message += _("If you'd like to help us make Ink/Stitch better, please paste this whole message into a new issue at: https://github.com/inkstitch/inkstitch/issues/new") - message += "\n\n" + # L10N this message is followed by a URL: https://github.com/inkstitch/inkstitch/issues/new + message += _("If you'd like to help us make Ink/Stitch better, please paste this whole message into a new issue at: ") + message += "https://github.com/inkstitch/inkstitch/issues/new\n\n" message += traceback.format_exc() self.fatal(message) -- cgit v1.2.3