From 970b260333a4a8dc3aeb1ec5e9e6fbf3ebee8774 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 29 Jan 2019 11:59:03 +0200 Subject: [PATCH] - added more shortcut keys in the Geometry Editor and in Excellon Editor; activated also the zoom (fit, in, out) shortcut keys ('1' , '2', '3') for the editors --- FlatCAMEditor.py | 83 +++++++++++++++++++++++++++++++++++++++++++++--- FlatCAMGUI.py | 6 ++-- README.md | 1 + 3 files changed, 82 insertions(+), 8 deletions(-) diff --git a/FlatCAMEditor.py b/FlatCAMEditor.py index e497db5d..fc33e3e4 100644 --- a/FlatCAMEditor.py +++ b/FlatCAMEditor.py @@ -2569,6 +2569,15 @@ class FlatCAMGeoEditor(QtCore.QObject): self.on_tool_select('rotate') self.active_tool.set_origin(self.snap(self.x, self.y)) + if event.key == '1': + self.app.on_zoom_fit(None) + + if event.key == '2': + self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y]) + + if event.key == '3': + self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y]) + # Arc Tool if event.key.name == 'A': self.select_tool('arc') @@ -2584,6 +2593,22 @@ class FlatCAMGeoEditor(QtCore.QObject): self.active_tool.set_origin(self.snap(self.x, self.y)) self.app.inform.emit("Click on target point.") + # Substract Tool + if event.key.name == 'E': + if self.get_selected() is not None: + self.intersection() + else: + msg = "Please select geometry items \n" \ + "on which to perform Intersection Tool." + + messagebox =QtWidgets.QMessageBox() + messagebox.setText(msg) + messagebox.setWindowTitle("Warning") + messagebox.setWindowIcon(QtGui.QIcon('share/warning.png')) + messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.exec_() + # Grid Snap if event.key.name == 'G': self.app.ui.grid_snap_btn.trigger() @@ -2622,14 +2647,42 @@ class FlatCAMGeoEditor(QtCore.QObject): if event.key.name == 'R': self.select_tool('rectangle') - # Select Tool + # Substract Tool if event.key.name == 'S': - self.select_tool('select') + if self.get_selected() is not None: + self.subtract() + else: + msg = "Please select geometry items \n" \ + "on which to perform Substraction Tool." + + messagebox =QtWidgets.QMessageBox() + messagebox.setText(msg) + messagebox.setWindowTitle("Warning") + messagebox.setWindowIcon(QtGui.QIcon('share/warning.png')) + messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.exec_() # Add Text Tool if event.key.name == 'T': self.select_tool('text') + # Substract Tool + if event.key.name == 'U': + if self.get_selected() is not None: + self.union() + else: + msg = "Please select geometry items \n" \ + "on which to perform union." + + messagebox =QtWidgets.QMessageBox() + messagebox.setText(msg) + messagebox.setWindowTitle("Warning") + messagebox.setWindowIcon(QtGui.QIcon('share/warning.png')) + messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.exec_() + # Cut Action Tool if event.key.name == 'X': if self.get_selected() is not None: @@ -2662,11 +2715,15 @@ class FlatCAMGeoEditor(QtCore.QObject): def on_shortcut_list(self): msg = '''Shortcut list in Geometry Editor

+1: Zoom Fit
+2: Zoom Out
+3: Zoom In
A: Add an 'Arc'
B: Add a Buffer Geo
C: Copy Geo Item
+E: Intersection Tool
G: Grid Snap On/Off
-G: Paint Tool
+I: Paint Tool
K: Corner Snap On/Off
M: Move Geo Item

@@ -2674,8 +2731,9 @@ class FlatCAMGeoEditor(QtCore.QObject): O: Add a 'Circle'
P: Add a 'Path'
R: Add an 'Rectangle'
-S: Select Tool Active
+S: Substraction Tool
T: Add Text Geometry
+U: Union Tool

X: Cut Path

@@ -2683,7 +2741,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
Space: Rotate selected Geometry
Enter: Finish Current Action
-Escape: Abort Current Action
+Escape: Select Tool (Exit any other Tool)
Delete: Delete Obj''' helpbox =QtWidgets.QMessageBox() @@ -4756,6 +4814,18 @@ class FlatCAMExcEditor(QtCore.QObject): self.app.inform.emit("[warning_notcl]Cancelled. Nothing selected to delete.") return + if event.key == '1': + self.launched_from_shortcuts = True + self.app.on_zoom_fit(None) + + if event.key == '2': + self.launched_from_shortcuts = True + self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y]) + + if event.key == '3': + self.launched_from_shortcuts = True + self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y]) + # Add Array of Drill Hole Tool if event.key.name == 'A': self.launched_from_shortcuts = True @@ -4840,6 +4910,9 @@ class FlatCAMExcEditor(QtCore.QObject): def on_shortcut_list(self): msg = '''Shortcut list in Geometry Editor

+1: Zoom Fit
+2: Zoom Out
+3: Zoom In
A: Add an 'Drill Array'
C: Copy Drill Hole
D: Add an Drill Hole
diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index 6e6b85ae..2de7edf9 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -294,11 +294,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow): self.geo_editor_menu.addSeparator() self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), 'Add Text\tT') self.geo_editor_menu.addSeparator() - self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union') + self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union\tU') self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'), - 'Polygon Intersection') + 'Polygon Intersection\tE') self.geo_subtract_menuitem = self.geo_editor_menu.addAction( - QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction' + QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction\tS' ) self.geo_editor_menu.addSeparator() self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'), 'Cut Path\tX') diff --git a/README.md b/README.md index c16952f6..6c810bd1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - fixed issue in Tool Calculators when a float value was entered starting only with the dot. - added protection for entering incorrect values in Offset and Scale fields for Gerber and Geometry objects (in Selected Tab) +- added more shortcut keys in the Geometry Editor and in Excellon Editor; activated also the zoom (fit, in, out) shortcut keys ('1' , '2', '3') for the editors 28.01.2018