diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-05-08 17:17:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-08 17:17:14 +0200 |
| commit | c25bf5370ccb415c689295e541d8bbccb4684d5e (patch) | |
| tree | c4e3e8dcabe817e4c700008b238b7adc7112d80e | |
| parent | 762f052b663da16a32534fa2ed70df602d79fdab (diff) | |
save stitch plan display mode (#2278)
| -rw-r--r-- | lib/extensions/stitch_plan_preview.py | 9 | ||||
| -rw-r--r-- | lib/extensions/stitch_plan_preview_undo.py | 4 | ||||
| -rw-r--r-- | lib/svg/tags.py | 1 | ||||
| -rw-r--r-- | templates/stitch_plan_preview.xml | 6 |
4 files changed, 13 insertions, 7 deletions
diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py index 7e35f55d..4b2898bd 100644 --- a/lib/extensions/stitch_plan_preview.py +++ b/lib/extensions/stitch_plan_preview.py @@ -19,7 +19,7 @@ class StitchPlanPreview(InkstitchExtension): def __init__(self, *args, **kwargs): InkstitchExtension.__init__(self, *args, **kwargs) self.arg_parser.add_argument("-s", "--move-to-side", type=Boolean, default=True, dest="move_to_side") - self.arg_parser.add_argument("-v", "--layer-visibility", type=int, default=0, dest="layer_visibility") + self.arg_parser.add_argument("-v", "--layer-visibility", type=str, default="unchanged", dest="layer_visibility") self.arg_parser.add_argument("-n", "--needle-points", type=Boolean, default=False, dest="needle_points") self.arg_parser.add_argument("-i", "--insensitive", type=Boolean, default=False, dest="insensitive") self.arg_parser.add_argument("-c", "--visual-commands", type=Boolean, default="symbols", dest="visual_commands") @@ -45,13 +45,13 @@ class StitchPlanPreview(InkstitchExtension): # apply options layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") - # update layer visibility 0 = unchanged, 1 = hidden, 2 = lower opacity + # update layer visibility (unchanged, hidden, lower opacity) groups = self.document.getroot().findall(SVG_GROUP_TAG) self.set_invisible_layers_attribute(groups, layer) - if self.options.layer_visibility == 1: + if self.options.layer_visibility == "hidden": self.hide_all_layers() layer.style['display'] = "inline" - elif self.options.layer_visibility == 2: + elif self.options.layer_visibility == "lower_opacity": for g in groups: style = g.specified_style() # check groupmode and exclude stitch_plan layer @@ -85,6 +85,7 @@ class StitchPlanPreview(InkstitchExtension): if g.get(INKSCAPE_GROUPMODE) == "layer" and 'display' in g.style and g.style['display'] == 'none': invisible_layers.append(g.get_id()) layer.set(INKSTITCH_ATTRIBS['invisible_layers'], ",".join(invisible_layers)) + layer.set(INKSTITCH_ATTRIBS['layer_visibility'], self.options.layer_visibility) def ensure_marker(self): xpath = ".//svg:marker[@id='inkstitch-needle-point']" diff --git a/lib/extensions/stitch_plan_preview_undo.py b/lib/extensions/stitch_plan_preview_undo.py index 381cf549..f5cac709 100644 --- a/lib/extensions/stitch_plan_preview_undo.py +++ b/lib/extensions/stitch_plan_preview_undo.py @@ -17,9 +17,13 @@ def reset_stitch_plan(svg): layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") # get previously invisible layers (they still should be hidden afterwards) if layer is not None: + display_method = layer.get(INKSTITCH_ATTRIBS['layer_visibility'], 'unchanged') invisible_layers = layer.get(INKSTITCH_ATTRIBS['invisible_layers'], '').split(",") layer.getparent().remove(layer) + if display_method == "unchanged": + return + # if there are layers with reduced opacity, remove opacity attribute or unhide hidden layers for g in svg.findall(SVG_GROUP_TAG): style = g.specified_style() diff --git a/lib/svg/tags.py b/lib/svg/tags.py index f114d159..8045840d 100644 --- a/lib/svg/tags.py +++ b/lib/svg/tags.py @@ -153,6 +153,7 @@ inkstitch_attribs = [ 'min_random_split_length_mm', # stitch_plan 'invisible_layers', + 'layer_visibility', # All elements 'trim_after', 'stop_after', diff --git a/templates/stitch_plan_preview.xml b/templates/stitch_plan_preview.xml index 835475b0..b7c41898 100644 --- a/templates/stitch_plan_preview.xml +++ b/templates/stitch_plan_preview.xml @@ -13,9 +13,9 @@ </effect> <param name="move-to-side" type="boolean" gui-text="Move stitch plan beside the canvas">true</param> <param name="layer-visibility" type="optiongroup" appearance="combo" gui-text="Design layer visibility"> - <option value="0">Unchanged</option> - <option value="1">Hidden</option> - <option value="2">Lower opacity</option> + <option value="unchanged">Unchanged</option> + <option value="hidden">Hidden</option> + <option value="lower_opacity">Lower opacity</option> </param> <param name="needle-points" type="boolean" gui-text="Needle points">false</param> <param name="insensitive" type="boolean" gui-text="Lock" |
