- 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)
This commit is contained in:
Marius Stanciu
2022-03-31 23:28:08 +03:00
committed by Marius
parent ada48269a9
commit 8e18669249
3 changed files with 31 additions and 7 deletions

View File

@@ -124,7 +124,8 @@ class ToolExtract(AppTool):
self.set_tool_ui()
self.build_tool_ui()
self.app.ui.notebook.setTabText(2, _("Extract"))
# trigger this once at plugin launch
self.on_object_combo_changed()
def connect_signals_at_init(self):
# ## Signals
@@ -207,9 +208,18 @@ class ToolExtract(AppTool):
# 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)
self.app.ui.notebook.setTabText(2, _("Extract"))
def build_tool_ui(self):
self.ui_disconnect()
@@ -330,6 +340,17 @@ class ToolExtract(AppTool):
# 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 ui_connect(self):