Browse Source

- fixed some decimals issues in NCC Tool, Paint Tool and Excellon Editor (they were still using the harcoded values)
- some small updates in the NCC Tool

Marius Stanciu 6 years ago
parent
commit
f7084f4e56

+ 8 - 9
FlatCAMApp.py

@@ -1795,12 +1795,14 @@ class App(QtCore.QObject):
 
 
             if self.cmd_line_headless == 1:
             if self.cmd_line_headless == 1:
                 self.trayIcon = FlatCAMSystemTray(app=self,
                 self.trayIcon = FlatCAMSystemTray(app=self,
-                                                  icon=QtGui.QIcon(self.resource_location + '/flatcam_icon32_green.png'),
+                                                  icon=QtGui.QIcon(self.resource_location +
+                                                                   '/flatcam_icon32_green.png'),
                                                   headless=True,
                                                   headless=True,
                                                   parent=self.parent_w)
                                                   parent=self.parent_w)
             else:
             else:
                 self.trayIcon = FlatCAMSystemTray(app=self,
                 self.trayIcon = FlatCAMSystemTray(app=self,
-                                                  icon=QtGui.QIcon(self.resource_location + '/flatcam_icon32_green.png'),
+                                                  icon=QtGui.QIcon(self.resource_location +
+                                                                   '/flatcam_icon32_green.png'),
                                                   parent=self.parent_w)
                                                   parent=self.parent_w)
 
 
         # #############################################################################
         # #############################################################################
@@ -2921,7 +2923,6 @@ class App(QtCore.QObject):
             #     self.defaults_form_fields[option].set_value(self.defaults[option])
             #     self.defaults_form_fields[option].set_value(self.defaults[option])
             # except KeyError:
             # except KeyError:
             #     #self.log.debug("defaults_write_form(): No field for: %s" % option)
             #     #self.log.debug("defaults_write_form(): No field for: %s" % option)
-            #     # TODO: Rethink this?
             #     pass
             #     pass
 
 
     def defaults_write_form_field(self, field, factor=None, units=None, defaults_dict=None):
     def defaults_write_form_field(self, field, factor=None, units=None, defaults_dict=None):
@@ -2931,6 +2932,7 @@ class App(QtCore.QObject):
         :param field: the GUI element in Preferences GUI to be updated
         :param field: the GUI element in Preferences GUI to be updated
         :param factor: factor to be applied to the field parameter
         :param factor: factor to be applied to the field parameter
         :param units: current FLatCAM measuring units
         :param units: current FLatCAM measuring units
+        :param defaults_dict: the defaults storage
         :return: None, it updates GUI elements
         :return: None, it updates GUI elements
         """
         """
 
 
@@ -2951,8 +2953,6 @@ class App(QtCore.QObject):
                 elif units == 'MM' and (field == 'global_gridx' or field == 'global_gridy'):
                 elif units == 'MM' and (field == 'global_gridx' or field == 'global_gridy'):
                     self.defaults_form_fields[field].set_value((def_dict[field] * factor))
                     self.defaults_form_fields[field].set_value((def_dict[field] * factor))
         except KeyError:
         except KeyError:
-            # self.log.debug("defaults_write_form(): No field for: %s" % option)
-            # TODO: Rethink this?
             pass
             pass
         except AttributeError:
         except AttributeError:
             log.debug(field)
             log.debug(field)
@@ -6910,7 +6910,7 @@ class App(QtCore.QObject):
 
 
         # work only if the notebook tab on focus is the Selected_Tab and only if the object is Geometry
         # work only if the notebook tab on focus is the Selected_Tab and only if the object is Geometry
         if notebook_widget_name == 'selected_tab':
         if notebook_widget_name == 'selected_tab':
-            if str(type(self.collection.get_active())) == "<class 'FlatCAMObj.FlatCAMGeometry'>":
+            if self.collection.get_active().kind == 'geometry':
                 # Tool add works for Geometry only if Advanced is True in Preferences
                 # Tool add works for Geometry only if Advanced is True in Preferences
                 if self.defaults["global_app_level"] == 'a':
                 if self.defaults["global_app_level"] == 'a':
                     tool_add_popup = FCInputDialog(title="New Tool ...",
                     tool_add_popup = FCInputDialog(title="New Tool ...",
@@ -6926,12 +6926,11 @@ class App(QtCore.QObject):
                             return
                             return
                         self.collection.get_active().on_tool_add(dia=float(val))
                         self.collection.get_active().on_tool_add(dia=float(val))
                     else:
                     else:
-                        self.inform.emit('[WARNING_NOTCL] %s...' %
-                                         _("Adding Tool cancelled"))
+                        self.inform.emit('[WARNING_NOTCL] %s...' % _("Adding Tool cancelled"))
                 else:
                 else:
                     msgbox = QtWidgets.QMessageBox()
                     msgbox = QtWidgets.QMessageBox()
                     msgbox.setText(_("Adding Tool works only when Advanced is checked.\n"
                     msgbox.setText(_("Adding Tool works only when Advanced is checked.\n"
-                                   "Go to Preferences -> General - Show Advanced Options."))
+                                     "Go to Preferences -> General - Show Advanced Options."))
                     msgbox.setWindowTitle("Tool adding ...")
                     msgbox.setWindowTitle("Tool adding ...")
                     msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/warning.png'))
                     msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/warning.png'))
                     bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
                     bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)

+ 2 - 0
README.md

@@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
 
 
 - Buffer sub-tool in Transform Tool: added the possibility to apply a factor effectively scaling the aperture size thus the copper features sizes
 - Buffer sub-tool in Transform Tool: added the possibility to apply a factor effectively scaling the aperture size thus the copper features sizes
 - in Transform Tool adjusted the GUI
 - in Transform Tool adjusted the GUI
+- fixed some decimals issues in NCC Tool, Paint Tool and Excellon Editor (they were still using the harcoded values)
+- some small updates in the NCC Tool
 
 
 29.12.2019
 29.12.2019
 
 

+ 0 - 5
flatcamEditors/FlatCAMExcEditor.py

@@ -2227,11 +2227,6 @@ class FlatCAMExcEditor(QtCore.QObject):
         # updated units
         # updated units
         self.units = self.app.defaults['units'].upper()
         self.units = self.app.defaults['units'].upper()
 
 
-        if self.units == "IN":
-            self.decimals = 4
-        else:
-            self.decimals = 2
-
         self.olddia_newdia.clear()
         self.olddia_newdia.clear()
         self.tool2tooldia.clear()
         self.tool2tooldia.clear()
 
 

+ 5 - 8
flatcamTools/ToolNonCopperClear.py

@@ -634,11 +634,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
     def set_tool_ui(self):
     def set_tool_ui(self):
         self.units = self.app.defaults['units'].upper()
         self.units = self.app.defaults['units'].upper()
 
 
-        if self.units == "IN":
-            self.decimals = 4
-        else:
-            self.decimals = 2
-
         self.tools_frame.show()
         self.tools_frame.show()
 
 
         self.ncc_order_radio.set_value(self.app.defaults["tools_nccorder"])
         self.ncc_order_radio.set_value(self.app.defaults["tools_nccorder"])
@@ -701,10 +696,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
         })
         })
 
 
         try:
         try:
+            dias = [float(self.app.defaults["tools_ncctools"])]
+        except (ValueError, TypeError):
             dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
             dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
-        except Exception as e:
-            log.error("At least one tool diameter needed. "
-                      "Verify in Edit -> Preferences -> TOOLS -> NCC Tools. %s" % str(e))
+
+        if not dias:
+            log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.")
             return
             return
 
 
         self.tooluid = 0
         self.tooluid = 0

+ 8 - 7
flatcamTools/ToolPaint.py

@@ -601,13 +601,6 @@ class ToolPaint(FlatCAMTool, Gerber):
         # updated units
         # updated units
         self.units = self.app.defaults['units'].upper()
         self.units = self.app.defaults['units'].upper()
 
 
-        if self.units == "IN":
-            self.decimals = 4
-            self.addtool_entry.set_value(0.039)
-        else:
-            self.decimals = 2
-            self.addtool_entry.set_value(1)
-
         # set the working variables to a known state
         # set the working variables to a known state
         self.paint_tools.clear()
         self.paint_tools.clear()
         self.tooluid = 0
         self.tooluid = 0
@@ -651,6 +644,14 @@ class ToolPaint(FlatCAMTool, Gerber):
         except (ValueError, TypeError):
         except (ValueError, TypeError):
             diameters = [eval(x) for x in self.app.defaults["tools_painttooldia"].split(",") if x != '']
             diameters = [eval(x) for x in self.app.defaults["tools_painttooldia"].split(",") if x != '']
 
 
+        if not diameters:
+            log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.")
+            self.build_ui()
+            # if the Paint Method is "Single" disable the tool table context menu
+            if self.default_data["selectmethod"] == "single":
+                self.tools_table.setContextMenuPolicy(Qt.NoContextMenu)
+            return
+
         # call on self.on_tool_add() counts as an call to self.build_ui()
         # call on self.on_tool_add() counts as an call to self.build_ui()
         # through this, we add a initial row / tool in the tool_table
         # through this, we add a initial row / tool in the tool_table
         for dia in diameters:
         for dia in diameters:

+ 0 - 5
flatcamTools/ToolSolderPaste.py

@@ -621,11 +621,6 @@ class SolderPaste(FlatCAMTool):
 
 
         self.units = self.app.defaults['units'].upper()
         self.units = self.app.defaults['units'].upper()
 
 
-        if self.units == "IN":
-            self.decimals = 4
-        else:
-            self.decimals = 2
-
         for name in list(self.app.preprocessors.keys()):
         for name in list(self.app.preprocessors.keys()):
             # populate only with preprocessor files that start with 'Paste_'
             # populate only with preprocessor files that start with 'Paste_'
             if name.partition('_')[0] != 'Paste':
             if name.partition('_')[0] != 'Paste':