diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html
index a2548070d..d5111562e 100644
--- a/print/templates/print_overview.html
+++ b/print/templates/print_overview.html
@@ -26,7 +26,7 @@
diff --git a/print/templates/ui.html b/print/templates/ui.html
index 2db3a81d8..71908b52f 100644
--- a/print/templates/ui.html
+++ b/print/templates/ui.html
@@ -112,12 +112,12 @@
From f3cdcfbdfa693c569981c5ec6b3c87e6f352916e Mon Sep 17 00:00:00 2001
From: redhat421
Date: Tue, 15 Jan 2019 16:45:31 -0800
Subject: [PATCH 19/26] Remove extra self param from store_preset call. (#381)
It looks like an extra "self" parameter was added to the store_preset call in the add_preset function.
This prevents add_preset from working.
---
lib/gui/presets.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/gui/presets.py b/lib/gui/presets.py
index e6000718d..5337d8792 100644
--- a/lib/gui/presets.py
+++ b/lib/gui/presets.py
@@ -141,7 +141,7 @@ class PresetsPanel(wx.Panel):
if not overwrite and preset_name in self._load_presets():
info_dialog(self, _('Preset "%s" already exists. Please use another name or press "Overwrite"') % preset_name, caption=_('Preset'))
- self.store_preset(self, preset_name, self.parent.get_preset_data())
+ self.store_preset(preset_name, self.parent.get_preset_data())
event.Skip()
From fdd9a74fd6fc6e0aacc6766e186c4ffb2fec8e7a Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Sat, 26 Jan 2019 19:48:25 -0500
Subject: [PATCH 20/26] fix argument bug in auto-satin
---
lib/stitches/auto_satin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/stitches/auto_satin.py b/lib/stitches/auto_satin.py
index 7bc3e67ce..e204a4456 100644
--- a/lib/stitches/auto_satin.py
+++ b/lib/stitches/auto_satin.py
@@ -242,7 +242,7 @@ class RunningStitch(object):
@cache
def reversed(self):
- return RunningStitch(shgeo.LineString(reversed(self.path.coords)), self.style)
+ return RunningStitch(shgeo.LineString(reversed(self.path.coords)), self.original_element)
def is_sequential(self, other):
if not isinstance(other, RunningStitch):
From 4fe95be93ac3cbf29b721ca861828f580efbc484 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Thu, 7 Feb 2019 20:37:50 -0500
Subject: [PATCH 21/26] another try at a .JEF trim fix
---
pyembroidery | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyembroidery b/pyembroidery
index 73ca3eb8c..47b795a08 160000
--- a/pyembroidery
+++ b/pyembroidery
@@ -1 +1 @@
-Subproject commit 73ca3eb8c32da0636a4cad7a6915440705a5c71f
+Subproject commit 47b795a084bdc3281fbf944b940609bf86193fd8
From 52bf2c80b66889d471745260bf1679289d1c59e3 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Sat, 9 Feb 2019 20:37:14 -0500
Subject: [PATCH 22/26] fix style
---
lib/extensions/convert_to_satin.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py
index ef4ac557a..2b586e360 100644
--- a/lib/extensions/convert_to_satin.py
+++ b/lib/extensions/convert_to_satin.py
@@ -1,17 +1,18 @@
-import inkex
-from shapely import geometry as shgeo
-from itertools import chain, groupby
-import numpy
-from numpy import diff, sign, setdiff1d
-import math
from copy import deepcopy
+from itertools import chain, groupby
+import math
+
+import inkex
+from numpy import diff, sign, setdiff1d
+import numpy
+from shapely import geometry as shgeo
-from .base import InkstitchExtension
-from ..svg.tags import SVG_PATH_TAG
-from ..svg import get_correction_transform, PIXELS_PER_MM
from ..elements import Stroke
-from ..utils import Point
from ..i18n import _
+from ..svg import get_correction_transform, PIXELS_PER_MM
+from ..svg.tags import SVG_PATH_TAG
+from ..utils import Point
+from .base import InkstitchExtension
class SelfIntersectionError(Exception):
@@ -112,10 +113,10 @@ class ConvertToSatin(InkstitchExtension):
if not isinstance(left_rail, shgeo.LineString) or \
not isinstance(right_rail, shgeo.LineString):
- # If the parallel offsets come out as anything but a LineString, that means the
- # path intersects itself, when taking its stroke width into consideration. See
- # the last example for parallel_offset() in the Shapely documentation:
- # https://shapely.readthedocs.io/en/latest/manual.html#object.parallel_offset
+ # If the parallel offsets come out as anything but a LineString, that means the
+ # path intersects itself, when taking its stroke width into consideration. See
+ # the last example for parallel_offset() in the Shapely documentation:
+ # https://shapely.readthedocs.io/en/latest/manual.html#object.parallel_offset
raise SelfIntersectionError()
# for whatever reason, shapely returns a right-side offset's coordinates in reverse
From 754c2aa63af84a25efc401e8f364deb660361e98 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Thu, 14 Feb 2019 20:25:36 -0500
Subject: [PATCH 23/26] fix stub output handling
---
stub.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/stub.py b/stub.py
index 3d8731962..7c9975244 100644
--- a/stub.py
+++ b/stub.py
@@ -1,10 +1,11 @@
#!/usr/bin/env python
-import sys
import os
import subprocess
+import sys
import traceback
+
# ink/stitch
#
# stub.py: pyinstaller execution stub
@@ -15,7 +16,6 @@ import traceback
# This Python script exists only to execute the actual extension binary. It
# can be copied to, e.g., "embroider_params.py", in which case it will look
# for a binary at inkstitch/bin/embroider_params.
-
script_name = os.path.basename(__file__)
if script_name.endswith('.py'):
@@ -48,12 +48,12 @@ if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
-stdout = stdout.strip()
-if stdout:
- print stdout.strip(),
+sys.stdout.write(stdout)
+sys.stdout.flush()
stderr = stderr.strip()
if stderr:
- print >> sys.stderr, stderr.strip(),
+ sys.stderr.write(stderr.strip())
+ sys.stderr.flush()
sys.exit(extension.returncode)
From 4c7f8f32fd13cb41680efe9b9d478fab23dacfa0 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Fri, 15 Feb 2019 20:45:39 -0500
Subject: [PATCH 24/26] show inkscape label in error messages
---
lib/elements/element.py | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/lib/elements/element.py b/lib/elements/element.py
index d98673513..10b1852ad 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -1,15 +1,15 @@
-import sys
from copy import deepcopy
+import sys
-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
+import cubicsuperpath
+import simplestyle
+
+from ..commands import find_commands
+from ..i18n import _
+from ..svg import PIXELS_PER_MM, convert_length, get_doc_size, apply_transforms
+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)
From be7d0af82da95d64261351b6281153db1944c0b4 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Fri, 15 Feb 2019 20:51:10 -0500
Subject: [PATCH 25/26] improve error message when trying to autofill tiny
shapes
---
lib/elements/auto_fill.py | 54 +++++++++++++++++++++++++--------------
lib/exceptions.py | 2 ++
lib/stitches/auto_fill.py | 19 ++++++++++----
3 files changed, 51 insertions(+), 24 deletions(-)
create mode 100644 lib/exceptions.py
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 486243ea6..552922126 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]
+ 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()
- 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.fatal(message)
return [Patch(stitches=stitches, color=self.color)]
diff --git a/lib/exceptions.py b/lib/exceptions.py
new file mode 100644
index 000000000..30e595ea4
--- /dev/null
+++ b/lib/exceptions.py
@@ -0,0 +1,2 @@
+class InkstitchException(Exception):
+ pass
\ No newline at end of file
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index c7e654735..1c0be0a00 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -5,13 +5,18 @@ import sys
import networkx
import shapely
+from ..exceptions import InkstitchException
from ..i18n import _
from ..utils.geometry import Point as InkstitchPoint, cut
from .fill import intersect_region_with_grating, row_num, stitch_row
from .running_stitch import running_stitch
-class MaxQueueLengthExceeded(Exception):
+class MaxQueueLengthExceeded(InkstitchException):
+ pass
+
+
+class InvalidPath(InkstitchException):
pass
@@ -55,7 +60,7 @@ def auto_fill(shape,
rows_of_segments = intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing)
segments = [segment for row in rows_of_segments for segment in row]
- graph = build_graph(shape, segments, angle, row_spacing)
+ graph = build_graph(shape, segments, angle, row_spacing, max_stitch_length)
path = find_stitch_path(graph, segments, starting_point, ending_point)
stitches.extend(path_to_stitches(graph, path, shape, angle, row_spacing, max_stitch_length, running_stitch_length, staggers, skip_last))
@@ -90,7 +95,7 @@ def project(shape, coords, outline_index):
return outline.project(shapely.geometry.Point(*coords))
-def build_graph(shape, segments, angle, row_spacing):
+def build_graph(shape, segments, angle, row_spacing, max_stitch_length):
"""build a graph representation of the grating segments
This function builds a specialized graph (as in graph theory) that will
@@ -173,8 +178,12 @@ def build_graph(shape, segments, angle, row_spacing):
if i % 2 == edge_set:
graph.add_edge(node1, node2, key="extra")
- if not networkx.is_eulerian(graph):
- raise Exception(_("Unable to autofill. This most often happens because your shape is made up of multiple sections that aren't connected."))
+ if networkx.is_empty(graph) or not networkx.is_eulerian(graph):
+ if shape.area < max_stitch_length ** 2:
+ raise InvalidPath(_("This shape is so small that it cannot be filled with rows of stitches. "
+ "It would probably look best as a satin column or running stitch."))
+ else:
+ raise InvalidPath(_("Cannot parse shape. This most often happens because your shape is made up of multiple sections that aren't connected."))
return graph
From fa3236372bcee28f4aaa78da47b68c5d7f32cca4 Mon Sep 17 00:00:00 2001
From: Lex Neva
Date: Sat, 16 Feb 2019 16:46:16 -0500
Subject: [PATCH 26/26] fix style
---
lib/elements/auto_fill.py | 5 +++--
lib/exceptions.py | 2 +-
lib/stitches/auto_fill.py | 11 ++++++++---
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 552922126..b8d8d15fb 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)
diff --git a/lib/exceptions.py b/lib/exceptions.py
index 30e595ea4..c1ff36f0b 100644
--- a/lib/exceptions.py
+++ b/lib/exceptions.py
@@ -1,2 +1,2 @@
class InkstitchException(Exception):
- pass
\ No newline at end of file
+ pass
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index 1c0be0a00..0f07b7952 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -178,14 +178,19 @@ def build_graph(shape, segments, angle, row_spacing, max_stitch_length):
if i % 2 == edge_set:
graph.add_edge(node1, node2, key="extra")
+ check_graph(graph, shape, max_stitch_length)
+
+ return graph
+
+
+def check_graph(graph, shape, max_stitch_length):
if networkx.is_empty(graph) or not networkx.is_eulerian(graph):
if shape.area < max_stitch_length ** 2:
raise InvalidPath(_("This shape is so small that it cannot be filled with rows of stitches. "
"It would probably look best as a satin column or running stitch."))
else:
- raise InvalidPath(_("Cannot parse shape. This most often happens because your shape is made up of multiple sections that aren't connected."))
-
- return graph
+ raise InvalidPath(_("Cannot parse shape. "
+ "This most often happens because your shape is made up of multiple sections that aren't connected."))
def node_list_to_edge_list(node_list):