From f7a8fee74cc991ce6498c086fd84baad4f36c03e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 19 Apr 2018 14:49:33 -0400 Subject: [PATCH] deprecate 0.5-width running stitch mode Discussion: https://github.com/lexelby/inkstitch/issues/136#issuecomment-382824153 --- inkstitch/elements/stroke.py | 43 ++++++++++++++++++++++++++++++++++-- messages.po | 10 ++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/inkstitch/elements/stroke.py b/inkstitch/elements/stroke.py index 0ce3fa67b..360e37447 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 956d1986b..82c2dc2e6 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 \n" "Language-Team: LANGUAGE \n" @@ -315,6 +315,14 @@ msgid "" "ignored." 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."