diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e9b48d..e675ca62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ CHANGELOG for FlatCAM Evo beta - added a new feature in the Isolation Plugin: now for all the isolation Geometry objects this plugin can do a supplementary simplification of the geometry using the tolerance parameter defined in the General Parameters. This should lead to a reduced number of tool lifts when doing corners - fixed aperture marking in Extract Plugin - in Extract Plugin if no Gerber object is selected then the first Gerber object in the project list is selected (if any) +- in Punch Gerber Plugin if no Gerber object is selected then the first Gerber object in the project list is selected (if any); fixed aperture marking in Punch Gerber Plugin +- in Punch Gerber and Extrat plugins, clean up the aperture markings on Plugin exit 30.03.2022 diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index 173b550f..386b52e5 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -359,10 +359,14 @@ class ToolExtract(AppTool): # Mark Checkboxes for row in range(self.ui.apertures_table.rowCount()): try: - self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect() + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.clicked.disconnect() except (TypeError, AttributeError): pass - self.ui.apertures_table.cellWidget(row, 3).stateChanged.connect(self.on_mark_cb_click_table) + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.stateChanged.connect(self.on_mark_cb_click_table) def ui_disconnect(self): try: @@ -373,7 +377,9 @@ class ToolExtract(AppTool): # Mark Checkboxes for row in range(self.ui.apertures_table.rowCount()): try: - self.ui.apertures_table.cellWidget(row, 3).stateChanged.disconnect() + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.stateChanged.disconnect() except (TypeError, AttributeError): pass @@ -943,7 +949,9 @@ class ToolExtract(AppTool): except Exception: return - if self.ui.apertures_table.cellWidget(cw_row, 3).isChecked(): + wdg = self.ui.apertures_table.cellWidget(cw_row, 3) + assert isinstance(wdg, FCCheckBox) + if wdg.isChecked(): # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) color = self.app.options['global_sel_draw_color'] color = (color + 'AA') if len(color) == 7 else (color[:-2] + 'AA') @@ -951,6 +959,9 @@ class ToolExtract(AppTool): else: grb_obj.clear_plot_apertures(aperture=aperture) + def on_plugin_cleanup(self): + self.reset_fields() + def clear_aperture_marking(self): """ Will clear all aperture markings after creating an Excellon object with extracted drill holes @@ -960,7 +971,9 @@ class ToolExtract(AppTool): """ for row in range(self.ui.apertures_table.rowCount()): - self.ui.apertures_table.cellWidget(row, 3).set_value(False) + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.set_value(False) def reset_fields(self): self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index 041114c6..a82780e7 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -150,7 +150,8 @@ class ToolPunchGerber(AppTool, Gerber): self.set_tool_ui() self.build_tool_ui() - self.app.ui.notebook.setTabText(2, _("Punch Geber")) + # trigger this once at plugin launch + self.on_object_combo_changed() def install(self, icon=None, separator=None, **kwargs): AppTool.install(self, icon, separator, shortcut='Alt+H', **kwargs) @@ -238,14 +239,23 @@ class ToolPunchGerber(AppTool, Gerber): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() - if obj and obj.kind == 'gerber': - obj_name = obj.obj_options['name'] - self.ui.gerber_object_combo.set_value(obj_name) + if obj: + if obj.kind == 'gerber': + obj_name = obj.obj_options['name'] + self.ui.gerber_object_combo.set_value(obj_name) + else: + # take first available Gerber file, if any + available_gerber_list = [o for o in self.app.collection.get_list() if o.kind == 'gerber'] + if available_gerber_list: + obj_name = available_gerber_list[0].obj_options['name'] + self.ui.gerber_object_combo.set_value(obj_name) # Show/Hide Advanced Options app_mode = self.app.options["global_app_level"] self.change_level(app_mode) + self.app.ui.notebook.setTabText(2, _("Punch Gerber")) + def build_tool_ui(self): self.ui_disconnect() @@ -365,6 +375,17 @@ class ToolPunchGerber(AppTool, Gerber): # self.ui.apertures_table.setMinimumHeight(self.ui.apertures_table.getHeight()) # self.ui.apertures_table.setMaximumHeight(self.ui.apertures_table.getHeight()) + # make sure you clear the Gerber aperture markings when the table is rebuilt + # get the Gerber file who is the source of the punched Gerber + selection_index = self.ui.gerber_object_combo.currentIndex() + model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex()) + try: + grb_obj = model_index.internalPointer().obj + except Exception: + self.ui_connect() + return + grb_obj.clear_plot_apertures() + self.ui_connect() def change_level(self, level): @@ -474,10 +495,14 @@ class ToolPunchGerber(AppTool, Gerber): # Mark Checkboxes for row in range(self.ui.apertures_table.rowCount()): try: - self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect() + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.clicked.disconnect() except (TypeError, AttributeError): pass - self.ui.apertures_table.cellWidget(row, 3).clicked.connect(self.on_mark_cb_click_table) + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.clicked.connect(self.on_mark_cb_click_table) def ui_disconnect(self): try: @@ -488,7 +513,9 @@ class ToolPunchGerber(AppTool, Gerber): # Mark Checkboxes for row in range(self.ui.apertures_table.rowCount()): try: - self.ui.apertures_table.cellWidget(row, 3).clicked.disconnect() + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.clicked.disconnect() except (TypeError, AttributeError): pass @@ -1858,10 +1885,14 @@ class ToolPunchGerber(AppTool, Gerber): except Exception: return - if self.ui.apertures_table.cellWidget(cw_row, 3).isChecked(): + wdg = self.ui.apertures_table.cellWidget(cw_row, 3) + assert isinstance(wdg, FCCheckBox) + if wdg.isChecked(): # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) - grb_obj.plot_aperture(color='#e32b07' + '60', - marked_aperture=aperture, visible=True, run_thread=True) + # color = '#e32b0760' + color = self.app.options['global_sel_draw_color'] + color = (color + 'AA') if len(color) == 7 else (color[:-2] + 'AA') + grb_obj.plot_aperture(color=color, marked_aperture=aperture, visible=True, run_thread=True) else: grb_obj.clear_plot_apertures(aperture=aperture) @@ -1933,7 +1964,12 @@ class ToolPunchGerber(AppTool, Gerber): """ for row in range(self.ui.apertures_table.rowCount()): - self.ui.apertures_table.cellWidget(row, 3).set_value(False) + wdg = self.ui.apertures_table.cellWidget(row, 3) + assert isinstance(wdg, FCCheckBox) + wdg.set_value(False) + + def on_plugin_cleanup(self): + self.reset_fields() def reset_fields(self): self.ui.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))