From 708102d581a6837ba3c1b7f2fec3832fad1e71ee Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 30 Apr 2022 18:37:04 +0300 Subject: [PATCH] - minor changes in the Excellon Editor -> Resize Plugin --- CHANGELOG.md | 1 + appEditors/AppExcEditor.py | 56 +++++++++++++++++------ appEditors/exc_plugins/ExcResizePlugin.py | 2 +- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5afc68c..aeaa3b08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ CHANGELOG for FlatCAM Evo beta - in Excellon Editor, finished the upgrade work on the Drill Array Plugin - in Excellon Editor, finished the upgrade work on the Slot Array Plugin - in Excellon Editor, finished the upgrade work on the Resize Plugin +- minor changes in the Excellon Editor -> Resize Plugin 29.04.2022 diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index d998884b..640458f9 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -1946,13 +1946,32 @@ class ResizeEditorExc(FCShapeTool): self.draw_app.app.inform.emit(_("Click on the Drill(s) to resize ...")) def set_plugin_ui(self): - curr_row = self.draw_app.ui.tools_table_exc.currentRow() - tool_dia = float(self.draw_app.ui.tools_table_exc.item(curr_row, 1).text()) - self.ui.dia_entry.set_value(tool_dia) + # curr_row = self.draw_app.ui.tools_table_exc.currentRow() + # tool_dia = float(self.draw_app.ui.tools_table_exc.item(curr_row, 1).text()) + # self.ui.dia_entry.set_value(tool_dia) + + self.update_diameters() def utility_geometry(self, data=None): return DrawToolUtilityShape([]) + def click_release(self, point): + self.update_diameters() + + def update_diameters(self): + sel_dia_list = set() + for index in self.draw_app.ui.tools_table_exc.selectedIndexes(): + row = index.row() + if row < 0: + continue + # on column 1 in tool tables we hold the diameters, and we retrieve them as strings + # therefore below we convert to float + dia_on_row = self.draw_app.ui.tools_table_exc.item(row, 1).text() + if dia_on_row != '': + sel_dia_list.add(dia_on_row) + + self.ui.dia_entry.set_value(', '.join([i for i in list(sel_dia_list)])) + def make(self): self.draw_app.is_modified = True @@ -4075,21 +4094,28 @@ class AppExcEditor(QtCore.QObject): # if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right # selection and then select a type of selection ("enclosing" or "touching") - try: - if event.button == 1: # left click - if self.app.selection_type is not None: + if event.button == 1: # left click + if self.app.selection_type is not None: + try: self.draw_selection_area_handler(self.clicked_pos, pos, self.app.selection_type) - self.app.selection_type = None + except Exception as e: + self.app.log.error("AppExcEditor.on_exc_click_release() LMB click --> Error: %s" % str(e)) + raise + self.app.selection_type = None + elif isinstance(self.active_tool, SelectEditorExc): + self.active_tool.click_release((self.clicked_pos[0], self.clicked_pos[1])) - elif isinstance(self.active_tool, SelectEditorExc): - self.active_tool.click_release((self.clicked_pos[0], self.clicked_pos[1])) + # if there are selected objects then plot them + if self.selected: + self.replot() - # if there are selected objects then plot them - if self.selected: - self.replot() - except Exception as e: - self.app.log.error("AppExcEditor.on_exc_click_release() LMB click --> Error: %s" % str(e)) - raise + click_position = pos if pos is not None else self.clicked_pos + if self.active_tool is not None: + # Dispatch event to active_tool + try: + self.active_tool.click_release(click_position) + except AttributeError: + pass def on_canvas_move(self, event): """ diff --git a/appEditors/exc_plugins/ExcResizePlugin.py b/appEditors/exc_plugins/ExcResizePlugin.py index 98dde557..4fee1991 100644 --- a/appEditors/exc_plugins/ExcResizePlugin.py +++ b/appEditors/exc_plugins/ExcResizePlugin.py @@ -25,7 +25,7 @@ class ExcResizeEditorTool(AppTool): def connect_signals_at_init(self): # Signals - self.ui.clear_btn.clicked.connect(self.on_clear) + self.ui.clear_btn.clicked.connect(lambda: self.ui.res_dia_entry.set_value(0.0)) def disconnect_signals(self): # Signals