Просмотр исходного кода

Merged jpcgt/flatcam/master into tcl-commands

Kamil Sopko 9 лет назад
Родитель
Сommit
1bc3a0230c
4 измененных файлов с 39 добавлено и 11 удалено
  1. 9 5
      FlatCAM.py
  2. 2 0
      FlatCAMApp.py
  3. 17 0
      FlatCAMGUI.py
  4. 11 6
      camlib.py

+ 9 - 5
FlatCAM.py

@@ -1,10 +1,13 @@
 import sys
 from PyQt4 import QtGui
-from PyQt4 import QtCore
 from FlatCAMApp import App
 
+
 def debug_trace():
-    '''Set a tracepoint in the Python debugger that works with Qt'''
+    """
+    Set a tracepoint in the Python debugger that works with Qt
+    :return: None
+    """
     from PyQt4.QtCore import pyqtRemoveInputHook
     #from pdb import set_trace
     pyqtRemoveInputHook()
@@ -12,9 +15,10 @@ def debug_trace():
 
 debug_trace()
 
-# all X11 calling should  be thread safe otherwise we have strange issues
-QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
+# All X11 calling should be thread safe otherwise we have strange issues
+# QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_X11InitThreads)
+# NOTE: Never talk to the GUI from threads! This is why I commented the above.
 
 app = QtGui.QApplication(sys.argv)
 fc = App()
-sys.exit(app.exec_())
+sys.exit(app.exec_())

+ 2 - 0
FlatCAMApp.py

@@ -231,6 +231,7 @@ class App(QtCore.QObject):
             "excellon_feedrate": self.defaults_form.excellon_group.feedrate_entry,
             "excellon_spindlespeed": self.defaults_form.excellon_group.spindlespeed_entry,
             "excellon_toolchangez": self.defaults_form.excellon_group.toolchangez_entry,
+            "excellon_tooldia": self.defaults_form.excellon_group.tooldia_entry,
             "geometry_plot": self.defaults_form.geometry_group.plot_cb,
             "geometry_cutz": self.defaults_form.geometry_group.cutz_entry,
             "geometry_travelz": self.defaults_form.geometry_group.travelz_entry,
@@ -360,6 +361,7 @@ class App(QtCore.QObject):
             "excellon_feedrate": self.options_form.excellon_group.feedrate_entry,
             "excellon_spindlespeed": self.options_form.excellon_group.spindlespeed_entry,
             "excellon_toolchangez": self.options_form.excellon_group.toolchangez_entry,
+            "excellon_tooldia": self.options_form.excellon_group.tooldia_entry,
             "geometry_plot": self.options_form.geometry_group.plot_cb,
             "geometry_cutz": self.options_form.geometry_group.cutz_entry,
             "geometry_travelz": self.options_form.geometry_group.travelz_entry,

+ 17 - 0
FlatCAMGUI.py

@@ -607,6 +607,23 @@ class ExcellonOptionsGroupUI(OptionsGroupUI):
         self.spindlespeed_entry = IntEntry(allow_empty=True)
         grid1.addWidget(self.spindlespeed_entry, 4, 1)
 
+        #### Milling Holes ####
+        self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
+        self.mill_hole_label.setToolTip(
+            "Create Geometry for milling holes."
+        )
+        self.layout.addWidget(self.mill_hole_label)
+
+        grid1 = QtGui.QGridLayout()
+        self.layout.addLayout(grid1)
+        tdlabel = QtGui.QLabel('Tool dia:')
+        tdlabel.setToolTip(
+            "Diameter of the cutting tool."
+        )
+        grid1.addWidget(tdlabel, 0, 0)
+        self.tooldia_entry = LengthEntry()
+        grid1.addWidget(self.tooldia_entry, 0, 1)
+
 
 class GeometryOptionsGroupUI(OptionsGroupUI):
     def __init__(self, parent=None):

+ 11 - 6
camlib.py

@@ -2782,7 +2782,9 @@ class CNCjob(Geometry):
         else:
             selected_tools = [x.strip() for x in tools.split(",")]  # we strip spaces and also separate the tools by ','
             selected_tools = filter(lambda i: i in selected_tools, selected_tools)
-            tools = [i for i,j in sorted_tools for k in selected_tools if i == k]   # create a sorted list of selected tools from the sorted_tools list
+
+            # Create a sorted list of selected tools from the sorted_tools list
+            tools = [i for i, j in sorted_tools for k in selected_tools if i == k]
             log.debug("Tools selected and sorted are: %s" % str(tools)) 
 
         # Points (Group by tool)
@@ -2800,7 +2802,8 @@ class CNCjob(Geometry):
         # Basic G-Code macros
         t = "G00 " + CNCjob.defaults["coordinate_format"] + "\n"
         down = "G01 Z%.4f\n" % self.z_cut
-        up = "G01 Z%.4f\n" % self.z_move
+        up = "G00 Z%.4f\n" % self.z_move
+        up_to_zero = "G01 Z0\n"
 
         # Initialization
         gcode = self.unitcode[self.units.upper()] + "\n"
@@ -2810,7 +2813,8 @@ class CNCjob(Geometry):
         gcode += "G00 Z%.4f\n" % self.z_move  # Move to travel height
 
         if self.spindlespeed is not None:
-            gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
+            # Spindle start with configured speed
+            gcode += "M03 S%d\n" % int(self.spindlespeed)
         else:
             gcode += "M03\n"  # Spindle start
 
@@ -2818,7 +2822,7 @@ class CNCjob(Geometry):
 
         for tool in tools:
 
-            # only if tool have some points, otherwise thre may be error and this part is useless
+            # Only if tool has points.
             if tool in points:
                 # Tool change sequence (optional)
                 if toolchange:
@@ -2829,7 +2833,8 @@ class CNCjob(Geometry):
                     gcode += "(MSG, Change to tool dia=%.4f)\n" % exobj.tools[tool]["C"]
                     gcode += "M0\n"  # Temporary machine stop
                     if self.spindlespeed is not None:
-                        gcode += "M03 S%d\n" % int(self.spindlespeed)  # Spindle start with configured speed
+                        # Spindle start with configured speed
+                        gcode += "M03 S%d\n" % int(self.spindlespeed)
                     else:
                         gcode += "M03\n"  # Spindle start
 
@@ -2837,7 +2842,7 @@ class CNCjob(Geometry):
                 for point in points[tool]:
                     x, y = point.coords.xy
                     gcode += t % (x[0], y[0])
-                    gcode += down + up
+                    gcode += down + up_to_zero + up
 
         gcode += t % (0, 0)
         gcode += "M05\n"  # Spindle stop