summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2019-02-16 17:07:34 -0500
committerGitHub <noreply@github.com>2019-02-16 17:07:34 -0500
commit2ab4c451e8042868b2516a6b3fe1f60836f27ffe (patch)
tree0ce616ac57e6a2aa507461486233c71373467c9a /lib/elements
parentbd6e4d9d32fd314b66f3c5d798c7151bf543d07f (diff)
parentfa3236372bcee28f4aaa78da47b68c5d7f32cca4 (diff)
tons of bug fixes (#364)
bug fixes
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/auto_fill.py71
-rw-r--r--lib/elements/element.py29
-rw-r--r--lib/elements/fill.py21
-rw-r--r--lib/elements/satin_column.py25
4 files changed, 100 insertions, 46 deletions
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 65b11fb1..b8d8d15f 100644
--- a/lib/elements/auto_fill.py
+++ b/lib/elements/auto_fill.py
@@ -1,8 +1,12 @@
import math
+import traceback
+
from shapely import geometry as shgeo
+
+from ..exceptions import InkstitchException
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
@@ -93,6 +97,18 @@ class AutoFill(Fill):
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'),
tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'),
@@ -142,25 +158,42 @@ 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,
- 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,
- 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"
+ # 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)
return [Patch(stitches=stitches, color=self.color)]
diff --git a/lib/elements/element.py b/lib/elements/element.py
index d9867351..10b1852a 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -1,15 +1,15 @@
-import sys
from copy import deepcopy
+import sys
+
+from cspsubdiv import cspsubdiv
+import cubicsuperpath
+import simplestyle
+from ..commands import find_commands
from ..i18n import _
-from ..utils import cache
from ..svg import PIXELS_PER_MM, convert_length, get_doc_size, apply_transforms
-from ..commands import find_commands
-
-# inkscape-provided utilities
-import simplestyle
-import cubicsuperpath
-from cspsubdiv import cspsubdiv
+from ..svg.tags import INKSCAPE_LABEL
+from ..utils import cache
class Patch:
@@ -274,7 +274,14 @@ class EmbroideryElement(object):
return patches
def fatal(self, message):
- # L10N used when showing an error message to the user such as "satin column: One or more of the rungs doesn't
- # intersect both rails."
- print >> sys.stderr, self.node.get("id") + ":", _("error:"), message.encode("UTF-8")
+ label = self.node.get(INKSCAPE_LABEL)
+ id = self.node.get("id")
+ if label:
+ name = "%s (%s)" % (label, id)
+ else:
+ name = id
+
+ # L10N used when showing an error message to the user such as
+ # "Some Path (path1234): error: satin column: One or more of the rungs doesn't intersect both rails."
+ print >> sys.stderr, "%s: %s %s" % (name, _("error:"), message.encode("UTF-8"))
sys.exit(1)
diff --git a/lib/elements/fill.py b/lib/elements/fill.py
index 4156a24b..357adf4b 100644
--- a/lib/elements/fill.py
+++ b/lib/elements/fill.py
@@ -1,11 +1,12 @@
-from shapely import geometry as shgeo
import math
-from .element import param, EmbroideryElement, Patch
+from shapely import geometry as shgeo
+
from ..i18n import _
+from ..stitches import legacy_fill
from ..svg import PIXELS_PER_MM
from ..utils import cache
-from ..stitches import legacy_fill
+from .element import param, EmbroideryElement, Patch
class Fill(EmbroideryElement):
@@ -42,6 +43,17 @@ class Fill(EmbroideryElement):
@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',
+ 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. '
@@ -133,5 +145,6 @@ class Fill(EmbroideryElement):
self.end_row_spacing,
self.max_stitch_length,
self.flip,
- self.staggers)
+ self.staggers,
+ self.skip_last)
return [Patch(stitches=stitch_list, color=self.color) for stitch_list in stitch_lists]
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 1f9854ed..f891e049 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -1,12 +1,13 @@
-from itertools import chain, izip
from copy import deepcopy
-from shapely import geometry as shgeo, affinity as shaffinity
+from itertools import chain, izip
+
import cubicsuperpath
+from shapely import geometry as shgeo, affinity as shaffinity
-from .element import param, EmbroideryElement, Patch
from ..i18n import _
-from ..utils import cache, Point, cut, collapse_duplicate_point
from ..svg import line_strings_to_csp, point_lists_to_csp
+from ..utils import cache, Point, cut, collapse_duplicate_point
+from .element import param, EmbroideryElement, Patch
class SatinColumn(EmbroideryElement):
@@ -255,7 +256,7 @@ class SatinColumn(EmbroideryElement):
intersections += len(intersection)
break
elif not isinstance(intersection, shgeo.Point):
- self.fatal("intersection is a: %s %s" % (intersection, intersection.geoms))
+ self.fatal("INTERNAL ERROR: intersection is: %s %s" % (intersection, getattr(intersection, 'geoms', None)))
else:
intersections += 1
@@ -716,22 +717,22 @@ class SatinColumn(EmbroideryElement):
# First, verify that we have valid paths.
self.validate_satin_column()
- patches = []
+ patch = Patch(color=self.color)
if self.center_walk_underlay:
- patches.append(self.do_center_walk())
+ patch += self.do_center_walk()
if self.contour_underlay:
- patches.append(self.do_contour_underlay())
+ patch += self.do_contour_underlay()
if self.zigzag_underlay:
# zigzag underlay comes after contour walk underlay, so that the
# zigzags sit on the contour walk underlay like rail ties on rails.
- patches.append(self.do_zigzag_underlay())
+ patch += self.do_zigzag_underlay()
if self.e_stitch:
- patches.append(self.do_e_stitch())
+ patch += self.do_e_stitch()
else:
- patches.append(self.do_satin())
+ patch += self.do_satin()
- return patches
+ return [patch]