From 26354e1f9e46272620ebaa77c81badc6f1c0dadb Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 7 Oct 2021 20:59:08 +0300 Subject: [PATCH] - in "Punch Gerber" and "Extract" Plugins - make sure that the aperture markings are deleted on Reset Tool click and upon finishing the Plugin main function - in Punch Gerber Plugin the object is no longer populated automatically with the generated object - in Corner Markers Plugin fixed the position of "drills in locations" and for Checking Exceloon; the source object is no longer auto-updated to the latest one since we have to always work on the original object --- CHANGELOG.md | 5 ++++- appPlugins/ToolCorners.py | 37 +++++++++++++++++----------------- appPlugins/ToolExtract.py | 18 +++++++++++++++-- appPlugins/ToolPunchGerber.py | 38 ++++++++++++++++++++++++++--------- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d89148..a708f62a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,12 @@ CHANGELOG for FlatCAM beta - updated the Turkish translation files (by Mehmet Kaya) - added a new color in the Object Colors ("indigo") - now the object color transparency is preserved if a new color is chosen -- the Proprties tab UI is now populated with the object UI only when the Properties tab is selected and not on object selection like it was done previously +- the Properties tab UI is now populated with the object UI only when the Properties tab is selected and not on object selection like it was done previously - make sure that if the Properties Tab is selected then the Object UI is updated (built) on object selection on canvas - code cleanup +- in "Punch Gerber" and "Extract" Plugins - make sure that the aperture markings are deleted on Reset Tool click and upon finishing the Plugin main function +- in Punch Gerber Plugin the object is no longer populated automatically with the generated object +- in Corner Markers Plugin fixed the position of "drills in locations" and for Checking Exceloon; the source object is no longer auto-updated to the latest one since we have to always work on the original object 5.10.2021 diff --git a/appPlugins/ToolCorners.py b/appPlugins/ToolCorners.py index 57456698..f307c533 100644 --- a/appPlugins/ToolCorners.py +++ b/appPlugins/ToolCorners.py @@ -507,7 +507,7 @@ class ToolCorners(AppTool): grb_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=grb_obj, use_thread=False) - ret = self.app.app_obj.new_object('gerber', outname, initialize, plot=True) + ret = self.app.app_obj.new_object('gerber', outname, initialize, plot=True, autoselected=False) return ret @@ -552,29 +552,29 @@ class ToolCorners(AppTool): if 'manual' not in self.points: if tl_state: - x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 - y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 + x = xmin - margin - line_thickness / 2.0 + y = ymax + margin + line_thickness / 2.0 drill_list.append( Point((x, y)) ) if tr_state: - x = xmax + margin + line_thickness / 2.0 - tooldia / 2.0 - y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 + x = xmax + margin + line_thickness / 2.0 + y = ymax + margin + line_thickness / 2.0 drill_list.append( Point((x, y)) ) if bl_state: - x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 - y = ymin - margin - line_thickness / 2.0 + tooldia / 2.0 + x = xmin - margin - line_thickness / 2.0 + y = ymin - margin - line_thickness / 2.0 drill_list.append( Point((x, y)) ) if br_state: - x = xmax + margin + line_thickness / 2.0 - tooldia / 2.0 - y = ymin - margin - line_thickness / 2.0 + tooldia / 2.0 + x = xmax + margin + line_thickness / 2.0 + y = ymin - margin - line_thickness / 2.0 drill_list.append( Point((x, y)) ) @@ -662,29 +662,29 @@ class ToolCorners(AppTool): if 'manual' not in self.points: if tl_state: - x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 - y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 + x = xmin - margin - line_thickness / 2.0 + y = ymax + margin + line_thickness / 2.0 drill_list.append( Point((x, y)) ) if tr_state: - x = xmax + margin + line_thickness / 2.0 - tooldia / 2.0 - y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 + x = xmax + margin + line_thickness / 2.0 + y = ymax + margin + line_thickness / 2.0 drill_list.append( Point((x, y)) ) if bl_state: - x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 - y = ymin - margin - line_thickness / 2.0 + tooldia / 2.0 + x = xmin - margin - line_thickness / 2.0 + y = ymin - margin - line_thickness / 2.0 drill_list.append( Point((x, y)) ) if br_state: - x = xmax + margin + line_thickness / 2.0 - tooldia / 2.0 - y = ymin - margin - line_thickness / 2.0 + tooldia / 2.0 + x = xmax + margin + line_thickness / 2.0 + y = ymin - margin - line_thickness / 2.0 drill_list.append( Point((x, y)) ) @@ -891,14 +891,13 @@ class CornersUI: # Gerber Source Object # ############################################################################################################# - # Gerber object # self.object_label = FCLabel('%s' % _("Source Object")) self.object_label.setToolTip(_("The Gerber object to which will be added corner markers.")) self.object_combo = FCComboBox() self.object_combo.setModel(self.app.collection) self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - self.object_combo.is_last = True + self.object_combo.is_last = False self.object_combo.obj_type = "Gerber" self.tools_box.addWidget(self.object_label) diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index f3babe81..03ca2fb7 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -345,7 +345,7 @@ class ToolExtract(AppTool): self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect() except (TypeError, AttributeError): pass - self.ui.apertures_table.cellWidget(row, 3).clicked.connect(self.on_mark_cb_click_table) + self.ui.apertures_table.cellWidget(row, 3).stateChanged.connect(self.on_mark_cb_click_table) def ui_disconnect(self): try: @@ -356,7 +356,7 @@ class ToolExtract(AppTool): # Mark Checkboxes for row in range(self.ui.apertures_table.rowCount()): try: - self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect() + self.ui.apertures_table.cellWidget(row, 3).stateChanged.disconnect() except (TypeError, AttributeError): pass @@ -409,6 +409,8 @@ class ToolExtract(AppTool): use_thread=False) with self.app.proc_container.new('%s...' % _("Working")): + self.clear_aperture_marking() + try: self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False) except Exception as e: @@ -931,9 +933,21 @@ class ToolExtract(AppTool): else: grb_obj.clear_plot_apertures(aperture=aperture) + def clear_aperture_marking(self): + """ + Will clear all aperture markings after creating an Excellon object with extracted drill holes + + :return: + :rtype: + """ + + for row in range(self.ui.apertures_table.rowCount()): + self.ui.apertures_table.cellWidget(row, 3).set_value(False) + def reset_fields(self): self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.ui.gerber_object_combo.setCurrentIndex(0) + self.clear_aperture_marking() class ExtractUI: diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index e6f2d360..81100f5b 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -529,6 +529,7 @@ class ToolPunchGerber(AppTool, Gerber): self.on_ring_method(self.grb_obj, outname) elif punch_method == 'prop': self.on_proportional_method(self.grb_obj, outname) + self.clear_aperture_marking() else: if punch_method == 'exc': # get the Excellon file whose geometry will create the punch holes @@ -562,6 +563,7 @@ class ToolPunchGerber(AppTool, Gerber): # disconnect flags self.poly_sel_disconnect_flag = True + self.app.ui.notebook.setDisabled(True) # disable the canvas mouse dragging seelction shape self.old_selection_status = deepcopy(self.app.defaults['global_selection_shape']) @@ -670,7 +672,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_excellon_manual_method(self, outname): # get the Excellon file whose geometry will create the punch holes @@ -791,7 +793,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_fixed_method(self, grb_obj, outname): punch_size = float(self.ui.dia_entry.get_value()) @@ -924,7 +926,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_fixed_manual_method(self, outname): punch_size = float(self.ui.dia_entry.get_value()) @@ -1019,7 +1021,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_ring_method(self, grb_obj, outname): circ_r_val = self.ui.circular_ring_entry.get_value() @@ -1168,7 +1170,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_ring_manual_method(self, outname): circ_r_val = self.ui.circular_ring_entry.get_value() @@ -1308,7 +1310,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_proportional_method(self, grb_obj, outname): prop_factor = self.ui.factor_entry.get_value() / 100.0 @@ -1452,7 +1454,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def on_proportional_manual_method(self, outname): prop_factor = self.ui.factor_entry.get_value() / 100.0 @@ -1588,7 +1590,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, use_thread=False) - self.app.app_obj.new_object('gerber', outname, init_func) + self.app.app_obj.new_object('gerber', outname, init_func, autoselected=False) def find_pad(self, point): pt = Point(point) if type(point) is tuple else point @@ -1752,6 +1754,8 @@ class ToolPunchGerber(AppTool, Gerber): self.app.tool_shapes.clear(update=True) self.on_manual_punch() + self.clear_aperture_marking() + self.app.ui.notebook.setDisabled(False) # initialize the work variables self.manual_pads = [] @@ -1844,8 +1848,9 @@ class ToolPunchGerber(AppTool, Gerber): if self.old_selection_status is not None: self.app.defaults['global_selection_shape'] = self.old_selection_status + self.app.ui.notebook.setDisabled(False) self.poly_dict.clear() - + self.clear_aperture_marking() self.delete_moving_selection_shape() self.delete_tool_selection_shape() @@ -1942,9 +1947,22 @@ class ToolPunchGerber(AppTool, Gerber): self.app.tool_shapes.redraw() self.app.inform.emit(_("Selection cleared.")) + def clear_aperture_marking(self): + """ + Will clear all aperture markings after creating an Excellon object with extracted drill holes + + :return: + :rtype: + """ + + for row in range(self.ui.apertures_table.rowCount()): + self.ui.apertures_table.cellWidget(row, 3).set_value(False) + def reset_fields(self): self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.ui.exc_combo.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex())) + self.clear_aperture_marking() + self.ui_disconnect() @@ -2008,7 +2026,7 @@ class PunchUI: self.gerber_object_combo = FCComboBox() self.gerber_object_combo.setModel(self.app.collection) self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) - self.gerber_object_combo.is_last = True + self.gerber_object_combo.is_last = False self.gerber_object_combo.obj_type = "Gerber" grid0.addWidget(self.gerber_object_combo, 0, 0, 1, 2)