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

- added messages in info bar when selecting objects in the Project View list
- fixed DblSided Tool so it correctly creates the Alignment Drills Excellon file using the new structure
- fixed DblSided Tool so it will not crash the app if the user tries to make a mirror using no coordinates
- added some relevant status bar messages in DblSided Tool
- fixed DblSided Tool to correctly use the Box object (until now it used as reference only Gerber object in spite of Excellon or Geometry objects being available)
- fixed DblSided Tool crash when trying to create Alignment Drills object without a Tool diameter specified

Marius Stanciu 7 лет назад
Родитель
Сommit
ffb7931adb
3 измененных файлов с 55 добавлено и 5 удалено
  1. 14 0
      ObjectCollection.py
  2. 6 0
      README.md
  3. 35 5
      flatcamTools/ToolDblSided.py

+ 14 - 0
ObjectCollection.py

@@ -902,6 +902,20 @@ class ObjectCollection(QtCore.QAbstractItemModel):
 
 
         try:
         try:
             obj = current.indexes()[0].internalPointer().obj
             obj = current.indexes()[0].internalPointer().obj
+
+            if obj.kind == 'gerber':
+                self.app.inform.emit('[selected]<span style="color:%s;">%s</span> selected' %
+                                 ('green', str(obj.options['name'])))
+            elif obj.kind == 'excellon':
+                self.app.inform.emit('[selected]<span style="color:%s;">%s</span> selected' %
+                                 ('brown', str(obj.options['name'])))
+            elif obj.kind == 'cncjob':
+                self.app.inform.emit('[selected]<span style="color:%s;">%s</span> selected' %
+                                 ('blue', str(obj.options['name'])))
+            elif obj.kind == 'geometry':
+                self.app.inform.emit('[selected]<span style="color:%s;">%s</span> selected' %
+                                 ('red', str(obj.options['name'])))
+
         except IndexError:
         except IndexError:
             FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)")
             FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)")
 
 

+ 6 - 0
README.md

@@ -12,6 +12,12 @@ CAD program, and create G-Code for Isolation routing.
 16.02.2019
 16.02.2019
 
 
 - added the 'Save' menu entry to the Project context menu, for CNCJob: it will export the GCode.
 - added the 'Save' menu entry to the Project context menu, for CNCJob: it will export the GCode.
+- added messages in info bar when selecting objects in the Project View list
+- fixed DblSided Tool so it correctly creates the Alignment Drills Excellon file using the new structure
+- fixed DblSided Tool so it will not crash the app if the user tries to make a mirror using no coordinates
+- added some relevant status bar messages in DblSided Tool
+- fixed DblSided Tool to correctly use the Box object (until now it used as reference only Gerber object in spite of Excellon or Geometry objects being available)
+- fixed DblSided Tool crash when trying to create Alignment Drills object without a Tool diameter specified
 
 
 15.02.2019
 15.02.2019
 
 

+ 35 - 5
flatcamTools/ToolDblSided.py

@@ -128,7 +128,7 @@ class DblSidedTool(FlatCAMTool):
 
 
         ## Point/Box
         ## Point/Box
         self.point_box_container = QtWidgets.QVBoxLayout()
         self.point_box_container = QtWidgets.QVBoxLayout()
-        self.pb_label = QtWidgets.QLabel("<b>Point/Box:</b>")
+        self.pb_label = QtWidgets.QLabel("<b>Point/Box Reference:</b>")
         self.pb_label.setToolTip(
         self.pb_label.setToolTip(
             "If 'Point' is selected above it store the coordinates (x, y) through which\n"
             "If 'Point' is selected above it store the coordinates (x, y) through which\n"
             "the mirroring axis passes.\n"
             "the mirroring axis passes.\n"
@@ -210,7 +210,7 @@ class DblSidedTool(FlatCAMTool):
         grid_lay2 = QtWidgets.QGridLayout()
         grid_lay2 = QtWidgets.QGridLayout()
         self.layout.addLayout(grid_lay2)
         self.layout.addLayout(grid_lay2)
 
 
-        self.drill_dia = LengthEntry()
+        self.drill_dia = FCEntry()
         self.dd_label = QtWidgets.QLabel("Drill diam.:")
         self.dd_label = QtWidgets.QLabel("Drill diam.:")
         self.dd_label.setToolTip(
         self.dd_label.setToolTip(
             "Diameter of the drill for the "
             "Diameter of the drill for the "
@@ -295,7 +295,22 @@ class DblSidedTool(FlatCAMTool):
         else:
         else:
             selection_index = self.box_combo.currentIndex()
             selection_index = self.box_combo.currentIndex()
             model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
             model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
-            bb_obj = model_index.internalPointer().obj
+            try:
+                bb_obj = model_index.internalPointer().obj
+            except AttributeError:
+                model_index = self.app.collection.index(selection_index, 0, self.exc_object_combo.rootModelIndex())
+                try:
+                    bb_obj = model_index.internalPointer().obj
+                except AttributeError:
+                    model_index = self.app.collection.index(selection_index, 0,
+                                                            self.geo_object_combo.rootModelIndex())
+                    try:
+                        bb_obj = model_index.internalPointer().obj
+                    except AttributeError:
+                        self.app.inform.emit(
+                            "[WARNING_NOTCL] There is no Box reference object loaded. Load one and retry.")
+                        return
+
             xmin, ymin, xmax, ymax = bb_obj.bounds()
             xmin, ymin, xmax, ymax = bb_obj.bounds()
             px = 0.5 * (xmin + xmax)
             px = 0.5 * (xmin + xmax)
             py = 0.5 * (ymin + ymax)
             py = 0.5 * (ymin + ymax)
@@ -303,7 +318,7 @@ class DblSidedTool(FlatCAMTool):
         xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
         xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
 
 
         dia = self.drill_dia.get_value()
         dia = self.drill_dia.get_value()
-        if dia is None:
+        if dia is '':
             self.app.inform.emit("[WARNING_NOTCL]No value or wrong format in Drill Dia entry. Add it and retry.")
             self.app.inform.emit("[WARNING_NOTCL]No value or wrong format in Drill Dia entry. Add it and retry.")
             return
             return
         tools = {"1": {"C": dia}}
         tools = {"1": {"C": dia}}
@@ -321,6 +336,10 @@ class DblSidedTool(FlatCAMTool):
             point_mirror = affinity.scale(point, xscale, yscale, origin=(px, py))
             point_mirror = affinity.scale(point, xscale, yscale, origin=(px, py))
             drills.append({"point": point, "tool": "1"})
             drills.append({"point": point, "tool": "1"})
             drills.append({"point": point_mirror, "tool": "1"})
             drills.append({"point": point_mirror, "tool": "1"})
+            if 'solid_geometry' not in tools:
+                tools["1"]['solid_geometry'] = []
+            else:
+                tools["1"]['solid_geometry'].append(point_mirror)
 
 
         def obj_init(obj_inst, app_inst):
         def obj_init(obj_inst, app_inst):
             obj_inst.tools = tools
             obj_inst.tools = tools
@@ -329,6 +348,7 @@ class DblSidedTool(FlatCAMTool):
 
 
         self.app.new_object("excellon", "Alignment Drills", obj_init)
         self.app.new_object("excellon", "Alignment Drills", obj_init)
         self.drill_values = ''
         self.drill_values = ''
+        self.app.inform.emit("[success] Excellon object with alignment drills created...")
 
 
     def on_mirror_gerber(self):
     def on_mirror_gerber(self):
         selection_index = self.gerber_object_combo.currentIndex()
         selection_index = self.gerber_object_combo.currentIndex()
@@ -371,6 +391,7 @@ class DblSidedTool(FlatCAMTool):
         fcobj.mirror(axis, [px, py])
         fcobj.mirror(axis, [px, py])
         self.app.object_changed.emit(fcobj)
         self.app.object_changed.emit(fcobj)
         fcobj.plot()
         fcobj.plot()
+        self.app.inform.emit("[success] Gerber %s was mirrored..." % str(fcobj.options['name']))
 
 
     def on_mirror_exc(self):
     def on_mirror_exc(self):
         selection_index = self.exc_object_combo.currentIndex()
         selection_index = self.exc_object_combo.currentIndex()
@@ -390,13 +411,20 @@ class DblSidedTool(FlatCAMTool):
         mode = self.axis_location.get_value()
         mode = self.axis_location.get_value()
 
 
         if mode == "point":
         if mode == "point":
-            px, py = self.point_entry.get_value()
+            try:
+                px, py = self.point_entry.get_value()
+            except Exception as e:
+                log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e))
+                self.app.inform.emit("[WARNING_NOTCL] There are no Point coordinates in the Point field. "
+                                     "Add coords and try again ...")
+                return
         else:
         else:
             selection_index_box = self.box_combo.currentIndex()
             selection_index_box = self.box_combo.currentIndex()
             model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
             model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
             try:
             try:
                 bb_obj = model_index_box.internalPointer().obj
                 bb_obj = model_index_box.internalPointer().obj
             except Exception as e:
             except Exception as e:
+                log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e))
                 self.app.inform.emit("[WARNING_NOTCL] There is no Box object loaded ...")
                 self.app.inform.emit("[WARNING_NOTCL] There is no Box object loaded ...")
                 return
                 return
 
 
@@ -407,6 +435,7 @@ class DblSidedTool(FlatCAMTool):
         fcobj.mirror(axis, [px, py])
         fcobj.mirror(axis, [px, py])
         self.app.object_changed.emit(fcobj)
         self.app.object_changed.emit(fcobj)
         fcobj.plot()
         fcobj.plot()
+        self.app.inform.emit("[success] Excellon %s was mirrored..." % str(fcobj.options['name']))
 
 
     def on_mirror_geo(self):
     def on_mirror_geo(self):
         selection_index = self.geo_object_combo.currentIndex()
         selection_index = self.geo_object_combo.currentIndex()
@@ -443,6 +472,7 @@ class DblSidedTool(FlatCAMTool):
         fcobj.mirror(axis, [px, py])
         fcobj.mirror(axis, [px, py])
         self.app.object_changed.emit(fcobj)
         self.app.object_changed.emit(fcobj)
         fcobj.plot()
         fcobj.plot()
+        self.app.inform.emit("[success] Geometry %s was mirrored..." % str(fcobj.options['name']))
 
 
     def on_point_add(self):
     def on_point_add(self):
         val = self.app.defaults["global_point_clipboard_format"] % (self.app.pos[0], self.app.pos[1])
         val = self.app.defaults["global_point_clipboard_format"] % (self.app.pos[0], self.app.pos[1])