diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2024-04-30 14:21:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-30 20:21:32 +0200 |
| commit | 3f0f04abec4ef1d12c670bca866db76a5a7d4d6a (patch) | |
| tree | 1a485e0a126d0a3d0619f2b7521081d9edcfe299 /lib/extensions/simulator.py | |
| parent | 7af665806adc3194ff37393622b088043fec77c7 (diff) | |
simulator fixes (#2844)
* fix slide and control panel rendering bugs
* clear marker lists when clearing stitch plan
* switch simulator back to wx
* remove unused function
* fix off-by-one error in color bar
* avoid overlapping command symbols of different types
* don't maximize simulator
* adjust alignment
* remove unused API server
* bugfix
* focus entire simulator panel
* rename simulator/realistic preview -> simulator
* experimental: background color picker
* set pagecolor to background color by default
* satisfy macos
* toggle jumps on drawing canvas
* clear frog family
---------
Co-authored-by: Kaalleen
Diffstat (limited to 'lib/extensions/simulator.py')
| -rw-r--r-- | lib/extensions/simulator.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/extensions/simulator.py b/lib/extensions/simulator.py index 3b532bf2..57978b73 100644 --- a/lib/extensions/simulator.py +++ b/lib/extensions/simulator.py @@ -3,9 +3,11 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -from ..api import APIServer -from ..gui import open_url +import wx +from ..gui.simulator import SimulatorWindow +from ..stitch_plan import stitch_groups_to_stitch_plan +from ..utils.svg_data import get_pagecolor from .base import InkstitchExtension @@ -16,9 +18,23 @@ class Simulator(InkstitchExtension): def effect(self): if not self.get_elements(): return - api_server = APIServer(self) - port = api_server.start_server() - electron = open_url("/simulator", port) - electron.wait() - api_server.stop() - api_server.join() + + metadata = self.get_inkstitch_metadata() + collapse_len = metadata['collapse_len_mm'] + min_stitch_len = metadata['min_stitch_len_mm'] + stitch_groups = self.elements_to_stitch_groups(self.elements) + stitch_plan = stitch_groups_to_stitch_plan(stitch_groups, collapse_len=collapse_len, min_stitch_len=min_stitch_len) + background_color = get_pagecolor(self.svg.namedview) + + app = wx.App() + current_screen = wx.Display.GetFromPoint(wx.GetMousePosition()) + display = wx.Display(current_screen) + screen_rect = display.GetClientArea() + height = int(screen_rect[3] * 0.8) + simulator = SimulatorWindow(size=(0, height), background_color=background_color) + wx.CallLater(100, simulator.Centre) + app.SetTopWindow(simulator) + simulator.Show() + simulator.load(stitch_plan) + simulator.go() + app.MainLoop() |
