From 408327e48ff94fe6f65763041ed149ce5270408f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 19 Oct 2020 16:56:21 +0300 Subject: [PATCH] - added a check (and added to Preferences too) for the verification of tools validity in the Isolation Tool --- CHANGELOG.md | 4 ++ appGUI/preferences/PreferencesUIManager.py | 1 + .../preferences/tools/ToolsISOPrefGroupUI.py | 10 +++ appTools/ToolIsolation.py | 62 ++++++++++++------- appTools/ToolNCC.py | 2 +- appTools/ToolPaint.py | 4 +- defaults.py | 1 + 7 files changed, 57 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a31501..b4523a36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +19.10.2020 + +- added a check (and added to Preferences too) for the verification of tools validity in the Isolation Tool + 18.10.2020 - fixed issue with calling the inform signal in the FlatCAMDefaults.load method diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index d87e7675..249a3b72 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -342,6 +342,7 @@ class PreferencesUIManager: "tools_iso_rest": self.ui.tools_defaults_form.tools_iso_group.rest_cb, "tools_iso_combine_passes": self.ui.tools_defaults_form.tools_iso_group.combine_passes_cb, + "tools_iso_check_valid": self.ui.tools_defaults_form.tools_iso_group.valid_cb, "tools_iso_isoexcept": self.ui.tools_defaults_form.tools_iso_group.except_cb, "tools_iso_selection": self.ui.tools_defaults_form.tools_iso_group.select_combo, "tools_iso_poly_ints": self.ui.tools_defaults_form.tools_iso_group.poly_int_cb, diff --git a/appGUI/preferences/tools/ToolsISOPrefGroupUI.py b/appGUI/preferences/tools/ToolsISOPrefGroupUI.py index 4a418ca5..71bff3c7 100644 --- a/appGUI/preferences/tools/ToolsISOPrefGroupUI.py +++ b/appGUI/preferences/tools/ToolsISOPrefGroupUI.py @@ -271,6 +271,16 @@ class ToolsISOPrefGroupUI(OptionsGroupUI): self.except_cb.setObjectName("i_except") grid0.addWidget(self.except_cb, 17, 2) + # Check Tool validity + self.valid_cb = FCCheckBox(label=_('Check validity')) + self.valid_cb.setToolTip( + _("If checked then the tools diameters are verified\n" + "if they will provide a complete isolation.") + ) + self.valid_cb.setObjectName("i_check") + + grid0.addWidget(self.valid_cb, 18, 0, 1, 3) + # Isolation Scope self.select_label = QtWidgets.QLabel('%s:' % _("Selection")) self.select_label.setToolTip( diff --git a/appTools/ToolIsolation.py b/appTools/ToolIsolation.py index 23e70ea2..19927057 100644 --- a/appTools/ToolIsolation.py +++ b/appTools/ToolIsolation.py @@ -318,6 +318,7 @@ class ToolIsolation(AppTool, Gerber): self.ui.iso_overlap_entry.set_value(self.app.defaults["tools_iso_overlap"]) self.ui.milling_type_radio.set_value(self.app.defaults["tools_iso_milling_type"]) self.ui.combine_passes_cb.set_value(self.app.defaults["tools_iso_combine_passes"]) + self.ui.valid_cb.set_value(self.app.defaults["tools_iso_check_valid"]) self.ui.area_shape_radio.set_value(self.app.defaults["tools_iso_area_shape"]) self.ui.poly_int_cb.set_value(self.app.defaults["tools_iso_poly_ints"]) self.ui.forced_rest_iso_cb.set_value(self.app.defaults["tools_iso_force"]) @@ -937,9 +938,9 @@ class ToolIsolation(AppTool, Gerber): geo_len = len(total_geo) geo_len = (geo_len * (geo_len - 1)) / 2 except TypeError: - app_obj.inform.emit('[ERROR_NOTCL] %s' % - _("The Gerber object has one Polygon as geometry.\n" - "There are no distances between geometry elements to be found.")) + msg = _("The Gerber object has one Polygon as geometry.\n" + "There are no distances between geometry elements to be found.") + app_obj.inform.emit('[ERROR_NOTCL] %s' % msg) return 'fail' min_dict = {} @@ -950,7 +951,8 @@ class ToolIsolation(AppTool, Gerber): # graceful abort requested by the user raise grace - # minimize the number of distances by not taking into considerations those that are too small + # minimize the number of distances by not taking into considerations those + # that are too small dist = geo.distance(s_geo) dist = float('%.*f' % (self.decimals, dist)) loc_1, loc_2 = nearest_points(geo, s_geo) @@ -995,7 +997,8 @@ class ToolIsolation(AppTool, Gerber): tid = int(self.ui.tools_table.item(row, 3).text()) sorted_tools.append(tid) if not sorted_tools: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + msg = _("There are no tools selected in the Tool Table.") + self.app.inform.emit('[ERROR_NOTCL] %s' % msg) return 'fail' # check if the tools diameters are less then the safe tool diameter @@ -1365,7 +1368,7 @@ class ToolIsolation(AppTool, Gerber): # Get source object. try: self.grb_obj = self.app.collection.get_by_name(self.obj_name) - except Exception as e: + except Exception: self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), str(self.obj_name))) return @@ -1373,7 +1376,8 @@ class ToolIsolation(AppTool, Gerber): self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), str(self.obj_name))) return - self.find_safe_tooldia_worker(is_displayed=False) + if self.ui.valid_cb.get_value() is True: + self.find_safe_tooldia_worker(is_displayed=False) def worker_task(iso_obj): with self.app.proc_container.new(_("Isolating...")): @@ -1501,7 +1505,7 @@ class ToolIsolation(AppTool, Gerber): tid = int(self.ui.tools_table.item(row, 3).text()) sorted_tools.append(tid) if not sorted_tools: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return 'fail' # update the Common Parameters values in the self.iso_tools @@ -1703,7 +1707,7 @@ class ToolIsolation(AppTool, Gerber): sorted_tools.append(float('%.*f' % (self.decimals, tdia))) if not sorted_tools: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return 'fail' order = self.ui.order_radio.get_value() @@ -1890,7 +1894,7 @@ class ToolIsolation(AppTool, Gerber): tid = int(self.ui.tools_table.item(row, 3).text()) sorted_tools.append(tid) if not sorted_tools: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return 'fail' for tool in sorted_tools: @@ -2279,7 +2283,7 @@ class ToolIsolation(AppTool, Gerber): except TypeError: if self.solid_geometry not in self.poly_dict.values(): if sel_type is True: - if self.solid_geometry.within(poly_selection): + if poly_selection.contains(self.solid_geometry): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=self.solid_geometry, color=self.app.defaults['global_sel_draw_color'] + 'AF', @@ -3312,13 +3316,23 @@ class IsoUI: self.grid3.addWidget(self.combine_passes_cb, 26, 0, 1, 2) + # Check Tool validity + self.valid_cb = FCCheckBox(label=_('Check validity')) + self.valid_cb.setToolTip( + _("If checked then the tools diameters are verified\n" + "if they will provide a complete isolation.") + ) + self.valid_cb.setObjectName("i_check") + + self.grid3.addWidget(self.valid_cb, 28, 0, 1, 2) + # Exception Areas self.except_cb = FCCheckBox(label=_('Except')) self.except_cb.setToolTip(_("When the isolation geometry is generated,\n" "by checking this, the area of the object below\n" "will be subtracted from the isolation geometry.")) self.except_cb.setObjectName("i_except") - self.grid3.addWidget(self.except_cb, 27, 0) + self.grid3.addWidget(self.except_cb, 30, 0) # Type of object to be excepted self.type_excobj_radio = RadioSet([{'label': _("Geometry"), 'value': 'geometry'}, @@ -3330,7 +3344,7 @@ class IsoUI: "of objects that will populate the 'Object' combobox.") ) - self.grid3.addWidget(self.type_excobj_radio, 27, 1) + self.grid3.addWidget(self.type_excobj_radio, 30, 1) # The object to be excepted self.exc_obj_combo = FCComboBox() @@ -3342,7 +3356,7 @@ class IsoUI: self.exc_obj_combo.is_last = True self.exc_obj_combo.obj_type = "gerber" - self.grid3.addWidget(self.exc_obj_combo, 28, 0, 1, 2) + self.grid3.addWidget(self.exc_obj_combo, 32, 0, 1, 2) self.e_ois = OptionalInputSection(self.except_cb, [ @@ -3365,8 +3379,8 @@ class IsoUI: ) self.select_combo.setObjectName("i_selection") - self.grid3.addWidget(self.select_label, 33, 0) - self.grid3.addWidget(self.select_combo, 33, 1) + self.grid3.addWidget(self.select_label, 34, 0) + self.grid3.addWidget(self.select_combo, 34, 1) self.reference_combo_type_label = FCLabel('%s:' % _("Ref. Type")) self.reference_combo_type_label.setToolTip( @@ -3376,8 +3390,8 @@ class IsoUI: self.reference_combo_type = FCComboBox() self.reference_combo_type.addItems([_("Gerber"), _("Excellon"), _("Geometry")]) - self.grid3.addWidget(self.reference_combo_type_label, 34, 0) - self.grid3.addWidget(self.reference_combo_type, 34, 1) + self.grid3.addWidget(self.reference_combo_type_label, 36, 0) + self.grid3.addWidget(self.reference_combo_type, 36, 1) self.reference_combo_label = FCLabel('%s:' % _("Ref. Object")) self.reference_combo_label.setToolTip( @@ -3388,8 +3402,8 @@ class IsoUI: self.reference_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.reference_combo.is_last = True - self.grid3.addWidget(self.reference_combo_label, 35, 0) - self.grid3.addWidget(self.reference_combo, 35, 1) + self.grid3.addWidget(self.reference_combo_label, 38, 0) + self.grid3.addWidget(self.reference_combo, 38, 1) self.reference_combo.hide() self.reference_combo_label.hide() @@ -3403,7 +3417,7 @@ class IsoUI: "(holes in the polygon).") ) - self.grid3.addWidget(self.poly_int_cb, 36, 0) + self.grid3.addWidget(self.poly_int_cb, 40, 0) self.poly_int_cb.hide() @@ -3416,8 +3430,8 @@ class IsoUI: self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'}, {'label': _("Polygon"), 'value': 'polygon'}]) - self.grid3.addWidget(self.area_shape_label, 38, 0) - self.grid3.addWidget(self.area_shape_radio, 38, 1) + self.grid3.addWidget(self.area_shape_label, 42, 0) + self.grid3.addWidget(self.area_shape_radio, 42, 1) self.area_shape_label.hide() self.area_shape_radio.hide() @@ -3425,7 +3439,7 @@ class IsoUI: separator_line = QtWidgets.QFrame() separator_line.setFrameShape(QtWidgets.QFrame.HLine) separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.grid3.addWidget(separator_line, 39, 0, 1, 2) + self.grid3.addWidget(separator_line, 44, 0, 1, 2) self.generate_iso_button = FCButton("%s" % _("Generate Geometry")) self.generate_iso_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png')) diff --git a/appTools/ToolNCC.py b/appTools/ToolNCC.py index 09a4b6e4..51b87269 100644 --- a/appTools/ToolNCC.py +++ b/appTools/ToolNCC.py @@ -1292,7 +1292,7 @@ class NonCopperClear(AppTool, Gerber): else: self.ncc_dia_list.append(self.tooldia) else: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return self.o_name = '%s_ncc' % self.obj_name diff --git a/appTools/ToolPaint.py b/appTools/ToolPaint.py index 45185440..c14769e5 100644 --- a/appTools/ToolPaint.py +++ b/appTools/ToolPaint.py @@ -1027,7 +1027,7 @@ class ToolPaint(AppTool, Gerber): continue self.tooldia_list.append(self.tooldia) else: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return self.select_method = self.ui.selectmethod_combo.get_value() @@ -1740,7 +1740,7 @@ class ToolPaint(AppTool, Gerber): continue sorted_tools.append(self.tooldia) if not sorted_tools: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("There are no tools selected in the Tool Table.")) return 'fail' # Initializes the new geometry object diff --git a/defaults.py b/defaults.py index bfa6d664..ae558e4f 100644 --- a/defaults.py +++ b/defaults.py @@ -410,6 +410,7 @@ class FlatCAMDefaults: "tools_iso_rest": False, "tools_iso_combine_passes": True, + "tools_iso_check_valid": False, "tools_iso_isoexcept": False, "tools_iso_selection": _("All"), "tools_iso_poly_ints": False,