diff --git a/CHANGELOG.md b/CHANGELOG.md index 11f0c0fe..abd96645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta - made sure that the CNCJob UI building no longer have issues with table items added from an already existing table - fixed CNCJob UI showing all tools in the Tools Table even when only some tools were selected for processing - fixed the `drillcncjob` Tcl Command to work in the case of drilling a selection of tools instead of all, with toolchange inactive +- in Excellon Object UI, Advanced Mode, added a Tools Table context menu allowing to copy the tool diameters in the selected rows to clipboard 16.02.2022 diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index 2f2c0b1f..d5c35613 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -5191,7 +5191,7 @@ class AppGerberEditor(QtCore.QObject): self.app.defaults["global_point_clipboard_format"] % (self.decimals, self.pos[0], self.decimals, self.pos[1]) ) - self.app.inform.emit('[success] %s' % _("Coordinates copied to clipboard.")) + self.app.inform.emit('[success] %s' % _("Copied to clipboard.")) return # Dispatch event to active_tool diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index cd1deaf8..7984c03a 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -148,10 +148,6 @@ class ExcellonObject(FlatCAMObj, Excellon): assert isinstance(self.ui, ExcellonObjectUI), \ "Expected a ExcellonObjectUI, got %s" % type(self.ui) - # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] - self.change_level(app_mode) - # ############################################################################# # ############################ SIGNALS ######################################## # ############################################################################# @@ -189,6 +185,13 @@ class ExcellonObject(FlatCAMObj, Excellon): self.set_offset_values() + self.clear_contex_menu() + self.init_context_menu() + + # Show/Hide Advanced Options + app_mode = self.app.defaults["global_app_level"] + self.change_level(app_mode) + def set_offset_values(self): xmin, ymin, xmax, ymax = self.bounds() center_coords = ( @@ -226,6 +229,9 @@ class ExcellonObject(FlatCAMObj, Excellon): self.ui.table_visibility_cb.set_value(True) self.ui.table_visibility_cb.hide() self.ui.autoload_db_cb.hide() + + # Context Menu section + self.ui.tools_table.removeContextMenu() else: self.ui.level.setText('%s' % _('Advanced')) self.ui.level.setStyleSheet(""" @@ -242,6 +248,9 @@ class ExcellonObject(FlatCAMObj, Excellon): self.on_table_visibility_toggle(state=self.app.defaults["excellon_tools_table_display"]) self.ui.autoload_db_cb.show() + # Context Menu section + self.ui.tools_table.setupContextMenu() + def build_ui(self): """ Will (re)build the Excellon UI updating it (the tool table) @@ -495,6 +504,53 @@ class ExcellonObject(FlatCAMObj, Excellon): self.ui_connect() + def clear_contex_menu(self): + self.ui.tools_table.removeContextMenu() + + def init_context_menu(self): + # ############################################################################# + # ###################### Setup CONTEXT MENU ################################### + # ############################################################################# + self.ui.tools_table.setupContextMenu() + self.ui.tools_table.addContextMenu( + _("Copy"), + lambda: self.on_table_copy_dia(), + icon=QtGui.QIcon(self.app.resource_location + "/copy32.png") + ) + + def on_table_copy_dia(self): + sel_model = self.ui.tools_table.selectionModel() + sel_indexes = sel_model.selectedIndexes() + + # it will iterate over all indexes which means all items in all columns too but I'm interested only on rows + # so the duplicate rows will not be added + sel_rows = set() + for idx in sel_indexes: + sel_rows.add(idx.row()) + + sel_rows_list = list(sel_rows) + if len(sel_rows_list) == 1: + copied_dia_text = self.ui.tools_table.item(sel_rows_list[0], 1).text() + try: + # only rows that have float values are allowed + copied_dia = float(copied_dia_text) + except ValueError: + return + else: + copied_dia = self.ui.tools_table.item(sel_rows_list[0], 1).text() + for row_idx in sel_rows_list[1:]: + copied_dia_text = self.ui.tools_table.item(row_idx, 1).text() + try: + # this is done to avoid selected rows that do not have real numbers in the tool diameter column + copied_test_dia = float(copied_dia_text) + copied_dia += ',' + copied_dia += str(copied_test_dia) + except ValueError: + continue + + self.app.clipboard.setText(str(copied_dia)) + self.app.inform.emit('[success] %s' % _("Copied to clipboard.")) + def ui_connect(self): """ Will connect all signals in the Excellon UI that needs to be connected diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index d9cad1da..5c630693 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -1709,7 +1709,7 @@ class ToolDrilling(AppTool, Excellon): sel_rows.add(idx.row()) if len(sel_rows) != 1: - self.app.inform.emit("[WARNING_NOTCL] %s" % _("Multiple areas selected. Only one area is allowed.")) + self.app.inform.emit("[WARNING_NOTCL] %s" % _("Only one selected row is allowed.")) return row_idx = list(sel_rows)[0] @@ -1717,7 +1717,7 @@ class ToolDrilling(AppTool, Excellon): poly_coords = list(poly.exterior.coords) self.app.clipboard.setText(str(poly_coords)) - self.app.inform.emit('[success] %s' % _("Coordinates copied to clipboard.")) + self.app.inform.emit('[success] %s' % _("Copied to clipboard.")) def draw_sel_shape(self): sel_model = self.ui.exclusion_table.selectionModel() diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index fe03fd97..00951520 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -3806,7 +3806,7 @@ class ToolMilling(AppTool, Excellon): sel_rows.add(idx.row()) if len(sel_rows) != 1: - self.app.inform.emit("[WARNING_NOTCL] %s" % _("Multiple areas selected. Only one area is allowed.")) + self.app.inform.emit("[WARNING_NOTCL] %s" % _("Only one selected row is allowed.")) return row_idx = list(sel_rows)[0] @@ -3814,7 +3814,7 @@ class ToolMilling(AppTool, Excellon): poly_coords = list(poly.exterior.coords) self.app.clipboard.setText(str(poly_coords)) - self.app.inform.emit('[success] %s' % _("Coordinates copied to clipboard.")) + self.app.inform.emit('[success] %s' % _("Copied to clipboard.")) def draw_sel_shape(self): sel_model = self.ui.exclusion_table.selectionModel() diff --git a/app_Main.py b/app_Main.py index 294f7347..bf385f2b 100644 --- a/app_Main.py +++ b/app_Main.py @@ -7586,7 +7586,7 @@ class App(QtCore.QObject): self.defaults["global_point_clipboard_format"] % (self.decimals,position[0], self.decimals, position[1]) ) - self.inform.emit('[success] %s' % _("Coordinates copied to clipboard.")) + self.inform.emit('[success] %s' % _("Copied to clipboard.")) elif modifiers == QtCore.Qt.KeyboardModifier.ControlModifier | QtCore.Qt.KeyboardModifier.ShiftModifier: try: old_clipb = eval(self.clipboard.text()) @@ -7608,7 +7608,7 @@ class App(QtCore.QObject): else: old_clipb = [old_clipb, clip_pos_val] self.clipboard.setText(str(old_clipb)) - self.inform.emit('[success] %s' % _("Coordinates copied to clipboard.")) + self.inform.emit('[success] %s' % _("Copied to clipboard.")) def on_mouse_context_menu(self): """