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

- 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

Marius Stanciu 6 лет назад
Родитель
Сommit
ecd6472220
4 измененных файлов с 43 добавлено и 7 удалено
  1. 2 0
      FlatCAMApp.py
  2. 5 0
      README.md
  3. 9 0
      flatcamGUI/FlatCAMGUI.py
  4. 27 7
      flatcamTools/ToolCutOut.py

+ 2 - 0
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,

+ 5 - 0
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

+ 9 - 0
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()
 
 

+ 27 - 7
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("<font size=4><b>%s</b></font>" % _('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]