add lock stitches select box (#1076)

Co-authored-by: Lex Neva <github.com@lexneva.name>
pull/1097/head
Kaalleen 2021-03-14 09:38:36 +01:00 zatwierdzone przez GitHub
rodzic 3dd767917d
commit 21614c7c3a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
6 zmienionych plików z 50 dodań i 28 usunięć

Wyświetl plik

@ -17,11 +17,12 @@ from ..utils import Point, cache
class Patch:
"""A raw collection of stitches with attached instructions."""
def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, stitch_as_is=False):
def __init__(self, color=None, stitches=None, trim_after=False, stop_after=False, tie_modus=0, stitch_as_is=False):
self.color = color
self.stitches = stitches or []
self.trim_after = trim_after
self.stop_after = stop_after
self.tie_modus = tie_modus
self.stitch_as_is = stitch_as_is
def __add__(self, other):
@ -42,7 +43,8 @@ class Patch:
class Param(object):
def __init__(self, name, description, unit=None, values=[], type=None, group=None, inverse=False, default=None, tooltip=None, sort_index=0):
def __init__(self, name, description, unit=None, values=[], type=None, group=None, inverse=False,
options=[], default=None, tooltip=None, sort_index=0):
self.name = name
self.description = description
self.unit = unit
@ -50,6 +52,7 @@ class Param(object):
self.type = type
self.group = group
self.inverse = inverse
self.options = options
self.default = default
self.tooltip = tooltip
self.sort_index = sort_index
@ -74,14 +77,20 @@ class EmbroideryElement(object):
def __init__(self, node):
self.node = node
# update legacy embroider_ attributes to namespaced attributes
legacy_attribs = False
for attrib in self.node.attrib:
if attrib.startswith('embroider_'):
# update embroider_ attributes to namespaced attributes
self.replace_legacy_param(attrib)
legacy_attribs = True
# convert legacy tie setting
legacy_tie = self.get_boolean_param('ties', None)
if legacy_tie is False:
self.set_param('ties', 3)
elif legacy_tie is True:
self.set_param('ties', 0)
# defaut setting for fill_underlay has changed
if legacy_attribs and not self.get_param('fill_underlay', ""):
# defaut setting for fill_underlay has changed
self.set_param('fill_underlay', False)
@property
@ -234,14 +243,17 @@ class EmbroideryElement(object):
@property
@param('ties',
_('Ties'),
tooltip=_('Add ties. Manual stitch will not add ties.'),
type='boolean',
default=True,
_('Allow lock stitches'),
tooltip=_('Tie thread at the beginning and/or end of this object. Manual stitch will not add lock stitches.'),
type='dropdown',
# Ties: 0 = Both | 1 = Before | 2 = After | 3 = Neither
# L10N options to allow lock stitch before and after objects
options=[_("Both"), _("Before"), _("After"), _("Neither")],
default=0,
sort_index=4)
@cache
def ties(self):
return self.get_boolean_param("ties", True)
return self.get_int_param("ties", 0)
@property
def path(self):
@ -348,9 +360,8 @@ class EmbroideryElement(object):
patches = self.to_patches(last_patch)
if not self.ties:
for patch in patches:
patch.stitch_as_is = True
for patch in patches:
patch.tie_modus = self.ties
if patches:
patches[-1].trim_after = self.has_command("trim") or self.trim_after

Wyświetl plik

@ -153,7 +153,11 @@ class ParamsTab(ScrolledPanel):
for name, input in self.param_inputs.items():
if input in self.changed_inputs and input != self.toggle_checkbox:
values[name] = input.GetValue()
try:
values[name] = input.GetValue()
except AttributeError:
# dropdown
values[name] = input.GetSelection()
return values
@ -271,6 +275,10 @@ class ParamsTab(ScrolledPanel):
input.SetValue(param.values[0])
input.Bind(wx.EVT_CHECKBOX, self.changed)
elif param.type == 'dropdown':
input = wx.Choice(self, wx.ID_ANY, choices=param.options)
input.SetSelection(int(param.values[0]))
input.Bind(wx.EVT_CHOICE, self.changed)
elif len(param.values) > 1:
input = wx.ComboBox(self, wx.ID_ANY, choices=sorted(str(value) for value in param.values), style=wx.CB_DROPDOWN)
input.Bind(wx.EVT_COMBOBOX, self.changed)

Wyświetl plik

@ -681,7 +681,6 @@ class EmbroiderySimulator(wx.Frame):
stitch_plan = kwargs.pop('stitch_plan', None)
stitches_per_second = kwargs.pop('stitches_per_second', 16)
target_duration = kwargs.pop('target_duration', None)
size = kwargs.get('size', (0, 0))
wx.Frame.__init__(self, *args, **kwargs)
self.statusbar = self.CreateStatusBar(2)
self.statusbar.SetStatusWidths([250, -1])

Wyświetl plik

@ -2,7 +2,7 @@ from ..utils.geometry import Point
class Stitch(Point):
def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, no_ties=False):
def __init__(self, x, y=None, color=None, jump=False, stop=False, trim=False, color_change=False, tie_modus=0, no_ties=False):
self.x = x
self.y = y
self.color = color
@ -10,6 +10,7 @@ class Stitch(Point):
self.trim = trim
self.stop = stop
self.color_change = color_change
self.tie_modus = tie_modus
self.no_ties = no_ties
# Allow creating a Stitch from a Point
@ -19,18 +20,18 @@ class Stitch(Point):
self.y = point.y
def __repr__(self):
return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s)" % (self.x,
self.y,
self.color,
"JUMP" if self.jump else " ",
"TRIM" if self.trim else " ",
"STOP" if self.stop else " ",
"NO TIES" if self.no_ties else " ",
"COLOR CHANGE" if self.color_change else " "
)
return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.x,
self.y,
self.color,
"JUMP" if self.jump else " ",
"TRIM" if self.trim else " ",
"STOP" if self.stop else " ",
"TIE MODUS" if self.tie_modus else " ",
"NO TIES" if self.no_ties else " ",
"COLOR CHANGE" if self.color_change else " ")
def copy(self):
return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.no_ties)
return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.tie_modus, self.no_ties)
def __json__(self):
return vars(self)

Wyświetl plik

@ -40,7 +40,7 @@ def patches_to_stitch_plan(patches, collapse_len=None, disable_ties=False):
if len(color_block) and (patch.stitches[0] - color_block.stitches[-1]).length() > collapse_len:
color_block.add_stitch(patch.stitches[0], jump=True)
color_block.add_stitches(patch.stitches, no_ties=patch.stitch_as_is)
color_block.add_stitches(stitches=patch.stitches, tie_modus=patch.tie_modus, no_ties=patch.stitch_as_is)
if patch.trim_after:
color_block.add_stitch(trim=True)

Wyświetl plik

@ -31,11 +31,14 @@ def add_tie(stitches, tie_path):
def add_tie_off(stitches):
add_tie(stitches, stitches[-1:-3:-1])
# tie_modus: 0 = both | 1 = before | 2 = after | 3 = neither
if stitches[0].tie_modus not in [1, 3]:
add_tie(stitches, stitches[-1:-3:-1])
def add_tie_in(stitches, upcoming_stitches):
add_tie(stitches, upcoming_stitches)
if stitches[0].tie_modus not in [2, 3]:
add_tie(stitches, upcoming_stitches)
def add_ties(stitch_plan):