Browse Source

- finished the GUI in the Extract Drills Tool

Marius Stanciu 6 years ago
parent
commit
f2ccb48c98
3 changed files with 70 additions and 74 deletions
  1. 19 9
      FlatCAMApp.py
  2. 1 0
      README.md
  3. 50 65
      flatcamTools/ToolExtractDrills.py

+ 19 - 9
FlatCAMApp.py

@@ -954,6 +954,11 @@ class App(QtCore.QObject):
             "tools_cal_toolchange_xy": '',
             "tools_cal_sec_point": 'tl',
 
+            # Drills Extraction Tool
+            "tools_edrills_hole_type": 'fixed',
+            "tools_edrills_hole_fixed_dia": 0.5,
+            "tools_edrills_hole_ring": 0.2,
+
             # Utilities
             # file associations
             "fa_excellon": 'drd, drl, exc, ncd, tap, xln',
@@ -2464,12 +2469,13 @@ class App(QtCore.QObject):
         self.qrcode_tool = None
         self.copper_thieving_tool = None
         self.fiducial_tool = None
+        self.edrills_tool = None
 
         # always install tools only after the shell is initialized because the self.inform.emit() depends on shell
         try:
             self.install_tools()
-        except AttributeError:
-            pass
+        except AttributeError as e:
+            log.debug("App.__init__() install tools() --> %s" % str(e))
 
         # ##################################################################################
         # ########################### SETUP RECENT ITEMS ###################################
@@ -3017,13 +3023,6 @@ class App(QtCore.QObject):
 
         :return: None
         """
-        self.dblsidedtool = DblSidedTool(self)
-        self.dblsidedtool.install(icon=QtGui.QIcon(self.resource_location + '/doubleside16.png'), separator=True)
-
-        self.cal_exc_tool = ToolCalibration(self)
-        self.cal_exc_tool.install(icon=QtGui.QIcon(self.resource_location + '/calibrate_16.png'), pos=self.ui.menutool,
-                                  before=self.dblsidedtool.menuAction,
-                                  separator=False)
         self.distance_tool = Distance(self)
         self.distance_tool.install(icon=QtGui.QIcon(self.resource_location + '/distance16.png'), pos=self.ui.menuedit,
                                    before=self.ui.menueditorigin,
@@ -3035,6 +3034,17 @@ class App(QtCore.QObject):
                                        before=self.ui.menueditorigin,
                                        separator=True)
 
+        self.dblsidedtool = DblSidedTool(self)
+        self.dblsidedtool.install(icon=QtGui.QIcon(self.resource_location + '/doubleside16.png'), separator=False)
+
+        self.cal_exc_tool = ToolCalibration(self)
+        self.cal_exc_tool.install(icon=QtGui.QIcon(self.resource_location + '/calibrate_16.png'), pos=self.ui.menutool,
+                                  before=self.dblsidedtool.menuAction,
+                                  separator=False)
+
+        self.edrills_tool = ToolExtractDrills(self)
+        self.edrills_tool.install(icon=QtGui.QIcon(self.resource_location + '/drill16.png'), separator=True)
+
         self.panelize_tool = Panelize(self)
         self.panelize_tool.install(icon=QtGui.QIcon(self.resource_location + '/panelize16.png'))
 

+ 1 - 0
README.md

@@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
 10.02.2019
 
 - working on a new tool: Extract Drills Tool who will create a Excellon object out of the apertures of a Gerber object
+- finished the GUI in the Extract Drills Tool
 
 8.01.2019
 

+ 50 - 65
flatcamTools/ToolExtractDrills.py

@@ -59,21 +59,15 @@ class ToolExtractDrills(FlatCAMTool):
         self.grb_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
         self.grb_label.setToolTip('%s.' % _("Gerber from which to extract drill holes"))
 
-        self.mirror_gerber_button.setStyleSheet("""
-                        QPushButton
-                        {
-                            font-weight: bold;
-                        }
-                        """)
-        self.mirror_gerber_button.setMinimumWidth(60)
-
         # grid_lay.addRow("Bottom Layer:", self.object_combo)
         grid_lay.addWidget(self.grb_label, 0, 0)
         grid_lay.addWidget(self.gerber_object_combo, 1, 0)
 
         # ## Grid Layout
-        grid_lay1 = QtWidgets.QGridLayout()
-        self.layout.addLayout(grid_lay1)
+        grid1 = QtWidgets.QGridLayout()
+        self.layout.addLayout(grid1)
+        grid1.setColumnStretch(0, 0)
+        grid1.setColumnStretch(1, 1)
 
         # ## Axis
         self.hole_size_radio = RadioSet([{'label': _("Fixed"), 'value': 'fixed'},
@@ -85,20 +79,15 @@ class ToolExtractDrills(FlatCAMTool):
               "- Proprotional -> each hole will havea a variable size\n"
               "such as to preserve a set annular ring"))
 
-        grid_lay1.addWidget(self.hole_size_label, 3, 0)
-        grid_lay1.addWidget(self.hole_size_radio, 3, 1)
+        grid1.addWidget(self.hole_size_label, 3, 0)
+        grid1.addWidget(self.hole_size_radio, 3, 1)
 
-        self.layout.addWidget(QtWidgets.QLabel(''))
+        # grid_lay1.addWidget(QtWidgets.QLabel(''))
 
         separator_line = QtWidgets.QFrame()
         separator_line.setFrameShape(QtWidgets.QFrame.HLine)
         separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
-        self.layout.addWidget(separator_line)
-
-        grid1 = QtWidgets.QGridLayout()
-        self.layout.addLayout(grid1)
-        grid1.setColumnStretch(0, 0)
-        grid1.setColumnStretch(1, 1)
+        grid1.addWidget(separator_line, 5, 0, 1, 2)
 
         # Diameter value
         self.dia_entry = FCDoubleSpinner()
@@ -110,8 +99,8 @@ class ToolExtractDrills(FlatCAMTool):
             _("Fixed hole diameter.")
         )
 
-        grid1.addWidget(self.dia_label, 1, 0)
-        grid1.addWidget(self.dia_entry, 1, 1)
+        grid1.addWidget(self.dia_label, 7, 0)
+        grid1.addWidget(self.dia_entry, 7, 1)
 
         # Annular Ring value
         self.ring_entry = FCDoubleSpinner()
@@ -125,8 +114,8 @@ class ToolExtractDrills(FlatCAMTool):
               "and the margin of the copper pad.")
         )
 
-        grid1.addWidget(self.ring_label, 2, 0)
-        grid1.addWidget(self.ring_entry, 2, 1)
+        grid1.addWidget(self.ring_label, 8, 0)
+        grid1.addWidget(self.ring_entry, 8, 1)
 
         # Calculate Bounding box
         self.e_drills_button = QtWidgets.QPushButton(_("Extract Drills"))
@@ -157,7 +146,7 @@ class ToolExtractDrills(FlatCAMTool):
         self.layout.addWidget(self.reset_button)
 
         # ## Signals
-        self.hole_size_radio.activated_custom(self.on_hole_size_toggle)
+        self.hole_size_radio.activated_custom.connect(self.on_hole_size_toggle)
         self.e_drills_button.clicked.connect(self.on_extract_drills_click)
         self.reset_button.clicked.connect(self.set_tool_ui)
 
@@ -165,7 +154,7 @@ class ToolExtractDrills(FlatCAMTool):
         self.drills = dict()
 
     def install(self, icon=None, separator=None, **kwargs):
-        FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
+        FlatCAMTool.install(self, icon, separator, shortcut='ALT+E', **kwargs)
 
     def run(self, toggle=True):
         self.app.report_usage("Extract Drills()")
@@ -204,60 +193,56 @@ class ToolExtractDrills(FlatCAMTool):
 
     def on_extract_drills_click(self):
         selection_index = self.gerber_object_combo.currentIndex()
-        # fcobj = self.app.collection.object_list[selection_index]
         model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
+
         try:
             fcobj = model_index.internalPointer().obj
         except Exception as e:
             self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
             return
 
-        if not isinstance(fcobj, FlatCAMGerber):
-            self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber, Excellon and Geometry objects can be mirrored."))
-            return
-
-        axis = self.mirror_axis.get_value()
-        mode = self.axis_location.get_value()
-
-        if mode == "point":
-            try:
-                px, py = self.point_entry.get_value()
-            except TypeError:
-                self.app.inform.emit('[WARNING_NOTCL] %s' % _("'Point' coordinates missing. "
-                                                              "Using Origin (0, 0) as mirroring reference."))
-                px, py = (0, 0)
-
-        else:
-            selection_index_box = self.box_combo.currentIndex()
-            model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
-            try:
-                bb_obj = model_index_box.internalPointer().obj
-            except Exception as e:
-                self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Box object loaded ..."))
-                return
-
-            xmin, ymin, xmax, ymax = bb_obj.bounds()
-            px = 0.5 * (xmin + xmax)
-            py = 0.5 * (ymin + ymax)
-
-        fcobj.mirror(axis, [px, py])
-        self.app.object_changed.emit(fcobj)
-        fcobj.plot()
+        # axis = self.mirror_axis.get_value()
+        # mode = self.axis_location.get_value()
+        #
+        # if mode == "point":
+        #     try:
+        #         px, py = self.point_entry.get_value()
+        #     except TypeError:
+        #         self.app.inform.emit('[WARNING_NOTCL] %s' % _("'Point' coordinates missing. "
+        #                                                       "Using Origin (0, 0) as mirroring reference."))
+        #         px, py = (0, 0)
+        #
+        # else:
+        #     selection_index_box = self.box_combo.currentIndex()
+        #     model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
+        #     try:
+        #         bb_obj = model_index_box.internalPointer().obj
+        #     except Exception as e:
+        #         self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Box object loaded ..."))
+        #         return
+        #
+        #     xmin, ymin, xmax, ymax = bb_obj.bounds()
+        #     px = 0.5 * (xmin + xmax)
+        #     py = 0.5 * (ymin + ymax)
+        #
+        # fcobj.mirror(axis, [px, py])
+        # self.app.object_changed.emit(fcobj)
+        # fcobj.plot()
         self.app.inform.emit('[success] Gerber %s %s...' % (str(fcobj.options['name']), _("was mirrored")))
 
     def on_hole_size_toggle(self, val):
         if val == "fixed":
-            self.dia_entry.show()
-            self.dia_label.show()
+            self.dia_entry.setDisabled(False)
+            self.dia_label.setDisabled(False)
 
-            self.ring_label.hide()
-            self.ring_entry.hide()
+            self.ring_label.setDisabled(True)
+            self.ring_entry.setDisabled(True)
         else:
-            self.dia_entry.hide()
-            self.dia_label.hide()
+            self.dia_entry.setDisabled(True)
+            self.dia_label.setDisabled(True)
 
-            self.ring_label.show()
-            self.ring_entry.show()
+            self.ring_label.setDisabled(False)
+            self.ring_entry.setDisabled(False)
 
     def reset_fields(self):
         self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))