diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-05-01 06:59:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-01 06:59:46 +0200 |
| commit | 0c825d21631d467104cb65c61e15c39c46481e9e (patch) | |
| tree | dea60b14cdac3120df66639bf14e74fed7950170 /lib/extensions | |
| parent | b218aac86c016fac973fbdfe0e3c351062232e7b (diff) | |
Add multicolor satin extension (#2863)
Diffstat (limited to 'lib/extensions')
| -rw-r--r-- | lib/extensions/__init__.py | 2 | ||||
| -rw-r--r-- | lib/extensions/satin_multicolor.py | 56 |
2 files changed, 58 insertions, 0 deletions
diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index 7674fba5..86c75395 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -48,6 +48,7 @@ from .preferences import Preferences from .print_pdf import Print from .remove_embroidery_settings import RemoveEmbroiderySettings from .reorder import Reorder +from .satin_multicolor import SatinMulticolor from .select_elements import SelectElements from .selection_to_guide_line import SelectionToGuideLine from .selection_to_pattern import SelectionToPattern @@ -108,6 +109,7 @@ __all__ = extensions = [ApplyPalette, Print, RemoveEmbroiderySettings, Reorder, + SatinMulticolor, SelectElements, SelectionToGuideLine, SelectionToPattern, diff --git a/lib/extensions/satin_multicolor.py b/lib/extensions/satin_multicolor.py new file mode 100644 index 00000000..5657bdbf --- /dev/null +++ b/lib/extensions/satin_multicolor.py @@ -0,0 +1,56 @@ +# Authors: see git history +# +# Copyright (c) 2023 Authors +# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. + +import sys + +import wx +import wx.adv +from inkex import errormsg + +from ..elements import SatinColumn +from ..gui import MultiColorSatinPanel +from ..gui.simulator import SplitSimulatorWindow +from ..i18n import _ +from ..utils.svg_data import get_pagecolor +from .base import InkstitchExtension + + +class SatinMulticolor(InkstitchExtension): + def __init__(self, *args, **kwargs): + self.elements = set() + self.cancelled = False + InkstitchExtension.__init__(self, *args, **kwargs) + + def cancel(self): + self.cancelled = True + + def effect(self): + self.get_elements() + satins = [element for element in self.elements if isinstance(element, SatinColumn)] + if not satins: + errormsg(_("Please select at least one satin column.")) + return + + metadata = self.get_inkstitch_metadata() + background_color = get_pagecolor(self.svg.namedview) + + app = wx.App() + frame = SplitSimulatorWindow( + title=_("Ink/Stitch Multicolor Satin"), + panel_class=MultiColorSatinPanel, + elements=satins, + on_cancel=self.cancel, + metadata=metadata, + background_color=background_color, + target_duration=1 + ) + + frame.Show() + app.MainLoop() + + if self.cancelled: + # This prevents the superclass from outputting the SVG, because we + # may have modified the DOM. + sys.exit(0) |
