Explorar el Código

- fixed the Drillcncjob Tcl command by adding an custom self.options key "Tools_in_use" and build it's value, in case it does not exist, to make the toolchange command work
- middle mouse click on closable tabs will close them

Marius Stanciu hace 6 años
padre
commit
84c8588f89
Se han modificado 5 ficheros con 68 adiciones y 19 borrados
  1. 25 11
      FlatCAMApp.py
  2. 2 2
      FlatCAMCommon.py
  3. 2 0
      README.md
  4. 21 5
      camlib.py
  5. 18 1
      flatcamGUI/GUIElements.py

+ 25 - 11
FlatCAMApp.py

@@ -339,13 +339,23 @@ class App(QtCore.QObject):
             os.makedirs(self.preprocessorpaths)
             App.log.debug('Created preprocessors folder: ' + self.preprocessorpaths)
 
-        # create tools_db.FlatDB file if there is none
+        # create geo_tools_db.FlatDB file if there is none
         try:
-            f = open(self.data_path + '/tools_db.FlatDB')
+            f = open(self.data_path + '/geo_tools_db.FlatDB')
             f.close()
         except IOError:
-            App.log.debug('Creating empty tool_db.FlatDB')
-            f = open(self.data_path + '/tools_db.FlatDB', 'w')
+            App.log.debug('Creating empty geo_tool_db.FlatDB')
+            f = open(self.data_path + '/geo_tools_db.FlatDB', 'w')
+            json.dump({}, f)
+            f.close()
+
+        # create fctool_tools_db.FlatDB file if there is none
+        try:
+            f = open(self.data_path + '/fctool_tools_db.FlatDB')
+            f.close()
+        except IOError:
+            App.log.debug('Creating empty fctool_tool_db.FlatDB')
+            f = open(self.data_path + '/fctool_tools_db.FlatDB', 'w')
             json.dump({}, f)
             f.close()
 
@@ -956,13 +966,15 @@ class App(QtCore.QObject):
                                           'Repetier, Roland_MDX_20, Users, Toolchange_Custom, Toolchange_Probe_MACH3, '
                                           'Toolchange_manual, Users, all, angle_x, angle_y, axis, auto, axisoffset, '
                                           'box, center_x, center_y, columns, combine, connect, contour, default, '
-                                          'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwell, dwelltime, '
+                                          'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwelltime, '
+                                          'extracut_length, '
                                           'feedrate_z, grbl_11, grbl_laser, gridoffsety, gridx, gridy, has_offset, '
                                           'holes, hpgl, iso_type, line_xyz, margin, marlin, method, milled_dias, '
-                                          'minoffset, multidepth, name, offset, opt_type, order, outname, overlap, '
+                                          'minoffset, name, offset, opt_type, order, outname, overlap, '
                                           'passes, postamble, pp, ppname_e, ppname_g, preamble, radius, ref, rest, '
                                           'rows, shellvar_, scale_factor, spacing_columns, spacing_rows, spindlespeed, '
-                                          'toolchange_xy, tooldia, use_threads, value, x, x0, x1, y, y0, y1, z_cut, '
+                                          'toolchange_xy, toolchangez, '
+                                          'tooldia, use_threads, value, x, x0, x1, y, y0, y1, z_cut, '
                                           'z_move',
             "script_autocompleter": True,
             "script_text": "",
@@ -2188,14 +2200,16 @@ class App(QtCore.QObject):
                                  'Toolchange_manual', 'Users', 'all', 'angle_x', 'angle_y', 'auto', 'axis',
                                  'axisoffset',
                                  'box', 'center_x', 'center_y', 'columns', 'combine', 'connect', 'contour', 'default',
-                                 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz', 'dwell',
-                                 'dwelltime', 'feedrate_z', 'grbl_11', 'grbl_laser', 'gridoffsety', 'gridx', 'gridy',
+                                 'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz',
+                                 'dwelltime', 'extracut_length',
+                                 'feedrate_z', 'grbl_11', 'grbl_laser', 'gridoffsety', 'gridx', 'gridy',
                                  'has_offset', 'holes', 'hpgl', 'iso_type', 'line_xyz', 'margin', 'marlin', 'method',
-                                 'milled_dias', 'minoffset', 'multidepth', 'name', 'offset', 'opt_type', 'order',
+                                 'milled_dias', 'minoffset', 'name', 'offset', 'opt_type', 'order',
                                  'outname', 'overlap', 'passes', 'postamble', 'pp', 'ppname_e', 'ppname_g',
                                  'preamble', 'radius', 'ref', 'rest', 'rows', 'shellvar_', 'scale_factor',
                                  'spacing_columns',
-                                 'spacing_rows', 'spindlespeed', 'toolchange_xy', 'tooldia', 'use_threads', 'value',
+                                 'spacing_rows', 'spindlespeed', 'toolchange_xy', 'toolchangez',
+                                 'tooldia', 'use_threads', 'value',
                                  'x', 'x0', 'x1', 'y', 'y0', 'y1', 'z_cut', 'z_move'
                                  ]
 

+ 2 - 2
FlatCAMCommon.py

@@ -737,7 +737,7 @@ class ToolsDB(QtWidgets.QWidget):
               "A position on Z plane to move immediately after job stop."))
 
     def setup_db_ui(self):
-        filename = self.app.data_path + '/tools_db.FlatDB'
+        filename = self.app.data_path + '/geo_tools_db.FlatDB'
 
         # load the database tools from the file
         try:
@@ -1174,7 +1174,7 @@ class ToolsDB(QtWidgets.QWidget):
     def on_save_tools_db(self, silent=False):
         self.app.log.debug("ToolsDB.on_save_button() --> Saving Tools Database to file.")
 
-        filename = self.app.data_path + "/tools_db.FlatDB"
+        filename = self.app.data_path + "/geo_tools_db.FlatDB"
 
         # Preferences save, update the color of the Tools DB Tab text
         for idx in range(self.app.ui.plot_tab_area.count()):

+ 2 - 0
README.md

@@ -18,6 +18,8 @@ CAD program, and create G-Code for Isolation routing.
 - modified the Drillcncjob and Cncjob Tcl commands to be allowed to work without the 'dwell' and 'toolchange' arguments. If 'dwelltime' argument is present it will be assumed that the 'dwell' is True and the same for 'toolchangez' parameter, if present then 'toolchange' will be assumed to be True, else False
 - modified the extracut and multidepth parameters in Cncjob Tcl command like for dwell and toolchange
 - added ability for Tcl commands to have optional arguments with None value (meaning missing value). This case should be treated for each Tcl command in execute() method
+- fixed the Drillcncjob Tcl command by adding an custom self.options key "Tools_in_use" and build it's value, in case it does not exist, to make the toolchange command work
+- middle mouse click on closable tabs will close them
 
 30.12.2019
 

+ 21 - 5
camlib.py

@@ -2415,11 +2415,8 @@ class CNCjob(Geometry):
             must_visit.remove(nearest)
         return path
 
-    def generate_from_excellon_by_tool(
-            self, exobj, tools="all", drillz = 3.0,
-            toolchange=False, toolchangez=0.1, toolchangexy='',
-            endz=2.0, startz=None,
-            excellon_optimization_type='B'):
+    def generate_from_excellon_by_tool(self, exobj, tools="all", drillz = 3.0, toolchange=False, toolchangez=0.1,
+                                       toolchangexy='', endz=2.0, startz=None, excellon_optimization_type='B'):
         """
         Creates gcode for this object from an Excellon object
         for the specified tools.
@@ -2515,6 +2512,16 @@ class CNCjob(Geometry):
             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))
 
+        # build a self.options['Tools_in_use'] list from scratch if we don't have one like in the case of
+        # running this method from a Tcl Command
+        build_tools_in_use_list = False
+        if 'Tools_in_use' not in self.options:
+            self.options['Tools_in_use'] = list()
+
+        # if the list is empty (either we just added the key or it was already there but empty) signal to build it
+        if not self.options['Tools_in_use']:
+            build_tools_in_use_list = True
+
         # fill the data into the self.exc_cnc_tools dictionary
         for it in sorted_tools:
             for to_ol in tools:
@@ -2552,6 +2559,15 @@ class CNCjob(Geometry):
                     self.exc_cnc_tools[it[1]]['data'] = default_data
                     self.exc_cnc_tools[it[1]]['solid_geometry'] = deepcopy(sol_geo)
 
+                    # build a self.options['Tools_in_use'] list from scratch if we don't have one like in the case of
+                    # running this method from a Tcl Command
+                    if build_tools_in_use_list is True:
+                        self.options['Tools_in_use'].append(
+                            [it[0], it[1], drill_no, slot_no]
+                        )
+
+        print(self.options['Tools_in_use'])
+
         self.app.inform.emit(_("Creating a list of points to drill..."))
         # Points (Group by tool)
         points = dict()

+ 18 - 1
flatcamGUI/GUIElements.py

@@ -1263,6 +1263,8 @@ class FCDetachableTab(QtWidgets.QTabWidget):
 
         self.tabBar = self.FCTabBar(self)
         self.tabBar.onMoveTabSignal.connect(self.moveTab)
+        self.tabBar.onCloseTabSignal.connect(self.on_closetab_middle_button)
+
         self.tabBar.detachedTabDropSignal.connect(self.detachedTabDrop)
         self.set_detachable(val=True)
 
@@ -1351,6 +1353,17 @@ class FCDetachableTab(QtWidgets.QTabWidget):
 
         self.removeTab(currentIndex)
 
+    def on_closetab_middle_button(self, current_index):
+        """
+
+        :param current_index:
+        :return:
+        """
+
+        # if tab is protected don't delete it
+        if self.tabBar.tabButton(current_index, QtWidgets.QTabBar.RightSide) is not None:
+            self.removeTab(current_index)
+
     def protectTab(self, currentIndex):
         # self.FCTabBar().setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None)
         self.tabBar.setTabButton(currentIndex, QtWidgets.QTabBar.RightSide, None)
@@ -1664,7 +1677,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
         onDetachTabSignal = QtCore.pyqtSignal(int, QtCore.QPoint)
         onMoveTabSignal = QtCore.pyqtSignal(int, int)
         detachedTabDropSignal = QtCore.pyqtSignal(str, int, QtCore.QPoint)
-
+        onCloseTabSignal = QtCore.pyqtSignal(int)
         right_click = QtCore.pyqtSignal(int)
 
         def __init__(self, parent=None):
@@ -1724,6 +1737,10 @@ class FCDetachableTab(QtWidgets.QTabWidget):
             """
             if event.button() == QtCore.Qt.RightButton and self.prev_index == self.tabAt(event.pos()):
                 self.right_click.emit(self.prev_index)
+
+            if event.button() == QtCore.Qt.MiddleButton:
+                self.onCloseTabSignal.emit(int(self.tabAt(event.pos())))
+
             self.prev_index = -1
 
             QtWidgets.QTabBar.mouseReleaseEvent(self, event)