summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-04-28 20:44:45 -0400
committerGitHub <noreply@github.com>2018-04-28 20:44:45 -0400
commit19fcecd6bd71236b35a5b53f35aea2044dc53dce (patch)
tree5f946217629273fb3796c6e92ece38d4d7e59740
parent3b4c57d7fc88635d8a696c5279b39dcafa1f8b34 (diff)
parentf7a8fee74cc991ce6498c086fd84baad4f36c03e (diff)
Merge pull request #152 from lexelby/lexelby-stroke-fix
deprecate 0.5-width running stitch mode
-rw-r--r--inkstitch/elements/stroke.py43
-rw-r--r--messages.po10
2 files changed, 50 insertions, 3 deletions
diff --git a/inkstitch/elements/stroke.py b/inkstitch/elements/stroke.py
index 0ce3fa67..360e3744 100644
--- a/inkstitch/elements/stroke.py
+++ b/inkstitch/elements/stroke.py
@@ -1,8 +1,12 @@
+import sys
from .. import _, Point
from .element import param, EmbroideryElement, Patch
from ..utils import cache
+warned_about_legacy_running_stitch = False
+
+
class Stroke(EmbroideryElement):
element_name = "Stroke"
@@ -50,8 +54,43 @@ class Stroke(EmbroideryElement):
return self.get_boolean_param('manual_stitch')
def is_running_stitch(self):
- # stroke width <= 0.5 pixels is deprecated in favor of dashed lines
- return self.dashed or self.stroke_width <= 0.5
+ # using stroke width <= 0.5 pixels to indicate running stitch is deprecated in favor of dashed lines
+
+ try:
+ stroke_width = float(self.get_style("stroke-width"))
+ except ValueError:
+ stroke_width = 1
+
+ if self.dashed:
+ return True
+ elif stroke_width <= 0.5 and self.get_float_param('running_stitch_length_mm', None) is not None:
+ # if they use a stroke width less than 0.5 AND they specifically set a running stitch
+ # length, then assume they intend to use the deprecated <= 0.5 method to set running
+ # stitch.
+ #
+ # Note that we use self.get_style("stroke_width") _not_ self.stroke_width above. We
+ # explicitly want the stroke width in "user units" ("document units") -- that is, what
+ # the user sees in inkscape's stroke settings.
+ #
+ # Also note that we don't use self.running_stitch_length_mm above. This is because we
+ # want to see if they set a running stitch length at all, and the property will apply
+ # a default value.
+ #
+ # Thsi is so tricky, and and intricate that's a major reason that we deprecated the
+ # 0.5 units rule.
+
+ # Warn them the first time.
+ global warned_about_legacy_running_stitch
+ if not warned_about_legacy_running_stitch:
+ warned_about_legacy_running_stitch = True
+ print >> sys.stderr, _("Legacy running stitch setting detected!\n\nIt looks like you're using a stroke " + \
+ "smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set " + \
+ "your stroke to be dashed to indicate running stitch. Any kind of dash will work.")
+
+ # still allow the deprecated setting to work in order to support old files
+ return True
+ else:
+ return False
def stroke_points(self, emb_point_list, zigzag_spacing, stroke_width):
# TODO: use inkstitch.stitches.running_stitch
diff --git a/messages.po b/messages.po
index 956d1986..82c2dc2e 100644
--- a/messages.po
+++ b/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2018-04-28 17:59-0400\n"
+"POT-Creation-Date: 2018-04-28 20:42-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -316,6 +316,14 @@ msgid ""
msgstr ""
msgid ""
+"Legacy running stitch setting detected!\n"
+"\n"
+"It looks like you're using a stroke smaller than 0.5 units to indicate a "
+"running stitch, which is deprecated. Instead, please set your stroke to "
+"be dashed to indicate running stitch. Any kind of dash will work."
+msgstr ""
+
+msgid ""
"Unable to autofill. This most often happens because your shape is made "
"up of multiple sections that aren't connected."
msgstr ""