printrun-src/printrun/gui/controls.py

changeset 46
cce0af6351f0
parent 34
654a41b13258
child 48
3c27b4ee6fec
equal deleted inserted replaced
45:c82943fb205f 46:cce0af6351f0
1 # FILE MODIFIED BY NEOSOFT - MALTE DI DONATO
2 # Embed Lasercut controls
3
4 # This file is part of the Printrun suite. 1 # This file is part of the Printrun suite.
5 # 2 #
6 # Printrun is free software: you can redistribute it and/or modify 3 # Printrun is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by 4 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or 5 # the Free Software Foundation, either version 3 of the License, or
24 from .widgets import TempGauge 21 from .widgets import TempGauge
25 from wx.lib.agw.floatspin import FloatSpin 22 from wx.lib.agw.floatspin import FloatSpin
26 23
27 from .utils import make_button, make_custom_button 24 from .utils import make_button, make_custom_button
28 25
29 from .widgets import PronterOptions
30
31 class XYZControlsSizer(wx.GridBagSizer): 26 class XYZControlsSizer(wx.GridBagSizer):
32 27
33 def __init__(self, root, parentpanel = None): 28 def __init__(self, root, parentpanel = None):
34 super(XYZControlsSizer, self).__init__() 29 super(XYZControlsSizer, self).__init__()
35 if not parentpanel: parentpanel = root.panel 30 if not parentpanel: parentpanel = root.panel
36 root.xyb = XYButtons(parentpanel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.bgcolor, zcallback=root.moveZ) 31 root.xyb = XYButtons(parentpanel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.bgcolor, zcallback=root.moveZ)
32 root.xyb.SetToolTip(_('[J]og controls. (Shift)+TAB ESC Shift/Ctrl+(arrows PgUp/PgDn)'))
37 self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) 33 self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
38 root.zb = ZButtons(parentpanel, root.moveZ, root.bgcolor) 34 root.zb = ZButtons(parentpanel, root.moveZ, root.bgcolor)
39 self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) 35 self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
40 wx.CallAfter(root.xyb.SetFocus)
41 36
42 def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode = False): 37 def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode = False):
43 standalone_mode = extra_buttons is not None 38 standalone_mode = extra_buttons is not None
44 base_line = 1 if standalone_mode else 2 39 base_line = 1 if standalone_mode else 2
45 40
52 tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0) 47 tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0)
53 if mini_mode and root.display_graph: 48 if mini_mode and root.display_graph:
54 e_base_line = base_line + 3 49 e_base_line = base_line + 3
55 else: 50 else:
56 e_base_line = base_line + 2 51 e_base_line = base_line + 2
57
58 lasercut_base_line = 11
59 52
60 pos_mapping = { 53 pos_mapping = {
61 "htemp_label": (base_line + 0, 0), 54 "htemp_label": (base_line + 0, 0),
62 "htemp_off": (base_line + 0, 2), 55 "htemp_off": (base_line + 0, 2),
63 "htemp_val": (base_line + 0, 3), 56 "htemp_val": (base_line + 0, 3),
73 "htemp_gauge": (gauges_base_line + 0, 0), 66 "htemp_gauge": (gauges_base_line + 0, 0),
74 "btemp_gauge": (gauges_base_line + 1, 0), 67 "btemp_gauge": (gauges_base_line + 1, 0),
75 "tempdisp": (tempdisp_line, 0), 68 "tempdisp": (tempdisp_line, 0),
76 "extrude": (3, 0), 69 "extrude": (3, 0),
77 "reverse": (3, 2), 70 "reverse": (3, 2),
78 "lasercut_optionsbtn": (lasercut_base_line, 0),
79 "lasercut_printbtn": (lasercut_base_line, 2),
80 "lasercut_material_thickness": (lasercut_base_line+1, 4),
81 "lasercut_material_thickness_label": (lasercut_base_line+1, 0),
82 "lasercut_pass_count": (lasercut_base_line+2, 4),
83 "lasercut_pass_count_label": (lasercut_base_line+2, 0),
84 "lasercut_pass_zdiff": (lasercut_base_line+3, 4),
85 "lasercut_pass_zdiff_label": (lasercut_base_line+3, 0),
86 } 71 }
87 72
88 span_mapping = { 73 span_mapping = {
89 "htemp_label": (1, 2), 74 "htemp_label": (1, 2),
90 "htemp_off": (1, 1), 75 "htemp_off": (1, 1),
104 "extrude": (1, 2), 89 "extrude": (1, 2),
105 "reverse": (1, 3), 90 "reverse": (1, 3),
106 } 91 }
107 92
108 if standalone_mode: 93 if standalone_mode:
109 pos_mapping["tempgraph"] = (base_line + 5, 0) 94 pos_mapping["tempgraph"] = (base_line + 6, 0)
110 span_mapping["tempgraph"] = (5, 6) 95 span_mapping["tempgraph"] = (3, 2)
111 elif mini_mode: 96 elif mini_mode:
112 pos_mapping["tempgraph"] = (base_line + 2, 0) 97 pos_mapping["tempgraph"] = (base_line + 2, 0)
113 span_mapping["tempgraph"] = (1, 5) 98 span_mapping["tempgraph"] = (1, 5)
114 else: 99 else:
115 pos_mapping["tempgraph"] = (base_line + 0, 5) 100 pos_mapping["tempgraph"] = (base_line + 0, 5)
138 del kwargs["container"] 123 del kwargs["container"]
139 else: 124 else:
140 container = self 125 container = self
141 container.Add(widget, *args, **kwargs) 126 container.Add(widget, *args, **kwargs)
142 127
143 # Lasercutter quick controls #
144
145 root.lc_optionsbtn = make_button(parentpanel, _("Lasercutter options"), lambda e: PronterOptions(root, "Laser"), _("Open Lasercutter options"), style = wx.BU_EXACTFIT)
146 root.printerControls.append(root.lc_optionsbtn)
147 add("lasercut_optionsbtn", root.lc_optionsbtn, flag = wx.EXPAND)
148
149 root.lc_printbtn = make_button(parentpanel, _("Start cutting"), root.on_lc_printfile, _("Start printjob with lasercutting features"), style = wx.BU_EXACTFIT)
150 root.printerControls.append(root.lc_printbtn)
151 add("lasercut_printbtn", root.lc_printbtn, flag = wx.EXPAND)
152
153
154 root.lc_pass_count = speed_spin = FloatSpin(parentpanel, -1, value = root.settings.lc_pass_count, min_val = 1, max_val = 10, digits = 0, style = wx.ALIGN_LEFT, size = (80, -1))
155 add("lasercut_pass_count", root.lc_pass_count)
156 add("lasercut_pass_count_label", wx.StaticText(parentpanel, -1, _("Number of cutting passes:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
157
158 root.lc_pass_zdiff = speed_spin = FloatSpin(parentpanel, -1, increment = 0.1, value = root.settings.lc_pass_zdiff, min_val = -2, max_val = 2, digits = 1, style = wx.ALIGN_LEFT, size = (80, -1))
159 add("lasercut_pass_zdiff", root.lc_pass_zdiff)
160 add("lasercut_pass_zdiff_label", wx.StaticText(parentpanel, -1, _("Z movement after each cut:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
161
162 root.lc_material_thickness = speed_spin = FloatSpin(parentpanel, -1, increment = 0.1, value = root.settings.lc_material_thickness, min_val = 0, max_val = 75, digits = 1, style = wx.ALIGN_LEFT, size = (80, -1))
163 add("lasercut_material_thickness", root.lc_material_thickness)
164 add("lasercut_material_thickness_label", wx.StaticText(parentpanel, -1, _("Material Thickness:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
165
166
167
168 # Hotend & bed temperatures # 128 # Hotend & bed temperatures #
169 129
170 # Hotend temp 130 # Hotend temp
171 add("htemp_label", wx.StaticText(parentpanel, -1, _("Heat:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 131 add("htemp_label", wx.StaticText(parentpanel, -1, _("Heat:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
172 htemp_choices = [root.temps[i] + " (" + i + ")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])]
173 132
174 root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (38, -1), style = wx.BU_EXACTFIT) 133 root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (38, -1), style = wx.BU_EXACTFIT)
175 root.printerControls.append(root.settoff) 134 root.printerControls.append(root.settoff)
176 add("htemp_off", root.settoff) 135 add("htemp_off", root.settoff)
177 136
178 if root.settings.last_temperature not in map(float, root.temps.values()): 137 root.htemp = wx.ComboBox(parentpanel, style = wx.CB_DROPDOWN, size = (115, -1))
179 htemp_choices = [str(root.settings.last_temperature)] + htemp_choices 138 root.htemp.SetToolTip(wx.ToolTip(_("Select Temperature for [H]otend")))
180 root.htemp = wx.ComboBox(parentpanel, -1, choices = htemp_choices,
181 style = wx.CB_DROPDOWN, size = (80, -1))
182 root.htemp.SetToolTip(wx.ToolTip(_("Select Temperature for Hotend")))
183 root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change) 139 root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change)
184 140
185 add("htemp_val", root.htemp) 141 add("htemp_val", root.htemp)
186 root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT) 142 root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT)
187 root.printerControls.append(root.settbtn) 143 root.printerControls.append(root.settbtn)
188 add("htemp_set", root.settbtn, flag = wx.EXPAND) 144 add("htemp_set", root.settbtn, flag = wx.EXPAND)
189 145
190 # Bed temp 146 # Bed temp
191 add("btemp_label", wx.StaticText(parentpanel, -1, _("Bed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 147 add("btemp_label", wx.StaticText(parentpanel, -1, _("Bed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
192 btemp_choices = [root.bedtemps[i] + " (" + i + ")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])]
193 148
194 root.setboff = make_button(parentpanel, _("Off"), lambda e: root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (38, -1), style = wx.BU_EXACTFIT) 149 root.setboff = make_button(parentpanel, _("Off"), lambda e: root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (38, -1), style = wx.BU_EXACTFIT)
195 root.printerControls.append(root.setboff) 150 root.printerControls.append(root.setboff)
196 add("btemp_off", root.setboff) 151 add("btemp_off", root.setboff)
197 152
198 if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()): 153 root.btemp = wx.ComboBox(parentpanel, style = wx.CB_DROPDOWN, size = (115, -1))
199 btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices 154 root.btemp.SetToolTip(wx.ToolTip(_("Select Temperature for Heated [B]ed")))
200 root.btemp = wx.ComboBox(parentpanel, -1, choices = btemp_choices,
201 style = wx.CB_DROPDOWN, size = (80, -1))
202 root.btemp.SetToolTip(wx.ToolTip(_("Select Temperature for Heated Bed")))
203 root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change) 155 root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change)
204 add("btemp_val", root.btemp) 156 add("btemp_val", root.btemp)
205 157
206 root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, _("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT) 158 root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, _("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT)
207 root.printerControls.append(root.setbbtn) 159 root.printerControls.append(root.setbbtn)
208 add("btemp_set", root.setbbtn, flag = wx.EXPAND) 160 add("btemp_set", root.setbbtn, flag = wx.EXPAND)
209 161
210 root.btemp.SetValue(str(root.settings.last_bed_temperature)) 162 def set_labeled(temp, choices, widget):
211 root.htemp.SetValue(str(root.settings.last_temperature)) 163 choices = [(float(p[1]), p[0]) for p in choices.items()]
212 164 if not next((1 for p in choices if p[0] == temp), False):
213 # added for an error where only the bed would get (pla) or (abs). 165 choices.append((temp, 'user'))
214 # This ensures, if last temp is a default pla or abs, it will be marked so. 166
215 # if it is not, then a (user) remark is added. This denotes a manual entry 167 choices = sorted(choices)
216 168 widget.Items = ['%s (%s)'%tl for tl in choices]
217 for i in btemp_choices: 169 widget.Selection = next((i for i, tl in enumerate(choices) if tl[0] == temp), -1)
218 if i.split()[0] == str(root.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_bed_temperature): 170
219 root.btemp.SetValue(i) 171 set_labeled(root.settings.last_bed_temperature, root.bedtemps, root.btemp)
220 for i in htemp_choices: 172 set_labeled(root.settings.last_temperature, root.temps, root.htemp)
221 if i.split()[0] == str(root.settings.last_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_temperature):
222 root.htemp.SetValue(i)
223
224 if '(' not in root.btemp.Value:
225 root.btemp.SetValue(root.btemp.Value + ' (user)')
226 if '(' not in root.htemp.Value:
227 root.htemp.SetValue(root.htemp.Value + ' (user)')
228 173
229 # Speed control # 174 # Speed control #
230 speedpanel = root.newPanel(parentpanel) 175 speedpanel = root.newPanel(parentpanel)
231 speedsizer = wx.BoxSizer(wx.HORIZONTAL) 176 speedsizer = wx.BoxSizer(wx.HORIZONTAL)
232 speedsizer.Add(wx.StaticText(speedpanel, -1, _("Print speed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 177 speedsizer.Add(wx.StaticText(speedpanel, -1, _("Print speed:")), flag = wx.ALIGN_CENTER_VERTICAL)
233 178
234 root.speed_slider = wx.Slider(speedpanel, -1, 100, 1, 300) 179 root.speed_slider = wx.Slider(speedpanel, -1, 100, 1, 300)
235 speedsizer.Add(root.speed_slider, 1, flag = wx.EXPAND) 180 speedsizer.Add(root.speed_slider, 1, flag = wx.EXPAND)
236 181
237 root.speed_spin = FloatSpin(speedpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (80, -1)) 182 root.speed_spin = wx.SpinCtrlDouble(speedpanel, -1, initial = 100, min = 1, max = 300, style = wx.ALIGN_LEFT, size = (115, -1))
183 root.speed_spin.SetDigits(0)
238 speedsizer.Add(root.speed_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) 184 speedsizer.Add(root.speed_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL)
239 root.speed_label = wx.StaticText(speedpanel, -1, _("%")) 185 root.speed_label = wx.StaticText(speedpanel, -1, _("%"))
240 speedsizer.Add(root.speed_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 186 speedsizer.Add(root.speed_label, flag = wx.ALIGN_CENTER_VERTICAL)
241 187
242 def speedslider_set(event): 188 def speedslider_set(event):
243 root.do_setspeed() 189 root.do_setspeed()
244 root.speed_setbtn.SetBackgroundColour(wx.NullColour) 190 root.speed_setbtn.SetBackgroundColour(wx.NullColour)
245 root.speed_setbtn = make_button(speedpanel, _("Set"), speedslider_set, _("Set print speed factor"), size = (38, -1), style = wx.BU_EXACTFIT) 191 root.speed_setbtn = make_button(speedpanel, _("Set"), speedslider_set, _("Set print speed factor"), size = (38, -1), style = wx.BU_EXACTFIT)
250 196
251 def speedslider_spin(event): 197 def speedslider_spin(event):
252 value = root.speed_spin.GetValue() 198 value = root.speed_spin.GetValue()
253 root.speed_setbtn.SetBackgroundColour("red") 199 root.speed_setbtn.SetBackgroundColour("red")
254 root.speed_slider.SetValue(value) 200 root.speed_slider.SetValue(value)
255 root.speed_spin.Bind(wx.EVT_SPINCTRL, speedslider_spin) 201 root.speed_spin.Bind(wx.EVT_SPINCTRLDOUBLE, speedslider_spin)
256 202
257 def speedslider_scroll(event): 203 def speedslider_scroll(event):
258 value = root.speed_slider.GetValue() 204 value = root.speed_slider.GetValue()
259 root.speed_setbtn.SetBackgroundColour("red") 205 root.speed_setbtn.SetBackgroundColour("red")
260 root.speed_spin.SetValue(value) 206 root.speed_spin.SetValue(value)
261 root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll) 207 root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll)
262 208
263 # Flow control # 209 # Flow control #
264 flowpanel = root.newPanel(parentpanel) 210 flowpanel = root.newPanel(parentpanel)
265 flowsizer = wx.BoxSizer(wx.HORIZONTAL) 211 flowsizer = wx.BoxSizer(wx.HORIZONTAL)
266 flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 212 flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL)
267 213
268 root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300) 214 root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300)
269 flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND) 215 flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND)
270 216
271 root.flow_spin = FloatSpin(flowpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (60, -1)) 217 root.flow_spin = wx.SpinCtrlDouble(flowpanel, -1, initial = 100, min = 1, max = 300, style = wx.ALIGN_LEFT, size = (115, -1))
272 flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) 218 flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL)
273 root.flow_label = wx.StaticText(flowpanel, -1, _("%")) 219 root.flow_label = wx.StaticText(flowpanel, -1, _("%"))
274 flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) 220 flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL)
275 221
276 def flowslider_set(event): 222 def flowslider_set(event):
277 root.do_setflow() 223 root.do_setflow()
278 root.flow_setbtn.SetBackgroundColour(wx.NullColour) 224 root.flow_setbtn.SetBackgroundColour(wx.NullColour)
279 root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT) 225 root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT)
284 230
285 def flowslider_spin(event): 231 def flowslider_spin(event):
286 value = root.flow_spin.GetValue() 232 value = root.flow_spin.GetValue()
287 root.flow_setbtn.SetBackgroundColour("red") 233 root.flow_setbtn.SetBackgroundColour("red")
288 root.flow_slider.SetValue(value) 234 root.flow_slider.SetValue(value)
289 root.flow_spin.Bind(wx.EVT_SPINCTRL, flowslider_spin) 235 root.flow_spin.Bind(wx.EVT_SPINCTRLDOUBLE, flowslider_spin)
290 236
291 def flowslider_scroll(event): 237 def flowslider_scroll(event):
292 value = root.flow_slider.GetValue() 238 value = root.flow_slider.GetValue()
293 root.flow_setbtn.SetBackgroundColour("red") 239 root.flow_setbtn.SetBackgroundColour("red")
294 root.flow_spin.SetValue(value) 240 root.flow_spin.SetValue(value)
296 242
297 # Temperature gauges # 243 # Temperature gauges #
298 244
299 if root.display_gauges: 245 if root.display_gauges:
300 root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300, bgcolor = root.bgcolor) 246 root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300, bgcolor = root.bgcolor)
247 root.hottgauge.SetTarget(root.settings.last_temperature)
248 # root.hsetpoint = root.settings.last_temperature
301 add("htemp_gauge", root.hottgauge, flag = wx.EXPAND) 249 add("htemp_gauge", root.hottgauge, flag = wx.EXPAND)
302 root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor) 250 root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor)
251 root.bedtgauge.SetTarget(root.settings.last_bed_temperature)
252 # root.bsetpoint = root.settings.last_bed_temperature
303 add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND) 253 add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND)
304 254
305 def hotendgauge_scroll_setpoint(e): 255 def scroll_gauge(rot, cmd, setpoint):
306 rot = e.GetWheelRotation() 256 if rot:
307 if rot > 0: 257 temp = setpoint + (1 if rot > 0 else -1)
308 root.do_settemp(str(root.hsetpoint + 1)) 258 cmd(str(max(0, temp)))
309 elif rot < 0: 259
310 root.do_settemp(str(max(0, root.hsetpoint - 1))) 260 def hotend_handler(e):
311 261 scroll_gauge(e.WheelRotation, root.do_settemp, root.hsetpoint)
312 def bedgauge_scroll_setpoint(e): 262
313 rot = e.GetWheelRotation() 263 def bed_handler(e):
314 if rot > 0: 264 scroll_gauge(e.WheelRotation, root.do_bedtemp, root.bsetpoint)
315 root.do_settemp(str(root.bsetpoint + 1)) 265 root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotend_handler)
316 elif rot < 0: 266 root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bed_handler)
317 root.do_settemp(str(max(0, root.bsetpoint - 1))) 267
318 root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint) 268 def updateGauge(e, gauge):
319 root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint) 269 gauge.SetTarget(float(e.String.split()[0]))
270
271 root.htemp.Bind(wx.EVT_TEXT, lambda e: updateGauge(e, root.hottgauge))
272 root.btemp.Bind(wx.EVT_TEXT, lambda e: updateGauge(e, root.bedtgauge))
320 273
321 # Temperature (M105) feedback display # 274 # Temperature (M105) feedback display #
322 root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE) 275 root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE)
323 276
324 def on_tempdisp_size(evt): 277 def on_tempdisp_size(evt):
343 296
344 # Extrusion settings 297 # Extrusion settings
345 esettingspanel = root.newPanel(parentpanel) 298 esettingspanel = root.newPanel(parentpanel)
346 esettingssizer = wx.GridBagSizer() 299 esettingssizer = wx.GridBagSizer()
347 esettingssizer.SetEmptyCellSize((0, 0)) 300 esettingssizer.SetEmptyCellSize((0, 0))
348 root.edist = FloatSpin(esettingspanel, -1, value = root.settings.last_extrusion, min_val = 0, max_val = 1000, size = (90, -1), digits = 1) 301 root.edist = wx.SpinCtrlDouble(esettingspanel, -1, initial = root.settings.last_extrusion, min = 0, max = 1000, size = (135, -1))
302 root.edist.SetDigits(1)
303 root.edist.Bind(wx.EVT_SPINCTRLDOUBLE, root.setfeeds)
349 root.edist.SetBackgroundColour((225, 200, 200)) 304 root.edist.SetBackgroundColour((225, 200, 200))
350 root.edist.SetForegroundColour("black") 305 root.edist.SetForegroundColour("black")
351 root.edist.Bind(wx.EVT_SPINCTRL, root.setfeeds)
352 root.edist.Bind(wx.EVT_TEXT, root.setfeeds) 306 root.edist.Bind(wx.EVT_TEXT, root.setfeeds)
353 add("edist_label", wx.StaticText(esettingspanel, -1, _("Length:")), container = esettingssizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, border = 5) 307 add("edist_label", wx.StaticText(esettingspanel, -1, _("Length:")), container = esettingssizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, border = 5)
354 add("edist_val", root.edist, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) 308 add("edist_val", root.edist, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
355 unit_label = _("mm") if mini_mode else _("mm @") 309 unit_label = _("mm") if mini_mode else _("mm @")
356 add("edist_unit", wx.StaticText(esettingspanel, -1, unit_label), container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) 310 add("edist_unit", wx.StaticText(esettingspanel, -1, unit_label), container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
357 root.edist.SetToolTip(wx.ToolTip(_("Amount to Extrude or Retract (mm)"))) 311 root.edist.SetToolTip(wx.ToolTip(_("Amount to Extrude or Retract (mm)")))
358 if not mini_mode: 312 if not mini_mode:
359 root.efeedc = FloatSpin(esettingspanel, -1, value = root.settings.e_feedrate, min_val = 0, max_val = 50000, size = (90, -1), digits = 1) 313 root.efeedc = wx.SpinCtrlDouble(esettingspanel, -1, initial = root.settings.e_feedrate, min = 0, max = 50000, size = (145, -1))
314 root.efeedc.SetDigits(1)
315 root.efeedc.Bind(wx.EVT_SPINCTRLDOUBLE, root.setfeeds)
360 root.efeedc.SetToolTip(wx.ToolTip(_("Extrude / Retract speed (mm/min)"))) 316 root.efeedc.SetToolTip(wx.ToolTip(_("Extrude / Retract speed (mm/min)")))
361 root.efeedc.SetBackgroundColour((225, 200, 200)) 317 root.efeedc.SetBackgroundColour((225, 200, 200))
362 root.efeedc.SetForegroundColour("black") 318 root.efeedc.SetForegroundColour("black")
363 root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
364 root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds) 319 root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds)
365 add("efeed_val", root.efeedc, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) 320 add("efeed_val", root.efeedc, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
366 add("efeed_label", wx.StaticText(esettingspanel, -1, _("Speed:")), container = esettingssizer, flag = wx.ALIGN_LEFT) 321 add("efeed_label", wx.StaticText(esettingspanel, -1, _("Speed:")), container = esettingssizer, flag = wx.ALIGN_LEFT)
367 add("efeed_unit", wx.StaticText(esettingspanel, -1, _("mm/\nmin")), container = esettingssizer, flag = wx.ALIGN_CENTER) 322 add("efeed_unit", wx.StaticText(esettingspanel, -1, _("mm/\nmin")), container = esettingssizer, flag = wx.ALIGN_CENTER)
368 else: 323 else:
453 elif not standalone_mode: 408 elif not standalone_mode:
454 self.Add(btn, pos = pos_mapping[key], span = span_mapping[key], flag = wx.EXPAND) 409 self.Add(btn, pos = pos_mapping[key], span = span_mapping[key], flag = wx.EXPAND)
455 else: 410 else:
456 self.extra_buttons[key] = btn 411 self.extra_buttons[key] = btn
457 412
458 root.xyfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (97, -1)) 413 root.xyfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (130, -1))
459 root.xyfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for X & Y axes (mm/min)"))) 414 root.xyfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for X & Y axes (mm/min)")))
460 llts.Add(wx.StaticText(lltspanel, -1, _("XY:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) 415 llts.Add(wx.StaticText(lltspanel, -1, _("XY:")), flag = wx.ALIGN_CENTER_VERTICAL)
461 llts.Add(root.xyfeedc) 416 llts.Add(root.xyfeedc)
462 llts.Add(wx.StaticText(lltspanel, -1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) 417 llts.Add(wx.StaticText(lltspanel, -1, _("mm/min Z:")), flag = wx.ALIGN_CENTER_VERTICAL)
463 root.zfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (90, -1)) 418 root.zfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (130, -1))
464 root.zfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for Z axis (mm/min)"))) 419 root.zfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for Z axis (mm/min)")))
465 llts.Add(root.zfeedc,) 420 llts.Add(root.zfeedc,)
466 421
467 root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) 422 root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)
468 root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) 423 root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds)

mercurial