summaryrefslogtreecommitdiff
path: root/lib/extensions/simulator.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2024-08-08 09:43:36 -0400
committerGitHub <noreply@github.com>2024-08-08 09:43:36 -0400
commit47ad76f513846a8501f84c057b28a146031859b6 (patch)
tree0d29cb0f87473f925c07f9b58949357ae1cf141d /lib/extensions/simulator.py
parent17b88ce2c14a0802e18e90d8dd142224013dfb15 (diff)
Show page in simulator (#3120)
* add exception logging helpers * wip * show page and drop shadow from SVG * allow toggling page * add page icon * add dark mode icon * showpageshadow * refresh after background change (fix for macOS) * fix params sim background * try a native GraphicsBrush for windows * show page button in standalone simulator only and adapt shadow color * remove doubled line --------- Co-authored-by: Kaalleen <reni@allenka.de>
Diffstat (limited to 'lib/extensions/simulator.py')
-rw-r--r--lib/extensions/simulator.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/extensions/simulator.py b/lib/extensions/simulator.py
index 69f74b02..af793f03 100644
--- a/lib/extensions/simulator.py
+++ b/lib/extensions/simulator.py
@@ -7,6 +7,7 @@ import wx
from ..gui.simulator import SimulatorWindow
from ..stitch_plan import stitch_groups_to_stitch_plan
+from ..svg import convert_length
from ..utils.svg_data import get_pagecolor
from .base import InkstitchExtension
@@ -37,5 +38,33 @@ class Simulator(InkstitchExtension):
app.SetTopWindow(simulator)
simulator.Show()
simulator.load(stitch_plan)
+ simulator.set_page_specs(self.get_page_specs(stitch_plan))
simulator.go()
app.MainLoop()
+
+ def get_page_specs(self, stitch_plan):
+ svg = self.document.getroot()
+ width = svg.get('width', 0)
+ height = svg.get('height', 0)
+ page_color = "white"
+ desk_color = "white"
+ border_color = "black"
+ show_page_shadow = "true"
+
+ named_view = svg.namedview
+ if named_view is not None:
+ page_color = named_view.get('pagecolor', page_color)
+ desk_color = named_view.get('inkscape:deskcolor', desk_color)
+ border_color = named_view.get('bordercolor', border_color)
+ show_page_shadow = named_view.get('inkscape:showpageshadow', show_page_shadow) in ['true', 'yes', 'y', '1', '2']
+
+ return {
+ "width": convert_length(width),
+ "height": convert_length(height),
+ "x": stitch_plan.bounding_box[0],
+ "y": stitch_plan.bounding_box[1],
+ "page_color": page_color,
+ "desk_color": desk_color,
+ "border_color": border_color,
+ "show_page_shadow": show_page_shadow
+ }