diff --git a/embroider_params.py b/embroider_params.py index 7cba8fb09..0c5c52fc6 100644 --- a/embroider_params.py +++ b/embroider_params.py @@ -400,8 +400,19 @@ class SettingsFrame(wx.Frame): simulator_pos = my_rect.GetTopRight() simulator_pos.x += 5 + screen_rect = wx.Display(0).ClientArea + max_width = screen_rect.GetWidth() - my_rect.GetWidth() + max_height = screen_rect.GetHeight() + try: - self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator", simulator_pos, size=(300, 300), patches=patches, on_close=self.simulate_window_closed, target_duration=5) + self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator", + simulator_pos, + size=(300, 300), + patches=patches, + on_close=self.simulate_window_closed, + target_duration=5, + max_width=max_width, + max_height=max_height) except: error = traceback.format_exc() diff --git a/embroider_simulate.py b/embroider_simulate.py index 6ec35bd1c..f10f39f0a 100644 --- a/embroider_simulate.py +++ b/embroider_simulate.py @@ -16,7 +16,11 @@ class EmbroiderySimulator(wx.Frame): self.frame_period = kwargs.pop('frame_period', 80) self.stitches_per_frame = kwargs.pop('stitches_per_frame', 1) self.target_duration = kwargs.pop('target_duration', None) - self.scale = 3 + + screen_rect = wx.Display(0).ClientArea + self.max_width = kwargs.pop('max_width', screen_rect.GetWidth()) + self.max_height = kwargs.pop('max_height', screen_rect.GetHeight()) + self.scale = 1 wx.Frame.__init__(self, *args, **kwargs) @@ -56,7 +60,7 @@ class EmbroiderySimulator(wx.Frame): return self.trim_margins() - self.width, self.height = self.get_dimensions() + self.calculate_dimensions() def adjust_speed(self, duration): self.frame_period = 1000 * float(duration) / len(self.segments) @@ -218,7 +222,7 @@ class EmbroiderySimulator(wx.Frame): self.segments = new_segments - def get_dimensions(self): + def calculate_dimensions(self): width = 0 height = 0 @@ -226,7 +230,12 @@ class EmbroiderySimulator(wx.Frame): width = max(width, x) height = max(height, y) - return width, height + self.width = width + self.height = height + self.scale = min(float(self.max_width) / width, float(self.max_height) / height) + + # make room for decorations and a bit of a margin + self.scale *= 0.95 def go(self): self.clear()