Quellcode durchsuchen

- fixed bug in the Cutout Tool that did not allowed the manual cutous to be added on a Geometry created in the Tool
- fixed bug that made the selection box show in the stage of adding manual gaps
- updated Cutout Tool UI
- Cutout Tool - in manual gap adding there is now an option to automatically turn on the big cursor which could help
- Cutout Tool - fixed errors when trying to add a manual gap without having a geometry object selected in the combobox

Marius Stanciu vor 5 Jahren
Ursprung
Commit
79fec61934

+ 8 - 0
CHANGELOG.md

@@ -7,6 +7,14 @@ CHANGELOG for FlatCAM beta
 
 =================================================
 
+18.06.2020
+
+- fixed bug in the Cutout Tool that did not allowed the manual cutous to be added on a Geometry created in the Tool
+- fixed bug that made the selection box show in the stage of adding manual gaps
+- updated Cutout Tool UI
+- Cutout Tool - in manual gap adding there is now an option to automatically turn on the big cursor which could help
+- Cutout Tool - fixed errors when trying to add a manual gap without having a geometry object selected in the combobox
+
 17.06.2020
 
 - added the multi-save capability if multiple CNCJob objects are selected in Project tab but only if all are of type CNCJob

+ 10 - 9
appGUI/preferences/PreferencesUIManager.py

@@ -378,15 +378,16 @@ class PreferencesUIManager:
             "tools_ncc_plotting":       self.ui.tools_defaults_form.tools_ncc_group.plotting_radio,
 
             # CutOut Tool
-            "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,
+            "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,
+            "tools_cutout_big_cursor":      self.ui.tools_defaults_form.tools_cutout_group.big_cursor_cb,
 
             # Paint Area Tool
             "tools_painttooldia": self.ui.tools_defaults_form.tools_paint_group.painttooldia_entry,

+ 5 - 0
appGUI/preferences/tools/ToolsCutoutPrefGroupUI.py

@@ -174,4 +174,9 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI):
         )
         grid0.addWidget(self.convex_box, 7, 0, 1, 2)
 
+        self.big_cursor_cb = FCCheckBox('%s' % _("Big cursor"))
+        self.big_cursor_cb.setToolTip(
+            _("Use a big cursor when adding manual gaps."))
+        grid0.addWidget(self.big_cursor_cb, 8, 0, 1, 2)
+
         self.layout.addStretch()

+ 26 - 12
appObjects/FlatCAMExcellon.py

@@ -269,7 +269,12 @@ class ExcellonObject(FlatCAMObj, Excellon):
 
         sort = []
         for k, v in list(self.tools.items()):
-            sort.append((k, v['tooldia']))
+            try:
+                sort.append((k, v['tooldia']))
+            except KeyError:
+                # for old projects to be opened
+                sort.append((k, v['C']))
+
         sorted_tools = sorted(sort, key=lambda t1: t1[1])
         tools = [i[0] for i in sorted_tools]
 
@@ -278,11 +283,14 @@ class ExcellonObject(FlatCAMObj, Excellon):
             new_options[opt] = self.options[opt]
 
         for tool_no in tools:
+            try:
+                dia_val = self.tools[tool_no]['tooldia']
+            except KeyError:
+                # for old projects to be opened
+                dia_val = self.tools[tool_no]['C']
 
             # add the data dictionary for each tool with the default values
             self.tools[tool_no]['data'] = deepcopy(new_options)
-            # self.tools[tool_no]['data']["tooldia"] = self.tools[tool_no]["C"]
-            # self.tools[tool_no]['data']["slot_tooldia"] = self.tools[tool_no]["C"]
 
             drill_cnt = 0  # variable to store the nr of drills per tool
             slot_cnt = 0  # variable to store the nr of slots per tool
@@ -301,32 +309,38 @@ class ExcellonObject(FlatCAMObj, Excellon):
                 slot_cnt = 0
             self.tot_slot_cnt += slot_cnt
 
+            # Tool ID
             exc_id_item = QtWidgets.QTableWidgetItem('%d' % int(tool_no))
             exc_id_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+            self.ui.tools_table.setItem(self.tool_row, 0, exc_id_item)  # Tool name/id
 
-            dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, self.tools[tool_no]['tooldia']))
+            # Diameter
+            dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, dia_val))
             dia_item.setFlags(QtCore.Qt.ItemIsEnabled)
+            self.ui.tools_table.setItem(self.tool_row, 1, dia_item)  # Diameter
 
+            # Drill count
             drill_count_item = QtWidgets.QTableWidgetItem('%d' % drill_cnt)
             drill_count_item.setFlags(QtCore.Qt.ItemIsEnabled)
+            self.ui.tools_table.setItem(self.tool_row, 2, drill_count_item)  # Number of drills per tool
 
+            # Slot Count
             # if the slot number is zero is better to not clutter the GUI with zero's so we print a space
             slot_count_str = '%d' % slot_cnt if slot_cnt > 0 else ''
             slot_count_item = QtWidgets.QTableWidgetItem(slot_count_str)
             slot_count_item.setFlags(QtCore.Qt.ItemIsEnabled)
+            self.ui.tools_table.setItem(self.tool_row, 3, slot_count_item)  # Number of drills per tool
+
+            # Empty Plot Item
+            empty_plot_item = QtWidgets.QTableWidgetItem('')
+            empty_plot_item.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+            self.ui.tools_table.setItem(self.tool_row, 5, empty_plot_item)
 
+            # Plot Item
             plot_item = FCCheckBox()
             plot_item.setLayoutDirection(QtCore.Qt.RightToLeft)
             if self.ui.plot_cb.isChecked():
                 plot_item.setChecked(True)
-
-            self.ui.tools_table.setItem(self.tool_row, 0, exc_id_item)  # Tool name/id
-            self.ui.tools_table.setItem(self.tool_row, 1, dia_item)  # Diameter
-            self.ui.tools_table.setItem(self.tool_row, 2, drill_count_item)  # Number of drills per tool
-            self.ui.tools_table.setItem(self.tool_row, 3, slot_count_item)  # Number of drills per tool
-            empty_plot_item = QtWidgets.QTableWidgetItem('')
-            empty_plot_item.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
-            self.ui.tools_table.setItem(self.tool_row, 5, empty_plot_item)
             self.ui.tools_table.setCellWidget(self.tool_row, 5, plot_item)
 
             self.tool_row += 1

Datei-Diff unterdrückt, da er zu groß ist
+ 255 - 532
appTools/ToolCutOut.py


+ 4 - 1
appTools/ToolNCC.py

@@ -557,7 +557,10 @@ class NonCopperClear(AppTool, Gerber):
         try:
             dias = [float(self.app.defaults["tools_ncctools"])]
         except (ValueError, TypeError):
-            dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
+            try:
+                dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
+            except AttributeError:
+                dias = self.app.defaults["tools_ncctools"]
         except Exception:
             dias = []
 

+ 20 - 16
app_Main.py

@@ -6068,6 +6068,10 @@ class App(QtCore.QObject):
 
                 self.mouse = [pos[0], pos[1]]
 
+                if self.defaults['global_selection_shape'] is False:
+                    self.selection_type = None
+                    return
+
                 # if the mouse is moved and the LMB is clicked then the action is a selection
                 if self.event_is_dragging == 1 and event.button == 1:
                     self.delete_selection_shape()
@@ -9104,26 +9108,26 @@ class App(QtCore.QObject):
         App.log.debug(" **************** Started PROEJCT loading... **************** ")
 
         for obj in d['objs']:
-            try:
-                def obj_init(obj_inst, app_inst):
-
+            def obj_init(obj_inst, app_inst):
+                try:
                     obj_inst.from_dict(obj)
+                except Exception as e:
+                    print('App.open_project() --> ' + str(e))
+                    return 'fail'
 
-                App.log.debug("Recreating from opened project an %s object: %s" %
-                              (obj['kind'].capitalize(), obj['options']['name']))
+            App.log.debug("Recreating from opened project an %s object: %s" %
+                          (obj['kind'].capitalize(), obj['options']['name']))
 
-                # for some reason, setting ui_title does not work when this method is called from Tcl Shell
-                # it's because the TclCommand is run in another thread (it inherit TclCommandSignaled)
-                if cli is None:
-                    self.set_ui_title(name="{} {}: {}".format(_("Loading Project ... restoring"),
-                                                              obj['kind'].upper(),
-                                                              obj['options']['name']
-                                                              )
-                                      )
+            # for some reason, setting ui_title does not work when this method is called from Tcl Shell
+            # it's because the TclCommand is run in another thread (it inherit TclCommandSignaled)
+            if cli is None:
+                self.set_ui_title(name="{} {}: {}".format(_("Loading Project ... restoring"),
+                                                          obj['kind'].upper(),
+                                                          obj['options']['name']
+                                                          )
+                                  )
 
-                self.app_obj.new_object(obj['kind'], obj['options']['name'], obj_init, plot=plot)
-            except Exception as e:
-                print('App.open_project() --> ' + str(e))
+            self.app_obj.new_object(obj['kind'], obj['options']['name'], obj_init, plot=plot)
 
         self.inform.emit('[success] %s: %s' % (_("Project loaded from"), filename))
 

+ 9 - 5
camlib.py

@@ -592,8 +592,7 @@ class Geometry(object):
         if isinstance(self.solid_geometry, list):
             return len(self.solid_geometry) == 0
 
-        self.app.inform.emit('[ERROR_NOTCL] %s' %
-                             _("self.solid_geometry is neither BaseGeometry or list."))
+        self.app.inform.emit('[ERROR_NOTCL] %s' % _("self.solid_geometry is neither BaseGeometry or list."))
         return
 
     def subtract_polygon(self, points):
@@ -610,15 +609,20 @@ class Geometry(object):
         # pathonly should be allways True, otherwise polygons are not subtracted
         flat_geometry = self.flatten(pathonly=True)
         log.debug("%d paths" % len(flat_geometry))
-        polygon = Polygon(points)
+
+        if not isinstance(points, Polygon):
+            polygon = Polygon(points)
+        else:
+            polygon = points
         toolgeo = cascaded_union(polygon)
         diffs = []
         for target in flat_geometry:
-            if type(target) == LineString or type(target) == LinearRing:
+            if isinstance(target, LineString) or isinstance(target, LineString) or isinstance(target, MultiLineString):
                 diffs.append(target.difference(toolgeo))
             else:
                 log.warning("Not implemented.")
-        self.solid_geometry = cascaded_union(diffs)
+
+        self.solid_geometry = unary_union(diffs)
 
     def bounds(self, flatten=False):
         """

+ 1 - 0
defaults.py

@@ -457,6 +457,7 @@ class FlatCAMDefaults:
         "tools_cutoutgapsize": 4,
         "tools_gaps_ff": "4",
         "tools_cutout_convexshape": False,
+        "tools_cutout_big_cursor": True,
 
         # Paint Tool
         "tools_painttooldia": 0.3,

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.