From b1547bf6b980103e6bcafdb56601edc51a07179d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 3 Dec 2019 23:44:53 +0200 Subject: [PATCH] - added some geometry parameters in Cutout Tool as a convenience, to be passed to the generated Geometry objects --- FlatCAMApp.py | 6 +++ README.md | 1 + flatcamGUI/PreferencesUI.py | 75 ++++++++++++++++++++++++++++++------- flatcamTools/ToolCutOut.py | 67 ++++++++++++++++++++++----------- 4 files changed, 113 insertions(+), 36 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index b06e9f8a..a1d36c78 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -732,6 +732,9 @@ class App(QtCore.QObject): "tools_cutouttooldia": 2.4, "tools_cutoutkind": "single", "tools_cutoutmargin": 0.1, + "tools_cutout_z": -1.8, + "tools_cutout_depthperpass": 0.6, + "tools_cutout_mdepth": True, "tools_cutoutgapsize": 4, "tools_gaps_ff": "4", "tools_cutout_convexshape": False, @@ -1293,6 +1296,9 @@ class App(QtCore.QObject): "tools_cutouttooldia": self.ui.tools_defaults_form.tools_cutout_group.cutout_tooldia_entry, "tools_cutoutkind": self.ui.tools_defaults_form.tools_cutout_group.obj_kind_combo, "tools_cutoutmargin": self.ui.tools_defaults_form.tools_cutout_group.cutout_margin_entry, + "tools_cutout_z": self.ui.tools_defaults_form.tools_cutout_group.cutz_entry, + "tools_cutout_depthperpass": self.ui.tools_defaults_form.tools_cutout_group.maxdepth_entry, + "tools_cutout_mdepth": self.ui.tools_defaults_form.tools_cutout_group.mpass_cb, "tools_cutoutgapsize": self.ui.tools_defaults_form.tools_cutout_group.cutout_gap_entry, "tools_gaps_ff": self.ui.tools_defaults_form.tools_cutout_group.gaps_combo, "tools_cutout_convexshape": self.ui.tools_defaults_form.tools_cutout_group.convex_box, diff --git a/README.md b/README.md index 044850e7..2bee82fa 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing. - various small fixes - fix for toggle grid lines updating canvas only after moving the mouse (hack, actually) - some changes in the UI layout in Cutout Tool +- added some geometry parameters in Cutout Tool as a convenience, to be passed to the generated Geometry objects 2.12.2019 diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index 13596c97..00aa2b6e 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -4187,7 +4187,7 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): self.setTitle(str(_("Cutout Tool Options"))) self.decimals = 4 - # ## Board cuttout + # ## Board cutout self.board_cutout_label = QtWidgets.QLabel("%s:" % _("Parameters")) self.board_cutout_label.setToolTip( _("Create toolpaths to cut around\n" @@ -4199,33 +4199,77 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): grid0 = QtWidgets.QGridLayout() self.layout.addLayout(grid0) - tdclabel = QtWidgets.QLabel('%s:' % _('Tool dia')) + tdclabel = QtWidgets.QLabel('%s:' % _('Tool Diameter')) tdclabel.setToolTip( _("Diameter of the tool used to cutout\n" "the PCB shape out of the surrounding material.") ) - grid0.addWidget(tdclabel, 0, 0) + self.cutout_tooldia_entry = FCDoubleSpinner() self.cutout_tooldia_entry.set_range(0.000001, 9999.9999) self.cutout_tooldia_entry.set_precision(self.decimals) self.cutout_tooldia_entry.setSingleStep(0.1) + grid0.addWidget(tdclabel, 0, 0) grid0.addWidget(self.cutout_tooldia_entry, 0, 1) + # Cut Z + cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) + cutzlabel.setToolTip( + _( + "Cutting depth (negative)\n" + "below the copper surface." + ) + ) + self.cutz_entry = FCDoubleSpinner() + self.cutz_entry.set_precision(self.decimals) + + if machinist_setting == 0: + self.cutz_entry.setRange(-9999.9999, -0.00001) + else: + self.cutz_entry.setRange(-9999.9999, 9999.9999) + + self.cutz_entry.setSingleStep(0.1) + + grid0.addWidget(cutzlabel, 1, 0) + grid0.addWidget(self.cutz_entry, 1, 1) + + # Multi-pass + self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth")) + self.mpass_cb.setToolTip( + _( + "Use multiple passes to limit\n" + "the cut depth in each pass. Will\n" + "cut multiple times until Cut Z is\n" + "reached." + ) + ) + + self.maxdepth_entry = FCDoubleSpinner() + self.maxdepth_entry.set_precision(self.decimals) + self.maxdepth_entry.setRange(0, 9999.9999) + self.maxdepth_entry.setSingleStep(0.1) + + self.maxdepth_entry.setToolTip(_("Depth of each pass (positive).")) + + grid0.addWidget(self.mpass_cb, 2, 0) + grid0.addWidget(self.maxdepth_entry, 2, 1) + # Object kind - kindlabel = QtWidgets.QLabel('%s:' % _('Obj kind')) + kindlabel = QtWidgets.QLabel('%s:' % _('Object kind')) kindlabel.setToolTip( _("Choice of what kind the object we want to cutout is.
" "- Single: contain a single PCB Gerber outline object.
" "- Panel: a panel PCB Gerber object, which is made\n" "out of many individual PCB outlines.") ) - grid0.addWidget(kindlabel, 1, 0) + self.obj_kind_combo = RadioSet([ {"label": _("Single"), "value": "single"}, {"label": _("Panel"), "value": "panel"}, ]) - grid0.addWidget(self.obj_kind_combo, 1, 1) + grid0.addWidget(kindlabel, 3, 0) + grid0.addWidget(self.obj_kind_combo, 3, 1) marginlabel = QtWidgets.QLabel('%s:' % _('Margin')) marginlabel.setToolTip( @@ -4233,13 +4277,14 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): "will make the cutout of the PCB further from\n" "the actual PCB border") ) - grid0.addWidget(marginlabel, 2, 0) + self.cutout_margin_entry = FCDoubleSpinner() self.cutout_margin_entry.set_range(-9999.9999, 9999.9999) self.cutout_margin_entry.set_precision(self.decimals) self.cutout_margin_entry.setSingleStep(0.1) - grid0.addWidget(self.cutout_margin_entry, 2, 1) + grid0.addWidget(marginlabel, 4, 0) + grid0.addWidget(self.cutout_margin_entry, 4, 1) gaplabel = QtWidgets.QLabel('%s:' % _('Gap size')) gaplabel.setToolTip( @@ -4248,13 +4293,14 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): "the surrounding material (the one \n" "from which the PCB is cutout).") ) - grid0.addWidget(gaplabel, 3, 0) + self.cutout_gap_entry = FCDoubleSpinner() self.cutout_gap_entry.set_range(0.000001, 9999.9999) self.cutout_gap_entry.set_precision(self.decimals) self.cutout_gap_entry.setSingleStep(0.1) - grid0.addWidget(self.cutout_gap_entry, 3, 1) + grid0.addWidget(gaplabel, 5, 0) + grid0.addWidget(self.cutout_gap_entry, 5, 1) gaps_label = QtWidgets.QLabel('%s:' % _('Gaps')) gaps_label.setToolTip( @@ -4269,9 +4315,10 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): "- 2tb - 2*top + 2*bottom\n" "- 8 - 2*left + 2*right +2*top + 2*bottom") ) - grid0.addWidget(gaps_label, 4, 0) + self.gaps_combo = FCComboBox() - grid0.addWidget(self.gaps_combo, 4, 1) + grid0.addWidget(gaps_label, 6, 0) + grid0.addWidget(self.gaps_combo, 6, 1) gaps_items = ['None', 'LR', 'TB', '4', '2LR', '2TB', '8'] for it in gaps_items: @@ -4285,8 +4332,8 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): _("Create a convex shape surrounding the entire PCB.\n" "Used only if the source object type is Gerber.") ) - grid0.addWidget(self.convex_box_label, 5, 0) - grid0.addWidget(self.convex_box, 5, 1) + grid0.addWidget(self.convex_box_label, 7, 0) + grid0.addWidget(self.convex_box, 7, 1) self.layout.addStretch() diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index a3c8af6f..9d7be5b2 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -77,7 +77,7 @@ class CutOut(FlatCAMTool): # self.type_obj_combo.setItemIcon(1, QtGui.QIcon("share/drill16.png")) self.type_obj_combo.setItemIcon(2, QtGui.QIcon("share/geometry16.png")) - self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Obj Type")) + self.type_obj_combo_label = QtWidgets.QLabel('%s:' % _("Object Type")) self.type_obj_combo_label.setToolTip( _("Specify the type of object to be cutout.\n" "It can be of type: Gerber or Geometry.\n" @@ -88,21 +88,20 @@ class CutOut(FlatCAMTool): grid0.addWidget(self.type_obj_combo_label, 0, 0) grid0.addWidget(self.type_obj_combo, 0, 1) + self.object_label = QtWidgets.QLabel('%s:' % _("Object to be cutout")) + self.object_label.setToolTip('%s.' % _("Object to be cutout")) + # Object to be cutout self.obj_combo = QtWidgets.QComboBox() self.obj_combo.setModel(self.app.collection) self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.obj_combo.setCurrentIndex(1) - self.object_label = QtWidgets.QLabel('%s:' % _("Object")) - self.object_label.setToolTip( - _("Object to be cutout. ") - ) - grid0.addWidget(self.object_label, 1, 0) - grid0.addWidget(self.obj_combo, 1, 1) + grid0.addWidget(self.object_label, 1, 0, 1, 2) + grid0.addWidget(self.obj_combo, 2, 0, 1, 2) # Object kind - self.kindlabel = QtWidgets.QLabel('%s:' % _('Obj kind')) + self.kindlabel = QtWidgets.QLabel('%s:' % _('Object kind')) self.kindlabel.setToolTip( _("Choice of what kind the object we want to cutout is.
" "- Single: contain a single PCB Gerber outline object.
" @@ -113,20 +112,21 @@ class CutOut(FlatCAMTool): {"label": _("Single"), "value": "single"}, {"label": _("Panel"), "value": "panel"}, ]) - grid0.addWidget(self.kindlabel, 2, 0) - grid0.addWidget(self.obj_kind_combo, 2, 1) + grid0.addWidget(self.kindlabel, 3, 0) + grid0.addWidget(self.obj_kind_combo, 3, 1) # Tool Diameter self.dia = FCDoubleSpinner() self.dia.set_precision(self.decimals) + self.dia.set_range(0.0000, 9999.9999) - self.dia_label = QtWidgets.QLabel('%s:' % _("Tool dia")) + self.dia_label = QtWidgets.QLabel('%s:' % _("Tool Diameter")) self.dia_label.setToolTip( _("Diameter of the tool used to cutout\n" "the PCB shape out of the surrounding material.") ) - grid0.addWidget(self.dia_label, 3, 0) - grid0.addWidget(self.dia, 3, 1) + grid0.addWidget(self.dia_label, 4, 0) + grid0.addWidget(self.dia, 4, 1) # Cut Z cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) @@ -146,8 +146,8 @@ class CutOut(FlatCAMTool): self.cutz_entry.setSingleStep(0.1) - grid0.addWidget(cutzlabel, 4, 0) - grid0.addWidget(self.cutz_entry, 4, 1) + grid0.addWidget(cutzlabel, 5, 0) + grid0.addWidget(self.cutz_entry, 5, 1) # Multi-pass self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth")) @@ -172,8 +172,8 @@ class CutOut(FlatCAMTool): ) self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry]) - grid0.addWidget(self.mpass_cb, 5, 0) - grid0.addWidget(self.maxdepth_entry, 5, 1) + grid0.addWidget(self.mpass_cb, 6, 0) + grid0.addWidget(self.maxdepth_entry, 6, 1) # Margin self.margin = FCDoubleSpinner() @@ -185,8 +185,8 @@ class CutOut(FlatCAMTool): "will make the cutout of the PCB further from\n" "the actual PCB border") ) - grid0.addWidget(self.margin_label, 6, 0) - grid0.addWidget(self.margin, 6, 1) + grid0.addWidget(self.margin_label, 7, 0) + grid0.addWidget(self.margin, 7, 1) # Gapsize self.gapsize = FCDoubleSpinner() @@ -199,8 +199,8 @@ class CutOut(FlatCAMTool): "the surrounding material (the one \n" "from which the PCB is cutout).") ) - grid0.addWidget(self.gapsize_label, 7, 0) - grid0.addWidget(self.gapsize, 7, 1) + grid0.addWidget(self.gapsize_label, 8, 0) + grid0.addWidget(self.gapsize, 8, 1) # How gaps wil be rendered: # lr - left + right @@ -217,7 +217,12 @@ class CutOut(FlatCAMTool): _("Create a convex shape surrounding the entire PCB.\n" "Used only if the source object type is Gerber.") ) - grid0.addWidget(self.convex_box, 8, 0, 1, 2) + grid0.addWidget(self.convex_box, 9, 0, 1, 2) + + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + grid0.addWidget(separator_line, 10, 0, 1, 2) # Title2 title_param_label = QtWidgets.QLabel("%s" % _('A. Automatic Bridge Gaps')) @@ -283,6 +288,11 @@ class CutOut(FlatCAMTool): """) self.layout.addWidget(self.rect_cutout_object_btn) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.layout.addWidget(separator_line) + # Title5 title_manual_label = QtWidgets.QLabel("%s" % _('B. Manual Bridge Gaps')) title_manual_label.setToolTip( @@ -418,6 +428,10 @@ class CutOut(FlatCAMTool): self.dia.set_value(float(self.app.defaults["tools_cutouttooldia"])) self.obj_kind_combo.set_value(self.app.defaults["tools_cutoutkind"]) self.margin.set_value(float(self.app.defaults["tools_cutoutmargin"])) + self.cutz_entry.set_value(float(self.app.defaults["tools_cutout_z"])) + self.mpass_cb.set_value(float(self.app.defaults["tools_cutout_mdepth"])) + self.maxdepth_entry.set_value(float(self.app.defaults["tools_cutout_depthperpass"])) + self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"])) self.gaps.set_value(self.app.defaults["tools_gaps_ff"]) self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape']) @@ -584,6 +598,9 @@ class CutOut(FlatCAMTool): geo_obj.options['xmax'] = xmax geo_obj.options['ymax'] = ymax geo_obj.options['cnctooldia'] = str(dia) + geo_obj.options['cutz'] = self.cutz_entry.get_value() + geo_obj.options['multidepth'] = self.mpass_cb.get_value() + geo_obj.options['depthperpass'] = self.maxdepth_entry.get_value() outname = cutout_obj.options["name"] + "_cutout" self.app.new_object('geometry', outname, geo_init) @@ -739,6 +756,9 @@ class CutOut(FlatCAMTool): geo_obj.solid_geometry = deepcopy(solid_geo) geo_obj.options['cnctooldia'] = str(dia) + geo_obj.options['cutz'] = self.cutz_entry.get_value() + geo_obj.options['multidepth'] = self.mpass_cb.get_value() + geo_obj.options['depthperpass'] = self.maxdepth_entry.get_value() outname = cutout_obj.options["name"] + "_cutout" self.app.new_object('geometry', outname, geo_init) @@ -879,6 +899,9 @@ class CutOut(FlatCAMTool): solid_geo.append(poly.exterior) geo_obj.solid_geometry = deepcopy(solid_geo) geo_obj.options['cnctooldia'] = str(dia) + geo_obj.options['cutz'] = self.cutz_entry.get_value() + geo_obj.options['multidepth'] = self.mpass_cb.get_value() + geo_obj.options['depthperpass'] = self.maxdepth_entry.get_value() outname = cutout_obj.options["name"] + "_cutout" self.app.new_object('geometry', outname, geo_init)