From fabe5bcd32a8ce7488034b5d67f1dacf1b364556 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 28 Jan 2018 16:10:37 -0500 Subject: Fix simulate (#42) * Simulate now works regardless of the output format you chose when you ran Embroider. * Simulate (and the preview in Params) now respects TRIMs. * Inkscape restart required (embroider.inx changed). This one kind of grew in the telling. #37 was a theoretically simple bug, but in reality, the code necessary to fix it was the straw that broke the camel's back, and I had to do a fair bit of (much needed) code reorganization. Mostly the reorganization was just under the hood, but there was one user-facing change around the Embroider extension's settings window. Way back in the day, the only way to control things like the stitch length or satin density was through global options specified in the extension settings. We've long since moved to per-object params, but for backward compatibility, ink/stitch defaulted to the command-line arguments. That means that it was possible to get different stitch results from the same SVG file if you changed the extension's settings. For that reason, I never touched mine. I didn't intend for my users to use those extension-level settings at all, and I've planned to remove those settings for awhile now. At this point, the extension settings just getting in the way of implementing more features, so I'm getting rid of them and moving the defaults into the parameters system. I've still left things like the output format and the collapse length (although I'm considering moving that one too). --- embroider_params.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'embroider_params.py') diff --git a/embroider_params.py b/embroider_params.py index 78b5001c..b53a586d 100644 --- a/embroider_params.py +++ b/embroider_params.py @@ -13,7 +13,8 @@ import wx from wx.lib.scrolledpanel import ScrolledPanel from collections import defaultdict import inkex -from embroider import Param, EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn, descendants +from inkstitch import Param, EmbroideryElement, get_nodes +from embroider import Fill, AutoFill, Stroke, SatinColumn from functools import partial from itertools import groupby from embroider_simulate import EmbroiderySimulator @@ -307,7 +308,7 @@ class ParamsTab(ScrolledPanel): input.Bind(wx.EVT_TEXT, self.changed) else: value = param.values[0] if param.values else "" - input = wx.TextCtrl(self, wx.ID_ANY, value=value) + input = wx.TextCtrl(self, wx.ID_ANY, value=str(value)) input.Bind(wx.EVT_TEXT, self.changed) self.param_inputs[param.name] = input @@ -328,7 +329,8 @@ class SettingsFrame(wx.Frame): self.tabs_factory = kwargs.pop('tabs_factory', []) self.cancel_hook = kwargs.pop('on_cancel', None) wx.Frame.__init__(self, None, wx.ID_ANY, - "Embroidery Params" + "Embroidery Params", + pos=wx.Point(0,0) ) self.notebook = wx.Notebook(self, wx.ID_ANY) self.tabs = self.tabs_factory(self.notebook) @@ -623,17 +625,6 @@ class EmbroiderParams(inkex.Effect): self.cancelled = False inkex.Effect.__init__(self, *args, **kwargs) - def get_nodes(self): - if self.selected: - nodes = [] - for node in self.document.getroot().iter(): - if node.get("id") in self.selected: - nodes.extend(descendants(node)) - else: - nodes = descendants(self.document.getroot()) - - return nodes - def embroidery_classes(self, node): element = EmbroideryElement(node) classes = [] @@ -651,10 +642,10 @@ class EmbroiderParams(inkex.Effect): return classes def get_nodes_by_class(self): - nodes = self.get_nodes() + nodes = get_nodes(self) nodes_by_class = defaultdict(list) - for z, node in enumerate(self.get_nodes()): + for z, node in enumerate(nodes): for cls in self.embroidery_classes(node): element = cls(node) element.order = z -- cgit v1.2.3