Przeglądaj źródła

- in the Excellon Editor, added shortcut keys Space and Ctrl+Space for toggling the direction of the Slots, respectively for the Array of Slots

Marius Stanciu 5 lat temu
rodzic
commit
2536bd6a7d
3 zmienionych plików z 93 dodań i 1 usunięć
  1. 1 0
      CHANGELOG.md
  2. 71 0
      appEditors/AppExcEditor.py
  3. 21 1
      appGUI/MainGUI.py

+ 1 - 0
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
 

+ 71 - 0
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()

+ 21 - 1
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):
                     <td height="20"><strong>%s</strong></td>
                     <td>&nbsp;%s</td>
                 </tr>
+                <tr height="20">
+                    <td height="20"><strong>%s</strong></td>
+                    <td>&nbsp;%s</td>
+                </tr>
+                <tr height="20">
+                    <td height="20"><strong>%s</strong></td>
+                    <td>&nbsp;%s</td>
+                </tr>
                 <tr height="20">
                     <td height="20">&nbsp;</td>
                     <td>&nbsp;</td>
@@ -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