Sfoglia il codice sorgente

- fixed a bug in SolderPaste Tool that did not allow to view the GCode

Marius Stanciu 6 anni fa
parent
commit
eb091f3990
5 ha cambiato i file con 159 aggiunte e 125 eliminazioni
  1. 3 0
      FlatCAMApp.py
  2. 5 0
      README.md
  3. 70 50
      flatcamGUI/PreferencesUI.py
  4. 1 2
      flatcamTools/ToolCalculators.py
  5. 80 73
      flatcamTools/ToolNonCopperClear.py

+ 3 - 0
FlatCAMApp.py

@@ -729,6 +729,7 @@ class App(QtCore.QObject):
             "tools_ncccutz": self.ui.tools_defaults_form.tools_ncc_group.cutz_entry,
             "tools_ncccutz": self.ui.tools_defaults_form.tools_ncc_group.cutz_entry,
             "tools_ncctipdia": self.ui.tools_defaults_form.tools_ncc_group.tipdia_entry,
             "tools_ncctipdia": self.ui.tools_defaults_form.tools_ncc_group.tipdia_entry,
             "tools_ncctipangle": self.ui.tools_defaults_form.tools_ncc_group.tipangle_entry,
             "tools_ncctipangle": self.ui.tools_defaults_form.tools_ncc_group.tipangle_entry,
+            "tools_nccnewdia": self.ui.tools_defaults_form.tools_ncc_group.newdia_entry,
 
 
             # CutOut Tool
             # CutOut Tool
             "tools_cutouttooldia": self.ui.tools_defaults_form.tools_cutout_group.cutout_tooldia_entry,
             "tools_cutouttooldia": self.ui.tools_defaults_form.tools_cutout_group.cutout_tooldia_entry,
@@ -1205,6 +1206,7 @@ class App(QtCore.QObject):
             "tools_ncccutz": -0.001968504,
             "tools_ncccutz": -0.001968504,
             "tools_ncctipdia": 0.00393701,
             "tools_ncctipdia": 0.00393701,
             "tools_ncctipangle": 30,
             "tools_ncctipangle": 30,
+            "tools_nccnewdia": 0.0393701,
 
 
             # Cutout Tool
             # Cutout Tool
             "tools_cutouttooldia": 0.0944882,
             "tools_cutouttooldia": 0.0944882,
@@ -5811,6 +5813,7 @@ class App(QtCore.QObject):
 
 
                       '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_nccnewdia",
                       "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",

+ 5 - 0
README.md

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
 
 
 =================================================
 =================================================
 
 
+3.11.2019
+
+- fixed the V-shape tool diameter calculation in NCC Tool
+- in NCC Tool made the new tool dia (circular type) a parameter in Preferences
+
 30.10.2019
 30.10.2019
 
 
 - converted SolderPaste Tool to usage of SpinBoxes; changed the SolderPaste Tool UI in Preferences too
 - converted SolderPaste Tool to usage of SpinBoxes; changed the SolderPaste Tool UI in Preferences too

+ 70 - 50
flatcamGUI/PreferencesUI.py

@@ -3712,6 +3712,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         super(ToolsNCCPrefGroupUI, self).__init__(self)
         super(ToolsNCCPrefGroupUI, self).__init__(self)
 
 
         self.setTitle(str(_("NCC Tool Options")))
         self.setTitle(str(_("NCC Tool Options")))
+        self.decimals = 4
 
 
         # ## Clear non-copper regions
         # ## Clear non-copper regions
         self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
         self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
@@ -3756,7 +3757,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         self.tipdialabel.setToolTip(
         self.tipdialabel.setToolTip(
             _("The tip diameter for V-Shape Tool"))
             _("The tip diameter for V-Shape Tool"))
         self.tipdia_entry = FCDoubleSpinner()
         self.tipdia_entry = FCDoubleSpinner()
-        self.tipdia_entry.set_precision(4)
+        self.tipdia_entry.set_precision(self.decimals)
         self.tipdia_entry.set_range(0, 1000)
         self.tipdia_entry.set_range(0, 1000)
         self.tipdia_entry.setSingleStep(0.1)
         self.tipdia_entry.setSingleStep(0.1)
 
 
@@ -3769,7 +3770,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
             _("The tip angle for V-Shape Tool.\n"
             _("The tip angle for V-Shape Tool.\n"
               "In degree."))
               "In degree."))
         self.tipangle_entry = FCDoubleSpinner()
         self.tipangle_entry = FCDoubleSpinner()
-        self.tipangle_entry.set_precision(4)
+        self.tipangle_entry.set_precision(self.decimals)
         self.tipangle_entry.set_range(-360, 360)
         self.tipangle_entry.set_range(-360, 360)
         self.tipangle_entry.setSingleStep(5)
         self.tipangle_entry.setSingleStep(5)
         self.tipangle_entry.setWrapping(True)
         self.tipangle_entry.setWrapping(True)
@@ -3777,6 +3778,37 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
         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)
 
 
+        # Cut Z entry
+        cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
+        cutzlabel.setToolTip(
+           _("Depth of cut into material. Negative value.\n"
+             "In FlatCAM units.")
+        )
+        self.cutz_entry = FCDoubleSpinner()
+        self.cutz_entry.set_precision(self.decimals)
+        self.cutz_entry.set_range(-9999.9999, -0.000001)
+        self.cutz_entry.setSingleStep(0.1)
+
+        self.cutz_entry.setToolTip(
+           _("Depth of cut into material. Negative value.\n"
+             "In FlatCAM units.")
+        )
+
+        grid0.addWidget(cutzlabel, 4, 0)
+        grid0.addWidget(self.cutz_entry, 4, 1)
+
+        # New Diameter
+        self.newdialabel = QtWidgets.QLabel('%s:' % _('New Tool Dia'))
+        self.newdialabel.setToolTip(
+            _("The new tool diameter (cut width) to add in the tool table."))
+        self.newdia_entry = FCDoubleSpinner()
+        self.newdia_entry.set_precision(self.decimals)
+        self.newdia_entry.set_range(0.0001, 9999.9999)
+        self.newdia_entry.setSingleStep(0.1)
+
+        grid0.addWidget(self.newdialabel, 5, 0)
+        grid0.addWidget(self.newdia_entry, 5, 1)
+
         # Milling Type Radio Button
         # Milling Type Radio Button
         self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
         self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
         self.milling_type_label.setToolTip(
         self.milling_type_label.setToolTip(
@@ -3793,8 +3825,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "- conventional / useful when there is no backlash compensation")
               "- conventional / useful when there is no backlash compensation")
         )
         )
 
 
-        grid0.addWidget(self.milling_type_label, 4, 0)
-        grid0.addWidget(self.milling_type_radio, 4, 1)
+        grid0.addWidget(self.milling_type_label, 6, 0)
+        grid0.addWidget(self.milling_type_radio, 6, 1)
 
 
         # Tool order Radio Button
         # Tool order Radio Button
         self.ncc_order_label = QtWidgets.QLabel('%s:' % _('Tool order'))
         self.ncc_order_label = QtWidgets.QLabel('%s:' % _('Tool order'))
@@ -3814,27 +3846,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
                                           "'Reverse' --> menas that the tools will ordered from big to small\n\n"
                                           "'Reverse' --> menas that the tools will ordered from big to small\n\n"
                                           "WARNING: using rest machining will automatically set the order\n"
                                           "WARNING: using rest machining will automatically set the order\n"
                                           "in reverse and disable this control."))
                                           "in reverse and disable this control."))
-        grid0.addWidget(self.ncc_order_label, 5, 0)
-        grid0.addWidget(self.ncc_order_radio, 5, 1)
-
-        # Cut Z entry
-        cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
-        cutzlabel.setToolTip(
-           _("Depth of cut into material. Negative value.\n"
-             "In FlatCAM units.")
-        )
-        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(
-           _("Depth of cut into material. Negative value.\n"
-             "In FlatCAM units.")
-        )
-
-        grid0.addWidget(cutzlabel, 6, 0)
-        grid0.addWidget(self.cutz_entry, 6, 1)
+        grid0.addWidget(self.ncc_order_label, 7, 0)
+        grid0.addWidget(self.ncc_order_radio, 7, 1)
 
 
         # Overlap Entry
         # Overlap Entry
         nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate'))
         nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate'))
@@ -3850,25 +3863,25 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
              "due of too many paths.")
              "due of too many paths.")
         )
         )
         self.ncc_overlap_entry = FCDoubleSpinner()
         self.ncc_overlap_entry = FCDoubleSpinner()
-        self.ncc_overlap_entry.set_precision(3)
+        self.ncc_overlap_entry.set_precision(self.decimals)
         self.ncc_overlap_entry.setWrapping(True)
         self.ncc_overlap_entry.setWrapping(True)
         self.ncc_overlap_entry.setRange(0.000, 0.999)
         self.ncc_overlap_entry.setRange(0.000, 0.999)
         self.ncc_overlap_entry.setSingleStep(0.1)
         self.ncc_overlap_entry.setSingleStep(0.1)
-        grid0.addWidget(nccoverlabel, 7, 0)
-        grid0.addWidget(self.ncc_overlap_entry, 7, 1)
+        grid0.addWidget(nccoverlabel, 8, 0)
+        grid0.addWidget(self.ncc_overlap_entry, 8, 1)
 
 
         # Margin entry
         # Margin entry
         nccmarginlabel = QtWidgets.QLabel('%s:' % _('Margin'))
         nccmarginlabel = QtWidgets.QLabel('%s:' % _('Margin'))
         nccmarginlabel.setToolTip(
         nccmarginlabel.setToolTip(
             _("Bounding box margin.")
             _("Bounding box margin.")
         )
         )
-        grid0.addWidget(nccmarginlabel, 8, 0)
         self.ncc_margin_entry = FCDoubleSpinner()
         self.ncc_margin_entry = FCDoubleSpinner()
-        self.ncc_margin_entry.set_precision(4)
+        self.ncc_margin_entry.set_precision(self.decimals)
         self.ncc_margin_entry.set_range(-10000, 10000)
         self.ncc_margin_entry.set_range(-10000, 10000)
         self.ncc_margin_entry.setSingleStep(0.1)
         self.ncc_margin_entry.setSingleStep(0.1)
 
 
-        grid0.addWidget(self.ncc_margin_entry, 8, 1)
+        grid0.addWidget(nccmarginlabel, 9, 0)
+        grid0.addWidget(self.ncc_margin_entry, 9, 1)
 
 
         # Method
         # Method
         methodlabel = QtWidgets.QLabel('%s:' % _('Method'))
         methodlabel = QtWidgets.QLabel('%s:' % _('Method'))
@@ -3878,13 +3891,15 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "<B>Seed-based</B>: Outwards from seed.<BR>"
               "<B>Seed-based</B>: Outwards from seed.<BR>"
               "<B>Line-based</B>: Parallel lines.")
               "<B>Line-based</B>: Parallel lines.")
         )
         )
-        grid0.addWidget(methodlabel, 9, 0)
+
         self.ncc_method_radio = RadioSet([
         self.ncc_method_radio = RadioSet([
             {"label": _("Standard"), "value": "standard"},
             {"label": _("Standard"), "value": "standard"},
             {"label": _("Seed-based"), "value": "seed"},
             {"label": _("Seed-based"), "value": "seed"},
             {"label": _("Straight lines"), "value": "lines"}
             {"label": _("Straight lines"), "value": "lines"}
         ], orientation='vertical', stretch=False)
         ], orientation='vertical', stretch=False)
-        grid0.addWidget(self.ncc_method_radio, 9, 1)
+
+        grid0.addWidget(methodlabel, 10, 0)
+        grid0.addWidget(self.ncc_method_radio, 10, 1)
 
 
         # Connect lines
         # Connect lines
         pathconnectlabel = QtWidgets.QLabel('%s:' % _("Connect"))
         pathconnectlabel = QtWidgets.QLabel('%s:' % _("Connect"))
@@ -3892,9 +3907,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
             _("Draw lines between resulting\n"
             _("Draw lines between resulting\n"
               "segments to minimize tool lifts.")
               "segments to minimize tool lifts.")
         )
         )
-        grid0.addWidget(pathconnectlabel, 10, 0)
         self.ncc_connect_cb = FCCheckBox()
         self.ncc_connect_cb = FCCheckBox()
-        grid0.addWidget(self.ncc_connect_cb, 10, 1)
+
+        grid0.addWidget(pathconnectlabel, 11, 0)
+        grid0.addWidget(self.ncc_connect_cb, 11, 1)
 
 
         # Contour Checkbox
         # Contour Checkbox
         contourlabel = QtWidgets.QLabel('%s:' % _("Contour"))
         contourlabel = QtWidgets.QLabel('%s:' % _("Contour"))
@@ -3902,9 +3918,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
            _("Cut around the perimeter of the polygon\n"
            _("Cut around the perimeter of the polygon\n"
              "to trim rough edges.")
              "to trim rough edges.")
         )
         )
-        grid0.addWidget(contourlabel, 11, 0)
         self.ncc_contour_cb = FCCheckBox()
         self.ncc_contour_cb = FCCheckBox()
-        grid0.addWidget(self.ncc_contour_cb, 11, 1)
+
+        grid0.addWidget(contourlabel, 12, 0)
+        grid0.addWidget(self.ncc_contour_cb, 12, 1)
 
 
         # Rest machining CheckBox
         # Rest machining CheckBox
         restlabel = QtWidgets.QLabel('%s:' % _("Rest M."))
         restlabel = QtWidgets.QLabel('%s:' % _("Rest M."))
@@ -3917,9 +3934,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "no more copper to clear or there are no more tools.\n"
               "no more copper to clear or there are no more tools.\n"
               "If not checked, use the standard algorithm.")
               "If not checked, use the standard algorithm.")
         )
         )
-        grid0.addWidget(restlabel, 12, 0)
         self.ncc_rest_cb = FCCheckBox()
         self.ncc_rest_cb = FCCheckBox()
-        grid0.addWidget(self.ncc_rest_cb, 12, 1)
+
+        grid0.addWidget(restlabel, 13, 0)
+        grid0.addWidget(self.ncc_rest_cb, 13, 1)
 
 
         # ## NCC Offset choice
         # ## NCC Offset choice
         self.ncc_offset_choice_label = QtWidgets.QLabel('%s:' % _("Offset"))
         self.ncc_offset_choice_label = QtWidgets.QLabel('%s:' % _("Offset"))
@@ -3929,9 +3947,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "from the copper features.\n"
               "from the copper features.\n"
               "The value can be between 0 and 10 FlatCAM units.")
               "The value can be between 0 and 10 FlatCAM units.")
         )
         )
-        grid0.addWidget(self.ncc_offset_choice_label, 13, 0)
         self.ncc_choice_offset_cb = FCCheckBox()
         self.ncc_choice_offset_cb = FCCheckBox()
-        grid0.addWidget(self.ncc_choice_offset_cb, 13, 1)
+
+        grid0.addWidget(self.ncc_offset_choice_label, 14, 0)
+        grid0.addWidget(self.ncc_choice_offset_cb, 14, 1)
 
 
         # ## NCC Offset value
         # ## NCC Offset value
         self.ncc_offset_label = QtWidgets.QLabel('%s:' % _("Offset value"))
         self.ncc_offset_label = QtWidgets.QLabel('%s:' % _("Offset value"))
@@ -3939,16 +3958,16 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
             _("If used, it will add an offset to the copper features.\n"
             _("If used, it will add an offset to the copper features.\n"
               "The copper clearing will finish to a distance\n"
               "The copper clearing will finish to a distance\n"
               "from the copper features.\n"
               "from the copper features.\n"
-              "The value can be between 0 and 10 FlatCAM units.")
+              "The value can be between 0.0 and 9999.9 FlatCAM units.")
         )
         )
-        grid0.addWidget(self.ncc_offset_label, 14, 0)
         self.ncc_offset_spinner = FCDoubleSpinner()
         self.ncc_offset_spinner = FCDoubleSpinner()
-        self.ncc_offset_spinner.set_range(0.00, 10.00)
-        self.ncc_offset_spinner.set_precision(4)
+        self.ncc_offset_spinner.set_range(0.00, 9999.9999)
+        self.ncc_offset_spinner.set_precision(self.decimals)
         self.ncc_offset_spinner.setWrapping(True)
         self.ncc_offset_spinner.setWrapping(True)
         self.ncc_offset_spinner.setSingleStep(0.1)
         self.ncc_offset_spinner.setSingleStep(0.1)
 
 
-        grid0.addWidget(self.ncc_offset_spinner, 14, 1)
+        grid0.addWidget(self.ncc_offset_label, 15, 0)
+        grid0.addWidget(self.ncc_offset_spinner, 15, 1)
 
 
         # ## Reference
         # ## Reference
         self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'},
         self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'},
@@ -3963,8 +3982,9 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "- 'Reference Object' -  will do non copper clearing within the area\n"
               "- 'Reference Object' -  will do non copper clearing within the area\n"
               "specified by another object.")
               "specified by another object.")
         )
         )
-        grid0.addWidget(reference_label, 15, 0)
-        grid0.addWidget(self.reference_radio, 15, 1)
+
+        grid0.addWidget(reference_label, 16, 0)
+        grid0.addWidget(self.reference_radio, 16, 1)
 
 
         # ## Plotting type
         # ## Plotting type
         self.ncc_plotting_radio = RadioSet([{'label': _('Normal'), 'value': 'normal'},
         self.ncc_plotting_radio = RadioSet([{'label': _('Normal'), 'value': 'normal'},
@@ -3974,8 +3994,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
             _("- 'Normal' -  normal plotting, done at the end of the NCC job\n"
             _("- 'Normal' -  normal plotting, done at the end of the NCC job\n"
               "- 'Progressive' - after each shape is generated it will be plotted.")
               "- 'Progressive' - after each shape is generated it will be plotted.")
         )
         )
-        grid0.addWidget(plotting_label, 16, 0)
-        grid0.addWidget(self.ncc_plotting_radio, 16, 1)
+        grid0.addWidget(plotting_label, 17, 0)
+        grid0.addWidget(self.ncc_plotting_radio, 17, 1)
 
 
         self.layout.addStretch()
         self.layout.addStretch()
 
 

+ 1 - 2
flatcamTools/ToolCalculators.py

@@ -325,8 +325,7 @@ class ToolCalculator(FlatCAMTool):
 
 
         tip_diameter = float(self.tipDia_entry.get_value())
         tip_diameter = float(self.tipDia_entry.get_value())
 
 
-        half_tip_angle = float(self.tipAngle_entry.get_value())
-        half_tip_angle /= 2
+        half_tip_angle = float(self.tipAngle_entry.get_value()) / 2.0
 
 
         cut_depth = float(self.cutDepth_entry.get_value())
         cut_depth = float(self.cutDepth_entry.get_value())
         cut_depth = -cut_depth if cut_depth < 0 else cut_depth
         cut_depth = -cut_depth if cut_depth < 0 else cut_depth

+ 80 - 73
flatcamTools/ToolNonCopperClear.py

@@ -153,8 +153,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
               "If it's not successful then the non-copper clearing will fail, too.\n"
               "If it's not successful then the non-copper clearing will fail, too.\n"
               "- Clear -> the regular non-copper clearing."))
               "- Clear -> the regular non-copper clearing."))
 
 
-        form = QtWidgets.QFormLayout()
-        self.tools_box.addLayout(form)
+        grid1 = QtWidgets.QGridLayout()
+        self.tools_box.addLayout(grid1)
+        grid1.setColumnStretch(0, 0)
+        grid1.setColumnStretch(1, 1)
 
 
         # Milling Type Radio Button
         # Milling Type Radio Button
         self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
         self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
@@ -172,6 +174,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
               "- conventional / useful when there is no backlash compensation")
               "- conventional / useful when there is no backlash compensation")
         )
         )
 
 
+        grid1.addWidget(self.milling_type_label, 0, 0)
+        grid1.addWidget(self.milling_type_radio, 0, 1)
+
         # Tool order
         # Tool order
         self.ncc_order_label = QtWidgets.QLabel('<b>%s:</b>' % _('Tool order'))
         self.ncc_order_label = QtWidgets.QLabel('<b>%s:</b>' % _('Tool order'))
         self.ncc_order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n"
         self.ncc_order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n"
@@ -191,9 +196,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
                                           "WARNING: using rest machining will automatically set the order\n"
                                           "WARNING: using rest machining will automatically set the order\n"
                                           "in reverse and disable this control."))
                                           "in reverse and disable this control."))
 
 
-        form.addRow(self.milling_type_label, self.milling_type_radio)
-        form.addRow(self.ncc_order_label, self.ncc_order_radio)
-        form.addRow(QtWidgets.QLabel(''))
+        grid1.addWidget(self.ncc_order_label, 1, 0)
+        grid1.addWidget(self.ncc_order_radio, 1, 1)
+        grid1.addWidget(QtWidgets.QLabel(''), 2, 0)
 
 
         self.milling_type_label.hide()
         self.milling_type_label.hide()
         self.milling_type_radio.hide()
         self.milling_type_radio.hide()
@@ -202,7 +207,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
         # ############### Tool selection ##############################
         # ############### Tool selection ##############################
         # #############################################################
         # #############################################################
         self.tool_sel_label = QtWidgets.QLabel('<b>%s</b>' % _("Tool Selection"))
         self.tool_sel_label = QtWidgets.QLabel('<b>%s</b>' % _("Tool Selection"))
-        form.addRow(self.tool_sel_label)
+        grid1.addWidget(self.tool_sel_label, 3, 0, 1, 2)
 
 
         # Tool Type Radio Button
         # Tool Type Radio Button
         self.tool_type_label = QtWidgets.QLabel('%s:' % _('Tool Type'))
         self.tool_type_label = QtWidgets.QLabel('%s:' % _('Tool Type'))
@@ -219,17 +224,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
               "- 'V-shape'\n"
               "- 'V-shape'\n"
               "- Circular")
               "- Circular")
         )
         )
-        form.addRow(self.tool_type_label, self.tool_type_radio)
-
-        # ### Add a new Tool ####
-        self.addtool_entry_lbl = QtWidgets.QLabel('<b>%s:</b>' % _('Tool Dia'))
-        self.addtool_entry_lbl.setToolTip(
-            _("Diameter for the new tool to add in the Tool Table")
-        )
-        self.addtool_entry = FCDoubleSpinner()
-        self.addtool_entry.set_precision(self.decimals)
-
-        form.addRow(self.addtool_entry_lbl, self.addtool_entry)
+        grid1.addWidget(self.tool_type_label, 4, 0)
+        grid1.addWidget(self.tool_type_radio, 4, 1)
 
 
         # Tip Dia
         # Tip Dia
         self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
         self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
@@ -239,7 +235,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.tipdia_entry.set_precision(self.decimals)
         self.tipdia_entry.set_precision(self.decimals)
         self.tipdia_entry.setSingleStep(0.1)
         self.tipdia_entry.setSingleStep(0.1)
 
 
-        form.addRow(self.tipdialabel, self.tipdia_entry)
+        grid1.addWidget(self.tipdialabel, 5, 0)
+        grid1.addWidget(self.tipdia_entry, 5, 1)
 
 
         # Tip Angle
         # Tip Angle
         self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
         self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
@@ -250,7 +247,38 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.tipangle_entry.set_precision(self.decimals)
         self.tipangle_entry.set_precision(self.decimals)
         self.tipangle_entry.setSingleStep(5)
         self.tipangle_entry.setSingleStep(5)
 
 
-        form.addRow(self.tipanglelabel, self.tipangle_entry)
+        grid1.addWidget(self.tipanglelabel, 6, 0)
+        grid1.addWidget(self.tipangle_entry, 6 , 1)
+
+        # Cut Z entry
+        cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
+        cutzlabel.setToolTip(
+           _("Depth of cut into material. Negative value.\n"
+             "In FlatCAM units.")
+        )
+        self.cutz_entry = FCDoubleSpinner()
+        self.cutz_entry.set_precision(self.decimals)
+        self.cutz_entry.set_range(-99999, -0.00000000000001)
+
+        self.cutz_entry.setToolTip(
+           _("Depth of cut into material. Negative value.\n"
+             "In FlatCAM units.")
+        )
+        grid1.addWidget(cutzlabel, 7, 0)
+        grid1.addWidget(self.cutz_entry, 7, 1)
+
+        # ### Tool Diameter ####
+        self.addtool_entry_lbl = QtWidgets.QLabel('<b>%s:</b>' % _('Tool Dia'))
+        self.addtool_entry_lbl.setToolTip(
+            _("Diameter for the new tool to add in the Tool Table.\n"
+              "If the tool is V-shape type then this value is automatically\n"
+              "calculated from the other parameters.")
+        )
+        self.addtool_entry = FCDoubleSpinner()
+        self.addtool_entry.set_precision(self.decimals)
+
+        grid1.addWidget(self.addtool_entry_lbl, 8, 0)
+        grid1.addWidget(self.addtool_entry, 8, 1)
 
 
         grid2 = QtWidgets.QGridLayout()
         grid2 = QtWidgets.QGridLayout()
         self.tools_box.addLayout(grid2)
         self.tools_box.addLayout(grid2)
@@ -287,23 +315,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
         e_lab_1 = QtWidgets.QLabel('<b>%s:</b>' % _("Parameters"))
         e_lab_1 = QtWidgets.QLabel('<b>%s:</b>' % _("Parameters"))
         grid3.addWidget(e_lab_1, 0, 0)
         grid3.addWidget(e_lab_1, 0, 0)
 
 
-        # Cut Z entry
-        cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
-        cutzlabel.setToolTip(
-           _("Depth of cut into material. Negative value.\n"
-             "In FlatCAM units.")
-        )
-        self.cutz_entry = FCDoubleSpinner()
-        self.cutz_entry.set_precision(self.decimals)
-        self.cutz_entry.set_range(-99999, -0.00000000000001)
-
-        self.cutz_entry.setToolTip(
-           _("Depth of cut into material. Negative value.\n"
-             "In FlatCAM units.")
-        )
-        grid3.addWidget(cutzlabel, 1, 0)
-        grid3.addWidget(self.cutz_entry, 1, 1)
-
         # Overlap Entry
         # Overlap Entry
         nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate'))
         nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate'))
         nccoverlabel.setToolTip(
         nccoverlabel.setToolTip(
@@ -535,6 +546,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.deltool_btn.clicked.connect(self.on_tool_delete)
         self.deltool_btn.clicked.connect(self.on_tool_delete)
         self.generate_ncc_button.clicked.connect(self.on_ncc_click)
         self.generate_ncc_button.clicked.connect(self.on_ncc_click)
 
 
+        self.tipdia_entry.returnPressed.connect(self.on_calculate_tooldia)
+        self.tipangle_entry.returnPressed.connect(self.on_calculate_tooldia)
+        self.cutz_entry.returnPressed.connect(self.on_calculate_tooldia)
+
         self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type)
         self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type)
         self.reference_radio.group_toggle_fn = self.on_toggle_reference
         self.reference_radio.group_toggle_fn = self.on_toggle_reference
         self.ncc_choice_offset_cb.stateChanged.connect(self.on_offset_choice)
         self.ncc_choice_offset_cb.stateChanged.connect(self.on_offset_choice)
@@ -551,7 +566,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
     def on_add_tool_by_key(self):
     def on_add_tool_by_key(self):
         tool_add_popup = FCInputDialog(title='%s...' % _("New Tool"),
         tool_add_popup = FCInputDialog(title='%s...' % _("New Tool"),
                                        text='%s:' % _('Enter a Tool Diameter'),
                                        text='%s:' % _('Enter a Tool Diameter'),
-                                       min=0.0000, max=99.9999, decimals=4)
+                                       min=0.0001, max=9999.9999, decimals=self.decimals)
         tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
         tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
 
 
         val, ok = tool_add_popup.get_value()
         val, ok = tool_add_popup.get_value()
@@ -624,6 +639,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
         self.tool_type_radio.set_value(self.app.defaults["tools_ncctool_type"])
         self.tool_type_radio.set_value(self.app.defaults["tools_ncctool_type"])
         self.tipdia_entry.set_value(self.app.defaults["tools_ncctipdia"])
         self.tipdia_entry.set_value(self.app.defaults["tools_ncctipdia"])
         self.tipangle_entry.set_value(self.app.defaults["tools_ncctipangle"])
         self.tipangle_entry.set_value(self.app.defaults["tools_ncctipangle"])
+        self.addtool_entry.set_value(self.app.defaults["tools_nccnewdia"])
 
 
         self.on_tool_type(val=self.tool_type_radio.get_value())
         self.on_tool_type(val=self.tool_type_radio.get_value())
 
 
@@ -707,11 +723,6 @@ class NonCopperClear(FlatCAMTool, Gerber):
         # updated units
         # updated units
         self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
         self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
 
 
-        if self.units == "IN":
-            self.addtool_entry.set_value(0.039)
-        else:
-            self.addtool_entry.set_value(1)
-
         sorted_tools = []
         sorted_tools = []
         for k, v in self.ncc_tools.items():
         for k, v in self.ncc_tools.items():
             if self.units == "IN":
             if self.units == "IN":
@@ -905,54 +916,50 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
 
     def on_tool_type(self, val):
     def on_tool_type(self, val):
         if val == 'V':
         if val == 'V':
-            self.addtool_entry_lbl.hide()
-            self.addtool_entry.hide()
+            self.addtool_entry_lbl.setDisabled(True)
+            self.addtool_entry.setDisabled(True)
             self.tipdialabel.show()
             self.tipdialabel.show()
             self.tipdia_entry.show()
             self.tipdia_entry.show()
             self.tipanglelabel.show()
             self.tipanglelabel.show()
             self.tipangle_entry.show()
             self.tipangle_entry.show()
         else:
         else:
-            self.addtool_entry_lbl.show()
-            self.addtool_entry.show()
+            self.addtool_entry_lbl.setDisabled(False)
+            self.addtool_entry.setDisabled(False)
             self.tipdialabel.hide()
             self.tipdialabel.hide()
             self.tipdia_entry.hide()
             self.tipdia_entry.hide()
             self.tipanglelabel.hide()
             self.tipanglelabel.hide()
             self.tipangle_entry.hide()
             self.tipangle_entry.hide()
 
 
-    def on_tool_add(self, dia=None, muted=None):
+    def on_calculate_tooldia(self):
+        if self.tool_type_radio.get_value() == 'V':
+            tip_dia = float(self.tipdia_entry.get_value())
+            tip_angle = float(self.tipangle_entry.get_value()) / 2.0
+            cut_z = float(self.cutz_entry.get_value())
+            cut_z = -cut_z if cut_z < 0 else cut_z
 
 
-        self.ui_disconnect()
+            # calculated tool diameter so the cut_z parameter is obeyed
+            tool_dia = tip_dia + (2 * cut_z * math.tan(math.radians(tip_angle)))
 
 
+            # update the default_data so it is used in the ncc_tools dict
+            self.default_data.update({
+                "vtipdia": tip_dia,
+                "vtipangle": (tip_angle * 2),
+            })
+
+            self.addtool_entry.set_value(tool_dia)
+
+            return tool_dia
+        else:
+            return float(self.addtool_entry.get_value())
+
+    def on_tool_add(self, dia=None, muted=None):
+        self.ui_disconnect()
         self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
         self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
 
 
         if dia:
         if dia:
             tool_dia = dia
             tool_dia = dia
         else:
         else:
-            if self.tool_type_radio.get_value() == 'V':
-
-                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())
-
-                # calculated tool diameter so the cut_z parameter is obeyed
-                tool_dia = tip_dia + 2 * cut_z * math.tan(math.radians(tip_angle))
-
-                # update the default_data so it is used in the ncc_tools dict
-                self.default_data.update({
-                    "vtipdia": tip_dia,
-                    "vtipangle": (tip_angle * 2),
-                })
-            else:
-                try:
-                    tool_dia = float(self.addtool_entry.get_value())
-                except ValueError:
-                    # try to convert comma to decimal point. if it's still not working error message and return
-                    try:
-                        tool_dia = float(self.addtool_entry.get_value().replace(',', '.'))
-                    except ValueError:
-                        self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
-                        return
-
+            tool_dia = self.on_calculate_tooldia()
             if tool_dia is None:
             if tool_dia is None:
                 self.build_ui()
                 self.build_ui()
                 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."))