From ecd64722209230484d8cb74248f2de01cae7af97 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 31 Mar 2019 21:52:27 +0300 Subject: [PATCH] - fixed issue #281 by making generation of a convex shape for the freeform cutout in Tool Cutout a choice rather than the default - fixed bug in Tool Cutout, now in manual cutout mode the gap size reflect the value set --- FlatCAMApp.py | 2 ++ README.md | 5 +++++ flatcamGUI/FlatCAMGUI.py | 9 +++++++++ flatcamTools/ToolCutOut.py | 34 +++++++++++++++++++++++++++------- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 92030e55..26a2addd 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -465,6 +465,7 @@ class App(QtCore.QObject): "tools_cutoutmargin": self.ui.tools_defaults_form.tools_cutout_group.cutout_margin_entry, "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, # Paint Area Tool "tools_painttooldia": self.ui.tools_defaults_form.tools_paint_group.painttooldia_entry, @@ -766,6 +767,7 @@ class App(QtCore.QObject): "tools_cutoutmargin": 0.00393701, "tools_cutoutgapsize": 0.005905512, "tools_gaps_ff": "8", + "tools_cutout_convexshape": False, "tools_painttooldia": 0.07, "tools_paintoverlap": 0.15, diff --git a/README.md b/README.md index 0006aac0..b752b3c5 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing. ================================================= +31.03.2019 + +- fixed issue #281 by making generation of a convex shape for the freeform cutout in Tool Cutout a choice rather than the default +- fixed bug in Tool Cutout, now in manual cutout mode the gap size reflect the value set + 29.03.2019 - update the TCL keyword list diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index 32934603..d36a5fe9 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -4946,6 +4946,15 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI): self.gaps_combo.addItem(it) self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)') + # Surrounding convex box shape + self.convex_box = FCCheckBox() + self.convex_box_label = QtWidgets.QLabel(_("Convex Sh.:")) + self.convex_box_label.setToolTip( + _("Create a convex shape surrounding the entire PCB.") + ) + grid0.addWidget(self.convex_box_label, 4, 0) + grid0.addWidget(self.convex_box, 4, 1) + self.layout.addStretch() diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 687e1c29..d3e7b81b 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -110,6 +110,14 @@ class CutOut(FlatCAMTool): # 2tb - 2*top + 2*bottom # 8 - 2*left + 2*right +2*top + 2*bottom + # Surrounding convex box shape + self.convex_box = FCCheckBox() + self.convex_box_label = QtWidgets.QLabel(_("Convex Sh.:")) + self.convex_box_label.setToolTip( + _("Create a convex shape surrounding the entire PCB.") + ) + form_layout.addRow(self.convex_box_label, self.convex_box) + ## Title2 title_param_label = QtWidgets.QLabel("%s" % _('A. Automatic Bridge Gaps')) title_param_label.setToolTip( @@ -310,7 +318,8 @@ class CutOut(FlatCAMTool): self.dia.set_value(float(self.app.defaults["tools_cutouttooldia"])) self.margin.set_value(float(self.app.defaults["tools_cutoutmargin"])) self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"])) - self.gaps.set_value(4) + self.gaps.set_value(self.app.defaults["tools_gaps_ff"]) + self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape']) self.gapFinished.connect(self.on_gap_finished) @@ -388,6 +397,8 @@ class CutOut(FlatCAMTool): "and after that perform Cutout.")) return + convex_box = self.convex_box.get_value() + # Get min and max data for each object as we just cut rectangles across X or Y xmin, ymin, xmax, ymax = cutout_obj.bounds() px = 0.5 * (xmin + xmax) + margin @@ -402,8 +413,12 @@ class CutOut(FlatCAMTool): cutout_obj.options["name"] += "_cutout" else: def geo_init(geo_obj, app_obj): - geo = cutout_obj.solid_geometry.convex_hull - geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + if convex_box: + geo = cutout_obj.solid_geometry.convex_hull + geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + else: + geo = cutout_obj.solid_geometry + geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)).exterior outname = cutout_obj.options["name"] + "_cutout" self.app.new_object('geometry', outname, geo_init) @@ -722,16 +737,21 @@ class CutOut(FlatCAMTool): "Add it and retry.")) return + convex_box = self.convex_box.get_value() + def geo_init(geo_obj, app_obj): - geo = cutout_obj.solid_geometry.convex_hull - geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + if convex_box: + geo = cutout_obj.solid_geometry.convex_hull + geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)) + else: + geo = cutout_obj.solid_geometry + geo_obj.solid_geometry = geo.buffer(margin + abs(dia / 2)).exterior outname = cutout_obj.options["name"] + "_cutout" self.app.new_object('geometry', outname, geo_init) def cutting_geo(self, pos): - self.cutting_gapsize = self.cutting_gapsize / 2 + (self.cutting_dia / 2) - offset = self.cutting_gapsize / 2 + offset = self.cutting_dia / 2 + self.cutting_gapsize / 2 # cutting area definition orig_x = pos[0]