summaryrefslogtreecommitdiff
path: root/lib/elements/element.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements/element.py')
-rw-r--r--lib/elements/element.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index c0b7ee0f..d3690b4c 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -58,13 +58,16 @@ def param(*args, **kwargs):
class EmbroideryElement(object):
def __init__(self, node):
self.node = node
+ self._update_legacy_params()
+ def _update_legacy_params(self): # noqa: C901
# update legacy embroider_ attributes to namespaced attributes
legacy_attribs = False
for attrib in self.node.attrib:
if attrib.startswith('embroider_'):
self.replace_legacy_param(attrib)
legacy_attribs = True
+
# convert legacy tie setting
legacy_tie = self.get_param('ties', None)
if legacy_tie == "True":
@@ -83,10 +86,36 @@ class EmbroideryElement(object):
elif legacy_fill_method == 3:
self.set_param('fill_method', 'legacy_fill')
+ # legacy satin method
+ if self.get_boolean_param('e_stitch', False) is True:
+ self.remove_param('e_stitch')
+ self.set_param('satin_method', 'e_stitch')
+
# default setting for fill_underlay has changed
if legacy_attribs and not self.get_param('fill_underlay', ""):
self.set_param('fill_underlay', False)
+ # convert legacy stroke_method
+ if self.get_style("stroke"):
+ # manual stitch
+ legacy_manual_stitch = self.get_boolean_param('manual_stitch', False)
+ if legacy_manual_stitch is True:
+ self.remove_param('manual_stitch')
+ self.set_param('stroke_method', 'manual_stitch')
+ # stroke_method
+ legacy_stroke_method = self.get_int_param('stroke_method', None)
+ if legacy_stroke_method == 0:
+ self.set_param('stroke_method', 'running_stitch')
+ elif legacy_stroke_method == 1:
+ self.set_param('stroke_method', 'ripple_stitch')
+ if (not self.get_param('stroke_method', None) and
+ self.get_param('satin_column', False) is False and
+ not self.node.style('stroke-dasharray')):
+ self.set_param('stroke_method', 'zigzag_stitch')
+ # if the stroke method is a zigzag-stitch but we are receiving a dashed line, set it to running stitch
+ if self.get_param('stroke_method', None) == 'zigzag_stitch' and self.node.style('stroke-dasharray'):
+ self.set_param('stroke_method', 'running_stitch')
+
@property
def id(self):
return self.node.get('id')
@@ -193,6 +222,10 @@ class EmbroideryElement(object):
param = INKSTITCH_ATTRIBS[name]
self.node.set(param, str(value))
+ def remove_param(self, name):
+ param = INKSTITCH_ATTRIBS[name]
+ del self.node.attrib[param]
+
@cache
def _get_specified_style(self):
# We want to cache this, because it's quite expensive to generate.