From 2536bd6a7d89ef23b0c0500e9f7e1cc4faa57f7a Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 4 Nov 2020 03:20:42 +0200 Subject: [PATCH] - in the Excellon Editor, added shortcut keys Space and Ctrl+Space for toggling the direction of the Slots, respectively for the Array of Slots --- CHANGELOG.md | 1 + appEditors/AppExcEditor.py | 71 ++++++++++++++++++++++++++++++++++++++ appGUI/MainGUI.py | 22 +++++++++++- 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e66676eb..460ffdde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ CHANGELOG for FlatCAM beta - updated the Italian translation (by Massimiliano Golfetto) - fixed a series of issues in Gerber Editor tools when the user is trying to use the tools by preselecting a aperture without size (aperture macro) - moved all the UI stuff out of the Gerber Editor class in its own class +- in the Excellon Editor, added shortcut keys Space and Ctrl+Space for toggling the direction of the Slots, respectively for the Array of Slots 2.11.2020 diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index 9603cd72..a71851db 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -538,6 +538,31 @@ class FCDrillArray(FCShapeTool): self.draw_app.app.jump_signal.disconnect() + def on_key(self, key): + key_modifier = QtWidgets.QApplication.keyboardModifiers() + + if key_modifier == QtCore.Qt.ShiftModifier: + mod_key = 'Shift' + elif key_modifier == QtCore.Qt.ControlModifier: + mod_key = 'Control' + else: + mod_key = None + + if mod_key == 'Control': + # Toggle Pad Array Direction + if key == QtCore.Qt.Key_Space: + if self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'X': + self.draw_app.e_ui.slot_array_axis_radio.set_value('Y') + elif self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'Y': + self.draw_app.e_ui.slot_array_axis_radio.set_value('A') + elif self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'A': + self.draw_app.e_ui.slot_array_axis_radio.set_value('X') + + # ## Utility geometry (animated) + self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y)) + elif mod_key is None: + pass + def clean_up(self): self.draw_app.selected = [] self.draw_app.e_ui.tools_table_exc.clearSelection() @@ -740,6 +765,18 @@ class FCSlot(FCShapeTool): self.draw_app.e_ui.slot_frame.hide() self.draw_app.app.jump_signal.disconnect() + def on_key(self, key): + # Toggle Pad Direction + if key == QtCore.Qt.Key_Space: + if self.draw_app.e_ui.slot_axis_radio.get_value() == 'X': + self.draw_app.e_ui.slot_axis_radio.set_value('Y') + elif self.draw_app.e_ui.slot_axis_radio.get_value() == 'Y': + self.draw_app.e_ui.slot_axis_radio.set_value('A') + elif self.draw_app.e_ui.slot_axis_radio.get_value() == 'A': + self.draw_app.e_ui.slot_axis_radio.set_value('X') + # ## Utility geometry (animated) + self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y)) + def clean_up(self): self.draw_app.selected = [] self.draw_app.e_ui.tools_table_exc.clearSelection() @@ -1065,6 +1102,40 @@ class FCSlotArray(FCShapeTool): self.draw_app.e_ui.slot_array_frame.hide() self.draw_app.app.jump_signal.disconnect() + def on_key(self, key): + key_modifier = QtWidgets.QApplication.keyboardModifiers() + + if key_modifier == QtCore.Qt.ShiftModifier: + mod_key = 'Shift' + elif key_modifier == QtCore.Qt.ControlModifier: + mod_key = 'Control' + else: + mod_key = None + + if mod_key == 'Control': + # Toggle Pad Array Direction + if key == QtCore.Qt.Key_Space: + if self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'X': + self.draw_app.e_ui.slot_array_axis_radio.set_value('Y') + elif self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'Y': + self.draw_app.e_ui.slot_array_axis_radio.set_value('A') + elif self.draw_app.e_ui.slot_array_axis_radio.get_value() == 'A': + self.draw_app.e_ui.slot_array_axis_radio.set_value('X') + + # ## Utility geometry (animated) + self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y)) + elif mod_key is None: + # Toggle Pad Direction + if key == QtCore.Qt.Key_Space: + if self.draw_app.e_ui.slot_axis_radio.get_value() == 'X': + self.draw_app.e_ui.slot_axis_radio.set_value('Y') + elif self.draw_app.e_ui.slot_axis_radio.get_value() == 'Y': + self.draw_app.e_ui.slot_axis_radio.set_value('A') + elif self.draw_app.e_ui.slot_axis_radio.get_value() == 'A': + self.draw_app.e_ui.slot_axis_radio.set_value('X') + # ## Utility geometry (animated) + self.draw_app.update_utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y)) + def clean_up(self): self.draw_app.selected = [] self.draw_app.e_ui.tools_table_exc.clearSelection() diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index d7281701..8559c00d 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -3436,6 +3436,16 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key_M or key == 'M': self.app.distance_tool.run() return + + # we do this so we can reuse the following keys while inside a Tool + # the above keys are general enough so were left outside + if self.app.exc_editor.active_tool is not None and self.select_drill_btn.isChecked() is False: + response = self.app.exc_editor.active_tool.on_key(key=key) + if response is not None: + self.app.inform.emit(response) + else: + pass + # SHIFT elif modifiers == QtCore.Qt.ShiftModifier: # Run Distance Minimum Tool @@ -4774,6 +4784,14 @@ class ShortcutsTab(QtWidgets.QWidget): %s  %s + + %s +  %s + + + %s +  %s +     @@ -4804,7 +4822,9 @@ class ShortcutsTab(QtWidgets.QWidget): _('Del'), _("Delete Drill"), _('Del'), _("Alternate: Delete Tool"), _('Esc'), _("Abort and return to Select"), - _('Ctrl+S'), _("Save Object and Exit Editor") + _('Space'), _("Toggle Slot direction"), + _('Ctrl+S'), _("Save Object and Exit Editor"), + _('Ctrl+Space'), _("Toggle Slot Array direction") ) # GERBER EDITOR SHORTCUT LIST