diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2019-08-06 04:42:48 +0200 |
|---|---|---|
| committer | Lex Neva <lexelby@users.noreply.github.com> | 2019-08-05 22:42:48 -0400 |
| commit | 077f7ea72ba38790bf030d3181c44787fef953b6 (patch) | |
| tree | 1cd8bf2896d587735c98eee06589f4c88bee3aa9 /lib/elements/auto_fill.py | |
| parent | cdb8d1d0d4a6dba9a1eb146167b1aef01de0e9d6 (diff) | |
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
Diffstat (limited to 'lib/elements/auto_fill.py')
| -rw-r--r-- | lib/elements/auto_fill.py | 24 |
1 files changed, 18 insertions, 6 deletions
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 |
