diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/extensions/params.py | 11 | ||||
| -rw-r--r-- | lib/extensions/simulate.py | 4 | ||||
| -rw-r--r-- | lib/simulator.py | 34 |
3 files changed, 31 insertions, 18 deletions
diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 6d1464a3..9bde2a66 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -440,19 +440,16 @@ class SettingsFrame(wx.Frame): display = wx.Display(current_screen) screen_rect = display.GetClientArea() - max_width = screen_rect.GetWidth() - params_rect.GetWidth() - max_height = screen_rect.GetHeight() + width = screen_rect.GetWidth() - params_rect.GetWidth() + height = screen_rect.GetHeight() try: self.simulate_window = EmbroiderySimulator(None, -1, _("Preview"), simulator_pos, - size=(300, 300), - x_position=simulator_pos.x, + size=(width, height), stitch_plan=stitch_plan, on_close=self.simulate_window_closed, - target_duration=5, - max_width=max_width, - max_height=max_height) + target_duration=5) except: error = traceback.format_exc() diff --git a/lib/extensions/simulate.py b/lib/extensions/simulate.py index 38f86156..2e414ac6 100644 --- a/lib/extensions/simulate.py +++ b/lib/extensions/simulate.py @@ -25,8 +25,10 @@ class Simulate(InkstitchExtension): screen_rect = display.GetClientArea() simulator_pos = (screen_rect[0], screen_rect[1]) + width = screen_rect[2] + height = screen_rect[3] - frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), pos=simulator_pos, size=(1000, 1000), stitch_plan=stitch_plan) + frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), pos=simulator_pos, size=(width, height), stitch_plan=stitch_plan) app.SetTopWindow(frame) frame.Show() wx.CallAfter(frame.go) diff --git a/lib/simulator.py b/lib/simulator.py index 4483d653..5be503ef 100644 --- a/lib/simulator.py +++ b/lib/simulator.py @@ -14,6 +14,8 @@ class ControlPanel(wx.Panel): self.parent = parent self.drawing_panel = kwargs.pop('drawing_panel') self.stitch_plan = kwargs.pop('stitch_plan') + stitches_per_second = kwargs.pop('stitches_per_second') + target_duration = kwargs.pop('target_duration') kwargs['style'] = wx.BORDER_SUNKEN wx.Panel.__init__(self, parent, *args, **kwargs) @@ -93,10 +95,17 @@ class ControlPanel(wx.Panel): self.SetAcceleratorTable(accel_table) self.current_stitch = 1 - self.set_speed(16) + + self.choose_speed(stitches_per_second, target_duration) self.SetFocus() + def choose_speed(self, stitches_per_second, target_duration): + if target_duration: + self.set_speed(int(self.num_stitches / float(target_duration))) + else: + self.set_speed(stitches_per_second) + def animation_forward(self, event=None): self.direction.SetLabel(">>") self.drawing_panel.forward() @@ -370,11 +379,17 @@ class SimulatorPanel(wx.Panel): """""" self.parent = parent stitch_plan = kwargs.pop('stitch_plan') + target_duration = kwargs.pop('target_duration') + stitches_per_second = kwargs.pop('stitches_per_second') kwargs['style'] = wx.BORDER_SUNKEN wx.Panel.__init__(self, parent, *args, **kwargs) self.dp = DrawingPanel(self, stitch_plan=stitch_plan) - self.cp = ControlPanel(self, stitch_plan=stitch_plan, drawing_panel=self.dp) + self.cp = ControlPanel(self, + stitch_plan=stitch_plan, + drawing_panel=self.dp, + stitches_per_second=stitches_per_second, + target_duration=target_duration) self.dp.set_control_panel(self.cp) vbSizer = wx.BoxSizer(wx.VERTICAL) @@ -393,20 +408,19 @@ class SimulatorPanel(wx.Panel): class EmbroiderySimulator(wx.Frame): def __init__(self, *args, **kwargs): - stitch_plan = kwargs.pop('stitch_plan', None) - self.x_position = kwargs.pop('x_position', None) self.on_close_hook = kwargs.pop('on_close', None) - 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.max_height = kwargs.pop('max_height', None) - self.max_width = kwargs.pop('max_width', None) + stitch_plan = kwargs.pop('stitch_plan', None) + stitches_per_second = kwargs.pop('stitches_per_second', 16) + target_duration = kwargs.pop('target_duration', None) wx.Frame.__init__(self, *args, **kwargs) # self.status_bar = self.CreateStatusBar() # self.status_bar.SetStatusText(text) - self.simulator_panel = SimulatorPanel(self, stitch_plan=stitch_plan) + self.simulator_panel = SimulatorPanel(self, + stitch_plan=stitch_plan, + target_duration=target_duration, + stitches_per_second=stitches_per_second) self.Bind(wx.EVT_CLOSE, self.on_close) def quit(self): |
