Sat, 23 Sep 2017 08:51:58 +0200
Added support for multiple cutting passes with automatic Z refocusing
15 | 1 | # This file is part of the Printrun suite. |
2 | # | |
3 | # Printrun is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation, either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # Printrun is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | import wx | |
17 | ||
18 | from .xybuttons import XYButtons, XYButtonsMini | |
19 | from .zbuttons import ZButtons, ZButtonsMini | |
20 | from .graph import Graph | |
21 | from .widgets import TempGauge | |
22 | from wx.lib.agw.floatspin import FloatSpin | |
23 | ||
24 | from .utils import make_button, make_custom_button | |
25 | ||
26 | 26 | from .widgets import PronterOptions |
27 | ||
15 | 28 | class XYZControlsSizer(wx.GridBagSizer): |
29 | ||
30 | def __init__(self, root, parentpanel = None): | |
31 | super(XYZControlsSizer, self).__init__() | |
32 | if not parentpanel: parentpanel = root.panel | |
33 | root.xyb = XYButtons(parentpanel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.bgcolor, zcallback=root.moveZ) | |
34 | self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER) | |
35 | root.zb = ZButtons(parentpanel, root.moveZ, root.bgcolor) | |
36 | self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER) | |
37 | wx.CallAfter(root.xyb.SetFocus) | |
38 | ||
39 | def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode = False): | |
40 | standalone_mode = extra_buttons is not None | |
41 | base_line = 1 if standalone_mode else 2 | |
42 | ||
43 | if standalone_mode: | |
44 | gauges_base_line = base_line + 10 | |
45 | elif mini_mode and root.display_graph: | |
46 | gauges_base_line = base_line + 7 | |
47 | else: | |
48 | gauges_base_line = base_line + 6 | |
49 | tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0) | |
50 | if mini_mode and root.display_graph: | |
51 | e_base_line = base_line + 3 | |
52 | else: | |
53 | e_base_line = base_line + 2 | |
54 | ||
26 | 55 | lasercut_base_line = 11 |
56 | ||
15 | 57 | pos_mapping = { |
58 | "htemp_label": (base_line + 0, 0), | |
59 | "htemp_off": (base_line + 0, 2), | |
60 | "htemp_val": (base_line + 0, 3), | |
61 | "htemp_set": (base_line + 0, 4), | |
62 | "btemp_label": (base_line + 1, 0), | |
63 | "btemp_off": (base_line + 1, 2), | |
64 | "btemp_val": (base_line + 1, 3), | |
65 | "btemp_set": (base_line + 1, 4), | |
66 | "ebuttons": (e_base_line + 0, 0), | |
67 | "esettings": (e_base_line + 1, 0), | |
68 | "speedcontrol": (e_base_line + 2, 0), | |
69 | "flowcontrol": (e_base_line + 3, 0), | |
70 | "htemp_gauge": (gauges_base_line + 0, 0), | |
71 | "btemp_gauge": (gauges_base_line + 1, 0), | |
72 | "tempdisp": (tempdisp_line, 0), | |
73 | "extrude": (3, 0), | |
74 | "reverse": (3, 2), | |
26 | 75 | "lasercut": (lasercut_base_line, 0), |
33
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
76 | "lasercut_material_thickness": (lasercut_base_line+1, 4), |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
77 | "lasercut_material_thickness_label": (lasercut_base_line+1, 0), |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
78 | "lasercut_pass_count": (lasercut_base_line+2, 4), |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
79 | "lasercut_pass_count_label": (lasercut_base_line+2, 0), |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
80 | "lasercut_pass_zdiff": (lasercut_base_line+3, 4), |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
81 | "lasercut_pass_zdiff_label": (lasercut_base_line+3, 0), |
15 | 82 | } |
83 | ||
84 | span_mapping = { | |
85 | "htemp_label": (1, 2), | |
86 | "htemp_off": (1, 1), | |
87 | "htemp_val": (1, 1), | |
88 | "htemp_set": (1, 1 if root.display_graph else 2), | |
89 | "btemp_label": (1, 2), | |
90 | "btemp_off": (1, 1), | |
91 | "btemp_val": (1, 1), | |
92 | "btemp_set": (1, 1 if root.display_graph else 2), | |
93 | "ebuttons": (1, 5 if root.display_graph else 6), | |
94 | "esettings": (1, 5 if root.display_graph else 6), | |
95 | "speedcontrol": (1, 5 if root.display_graph else 6), | |
96 | "flowcontrol": (1, 5 if root.display_graph else 6), | |
97 | "htemp_gauge": (1, 5 if mini_mode else 6), | |
98 | "btemp_gauge": (1, 5 if mini_mode else 6), | |
99 | "tempdisp": (1, 5 if mini_mode else 6), | |
100 | "extrude": (1, 2), | |
101 | "reverse": (1, 3), | |
102 | } | |
103 | ||
104 | if standalone_mode: | |
105 | pos_mapping["tempgraph"] = (base_line + 5, 0) | |
106 | span_mapping["tempgraph"] = (5, 6) | |
107 | elif mini_mode: | |
108 | pos_mapping["tempgraph"] = (base_line + 2, 0) | |
109 | span_mapping["tempgraph"] = (1, 5) | |
110 | else: | |
111 | pos_mapping["tempgraph"] = (base_line + 0, 5) | |
112 | span_mapping["tempgraph"] = (5, 1) | |
113 | ||
114 | if mini_mode: | |
115 | pos_mapping["etool_label"] = (0, 0) | |
116 | pos_mapping["etool_val"] = (0, 1) | |
117 | pos_mapping["edist_label"] = (0, 2) | |
118 | pos_mapping["edist_val"] = (0, 3) | |
119 | pos_mapping["edist_unit"] = (0, 4) | |
120 | else: | |
121 | pos_mapping["edist_label"] = (0, 0) | |
122 | pos_mapping["edist_val"] = (1, 0) | |
123 | pos_mapping["edist_unit"] = (1, 1) | |
124 | pos_mapping["efeed_label"] = (0, 2) | |
125 | pos_mapping["efeed_val"] = (1, 2) | |
126 | pos_mapping["efeed_unit"] = (1, 3) | |
127 | ||
128 | def add(name, widget, *args, **kwargs): | |
129 | kwargs["pos"] = pos_mapping[name] | |
130 | if name in span_mapping: | |
131 | kwargs["span"] = span_mapping[name] | |
132 | if "container" in kwargs: | |
133 | container = kwargs["container"] | |
134 | del kwargs["container"] | |
135 | else: | |
136 | container = self | |
137 | container.Add(widget, *args, **kwargs) | |
138 | ||
139 | # Hotend & bed temperatures # | |
140 | ||
141 | # Hotend temp | |
142 | add("htemp_label", wx.StaticText(parentpanel, -1, _("Heat:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
143 | htemp_choices = [root.temps[i] + " (" + i + ")" for i in sorted(root.temps.keys(), key = lambda x:root.temps[x])] | |
144 | ||
145 | root.settoff = make_button(parentpanel, _("Off"), lambda e: root.do_settemp("off"), _("Switch Hotend Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
146 | root.printerControls.append(root.settoff) | |
147 | add("htemp_off", root.settoff) | |
148 | ||
149 | if root.settings.last_temperature not in map(float, root.temps.values()): | |
150 | htemp_choices = [str(root.settings.last_temperature)] + htemp_choices | |
151 | root.htemp = wx.ComboBox(parentpanel, -1, choices = htemp_choices, | |
152 | style = wx.CB_DROPDOWN, size = (80, -1)) | |
153 | root.htemp.SetToolTip(wx.ToolTip(_("Select Temperature for Hotend"))) | |
154 | root.htemp.Bind(wx.EVT_COMBOBOX, root.htemp_change) | |
155 | ||
156 | add("htemp_val", root.htemp) | |
157 | root.settbtn = make_button(parentpanel, _("Set"), root.do_settemp, _("Switch Hotend On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
158 | root.printerControls.append(root.settbtn) | |
159 | add("htemp_set", root.settbtn, flag = wx.EXPAND) | |
160 | ||
161 | # Bed temp | |
162 | add("btemp_label", wx.StaticText(parentpanel, -1, _("Bed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
163 | btemp_choices = [root.bedtemps[i] + " (" + i + ")" for i in sorted(root.bedtemps.keys(), key = lambda x:root.temps[x])] | |
164 | ||
165 | root.setboff = make_button(parentpanel, _("Off"), lambda e: root.do_bedtemp("off"), _("Switch Heated Bed Off"), size = (38, -1), style = wx.BU_EXACTFIT) | |
166 | root.printerControls.append(root.setboff) | |
167 | add("btemp_off", root.setboff) | |
168 | ||
169 | if root.settings.last_bed_temperature not in map(float, root.bedtemps.values()): | |
170 | btemp_choices = [str(root.settings.last_bed_temperature)] + btemp_choices | |
171 | root.btemp = wx.ComboBox(parentpanel, -1, choices = btemp_choices, | |
172 | style = wx.CB_DROPDOWN, size = (80, -1)) | |
173 | root.btemp.SetToolTip(wx.ToolTip(_("Select Temperature for Heated Bed"))) | |
174 | root.btemp.Bind(wx.EVT_COMBOBOX, root.btemp_change) | |
175 | add("btemp_val", root.btemp) | |
176 | ||
177 | root.setbbtn = make_button(parentpanel, _("Set"), root.do_bedtemp, _("Switch Heated Bed On"), size = (38, -1), style = wx.BU_EXACTFIT) | |
178 | root.printerControls.append(root.setbbtn) | |
179 | add("btemp_set", root.setbbtn, flag = wx.EXPAND) | |
180 | ||
181 | root.btemp.SetValue(str(root.settings.last_bed_temperature)) | |
182 | root.htemp.SetValue(str(root.settings.last_temperature)) | |
183 | ||
184 | # added for an error where only the bed would get (pla) or (abs). | |
185 | # This ensures, if last temp is a default pla or abs, it will be marked so. | |
186 | # if it is not, then a (user) remark is added. This denotes a manual entry | |
187 | ||
188 | for i in btemp_choices: | |
189 | if i.split()[0] == str(root.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_bed_temperature): | |
190 | root.btemp.SetValue(i) | |
191 | for i in htemp_choices: | |
192 | if i.split()[0] == str(root.settings.last_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_temperature): | |
193 | root.htemp.SetValue(i) | |
194 | ||
195 | if '(' not in root.btemp.Value: | |
196 | root.btemp.SetValue(root.btemp.Value + ' (user)') | |
197 | if '(' not in root.htemp.Value: | |
198 | root.htemp.SetValue(root.htemp.Value + ' (user)') | |
199 | ||
200 | # Speed control # | |
201 | speedpanel = root.newPanel(parentpanel) | |
202 | speedsizer = wx.BoxSizer(wx.HORIZONTAL) | |
203 | speedsizer.Add(wx.StaticText(speedpanel, -1, _("Print speed:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
204 | ||
205 | root.speed_slider = wx.Slider(speedpanel, -1, 100, 1, 300) | |
206 | speedsizer.Add(root.speed_slider, 1, flag = wx.EXPAND) | |
207 | ||
208 | root.speed_spin = FloatSpin(speedpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (80, -1)) | |
209 | speedsizer.Add(root.speed_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) | |
210 | root.speed_label = wx.StaticText(speedpanel, -1, _("%")) | |
211 | speedsizer.Add(root.speed_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
212 | ||
213 | def speedslider_set(event): | |
214 | root.do_setspeed() | |
215 | root.speed_setbtn.SetBackgroundColour(wx.NullColour) | |
216 | root.speed_setbtn = make_button(speedpanel, _("Set"), speedslider_set, _("Set print speed factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
217 | root.printerControls.append(root.speed_setbtn) | |
218 | speedsizer.Add(root.speed_setbtn, flag = wx.ALIGN_CENTER) | |
219 | speedpanel.SetSizer(speedsizer) | |
220 | add("speedcontrol", speedpanel, flag = wx.EXPAND) | |
221 | ||
222 | def speedslider_spin(event): | |
223 | value = root.speed_spin.GetValue() | |
224 | root.speed_setbtn.SetBackgroundColour("red") | |
225 | root.speed_slider.SetValue(value) | |
226 | root.speed_spin.Bind(wx.EVT_SPINCTRL, speedslider_spin) | |
227 | ||
228 | def speedslider_scroll(event): | |
229 | value = root.speed_slider.GetValue() | |
230 | root.speed_setbtn.SetBackgroundColour("red") | |
231 | root.speed_spin.SetValue(value) | |
232 | root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll) | |
233 | ||
234 | # Flow control # | |
235 | flowpanel = root.newPanel(parentpanel) | |
236 | flowsizer = wx.BoxSizer(wx.HORIZONTAL) | |
237 | flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
238 | ||
239 | root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300) | |
240 | flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND) | |
241 | ||
242 | root.flow_spin = FloatSpin(flowpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (60, -1)) | |
243 | flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL) | |
244 | root.flow_label = wx.StaticText(flowpanel, -1, _("%")) | |
245 | flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) | |
246 | ||
247 | def flowslider_set(event): | |
248 | root.do_setflow() | |
249 | root.flow_setbtn.SetBackgroundColour(wx.NullColour) | |
250 | root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT) | |
251 | root.printerControls.append(root.flow_setbtn) | |
252 | flowsizer.Add(root.flow_setbtn, flag = wx.ALIGN_CENTER) | |
253 | flowpanel.SetSizer(flowsizer) | |
254 | add("flowcontrol", flowpanel, flag = wx.EXPAND) | |
255 | ||
256 | def flowslider_spin(event): | |
257 | value = root.flow_spin.GetValue() | |
258 | root.flow_setbtn.SetBackgroundColour("red") | |
259 | root.flow_slider.SetValue(value) | |
260 | root.flow_spin.Bind(wx.EVT_SPINCTRL, flowslider_spin) | |
261 | ||
262 | def flowslider_scroll(event): | |
263 | value = root.flow_slider.GetValue() | |
264 | root.flow_setbtn.SetBackgroundColour("red") | |
265 | root.flow_spin.SetValue(value) | |
266 | root.flow_slider.Bind(wx.EVT_SCROLL, flowslider_scroll) | |
267 | ||
268 | # Temperature gauges # | |
269 | ||
270 | if root.display_gauges: | |
271 | root.hottgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Heater:"), maxval = 300, bgcolor = root.bgcolor) | |
272 | add("htemp_gauge", root.hottgauge, flag = wx.EXPAND) | |
273 | root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor) | |
274 | add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND) | |
275 | ||
276 | def hotendgauge_scroll_setpoint(e): | |
277 | rot = e.GetWheelRotation() | |
278 | if rot > 0: | |
279 | root.do_settemp(str(root.hsetpoint + 1)) | |
280 | elif rot < 0: | |
281 | root.do_settemp(str(max(0, root.hsetpoint - 1))) | |
282 | ||
283 | def bedgauge_scroll_setpoint(e): | |
284 | rot = e.GetWheelRotation() | |
285 | if rot > 0: | |
286 | root.do_settemp(str(root.bsetpoint + 1)) | |
287 | elif rot < 0: | |
288 | root.do_settemp(str(max(0, root.bsetpoint - 1))) | |
289 | root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint) | |
290 | root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint) | |
291 | ||
292 | # Temperature (M105) feedback display # | |
293 | root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE) | |
294 | ||
295 | def on_tempdisp_size(evt): | |
296 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
297 | root.tempdisp.Bind(wx.EVT_SIZE, on_tempdisp_size) | |
298 | ||
299 | def tempdisp_setlabel(label): | |
300 | wx.StaticText.SetLabel(root.tempdisp, label) | |
301 | root.tempdisp.Wrap(root.tempdisp.GetSize().width) | |
302 | root.tempdisp.SetSize((-1, root.tempdisp.GetBestSize().height)) | |
303 | root.tempdisp.SetLabel = tempdisp_setlabel | |
304 | add("tempdisp", root.tempdisp, flag = wx.EXPAND) | |
305 | ||
306 | # Temperature graph # | |
307 | ||
308 | if root.display_graph: | |
309 | root.graph = Graph(parentpanel, wx.ID_ANY, root) | |
310 | add("tempgraph", root.graph, flag = wx.EXPAND | wx.ALL, border = 5) | |
311 | root.graph.Bind(wx.EVT_LEFT_DOWN, root.graph.show_graph_window) | |
312 | ||
26 | 313 | # Lasercutter quick controls # |
314 | ||
315 | root.lc_optionsbtn = make_button(parentpanel, _("Lasercutter options"), lambda e: PronterOptions(root, "Laser"), _("Open Lasercutter options"), style = wx.BU_EXACTFIT) | |
316 | root.printerControls.append(root.lc_optionsbtn) | |
317 | add("lasercut", root.lc_optionsbtn, flag = wx.EXPAND) | |
318 | ||
33
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
319 | root.lc_pass_count = speed_spin = FloatSpin(parentpanel, -1, value = 1, min_val = 1, max_val = 10, digits = 0, style = wx.ALIGN_LEFT, size = (80, -1)) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
320 | add("lasercut_pass_count", root.lc_pass_count) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
321 | add("lasercut_pass_count_label", wx.StaticText(parentpanel, -1, _("Number of cutting passes:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
322 | |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
323 | root.lc_pass_zdiff = speed_spin = FloatSpin(parentpanel, -1, increment = 0.1, value = -1, min_val = -2, max_val = 2, digits = 1, style = wx.ALIGN_LEFT, size = (80, -1)) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
324 | add("lasercut_pass_zdiff", root.lc_pass_zdiff) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
325 | add("lasercut_pass_zdiff_label", wx.StaticText(parentpanel, -1, _("Z movement after each cut:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
326 | |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
327 | root.lc_material_thickness = speed_spin = FloatSpin(parentpanel, -1, increment = 0.1, value = 4, min_val = 0, max_val = 75, digits = 1, style = wx.ALIGN_LEFT, size = (80, -1)) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
328 | add("lasercut_material_thickness", root.lc_material_thickness) |
eee51ca7cbe7
Added support for multiple cutting passes with automatic Z refocusing
mdd
parents:
26
diff
changeset
|
329 | add("lasercut_material_thickness_label", wx.StaticText(parentpanel, -1, _("Material Thickness:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT) |
26 | 330 | |
15 | 331 | # Extrusion controls # |
332 | ||
333 | # Extrusion settings | |
334 | esettingspanel = root.newPanel(parentpanel) | |
335 | esettingssizer = wx.GridBagSizer() | |
336 | esettingssizer.SetEmptyCellSize((0, 0)) | |
337 | root.edist = FloatSpin(esettingspanel, -1, value = root.settings.last_extrusion, min_val = 0, max_val = 1000, size = (90, -1), digits = 1) | |
338 | root.edist.SetBackgroundColour((225, 200, 200)) | |
339 | root.edist.SetForegroundColour("black") | |
340 | root.edist.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
341 | root.edist.Bind(wx.EVT_TEXT, root.setfeeds) | |
342 | add("edist_label", wx.StaticText(esettingspanel, -1, _("Length:")), container = esettingssizer, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, border = 5) | |
343 | add("edist_val", root.edist, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
344 | unit_label = _("mm") if mini_mode else _("mm @") | |
345 | add("edist_unit", wx.StaticText(esettingspanel, -1, unit_label), container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
346 | root.edist.SetToolTip(wx.ToolTip(_("Amount to Extrude or Retract (mm)"))) | |
347 | if not mini_mode: | |
348 | root.efeedc = FloatSpin(esettingspanel, -1, value = root.settings.e_feedrate, min_val = 0, max_val = 50000, size = (90, -1), digits = 1) | |
349 | root.efeedc.SetToolTip(wx.ToolTip(_("Extrude / Retract speed (mm/min)"))) | |
350 | root.efeedc.SetBackgroundColour((225, 200, 200)) | |
351 | root.efeedc.SetForegroundColour("black") | |
352 | root.efeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
353 | root.efeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
354 | add("efeed_val", root.efeedc, container = esettingssizer, flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5) | |
355 | add("efeed_label", wx.StaticText(esettingspanel, -1, _("Speed:")), container = esettingssizer, flag = wx.ALIGN_LEFT) | |
356 | add("efeed_unit", wx.StaticText(esettingspanel, -1, _("mm/\nmin")), container = esettingssizer, flag = wx.ALIGN_CENTER) | |
357 | else: | |
358 | root.efeedc = None | |
359 | esettingspanel.SetSizer(esettingssizer) | |
360 | add("esettings", esettingspanel, flag = wx.ALIGN_LEFT) | |
361 | ||
362 | if not standalone_mode: | |
363 | ebuttonspanel = root.newPanel(parentpanel) | |
364 | ebuttonssizer = wx.BoxSizer(wx.HORIZONTAL) | |
365 | if root.settings.extruders > 1: | |
366 | etool_sel_panel = esettingspanel if mini_mode else ebuttonspanel | |
367 | etool_label = wx.StaticText(etool_sel_panel, -1, _("Tool:")) | |
368 | if root.settings.extruders == 2: | |
369 | root.extrudersel = wx.Button(etool_sel_panel, -1, "0", style = wx.BU_EXACTFIT) | |
370 | root.extrudersel.SetToolTip(wx.ToolTip(_("Click to switch current extruder"))) | |
371 | ||
372 | def extrudersel_cb(event): | |
373 | if root.extrudersel.GetLabel() == "1": | |
374 | new = "0" | |
375 | else: | |
376 | new = "1" | |
377 | root.extrudersel.SetLabel(new) | |
378 | root.tool_change(event) | |
379 | root.extrudersel.Bind(wx.EVT_BUTTON, extrudersel_cb) | |
380 | root.extrudersel.GetValue = root.extrudersel.GetLabel | |
381 | root.extrudersel.SetValue = root.extrudersel.SetLabel | |
382 | else: | |
383 | choices = [str(i) for i in range(0, root.settings.extruders)] | |
384 | root.extrudersel = wx.ComboBox(etool_sel_panel, -1, choices = choices, | |
385 | style = wx.CB_DROPDOWN | wx.CB_READONLY, | |
386 | size = (50, -1)) | |
387 | root.extrudersel.SetToolTip(wx.ToolTip(_("Select current extruder"))) | |
388 | root.extrudersel.SetValue(choices[0]) | |
389 | root.extrudersel.Bind(wx.EVT_COMBOBOX, root.tool_change) | |
390 | root.printerControls.append(root.extrudersel) | |
391 | if mini_mode: | |
392 | add("etool_label", etool_label, container = esettingssizer, flag = wx.ALIGN_CENTER) | |
393 | add("etool_val", root.extrudersel, container = esettingssizer) | |
394 | else: | |
395 | ebuttonssizer.Add(etool_label, flag = wx.ALIGN_CENTER) | |
396 | ebuttonssizer.Add(root.extrudersel) | |
397 | ||
398 | for key in ["extrude", "reverse"]: | |
399 | desc = root.cpbuttons[key] | |
400 | btn = make_custom_button(root, ebuttonspanel, desc, | |
401 | style = wx.BU_EXACTFIT) | |
402 | ebuttonssizer.Add(btn, 1, flag = wx.EXPAND) | |
403 | ||
404 | ebuttonspanel.SetSizer(ebuttonssizer) | |
405 | add("ebuttons", ebuttonspanel, flag = wx.EXPAND) | |
406 | else: | |
407 | for key, btn in extra_buttons.items(): | |
408 | add(key, btn, flag = wx.EXPAND) | |
409 | ||
410 | class ControlsSizer(wx.GridBagSizer): | |
411 | ||
412 | def __init__(self, root, parentpanel = None, standalone_mode = False, mini_mode = False): | |
413 | super(ControlsSizer, self).__init__() | |
414 | if not parentpanel: parentpanel = root.panel | |
415 | if mini_mode: self.make_mini(root, parentpanel) | |
416 | else: self.make_standard(root, parentpanel, standalone_mode) | |
417 | ||
418 | def make_standard(self, root, parentpanel, standalone_mode): | |
419 | lltspanel = root.newPanel(parentpanel) | |
420 | llts = wx.BoxSizer(wx.HORIZONTAL) | |
421 | lltspanel.SetSizer(llts) | |
422 | self.Add(lltspanel, pos = (0, 0), span = (1, 6)) | |
423 | xyzpanel = root.newPanel(parentpanel) | |
424 | self.xyzsizer = XYZControlsSizer(root, xyzpanel) | |
425 | xyzpanel.SetSizer(self.xyzsizer) | |
426 | self.Add(xyzpanel, pos = (1, 0), span = (1, 6), flag = wx.ALIGN_CENTER) | |
427 | ||
428 | self.extra_buttons = {} | |
429 | pos_mapping = {"extrude": (4, 0), | |
430 | "reverse": (4, 2), | |
431 | } | |
432 | span_mapping = {"extrude": (1, 2), | |
433 | "reverse": (1, 3), | |
434 | } | |
435 | for key, desc in root.cpbuttons.items(): | |
436 | if not standalone_mode and key in ["extrude", "reverse"]: | |
437 | continue | |
438 | panel = lltspanel if key == "motorsoff" else parentpanel | |
439 | btn = make_custom_button(root, panel, desc) | |
440 | if key == "motorsoff": | |
441 | llts.Add(btn) | |
442 | elif not standalone_mode: | |
443 | self.Add(btn, pos = pos_mapping[key], span = span_mapping[key], flag = wx.EXPAND) | |
444 | else: | |
445 | self.extra_buttons[key] = btn | |
446 | ||
447 | root.xyfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.xy_feedrate), min = 0, max = 50000, size = (97, -1)) | |
448 | root.xyfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for X & Y axes (mm/min)"))) | |
449 | llts.Add(wx.StaticText(lltspanel, -1, _("XY:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) | |
450 | llts.Add(root.xyfeedc) | |
451 | llts.Add(wx.StaticText(lltspanel, -1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) | |
452 | root.zfeedc = wx.SpinCtrl(lltspanel, -1, str(root.settings.z_feedrate), min = 0, max = 50000, size = (90, -1)) | |
453 | root.zfeedc.SetToolTip(wx.ToolTip(_("Set Maximum Speed for Z axis (mm/min)"))) | |
454 | llts.Add(root.zfeedc,) | |
455 | ||
456 | root.xyfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
457 | root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) | |
458 | root.xyfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
459 | root.zfeedc.Bind(wx.EVT_TEXT, root.setfeeds) | |
460 | root.zfeedc.SetBackgroundColour((180, 255, 180)) | |
461 | root.zfeedc.SetForegroundColour("black") | |
462 | ||
463 | if not standalone_mode: | |
464 | add_extra_controls(self, root, parentpanel, None) | |
465 | ||
466 | def make_mini(self, root, parentpanel): | |
467 | root.xyb = XYButtonsMini(parentpanel, root.moveXY, root.homeButtonClicked, | |
468 | root.spacebarAction, root.bgcolor, | |
469 | zcallback = root.moveZ) | |
470 | self.Add(root.xyb, pos = (1, 0), span = (1, 4), flag = wx.ALIGN_CENTER) | |
471 | root.zb = ZButtonsMini(parentpanel, root.moveZ, root.bgcolor) | |
472 | self.Add(root.zb, pos = (0, 4), span = (2, 1), flag = wx.ALIGN_CENTER) | |
473 | wx.CallAfter(root.xyb.SetFocus) | |
474 | ||
475 | pos_mapping = {"motorsoff": (0, 0), | |
476 | } | |
477 | span_mapping = {"motorsoff": (1, 4), | |
478 | } | |
479 | btn = make_custom_button(root, parentpanel, root.cpbuttons["motorsoff"]) | |
480 | self.Add(btn, pos = pos_mapping["motorsoff"], span = span_mapping["motorsoff"], flag = wx.EXPAND) | |
481 | ||
482 | add_extra_controls(self, root, parentpanel, None, True) |