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

- in ParseExcellon.Excellon the self.tools dict has now a key 'data' which holds a dict with all the default values for Excellon and Geometry
- Excellon and Geometry objects, when started with multiple tools selected, the parameters tool name reflect this situation

Marius Stanciu 6 лет назад
Родитель
Сommit
b71d4e8c45
3 измененных файлов с 44 добавлено и 7 удалено
  1. 22 1
      FlatCAMObj.py
  2. 2 0
      README.md
  3. 20 6
      flatcamParsers/ParseExcellon.py

+ 22 - 1
FlatCAMObj.py

@@ -2622,9 +2622,10 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
 
 
         # sort the tool diameter column
         # sort the tool diameter column
         # self.ui.tools_table.sortItems(1)
         # self.ui.tools_table.sortItems(1)
+
         # all the tools are selected by default
         # all the tools are selected by default
         self.ui.tools_table.selectColumn(0)
         self.ui.tools_table.selectColumn(0)
-        #
+
         self.ui.tools_table.resizeColumnsToContents()
         self.ui.tools_table.resizeColumnsToContents()
         self.ui.tools_table.resizeRowsToContents()
         self.ui.tools_table.resizeRowsToContents()
 
 
@@ -2686,6 +2687,16 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
             except (TypeError, AttributeError):
             except (TypeError, AttributeError):
                 pass
                 pass
 
 
+        # set the text on tool_data_label after loading the object
+        sel_rows = list()
+        sel_items = self.ui.tools_table.selectedItems()
+        for it in sel_items:
+            sel_rows.append(it.row())
+        if len(sel_rows) > 1:
+            self.ui.tool_data_label.setText(
+                "<b>%s: <font color='#0000FF'>%s</font></b>" % (_('Parameters for'), _("Multiple Tools"))
+            )
+
         self.ui_connect()
         self.ui_connect()
 
 
     def set_ui(self, ui):
     def set_ui(self, ui):
@@ -3855,6 +3866,16 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ui.e_cut_entry.setDisabled(False) if self.ui.extracut_cb.get_value() else \
         self.ui.e_cut_entry.setDisabled(False) if self.ui.extracut_cb.get_value() else \
             self.ui.e_cut_entry.setDisabled(True)
             self.ui.e_cut_entry.setDisabled(True)
 
 
+        # set the text on tool_data_label after loading the object
+        sel_rows = list()
+        sel_items = self.ui.geo_tools_table.selectedItems()
+        for it in sel_items:
+            sel_rows.append(it.row())
+        if len(sel_rows) > 1:
+            self.ui.tool_data_label.setText(
+                "<b>%s: <font color='#0000FF'>%s</font></b>" % (_('Parameters for'), _("Multiple Tools"))
+            )
+
     def set_ui(self, ui):
     def set_ui(self, ui):
         FlatCAMObj.set_ui(self, ui)
         FlatCAMObj.set_ui(self, ui)
 
 

+ 2 - 0
README.md

@@ -17,6 +17,8 @@ CAD program, and create G-Code for Isolation routing.
 - a small change in the Excellon UI
 - a small change in the Excellon UI
 - updated the Excellon and Geometry UI to be similar
 - updated the Excellon and Geometry UI to be similar
 - put bases for future changes to Excellon Object UI such that each tool will hold it's own parameters
 - put bases for future changes to Excellon Object UI such that each tool will hold it's own parameters
+- in ParseExcellon.Excellon the self.tools dict has now a key 'data' which holds a dict with all the default values for Excellon and Geometry
+- Excellon and Geometry objects, when started with multiple tools selected, the parameters tool name reflect this situation
 
 
 15.01.2020
 15.01.2020
 
 

+ 20 - 6
flatcamParsers/ParseExcellon.py

@@ -121,6 +121,9 @@ class Excellon(Geometry):
         self.zeros_found = deepcopy(self.zeros)
         self.zeros_found = deepcopy(self.zeros)
         self.units_found = deepcopy(self.units)
         self.units_found = deepcopy(self.units)
 
 
+        # default set of data to be added to each tool in self.tools as self.tools[tool]['data'] = self.default_data
+        self.default_data = dict()
+
         # this will serve as a default if the Excellon file has no info regarding of tool diameters (this info may be
         # this will serve as a default if the Excellon file has no info regarding of tool diameters (this info may be
         # in another file like for PCB WIzard ECAD software
         # in another file like for PCB WIzard ECAD software
         self.toolless_diam = 1.0
         self.toolless_diam = 1.0
@@ -261,6 +264,14 @@ class Excellon(Geometry):
         except Exception:
         except Exception:
             return "fail"
             return "fail"
 
 
+        # fill in self.default_data values from self.options
+        for opt_key, opt_val in self.app.options.items():
+            if opt_key.find('excellon_') == 0:
+                self.default_data[opt_key] = deepcopy(opt_val)
+        for opt_key, opt_val in self.app.options.items():
+            if opt_key.find('geometry_') == 0:
+                self.default_data[opt_key] = deepcopy(opt_val)
+
     def parse_lines(self, elines):
     def parse_lines(self, elines):
         """
         """
         Main Excellon parser.
         Main Excellon parser.
@@ -961,10 +972,8 @@ class Excellon(Geometry):
         try:
         try:
             # clear the solid_geometry in self.tools
             # clear the solid_geometry in self.tools
             for tool in self.tools:
             for tool in self.tools:
-                try:
-                    self.tools[tool]['solid_geometry'][:] = []
-                except KeyError:
-                    self.tools[tool]['solid_geometry'] = []
+                self.tools[tool]['solid_geometry'] = list()
+                self.tools[tool]['data'] = dict()
 
 
             for drill in self.drills:
             for drill in self.drills:
                 # poly = drill['point'].buffer(self.tools[drill['tool']]["C"]/2.0)
                 # poly = drill['point'].buffer(self.tools[drill['tool']]["C"]/2.0)
@@ -979,7 +988,10 @@ class Excellon(Geometry):
                 tooldia = self.tools[drill['tool']]['C']
                 tooldia = self.tools[drill['tool']]['C']
                 poly = drill['point'].buffer(tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
                 poly = drill['point'].buffer(tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
                 self.solid_geometry.append(poly)
                 self.solid_geometry.append(poly)
-                self.tools[drill['tool']]['solid_geometry'].append(poly)
+
+                tool_in_drills = drill['tool']
+                self.tools[tool_in_drills]['solid_geometry'].append(poly)
+                self.tools[tool_in_drills]['data'] = deepcopy(self.default_data)
 
 
             for slot in self.slots:
             for slot in self.slots:
                 slot_tooldia = self.tools[slot['tool']]['C']
                 slot_tooldia = self.tools[slot['tool']]['C']
@@ -989,8 +1001,10 @@ class Excellon(Geometry):
                 lines_string = LineString([start, stop])
                 lines_string = LineString([start, stop])
                 poly = lines_string.buffer(slot_tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
                 poly = lines_string.buffer(slot_tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
                 self.solid_geometry.append(poly)
                 self.solid_geometry.append(poly)
-                self.tools[slot['tool']]['solid_geometry'].append(poly)
 
 
+                tool_in_slots = slot['tool']
+                self.tools[tool_in_slots]['solid_geometry'].append(poly)
+                self.tools[tool_in_slots]['data'] = deepcopy(self.default_data)
         except Exception as e:
         except Exception as e:
             log.debug("flatcamParsers.ParseExcellon.Excellon.create_geometry() -> "
             log.debug("flatcamParsers.ParseExcellon.Excellon.create_geometry() -> "
                       "Excellon geometry creation failed due of ERROR: %s" % str(e))
                       "Excellon geometry creation failed due of ERROR: %s" % str(e))