2024-05-01 04:59:46 +00:00
|
|
|
# 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
|
2024-05-29 12:38:17 +00:00
|
|
|
from ..gui.satin_multicolor import MultiColorSatinPanel
|
2024-05-01 04:59:46 +00:00
|
|
|
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)
|