From 077f7ea72ba38790bf030d3181c44787fef953b6 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Tue, 6 Aug 2019 04:42:48 +0200 Subject: add Troubleshoot extension (#465) adds an extension to help you understand what's wrong with an object and how to fix it, e.g. "invalid" fill shapes --- lib/elements/auto_fill.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'lib/elements/auto_fill.py') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 62d3493c..a37078b8 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -4,13 +4,21 @@ import traceback from shapely import geometry as shgeo -from ..exceptions import InkstitchException from ..i18n import _ from ..stitches import auto_fill from ..utils import cache -from .element import param, Patch +from .element import Patch, param from .fill import Fill +from .validation import ValidationWarning + + +class SmallShapeWarning(ValidationWarning): + name = _("Small Fill") + description = _("This fill object is so small that it would probably look better as running stitch or satin column. " + "For very small shapes, fill stitch is not possible, and Ink/Stitch will use running stitch around " + "the outline instead.") + class AutoFill(Fill): element_name = _("AutoFill") @@ -208,10 +216,7 @@ class AutoFill(Fill): starting_point, ending_point, self.underpath)) - except InkstitchException, exc: - # for one of our exceptions, just print the message - self.fatal(_("Unable to autofill: ") + str(exc)) - except Exception, exc: + except Exception: if hasattr(sys, 'gettrace') and sys.gettrace(): # if we're debugging, let the exception bubble up raise @@ -228,3 +233,10 @@ class AutoFill(Fill): self.fatal(message) return [Patch(stitches=stitches, color=self.color)] + + def validation_warnings(self): + if self.shape.area < 20: + yield SmallShapeWarning(self.shape.centroid) + + for warning in super(AutoFill, self).validation_warnings(): + yield warning -- cgit v1.2.3