Added more default options

Sat, 23 Sep 2017 10:27:49 +0200

author
mdd
date
Sat, 23 Sep 2017 10:27:49 +0200
changeset 34
654a41b13258
parent 33
eee51ca7cbe7
child 35
72c4cbf64211

Added more default options
Code cleanup

.hgignore file | annotate | diff | comparison | revisions
printrun-src/printrun/gui/controls.py file | annotate | diff | comparison | revisions
printrun-src/printrun/pronterface.py file | annotate | diff | comparison | revisions
--- a/.hgignore	Sat Sep 23 08:51:58 2017 +0200
+++ b/.hgignore	Sat Sep 23 10:27:49 2017 +0200
@@ -1,4 +1,6 @@
 syntax: glob
 
 *.pyc
-*.bak
\ No newline at end of file
+*.bak
+*.lnk
+slic3r*
--- a/printrun-src/printrun/gui/controls.py	Sat Sep 23 08:51:58 2017 +0200
+++ b/printrun-src/printrun/gui/controls.py	Sat Sep 23 10:27:49 2017 +0200
@@ -1,3 +1,6 @@
+# FILE MODIFIED BY NEOSOFT - MALTE DI DONATO
+# Embed Lasercut controls
+
 # This file is part of the Printrun suite.
 #
 # Printrun is free software: you can redistribute it and/or modify
@@ -72,7 +75,8 @@
         "tempdisp": (tempdisp_line, 0),
         "extrude": (3, 0),
         "reverse": (3, 2),
-        "lasercut": (lasercut_base_line, 0),
+        "lasercut_optionsbtn": (lasercut_base_line, 0),
+        "lasercut_printbtn": (lasercut_base_line, 2),
         "lasercut_material_thickness": (lasercut_base_line+1, 4),
         "lasercut_material_thickness_label": (lasercut_base_line+1, 0),
         "lasercut_pass_count": (lasercut_base_line+2, 4),
@@ -136,6 +140,31 @@
             container = self
         container.Add(widget, *args, **kwargs)
 
+    # Lasercutter quick controls #
+
+    root.lc_optionsbtn = make_button(parentpanel, _("Lasercutter options"), lambda e: PronterOptions(root, "Laser"), _("Open Lasercutter options"), style = wx.BU_EXACTFIT)
+    root.printerControls.append(root.lc_optionsbtn)
+    add("lasercut_optionsbtn", root.lc_optionsbtn, flag = wx.EXPAND)
+
+    root.lc_printbtn = make_button(parentpanel, _("Start cutting"), root.on_lc_printfile, _("Start printjob with lasercutting features"), style = wx.BU_EXACTFIT)
+    root.printerControls.append(root.lc_printbtn)
+    add("lasercut_printbtn", root.lc_printbtn, flag = wx.EXPAND)
+
+
+    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))
+    add("lasercut_pass_count", root.lc_pass_count)
+    add("lasercut_pass_count_label", wx.StaticText(parentpanel, -1, _("Number of cutting passes:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+
+    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))
+    add("lasercut_pass_zdiff", root.lc_pass_zdiff)
+    add("lasercut_pass_zdiff_label", wx.StaticText(parentpanel, -1, _("Z movement after each cut:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+
+    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))
+    add("lasercut_material_thickness", root.lc_material_thickness)
+    add("lasercut_material_thickness_label", wx.StaticText(parentpanel, -1, _("Material Thickness:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+
+
+
     # Hotend & bed temperatures #
 
     # Hotend temp
@@ -310,24 +339,6 @@
         add("tempgraph", root.graph, flag = wx.EXPAND | wx.ALL, border = 5)
         root.graph.Bind(wx.EVT_LEFT_DOWN, root.graph.show_graph_window)
 
-    # Lasercutter quick controls #
-
-    root.lc_optionsbtn = make_button(parentpanel, _("Lasercutter options"), lambda e: PronterOptions(root, "Laser"), _("Open Lasercutter options"), style = wx.BU_EXACTFIT)
-    root.printerControls.append(root.lc_optionsbtn)
-    add("lasercut", root.lc_optionsbtn, flag = wx.EXPAND)
-
-    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))
-    add("lasercut_pass_count", root.lc_pass_count)
-    add("lasercut_pass_count_label", wx.StaticText(parentpanel, -1, _("Number of cutting passes:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
-
-    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))
-    add("lasercut_pass_zdiff", root.lc_pass_zdiff)
-    add("lasercut_pass_zdiff_label", wx.StaticText(parentpanel, -1, _("Z movement after each cut:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
-
-    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))
-    add("lasercut_material_thickness", root.lc_material_thickness)
-    add("lasercut_material_thickness_label", wx.StaticText(parentpanel, -1, _("Material Thickness:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
-
     # Extrusion controls #
 
     # Extrusion settings
--- a/printrun-src/printrun/pronterface.py	Sat Sep 23 08:51:58 2017 +0200
+++ b/printrun-src/printrun/pronterface.py	Sat Sep 23 10:27:49 2017 +0200
@@ -257,15 +257,28 @@
         if self.settings.monitor:
             self.update_monitor()
 
+        self.lc_printing = False
         self.pass_current = 1
 
     #  --------------------------------------------------------------
     #  Lasercutter methods
     #  --------------------------------------------------------------
 
+    def on_lc_printfile(self, event):
+        # lc print button
+        self.log("Priming Z axis to initial focus")
+        line = self.precmd("G1 Z%.2f" % (self.settings.lc_z_focus + self.lc_material_thickness.GetValue()))
+        self.onecmd(line)
+
+        self.printfile(event)
+        self.lc_printing = True
+
 
     def endcb_lasercut(self):
         # LASERCUT: Now check if we should do another print pass?
+        if not self.lc_printing:
+            return
+
         pass_count = self.lc_pass_count.GetValue()
         if pass_count > 1:
             time.sleep(0.5)
@@ -274,7 +287,8 @@
                 self.log("Starting lasercut pass # %i of %i" % (self.pass_current, pass_count))
                 if self.lc_pass_zdiff.GetValue() != 0:
                     # move Z focus
-                    new_z = self.settings.lc_z_focus + self.lc_material_thickness.GetValue() + (self.lc_pass_zdiff.GetValue() * self.pass_current)
+                    new_z = self.settings.lc_z_focus + self.lc_material_thickness.GetValue() + (
+                        self.lc_pass_zdiff.GetValue() * (self.pass_current - 1))
                     self.log("Re-Positioning laser focus by %.1f mm to %.1f" % (self.lc_pass_zdiff.GetValue(), new_z))
                     line = self.precmd("G1 Z%.2f" % (new_z))
                     self.onecmd(line)
@@ -285,10 +299,43 @@
                 self.printfile(None)
                 self.pass_current = tmp
             else:
+                self.lc_printing = False
+                wx.CallAfter(self.lc_printbtn.Enable)
+                wx.CallAfter(self.lc_printbtn.SetLabel, _("Start cutting"))
+
                 self.log("Resetting Z axis to initial focus")
                 line = self.precmd("G1 Z%.2f" % (self.settings.lc_z_focus + self.lc_material_thickness.GetValue()))
                 self.onecmd(line)
 
+    def update_lc_settings(self, key, value):
+        return True
+
+    def _lc_add_settings(self, size):
+        # first add the lasercutter options
+        self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser"))
+        self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_z_focus", 16, -80, 80, "Laser Z focus position", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_pass_count", 1, 0, 20, "Default Number of cutting passes", "", "Laser"), self.reload_ui)
+        self.settings._add(FloatSpinSetting("lc_pass_zdiff", -0.25, -2.0, 2.0, "Default Z movement after each cut", "", "Laser"), self.reload_ui)
+        self.settings._add(FloatSpinSetting("lc_material_thickness", 4.0, 0.0, 80.0, "Default Material Thickness", "", "Laser"), self.reload_ui)
+
+        self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings)
+        self.settings._add(BooleanSetting("lc_invert_cut", True, "PNG: Invert grey threshold", "Invert laser on/off logic", "Laser"), self.update_lc_settings)
+        self.settings._add(BooleanSetting("lc_change_dir", True, "PNG: Change direction", "Engrave in both directions on Y Axis", "Laser"), self.update_lc_settings)
+
+        self.settings._add(StaticTextSetting("separator_lc_hpgl", "HPGL processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_hpgl_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+
+        self.settings._add(StaticTextSetting("separator_lc_svg", "SVG processing", "", group = "Laser"))
+        self.settings._add(FloatSpinSetting("lc_svg_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
+        self.settings._add(FloatSpinSetting("lc_svg_smoothness", 0.2, 0.1, 10.0, "Smoothness", "Smoothness of curves (smaller value = smoother curve)", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_svg_width", 50, 1, 250, "Width (mm)", "Image width", "Laser"), self.update_lc_settings)
+        self.settings._add(SpinSetting("lc_svg_height", 50, 1, 250, "Height (mm)", "Image height", "Laser"), self.update_lc_settings)
+        self.settings._add(ComboSetting("lc_svg_scalemode", "scale", ["scale", "stretch"], "Scaling mode", "scale to dimensions / stretch to dimensions", "Laser"), self.update_lc_settings)
 
     #  --------------------------------------------------------------
     #  Main interface handling
@@ -886,35 +933,8 @@
     #  --------------------------------------------------------------
     #  Settings & command line handling (including update callbacks)
     #  --------------------------------------------------------------
-
-    def update_lc_settings(self, key, value):
-        return True
-
     def _add_settings(self, size):
-
-        # first add the lasercutter options
-        self.settings._add(StaticTextSetting("separator_lc_general", "General laser settings", "", group = "Laser"))
-        self.settings._add(SpinSetting("lc_travel_speed", 120, 1, 300, "Travel speed in mm/s", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_engrave_speed", 10, 1, 300, "Engrave speed in mm/s", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_z_focus", 16, -80, 80, "Laser Z focus position", "", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_bitmap", "PNG Bitmap processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_bitmap_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_dpi", 300, 25, 300, "Image DPI", "Image resolution for scaling", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_grey_threshold", 0, 0, 255, "Grey threshold value for RGB", "", "Laser"), self.update_lc_settings)
-        self.settings._add(BooleanSetting("lc_invert_cut", True, "PNG: Invert grey threshold", "Invert laser on/off logic", "Laser"), self.update_lc_settings)
-        self.settings._add(BooleanSetting("lc_change_dir", True, "PNG: Change direction", "Engrave in both directions on Y Axis", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_hpgl", "HPGL processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_hpgl_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-
-        self.settings._add(StaticTextSetting("separator_lc_svg", "SVG processing", "", group = "Laser"))
-        self.settings._add(FloatSpinSetting("lc_svg_speed_factor", 1.0, 0.1, 2.0, "Engrave speed factor", "", "Laser"), self.update_lc_settings)
-        self.settings._add(FloatSpinSetting("lc_svg_smoothness", 0.2, 0.1, 10.0, "Smoothness", "Smoothness of curves (smaller value = smoother curve)", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_svg_width", 50, 1, 250, "Width (mm)", "Image width", "Laser"), self.update_lc_settings)
-        self.settings._add(SpinSetting("lc_svg_height", 50, 1, 250, "Height (mm)", "Image height", "Laser"), self.update_lc_settings)
-        self.settings._add(ComboSetting("lc_svg_scalemode", "scale", ["scale", "stretch"], "Scaling mode", "scale to dimensions / stretch to dimensions", "Laser"), self.update_lc_settings)
-
+        self._lc_add_settings(size)
 
         self.settings._add(BooleanSetting("monitor", True, _("Monitor printer status"), _("Regularly monitor printer temperatures (required to have functional temperature graph or gauges)"), "Printer"), self.update_monitor)
         self.settings._add(StringSetting("simarrange_path", "", _("Simarrange command"), _("Path to the simarrange binary to use in the STL plater"), "External"))
@@ -1212,6 +1232,9 @@
         wx.CallAfter(self.printbtn.SetLabel, _("Restart"))
         wx.CallAfter(self.toolbarsizer.Layout)
 
+        wx.CallAfter(self.lc_printbtn.Disable)
+        wx.CallAfter(self.lc_printbtn.SetLabel, _("Cut in progress"))
+
     def printfile(self, event):
         self.extra_print_time = 0
         if self.paused:

mercurial