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

- when adding an aperture with code '0' (zero) it will automatically be set with size zero and type: 'REG' (from region); here we store all the regions from a Gerber file, the ones without a declared aperture

Marius Stanciu 6 лет назад
Родитель
Сommit
e478d6e043
2 измененных файлов с 54 добавлено и 38 удалено
  1. 1 0
      README.md
  2. 53 38
      flatcamEditors/FlatCAMGrbEditor.py

+ 1 - 0
README.md

@@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing.
 - Gerber Editor: added shortcut for Transform Tool and also toggle effect here, too
 - Gerber Editor: added shortcut for Transform Tool and also toggle effect here, too
 - updated the shortcut list with the Gerber Editor shortcut keys
 - updated the shortcut list with the Gerber Editor shortcut keys
 - Gerber Editor: fixed error when adding an aperture with code value lower than the ones that already exists
 - Gerber Editor: fixed error when adding an aperture with code value lower than the ones that already exists
+- when adding an aperture with code '0' (zero) it will automatically be set with size zero and type: 'REG' (from region); here we store all the regions from a Gerber file, the ones without a declared aperture
 
 
 11.04.2019
 11.04.2019
 
 

+ 53 - 38
flatcamEditors/FlatCAMGrbEditor.py

@@ -1541,50 +1541,65 @@ class FlatCAMGrbEditor(QtCore.QObject):
                                        "Add it and retry."))
                                        "Add it and retry."))
                 return
                 return
 
 
-        if ap_id not in self.olddia_newdia:
-            self.storage_dict[ap_id] = {}
+        if ap_id == '0':
+            if ap_id not in self.olddia_newdia:
+                self.storage_dict[ap_id] = {}
+                self.storage_dict[ap_id]['type'] = 'REG'
+                size_val = 0
+                self.apsize_entry.set_value(size_val)
+                self.storage_dict[ap_id]['size'] = size_val
+
+                self.storage_dict[ap_id]['solid_geometry'] = []
+                self.storage_dict[ap_id]['follow_geometry'] = []
+
+                # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values
+                # each time a aperture code is edited or added
+                self.olddia_newdia[ap_id] = ap_id
+        else:
+            if ap_id not in self.olddia_newdia:
+                self.storage_dict[ap_id] = {}
 
 
-            type_val = self.aptype_cb.currentText()
-            self.storage_dict[ap_id]['type'] = type_val
+                type_val = self.aptype_cb.currentText()
+                self.storage_dict[ap_id]['type'] = type_val
 
 
-            if type_val == 'R' or type_val == 'O':
-                try:
-                    dims = self.apdim_entry.get_value()
-                    self.storage_dict[ap_id]['width'] = dims[0]
-                    self.storage_dict[ap_id]['height'] = dims[1]
+                if type_val == 'R' or type_val == 'O':
+                    try:
+                        dims = self.apdim_entry.get_value()
+                        self.storage_dict[ap_id]['width'] = dims[0]
+                        self.storage_dict[ap_id]['height'] = dims[1]
 
 
-                    size_val = math.sqrt((dims[0] ** 2) + (dims[1] ** 2))
-                    self.apsize_entry.set_value(size_val)
+                        size_val = math.sqrt((dims[0] ** 2) + (dims[1] ** 2))
+                        self.apsize_entry.set_value(size_val)
 
 
-                except Exception as e:
-                    log.error("FlatCAMGrbEditor.on_aperture_add() --> the R or O aperture dims has to be in a "
-                              "tuple format (x,y)\nError: %s" % str(e))
-                    self.app.inform.emit(_("[WARNING_NOTCL] Aperture dimensions value is missing or wrong format. "
-                                           "Add it in format (width, height) and retry."))
-                    return
-            else:
-                try:
-                    size_val = float(self.apsize_entry.get_value())
-                except ValueError:
-                    # try to convert comma to decimal point. if it's still not working error message and return
+                    except Exception as e:
+                        log.error("FlatCAMGrbEditor.on_aperture_add() --> the R or O aperture dims has to be in a "
+                                  "tuple format (x,y)\nError: %s" % str(e))
+                        self.app.inform.emit(_("[WARNING_NOTCL] Aperture dimensions value is missing or wrong format. "
+                                               "Add it in format (width, height) and retry."))
+                        return
+                else:
                     try:
                     try:
-                        size_val = float(self.apsize_entry.get_value().replace(',', '.'))
-                        self.apsize_entry.set_value(size_val)
+                        size_val = float(self.apsize_entry.get_value())
                     except ValueError:
                     except ValueError:
-                        self.app.inform.emit(_("[WARNING_NOTCL] Aperture size value is missing or wrong format. "
-                                               "Add it and retry."))
-                        return
-            self.storage_dict[ap_id]['size'] = size_val
-
-            self.storage_dict[ap_id]['solid_geometry'] = []
-            self.storage_dict[ap_id]['follow_geometry'] = []
-
-            # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values
-            # each time a aperture code is edited or added
-            self.olddia_newdia[ap_id] = ap_id
-        else:
-            self.app.inform.emit(_("[WARNING_NOTCL] Aperture already in the aperture table."))
-            return
+                        # try to convert comma to decimal point. if it's still not working error message and return
+                        try:
+                            size_val = float(self.apsize_entry.get_value().replace(',', '.'))
+                            self.apsize_entry.set_value(size_val)
+                        except ValueError:
+                            self.app.inform.emit(_("[WARNING_NOTCL] Aperture size value is missing or wrong format. "
+                                                   "Add it and retry."))
+                            return
+                self.storage_dict[ap_id]['size'] = size_val
+
+                self.storage_dict[ap_id]['solid_geometry'] = []
+                self.storage_dict[ap_id]['follow_geometry'] = []
+
+                # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values
+                # each time a aperture code is edited or added
+                self.olddia_newdia[ap_id] = ap_id
+            else:
+                self.app.inform.emit(_("[WARNING_NOTCL] Aperture already in the aperture table."))
+                return
 
 
         # since we add a new tool, we update also the initial state of the tool_table through it's dictionary
         # since we add a new tool, we update also the initial state of the tool_table through it's dictionary
         # we add a new entry in the tool2tooldia dict
         # we add a new entry in the tool2tooldia dict