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

- more changes in Preferences GUI, replacing the FCEntries with Spinners
- some small fixes in toggle units conversion

Marius Stanciu 6 лет назад
Родитель
Сommit
1668939df7
5 измененных файлов с 126 добавлено и 145 удалено
  1. 20 19
      FlatCAMApp.py
  2. 2 0
      README.md
  3. 2 2
      flatcamGUI/GUIElements.py
  4. 74 58
      flatcamGUI/PreferencesUI.py
  5. 28 66
      flatcamTools/ToolNonCopperClear.py

+ 20 - 19
FlatCAMApp.py

@@ -471,7 +471,7 @@ class App(QtCore.QObject):
 
 
             "global_open_style": self.ui.general_defaults_form.general_app_group.open_style_cb,
             "global_open_style": self.ui.general_defaults_form.general_app_group.open_style_cb,
 
 
-            "global_compression_level": self.ui.general_defaults_form.general_app_group.compress_combo,
+            "global_compression_level": self.ui.general_defaults_form.general_app_group.compress_spinner,
             "global_save_compressed": self.ui.general_defaults_form.general_app_group.save_type_cb,
             "global_save_compressed": self.ui.general_defaults_form.general_app_group.save_type_cb,
 
 
             # General GUI Preferences
             # General GUI Preferences
@@ -866,7 +866,7 @@ class App(QtCore.QObject):
             "global_project_autohide": True,
             "global_project_autohide": True,
             "global_toggle_tooltips": True,
             "global_toggle_tooltips": True,
             "global_worker_number": 2,
             "global_worker_number": 2,
-            "global_tolerance": 0.005,
+            "global_tolerance": 0.0002,
             "global_open_style": True,
             "global_open_style": True,
             "global_delete_confirmation": True,
             "global_delete_confirmation": True,
             "global_compression_level": 3,
             "global_compression_level": 3,
@@ -2907,16 +2907,16 @@ class App(QtCore.QObject):
                 if units is None:
                 if units is None:
                     self.defaults_form_fields[field].set_value(self.defaults[field])
                     self.defaults_form_fields[field].set_value(self.defaults[field])
                 elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
                 elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
-                    self.defaults_form_fields[field].set_value(self.defaults[field], decimals=6)
+                    self.defaults_form_fields[field].set_value(self.defaults[field])
                 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(self.defaults[field], decimals=4)
+                    self.defaults_form_fields[field].set_value(self.defaults[field])
             else:
             else:
                 if units is None:
                 if units is None:
                     self.defaults_form_fields[field].set_value(self.defaults[field] * factor)
                     self.defaults_form_fields[field].set_value(self.defaults[field] * factor)
                 elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
                 elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
-                    self.defaults_form_fields[field].set_value((self.defaults[field] * factor), decimals=6)
+                    self.defaults_form_fields[field].set_value((self.defaults[field] * factor))
                 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((self.defaults[field] * factor), decimals=4)
+                    self.defaults_form_fields[field].set_value((self.defaults[field] * factor))
         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?
             # TODO: Rethink this?
@@ -5464,7 +5464,7 @@ class App(QtCore.QObject):
 
 
         # Options to scale
         # Options to scale
         dimensions = ['gerber_isotooldia', 'gerber_noncoppermargin', 'gerber_bboxmargin', "gerber_isooverlap",
         dimensions = ['gerber_isotooldia', 'gerber_noncoppermargin', 'gerber_bboxmargin', "gerber_isooverlap",
-                      "gerber_editor_newsize", "gerber_editor_lin_pitch", "gerber_editor_buff_f"
+                      "gerber_editor_newsize", "gerber_editor_lin_pitch", "gerber_editor_buff_f",
 
 
                       'excellon_drillz',  'excellon_travelz', "excellon_toolchangexy",
                       'excellon_drillz',  'excellon_travelz', "excellon_toolchangexy",
                       'excellon_feedrate', 'excellon_feedrate_rapid', 'excellon_toolchangez',
                       'excellon_feedrate', 'excellon_feedrate_rapid', 'excellon_toolchangez',
@@ -5480,7 +5480,7 @@ class App(QtCore.QObject):
                       'cncjob_tooldia',
                       'cncjob_tooldia',
 
 
                       'tools_paintmargin', 'tools_painttooldia', 'tools_paintoverlap',
                       'tools_paintmargin', 'tools_painttooldia', 'tools_paintoverlap',
-                      "tools_ncctools", "tools_nccoverlap", "tools_nccmargin", "tools_ncccutz", "tools_ncctipdia"
+                      "tools_ncctools", "tools_nccoverlap", "tools_nccmargin", "tools_ncccutz", "tools_ncctipdia",
                       "tools_2sided_drilldia", "tools_film_boundary",
                       "tools_2sided_drilldia", "tools_film_boundary",
                       "tools_cutouttooldia", 'tools_cutoutmargin', 'tools_cutoutgapsize',
                       "tools_cutouttooldia", 'tools_cutoutmargin', 'tools_cutoutgapsize',
                       "tools_panelize_constrainx", "tools_panelize_constrainy",
                       "tools_panelize_constrainx", "tools_panelize_constrainy",
@@ -5570,12 +5570,12 @@ class App(QtCore.QObject):
                         self.options[dim] = float('%.4f' % val)
                         self.options[dim] = float('%.4f' % val)
                 else:
                 else:
                     val = 0.1
                     val = 0.1
-                    try:
-                        val = float(self.options[dim]) * sfactor
-                    except Exception as e:
-                        log.debug('App.on_toggle_units().scale_options() --> %s' % str(e))
-
-                    self.options[dim] = val
+                    if self.options[dim]:
+                        try:
+                            val = float(self.options[dim]) * sfactor
+                        except Exception as e:
+                            log.debug('App.on_toggle_units().scale_options() --> %s' % str(e))
+                        self.options[dim] = val
 
 
         def scale_defaults(sfactor):
         def scale_defaults(sfactor):
             for dim in dimensions:
             for dim in dimensions:
@@ -5652,12 +5652,13 @@ class App(QtCore.QObject):
                         self.defaults[dim] = float('%.4f' % val)
                         self.defaults[dim] = float('%.4f' % val)
                 else:
                 else:
                     val = 0.1
                     val = 0.1
-                    try:
-                        val = float(self.defaults[dim]) * sfactor
-                    except Exception as e:
-                        log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
+                    if self.defaults[dim]:
+                        try:
+                            val = float(self.defaults[dim]) * sfactor
+                        except Exception as e:
+                            log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
 
 
-                    self.defaults[dim] = val
+                        self.defaults[dim] = val
 
 
         # The scaling factor depending on choice of units.
         # The scaling factor depending on choice of units.
         factor = 1/25.4
         factor = 1/25.4

+ 2 - 0
README.md

@@ -15,6 +15,8 @@ CAD program, and create G-Code for Isolation routing.
 - in Preferences General, Gerber, Geometry, Excellon, CNCJob sections made all the input fields of type SpinBox (where possible)
 - in Preferences General, Gerber, Geometry, Excellon, CNCJob sections made all the input fields of type SpinBox (where possible)
 - updated the Distance Tool utility geometry color to adapt to the dark theme canvas
 - updated the Distance Tool utility geometry color to adapt to the dark theme canvas
 - Toggle Code Editor now works as expected even when the user is closing the Editor tab and not using the command Toggle Code Editor
 - Toggle Code Editor now works as expected even when the user is closing the Editor tab and not using the command Toggle Code Editor
+- more changes in Preferences GUI, replacing the FCEntries with Spinners
+- some small fixes in toggle units conversion
 
 
 7.10.2019
 7.10.2019
 
 

+ 2 - 2
flatcamGUI/GUIElements.py

@@ -546,7 +546,7 @@ class FCSpinner(QtWidgets.QSpinBox):
             self.readyToEdit = True
             self.readyToEdit = True
 
 
     def get_value(self):
     def get_value(self):
-        return str(self.value())
+        return int(self.value())
 
 
     def set_value(self, val):
     def set_value(self, val):
         try:
         try:
@@ -603,7 +603,7 @@ class FCDoubleSpinner(QtWidgets.QDoubleSpinBox):
             self.readyToEdit = True
             self.readyToEdit = True
 
 
     def get_value(self):
     def get_value(self):
-        return str(self.value())
+        return float(self.value())
 
 
     def set_value(self, val):
     def set_value(self, val):
         try:
         try:

+ 74 - 58
flatcamGUI/PreferencesUI.py

@@ -911,7 +911,10 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.setTitle(str(_("App Preferences")))
         self.setTitle(str(_("App Preferences")))
 
 
         # Create a form layout for the Application general settings
         # Create a form layout for the Application general settings
-        self.form_box = QtWidgets.QFormLayout()
+        grid0 = QtWidgets.QGridLayout()
+        self.layout.addLayout(grid0)
+        grid0.setColumnStretch(0, 0)
+        grid0.setColumnStretch(1, 1)
 
 
         # Units for FlatCAM
         # Units for FlatCAM
         self.unitslabel = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('Units'))
         self.unitslabel = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('Units'))
@@ -921,6 +924,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.units_radio = RadioSet([{'label': _('IN'), 'value': 'IN'},
         self.units_radio = RadioSet([{'label': _('IN'), 'value': 'IN'},
                                      {'label': _('MM'), 'value': 'MM'}])
                                      {'label': _('MM'), 'value': 'MM'}])
 
 
+        grid0.addWidget(self.unitslabel, 0, 0)
+        grid0.addWidget(self.units_radio, 0, 1)
+
         # Graphic Engine for FlatCAM
         # Graphic Engine for FlatCAM
         self.ge_label = QtWidgets.QLabel('<b>%s:</b>' % _('Graphic Engine'))
         self.ge_label = QtWidgets.QLabel('<b>%s:</b>' % _('Graphic Engine'))
         self.ge_label.setToolTip(_("Choose what graphic engine to use in FlatCAM.\n"
         self.ge_label.setToolTip(_("Choose what graphic engine to use in FlatCAM.\n"
@@ -932,6 +938,10 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.ge_radio = RadioSet([{'label': _('Legacy(2D)'), 'value': '2D'},
         self.ge_radio = RadioSet([{'label': _('Legacy(2D)'), 'value': '2D'},
                                   {'label': _('OpenGL(3D)'), 'value': '3D'}])
                                   {'label': _('OpenGL(3D)'), 'value': '3D'}])
 
 
+        grid0.addWidget(self.ge_label, 1, 0)
+        grid0.addWidget(self.ge_radio, 1, 1)
+        grid0.addWidget(QtWidgets.QLabel(''), 2, 0)
+
         # Application Level for FlatCAM
         # Application Level for FlatCAM
         self.app_level_label = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('APP. LEVEL'))
         self.app_level_label = QtWidgets.QLabel('<span style="color:red;"><b>%s:</b></span>' % _('APP. LEVEL'))
         self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
         self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
@@ -942,7 +952,10 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.app_level_radio = RadioSet([{'label': _('Basic'), 'value': 'b'},
         self.app_level_radio = RadioSet([{'label': _('Basic'), 'value': 'b'},
                                          {'label': _('Advanced'), 'value': 'a'}])
                                          {'label': _('Advanced'), 'value': 'a'}])
 
 
-        # Application Level for FlatCAM
+        grid0.addWidget(self.app_level_label, 3, 0)
+        grid0.addWidget(self.app_level_radio, 3, 1)
+
+        # Portability for FlatCAM
         self.portability_label = QtWidgets.QLabel('%s:' % _('Portable app'))
         self.portability_label = QtWidgets.QLabel('%s:' % _('Portable app'))
         self.portability_label.setToolTip(_("Choose if the application should run as portable.\n\n"
         self.portability_label.setToolTip(_("Choose if the application should run as portable.\n\n"
                                             "If Checked the application will run portable,\n"
                                             "If Checked the application will run portable,\n"
@@ -950,11 +963,17 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
                                             "in the application folder, in the lib\\config subfolder."))
                                             "in the application folder, in the lib\\config subfolder."))
         self.portability_cb = FCCheckBox()
         self.portability_cb = FCCheckBox()
 
 
+        grid0.addWidget(self.portability_label, 4, 0)
+        grid0.addWidget(self.portability_cb, 4, 1)
+
         # Languages for FlatCAM
         # Languages for FlatCAM
         self.languagelabel = QtWidgets.QLabel('<b>%s:</b>' % _('Languages'))
         self.languagelabel = QtWidgets.QLabel('<b>%s:</b>' % _('Languages'))
         self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
         self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
         self.language_cb = FCComboBox()
         self.language_cb = FCComboBox()
-        self.languagespace = QtWidgets.QLabel('')
+
+        grid0.addWidget(self.languagelabel, 5, 0)
+        grid0.addWidget(self.language_cb, 5, 1)
+
         self.language_apply_btn = FCButton(_("Apply Language"))
         self.language_apply_btn = FCButton(_("Apply Language"))
         self.language_apply_btn.setToolTip(_("Set the language used throughout FlatCAM.\n"
         self.language_apply_btn.setToolTip(_("Set the language used throughout FlatCAM.\n"
                                              "The app will restart after click."
                                              "The app will restart after click."
@@ -964,6 +983,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
                                              "security features. In this case the language will be\n"
                                              "security features. In this case the language will be\n"
                                              "applied at the next app start."))
                                              "applied at the next app start."))
 
 
+        grid0.addWidget(self.language_apply_btn, 6, 0, 1, 2)
+        grid0.addWidget(QtWidgets.QLabel(''), 7, 0)
+
         # Version Check CB
         # Version Check CB
         self.version_check_label = QtWidgets.QLabel('%s:' % _('Version Check'))
         self.version_check_label = QtWidgets.QLabel('%s:' % _('Version Check'))
         self.version_check_label.setToolTip(
         self.version_check_label.setToolTip(
@@ -976,6 +998,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
               "for a new version automatically at startup.")
               "for a new version automatically at startup.")
         )
         )
 
 
+        grid0.addWidget(self.version_check_label, 8, 0)
+        grid0.addWidget(self.version_check_cb, 8, 1)
+
         # Send Stats CB
         # Send Stats CB
         self.send_stats_label = QtWidgets.QLabel('%s:' % _('Send Stats'))
         self.send_stats_label = QtWidgets.QLabel('%s:' % _('Send Stats'))
         self.send_stats_label.setToolTip(
         self.send_stats_label.setToolTip(
@@ -988,6 +1013,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
               "stats automatically at startup, to help improve FlatCAM.")
               "stats automatically at startup, to help improve FlatCAM.")
         )
         )
 
 
+        grid0.addWidget(self.send_stats_label, 9, 0)
+        grid0.addWidget(self.send_stats_cb, 9, 1)
+
         self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
         self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
 
 
         # Select mouse pan button
         # Select mouse pan button
@@ -998,12 +1026,18 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.pan_button_radio = RadioSet([{'label': _('MMB'), 'value': '3'},
         self.pan_button_radio = RadioSet([{'label': _('MMB'), 'value': '3'},
                                           {'label': _('RMB'), 'value': '2'}])
                                           {'label': _('RMB'), 'value': '2'}])
 
 
+        grid0.addWidget(self.panbuttonlabel, 10, 0)
+        grid0.addWidget(self.pan_button_radio, 10, 1)
+
         # Multiple Selection Modifier Key
         # Multiple Selection Modifier Key
         self.mselectlabel = QtWidgets.QLabel('<b>%s:</b>' % _('Multiple Sel'))
         self.mselectlabel = QtWidgets.QLabel('<b>%s:</b>' % _('Multiple Sel'))
         self.mselectlabel.setToolTip(_("Select the key used for multiple selection."))
         self.mselectlabel.setToolTip(_("Select the key used for multiple selection."))
         self.mselect_radio = RadioSet([{'label': _('CTRL'), 'value': 'Control'},
         self.mselect_radio = RadioSet([{'label': _('CTRL'), 'value': 'Control'},
                                        {'label': _('SHIFT'), 'value': 'Shift'}])
                                        {'label': _('SHIFT'), 'value': 'Shift'}])
 
 
+        grid0.addWidget(self.mselectlabel, 11, 0)
+        grid0.addWidget(self.mselect_radio, 11, 1)
+
         # Worker Numbers
         # Worker Numbers
         self.worker_number_label = QtWidgets.QLabel('%s:' % _('Workers number'))
         self.worker_number_label = QtWidgets.QLabel('%s:' % _('Workers number'))
         self.worker_number_label.setToolTip(
         self.worker_number_label.setToolTip(
@@ -1025,6 +1059,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         )
         )
         self.worker_number_sb.set_range(2, 16)
         self.worker_number_sb.set_range(2, 16)
 
 
+        grid0.addWidget(self.worker_number_label, 12, 0)
+        grid0.addWidget(self.worker_number_sb, 12, 1)
+
         # Geometric tolerance
         # Geometric tolerance
         tol_label = QtWidgets.QLabel('%s:' % _("Geo Tolerance"))
         tol_label = QtWidgets.QLabel('%s:' % _("Geo Tolerance"))
         tol_label.setToolTip(_(
         tol_label.setToolTip(_(
@@ -1047,34 +1084,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
         self.tol_entry.setSingleStep(0.001)
         self.tol_entry.setSingleStep(0.001)
         self.tol_entry.set_precision(6)
         self.tol_entry.set_precision(6)
 
 
-        # Just to add empty rows
-        self.spacelabel = QtWidgets.QLabel('')
-
-        # Add (label - input field) pair to the QFormLayout
-        self.form_box.addRow(self.unitslabel, self.units_radio)
-        self.form_box.addRow(self.ge_label, self.ge_radio)
-        self.form_box.addRow(QtWidgets.QLabel(''))
-        self.form_box.addRow(self.app_level_label, self.app_level_radio)
-        self.form_box.addRow(self.portability_label, self.portability_cb)
-        self.form_box.addRow(QtWidgets.QLabel(''))
-
-        self.form_box.addRow(self.languagelabel, self.language_cb)
-        self.form_box.addRow(self.languagespace, self.language_apply_btn)
-
-        self.form_box.addRow(self.spacelabel, self.spacelabel)
-        self.form_box.addRow(self.version_check_label, self.version_check_cb)
-        self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
-
-        self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
-        self.form_box.addRow(self.mselectlabel, self.mselect_radio)
-        self.form_box.addRow(self.worker_number_label, self.worker_number_sb)
-        self.form_box.addRow(tol_label, self.tol_entry)
-
-        self.form_box.addRow(self.spacelabel, self.spacelabel)
-
-        # Add the QFormLayout that holds the Application general defaults
-        # to the main layout of this TAB
-        self.layout.addLayout(self.form_box)
+        grid0.addWidget(tol_label, 13, 0)
+        grid0.addWidget(self.tol_entry, 13, 1)
+        grid0.addWidget(QtWidgets.QLabel(''), 14, 0)
 
 
         # Open behavior
         # Open behavior
         self.open_style_cb = FCCheckBox('%s' % _('"Open" behavior'))
         self.open_style_cb = FCCheckBox('%s' % _('"Open" behavior'))
@@ -1084,8 +1096,8 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
               "When unchecked the path for opening files is the one used last: either the\n"
               "When unchecked the path for opening files is the one used last: either the\n"
               "path for saving files or the path for opening files.")
               "path for saving files or the path for opening files.")
         )
         )
-        # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
-        self.layout.addWidget(self.open_style_cb)
+
+        grid0.addWidget(self.open_style_cb, 15, 0, 1, 2)
 
 
         # Save compressed project CB
         # Save compressed project CB
         self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
         self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
@@ -1093,30 +1105,23 @@ class GeneralAppPrefGroupUI(OptionsGroupUI):
             _("Whether to save a compressed or uncompressed project.\n"
             _("Whether to save a compressed or uncompressed project.\n"
               "When checked it will save a compressed FlatCAM project.")
               "When checked it will save a compressed FlatCAM project.")
         )
         )
-        # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
-        self.layout.addWidget(self.save_type_cb)
 
 
-        hlay1 = QtWidgets.QHBoxLayout()
-        self.layout.addLayout(hlay1)
+        grid0.addWidget(self.save_type_cb, 16, 0, 1, 2)
 
 
         # Project LZMA Comppression Level
         # Project LZMA Comppression Level
-        self.compress_combo = FCComboBox()
-        self.compress_label = QtWidgets.QLabel('%s:' % _('Compression Level'))
+        self.compress_spinner = FCSpinner()
+        self.compress_spinner.set_range(0, 9)
+        self.compress_label = QtWidgets.QLabel('%s:' % _('Compression'))
         self.compress_label.setToolTip(
         self.compress_label.setToolTip(
             _("The level of compression used when saving\n"
             _("The level of compression used when saving\n"
               "a FlatCAM project. Higher value means better compression\n"
               "a FlatCAM project. Higher value means better compression\n"
               "but require more RAM usage and more processing time.")
               "but require more RAM usage and more processing time.")
         )
         )
-        # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
-        self.compress_combo.addItems([str(i) for i in range(10)])
-
-        hlay1.addWidget(self.compress_label)
-        hlay1.addWidget(self.compress_combo)
 
 
-        self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_combo], True)
+        grid0.addWidget(self.compress_label, 17, 0)
+        grid0.addWidget(self.compress_spinner, 17, 1)
 
 
-        self.form_box_2 = QtWidgets.QFormLayout()
-        self.layout.addLayout(self.form_box_2)
+        self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_spinner], True)
 
 
         self.layout.addStretch()
         self.layout.addStretch()
 
 
@@ -2871,11 +2876,7 @@ class GeometryGenPrefGroupUI(OptionsGroupUI):
         tdlabel.setToolTip(
         tdlabel.setToolTip(
             _("Diameters of the cutting tools, separated by ','")
             _("Diameters of the cutting tools, separated by ','")
         )
         )
-        self.cnctooldia_entry = FCDoubleSpinner()
-        self.cnctooldia_entry.set_range(0.000001, 999.9999)
-        self.cnctooldia_entry.set_precision(4)
-        self.cnctooldia_entry.setSingleStep(0.1)
-        self.cnctooldia_entry.setWrapping(True)
+        self.cnctooldia_entry = FCEntry()
 
 
         grid0.addWidget(tdlabel, 3, 0)
         grid0.addWidget(tdlabel, 3, 0)
         grid0.addWidget(self.cnctooldia_entry, 3, 1)
         grid0.addWidget(self.cnctooldia_entry, 3, 1)
@@ -3309,8 +3310,8 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
 
 
         grid0 = QtWidgets.QGridLayout()
         grid0 = QtWidgets.QGridLayout()
         self.layout.addLayout(grid0)
         self.layout.addLayout(grid0)
-        # grid0.setColumnStretch(1, 1)
-        # grid0.setColumnStretch(2, 1)
+        grid0.setColumnStretch(0, 0)
+        grid0.setColumnStretch(1, 1)
 
 
         # Plot CB
         # Plot CB
         # self.plot_cb = QtWidgets.QCheckBox('Plot')
         # self.plot_cb = QtWidgets.QCheckBox('Plot')
@@ -3671,7 +3672,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
         self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
         self.tipdialabel.setToolTip(
         self.tipdialabel.setToolTip(
             _("The tip diameter for V-Shape Tool"))
             _("The tip diameter for V-Shape Tool"))
-        self.tipdia_entry = LengthEntry()
+        self.tipdia_entry = FCDoubleSpinner()
+        self.tipdia_entry.set_precision(4)
+        self.tipdia_entry.set_range(0, 1000)
+        self.tipdia_entry.setSingleStep(0.1)
 
 
         grid0.addWidget(self.tipdialabel, 2, 0)
         grid0.addWidget(self.tipdialabel, 2, 0)
         grid0.addWidget(self.tipdia_entry, 2, 1)
         grid0.addWidget(self.tipdia_entry, 2, 1)
@@ -3681,7 +3685,11 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         self.tipanglelabel.setToolTip(
         self.tipanglelabel.setToolTip(
             _("The tip angle for V-Shape Tool.\n"
             _("The tip angle for V-Shape Tool.\n"
               "In degree."))
               "In degree."))
-        self.tipangle_entry = LengthEntry()
+        self.tipangle_entry = FCDoubleSpinner()
+        self.tipangle_entry.set_precision(4)
+        self.tipangle_entry.set_range(-360, 360)
+        self.tipangle_entry.setSingleStep(5)
+        self.tipangle_entry.setWrapping(True)
 
 
         grid0.addWidget(self.tipanglelabel, 3, 0)
         grid0.addWidget(self.tipanglelabel, 3, 0)
         grid0.addWidget(self.tipangle_entry, 3, 1)
         grid0.addWidget(self.tipangle_entry, 3, 1)
@@ -3732,7 +3740,11 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
            _("Depth of cut into material. Negative value.\n"
            _("Depth of cut into material. Negative value.\n"
              "In FlatCAM units.")
              "In FlatCAM units.")
         )
         )
-        self.cutz_entry = FloatEntry()
+        self.cutz_entry = FCDoubleSpinner()
+        self.cutz_entry.set_precision(4)
+        self.cutz_entry.set_range(-1000, -0.000001)
+        self.cutz_entry.setSingleStep(0.1)
+
         self.cutz_entry.setToolTip(
         self.cutz_entry.setToolTip(
            _("Depth of cut into material. Negative value.\n"
            _("Depth of cut into material. Negative value.\n"
              "In FlatCAM units.")
              "In FlatCAM units.")
@@ -3768,7 +3780,11 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
             _("Bounding box margin.")
             _("Bounding box margin.")
         )
         )
         grid0.addWidget(nccmarginlabel, 8, 0)
         grid0.addWidget(nccmarginlabel, 8, 0)
-        self.ncc_margin_entry = FloatEntry()
+        self.ncc_margin_entry = FCDoubleSpinner()
+        self.ncc_margin_entry.set_precision(4)
+        self.ncc_margin_entry.set_range(-10000, 10000)
+        self.ncc_margin_entry.setSingleStep(0.1)
+
         grid0.addWidget(self.ncc_margin_entry, 8, 1)
         grid0.addWidget(self.ncc_margin_entry, 8, 1)
 
 
         # Method
         # Method

+ 28 - 66
flatcamTools/ToolNonCopperClear.py

@@ -515,6 +515,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.select_method = None
         self.select_method = None
         self.tool_type_item_options = list()
         self.tool_type_item_options = list()
 
 
+        self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"])
+
         # #############################################################################
         # #############################################################################
         # ############################ SGINALS ########################################
         # ############################ SGINALS ########################################
         # #############################################################################
         # #############################################################################
@@ -918,36 +920,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
         else:
         else:
             if self.tool_type_radio.get_value() == 'V':
             if self.tool_type_radio.get_value() == 'V':
 
 
-                try:
-                    tip_dia = float(self.tipdia_entry.get_value())
-                except ValueError:
-                    # try to convert comma to decimal point. if it's still not working error message and return
-                    try:
-                        tip_dia = float(self.tipdia_entry.get_value().replace(',', '.'))
-                    except ValueError:
-                        self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, "
-                                                                    "use a number."))
-                        return
+                tip_dia = float(self.tipdia_entry.get_value())
+                tip_angle = float(self.tipangle_entry.get_value()) / 2
+                cut_z = float(self.cutz_entry.get_value())
 
 
-                try:
-                    tip_angle = float(self.tipangle_entry.get_value()) / 2
-                except ValueError:
-                    # try to convert comma to decimal point. if it's still not working error message and return
-                    try:
-                        tip_angle = float(self.tipangle_entry.get_value().replace(',', '.')) / 2
-                    except ValueError:
-                        self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
-                        return
-
-                try:
-                    cut_z = float(self.cutz_entry.get_value())
-                except ValueError:
-                    # try to convert comma to decimal point. if it's still not working error message and return
-                    try:
-                        cut_z = float(self.cutz_entry.get_value().replace(',', '.'))
-                    except ValueError:
-                        self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
-                        return
                 # calculated tool diameter so the cut_z parameter is obeyed
                 # calculated tool diameter so the cut_z parameter is obeyed
                 tool_dia = tip_dia + 2 * cut_z * math.tan(math.radians(tip_angle))
                 tool_dia = tip_dia + 2 * cut_z * math.tan(math.radians(tip_angle))
 
 
@@ -972,7 +948,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
                 self.app.inform.emit('[WARNING_NOTCL] %s' % _("Please enter a tool diameter to add, in Float format."))
                 self.app.inform.emit('[WARNING_NOTCL] %s' % _("Please enter a tool diameter to add, in Float format."))
                 return
                 return
 
 
-
         tool_dia = float('%.*f' % (self.decimals, tool_dia))
         tool_dia = float('%.*f' % (self.decimals, tool_dia))
 
 
         if tool_dia == 0:
         if tool_dia == 0:
@@ -1110,22 +1085,18 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.build_ui()
         self.build_ui()
 
 
     def on_ncc_click(self):
     def on_ncc_click(self):
+        """
+        Slot for clicking signal of the self.generate.ncc_button
+        :return: None
+        """
 
 
         # init values for the next usage
         # init values for the next usage
         self.reset_usage()
         self.reset_usage()
-
         self.app.report_usage("on_paint_button_click")
         self.app.report_usage("on_paint_button_click")
 
 
-        try:
-            self.overlap = float(self.ncc_overlap_entry.get_value())
-        except ValueError:
-            # try to convert comma to decimal point. if it's still not working error message and return
-            try:
-                self.overlap = float(self.ncc_overlap_entry.get_value().replace(',', '.'))
-            except ValueError:
-                self.app.inform.emit('[ERROR_NOTCL]  %s' % _("Wrong value format entered, "
-                                                             "use a number."))
-                return
+        self.overlap = float(self.ncc_overlap_entry.get_value())
+
+        self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"])
 
 
         if self.overlap >= 1 or self.overlap < 0:
         if self.overlap >= 1 or self.overlap < 0:
             self.app.inform.emit('[ERROR_NOTCL] %s' % _("Overlap value must be between "
             self.app.inform.emit('[ERROR_NOTCL] %s' % _("Overlap value must be between "
@@ -1134,9 +1105,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
 
         self.connect = self.ncc_connect_cb.get_value()
         self.connect = self.ncc_connect_cb.get_value()
         self.contour = self.ncc_contour_cb.get_value()
         self.contour = self.ncc_contour_cb.get_value()
-
         self.has_offset = self.ncc_choice_offset_cb.isChecked()
         self.has_offset = self.ncc_choice_offset_cb.isChecked()
-
         self.rest = self.ncc_rest_cb.get_value()
         self.rest = self.ncc_rest_cb.get_value()
 
 
         self.obj_name = self.object_combo.currentText()
         self.obj_name = self.object_combo.currentText()
@@ -1410,22 +1379,15 @@ class NonCopperClear(FlatCAMTool, Gerber):
         if margin is not None:
         if margin is not None:
             ncc_margin = margin
             ncc_margin = margin
         else:
         else:
-            try:
-                ncc_margin = float(self.ncc_margin_entry.get_value())
-            except ValueError:
-                # try to convert comma to decimal point. if it's still not working error message and return
-                try:
-                    ncc_margin = float(self.ncc_margin_entry.get_value().replace(',', '.'))
-                except ValueError:
-                    self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
-                    return
+            ncc_margin = float(self.ncc_margin_entry.get_value())
 
 
         if select_method is not None:
         if select_method is not None:
             ncc_select = select_method
             ncc_select = select_method
         else:
         else:
             ncc_select = self.reference_radio.get_value()
             ncc_select = self.reference_radio.get_value()
 
 
-        overlap = overlap if overlap else self.app.defaults["tools_nccoverlap"]
+        overlap = overlap if overlap else float(self.app.defaults["tools_nccoverlap"])
+
         connect = connect if connect else self.app.defaults["tools_nccconnect"]
         connect = connect if connect else self.app.defaults["tools_nccconnect"]
         contour = contour if contour else self.app.defaults["tools_ncccontour"]
         contour = contour if contour else self.app.defaults["tools_ncccontour"]
         order = order if order else self.ncc_order_radio.get_value()
         order = order if order else self.ncc_order_radio.get_value()
@@ -1788,15 +1750,15 @@ class NonCopperClear(FlatCAMTool, Gerber):
                                 try:
                                 try:
                                     if isinstance(p, Polygon):
                                     if isinstance(p, Polygon):
                                         if ncc_method == 'standard':
                                         if ncc_method == 'standard':
-                                            cp = self.clear_polygon(p, tool, self.app.defaults["gerber_circle_steps"],
+                                            cp = self.clear_polygon(p, tool, self.grb_circle_steps,
                                                                     overlap=overlap, contour=contour, connect=connect,
                                                                     overlap=overlap, contour=contour, connect=connect,
                                                                     prog_plot=prog_plot)
                                                                     prog_plot=prog_plot)
                                         elif ncc_method == 'seed':
                                         elif ncc_method == 'seed':
-                                            cp = self.clear_polygon2(p, tool, self.app.defaults["gerber_circle_steps"],
+                                            cp = self.clear_polygon2(p, tool, self.grb_circle_steps,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      prog_plot=prog_plot)
                                                                      prog_plot=prog_plot)
                                         else:
                                         else:
-                                            cp = self.clear_polygon3(p, tool, self.app.defaults["gerber_circle_steps"],
+                                            cp = self.clear_polygon3(p, tool, self.grb_circle_steps,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      prog_plot=prog_plot)
                                                                      prog_plot=prog_plot)
                                         if cp:
                                         if cp:
@@ -1806,19 +1768,19 @@ class NonCopperClear(FlatCAMTool, Gerber):
                                             if pol is not None:
                                             if pol is not None:
                                                 if ncc_method == 'standard':
                                                 if ncc_method == 'standard':
                                                     cp = self.clear_polygon(pol, tool,
                                                     cp = self.clear_polygon(pol, tool,
-                                                                            self.app.defaults["gerber_circle_steps"],
+                                                                            self.grb_circle_steps,
                                                                             overlap=overlap, contour=contour,
                                                                             overlap=overlap, contour=contour,
                                                                             connect=connect,
                                                                             connect=connect,
                                                                             prog_plot=prog_plot)
                                                                             prog_plot=prog_plot)
                                                 elif ncc_method == 'seed':
                                                 elif ncc_method == 'seed':
                                                     cp = self.clear_polygon2(pol, tool,
                                                     cp = self.clear_polygon2(pol, tool,
-                                                                             self.app.defaults["gerber_circle_steps"],
+                                                                             self.grb_circle_steps,
                                                                              overlap=overlap, contour=contour,
                                                                              overlap=overlap, contour=contour,
                                                                              connect=connect,
                                                                              connect=connect,
                                                                              prog_plot=prog_plot)
                                                                              prog_plot=prog_plot)
                                                 else:
                                                 else:
                                                     cp = self.clear_polygon3(pol, tool,
                                                     cp = self.clear_polygon3(pol, tool,
-                                                                             self.app.defaults["gerber_circle_steps"],
+                                                                             self.grb_circle_steps,
                                                                              overlap=overlap, contour=contour,
                                                                              overlap=overlap, contour=contour,
                                                                              connect=connect,
                                                                              connect=connect,
                                                                              prog_plot=prog_plot)
                                                                              prog_plot=prog_plot)
@@ -1890,7 +1852,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
                 if geo_obj.tools[tooluid]['solid_geometry']:
                 if geo_obj.tools[tooluid]['solid_geometry']:
                     has_solid_geo += 1
                     has_solid_geo += 1
             if has_solid_geo == 0:
             if has_solid_geo == 0:
-                app_obj.inform.emit('[ERROR] %s' % _("There is no Painting Geometry in the file.\n"
+                app_obj.inform.emit('[ERROR] %s' % _("There is no NCC Geometry in the file.\n"
                                                      "Usually it means that the tool diameter is too big "
                                                      "Usually it means that the tool diameter is too big "
                                                      "for the painted geometry.\n"
                                                      "for the painted geometry.\n"
                                                      "Change the painting parameters and try again."))
                                                      "Change the painting parameters and try again."))
@@ -2140,17 +2102,17 @@ class NonCopperClear(FlatCAMTool, Gerber):
                                     try:
                                     try:
                                         if ncc_method == 'standard':
                                         if ncc_method == 'standard':
                                             cp = self.clear_polygon(p, tool_used,
                                             cp = self.clear_polygon(p, tool_used,
-                                                                    self.app.defaults["gerber_circle_steps"],
+                                                                    self.grb_circle_steps,
                                                                     overlap=overlap, contour=contour, connect=connect,
                                                                     overlap=overlap, contour=contour, connect=connect,
                                                                     prog_plot=prog_plot)
                                                                     prog_plot=prog_plot)
                                         elif ncc_method == 'seed':
                                         elif ncc_method == 'seed':
                                             cp = self.clear_polygon2(p, tool_used,
                                             cp = self.clear_polygon2(p, tool_used,
-                                                                     self.app.defaults["gerber_circle_steps"],
+                                                                     self.grb_circle_steps,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      prog_plot=prog_plot)
                                                                      prog_plot=prog_plot)
                                         else:
                                         else:
                                             cp = self.clear_polygon3(p, tool_used,
                                             cp = self.clear_polygon3(p, tool_used,
-                                                                     self.app.defaults["gerber_circle_steps"],
+                                                                     self.grb_circle_steps,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      overlap=overlap, contour=contour, connect=connect,
                                                                      prog_plot=prog_plot)
                                                                      prog_plot=prog_plot)
                                         cleared_geo.append(list(cp.get_objects()))
                                         cleared_geo.append(list(cp.get_objects()))
@@ -2165,19 +2127,19 @@ class NonCopperClear(FlatCAMTool, Gerber):
                                             try:
                                             try:
                                                 if ncc_method == 'standard':
                                                 if ncc_method == 'standard':
                                                     cp = self.clear_polygon(poly, tool_used,
                                                     cp = self.clear_polygon(poly, tool_used,
-                                                                            self.app.defaults["gerber_circle_steps"],
+                                                                            self.grb_circle_steps,
                                                                             overlap=overlap, contour=contour,
                                                                             overlap=overlap, contour=contour,
                                                                             connect=connect,
                                                                             connect=connect,
                                                                             prog_plot=prog_plot)
                                                                             prog_plot=prog_plot)
                                                 elif ncc_method == 'seed':
                                                 elif ncc_method == 'seed':
                                                     cp = self.clear_polygon2(poly, tool_used,
                                                     cp = self.clear_polygon2(poly, tool_used,
-                                                                             self.app.defaults["gerber_circle_steps"],
+                                                                             self.grb_circle_steps,
                                                                              overlap=overlap, contour=contour,
                                                                              overlap=overlap, contour=contour,
                                                                              connect=connect,
                                                                              connect=connect,
                                                                              prog_plot=prog_plot)
                                                                              prog_plot=prog_plot)
                                                 else:
                                                 else:
                                                     cp = self.clear_polygon3(poly, tool_used,
                                                     cp = self.clear_polygon3(poly, tool_used,
-                                                                             self.app.defaults["gerber_circle_steps"],
+                                                                             self.grb_circle_steps,
                                                                              overlap=overlap, contour=contour,
                                                                              overlap=overlap, contour=contour,
                                                                              connect=connect,
                                                                              connect=connect,
                                                                              prog_plot=prog_plot)
                                                                              prog_plot=prog_plot)