- moved all shortcut keys handlers from Editors to the keyPressEvent() handler from FLatCAMGUI
This commit is contained in:
parent
2be35e4248
commit
824b1a95ab
358
FlatCAMEditor.py
358
FlatCAMEditor.py
@ -2135,7 +2135,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
|
||||
# but those from FlatCAMGeoEditor
|
||||
|
||||
self.app.plotcanvas.vis_disconnect('key_press', self.app.ui.keyPressEvent)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||
@ -2146,7 +2145,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||
self.canvas.vis_connect('mouse_press', self.on_canvas_click)
|
||||
self.canvas.vis_connect('mouse_move', self.on_canvas_move)
|
||||
self.canvas.vis_connect('mouse_release', self.on_canvas_click_release)
|
||||
self.canvas.vis_connect('key_press', self.on_canvas_key)
|
||||
|
||||
|
||||
def disconnect_canvas_event_handlers(self):
|
||||
@ -2154,11 +2152,8 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||
self.canvas.vis_disconnect('mouse_press', self.on_canvas_click)
|
||||
self.canvas.vis_disconnect('mouse_move', self.on_canvas_move)
|
||||
self.canvas.vis_disconnect('mouse_release', self.on_canvas_click_release)
|
||||
self.canvas.vis_disconnect('key_press', self.on_canvas_key)
|
||||
|
||||
|
||||
# we restore the key and mouse control to FlatCAMApp method
|
||||
self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
|
||||
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||
self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||
self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||
@ -2572,211 +2567,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
|
||||
|
||||
self.tool_shape.redraw()
|
||||
|
||||
def on_canvas_key(self, event):
|
||||
"""
|
||||
event.key has the key.
|
||||
|
||||
:param event:
|
||||
:return:
|
||||
"""
|
||||
self.key = event.key.name
|
||||
self.geo_key_modifiers = QtWidgets.QApplication.keyboardModifiers()
|
||||
|
||||
if self.geo_key_modifiers == Qt.ControlModifier:
|
||||
# save (update) the current geometry and return to the App
|
||||
if self.key == 'S':
|
||||
self.app.editor2object()
|
||||
return
|
||||
|
||||
# toggle the measurement tool
|
||||
if self.key == 'M':
|
||||
self.app.measurement_tool.run()
|
||||
return
|
||||
|
||||
# Finish the current action. Use with tools that do not
|
||||
# complete automatically, like a polygon or path.
|
||||
if event.key.name == 'Enter':
|
||||
if isinstance(self.active_tool, FCShapeTool):
|
||||
self.active_tool.click(self.snap(self.x, self.y))
|
||||
self.active_tool.make()
|
||||
if self.active_tool.complete:
|
||||
self.on_shape_complete()
|
||||
self.app.inform.emit("[success]Done.")
|
||||
# automatically make the selection tool active after completing current action
|
||||
self.select_tool('select')
|
||||
return
|
||||
|
||||
# Abort the current action
|
||||
if event.key.name == 'Escape':
|
||||
# TODO: ...?
|
||||
# self.on_tool_select("select")
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
|
||||
|
||||
self.delete_utility_geometry()
|
||||
|
||||
self.replot()
|
||||
# self.select_btn.setChecked(True)
|
||||
# self.on_tool_select('select')
|
||||
self.select_tool('select')
|
||||
return
|
||||
|
||||
# Delete selected object
|
||||
if event.key.name == 'Delete':
|
||||
self.delete_selected()
|
||||
self.replot()
|
||||
|
||||
# Move
|
||||
if event.key.name == 'Space':
|
||||
self.app.ui.geo_rotate_btn.setChecked(True)
|
||||
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')
|
||||
|
||||
# Buffer
|
||||
if event.key.name == 'B':
|
||||
self.select_tool('buffer')
|
||||
|
||||
# Copy
|
||||
if event.key.name == 'C':
|
||||
self.app.ui.geo_copy_btn.setChecked(True)
|
||||
self.on_tool_select('copy')
|
||||
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()
|
||||
|
||||
# make sure that the cursor shape is enabled/disabled, too
|
||||
if self.options['grid_snap'] is True:
|
||||
self.app.app_cursor.enabled = True
|
||||
else:
|
||||
self.app.app_cursor.enabled = False
|
||||
|
||||
# Paint
|
||||
if event.key.name == 'I':
|
||||
self.select_tool('paint')
|
||||
|
||||
# Corner Snap
|
||||
if event.key.name == 'K':
|
||||
self.on_corner_snap()
|
||||
|
||||
# Move
|
||||
if event.key.name == 'M':
|
||||
self.on_move_click()
|
||||
|
||||
# Polygon Tool
|
||||
if event.key.name == 'N':
|
||||
self.select_tool('polygon')
|
||||
|
||||
# Circle Tool
|
||||
if event.key.name == 'O':
|
||||
self.select_tool('circle')
|
||||
|
||||
# Path Tool
|
||||
if event.key.name == 'P':
|
||||
self.select_tool('path')
|
||||
|
||||
# Rectangle Tool
|
||||
if event.key.name == 'R':
|
||||
self.select_tool('rectangle')
|
||||
|
||||
# Substract Tool
|
||||
if event.key.name == 'S':
|
||||
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:
|
||||
self.cutpath()
|
||||
else:
|
||||
msg = 'Please first select a geometry item to be cutted\n' \
|
||||
'then select the geometry item that will be cutted\n' \
|
||||
'out of the first item. In the end press ~X~ key or\n' \
|
||||
'the toolbar button.' \
|
||||
|
||||
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_()
|
||||
|
||||
# Propagate to tool
|
||||
response = None
|
||||
if self.active_tool is not None:
|
||||
response = self.active_tool.on_key(event.key)
|
||||
if response is not None:
|
||||
self.app.inform.emit(response)
|
||||
|
||||
# Show Shortcut list
|
||||
if event.key.name == '`':
|
||||
self.app.on_shortcut_list()
|
||||
|
||||
def on_canvas_key_release(self, event):
|
||||
self.key = None
|
||||
|
||||
def on_delete_btn(self):
|
||||
self.delete_selected()
|
||||
self.replot()
|
||||
@ -4277,34 +4067,27 @@ class FlatCAMExcEditor(QtCore.QObject):
|
||||
|
||||
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
|
||||
# but those from FlatCAMGeoEditor
|
||||
self.app.plotcanvas.vis_disconnect('key_press', self.app.ui.keyPressEvent)
|
||||
|
||||
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||
self.app.plotcanvas.vis_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
|
||||
self.app.collection.view.keyPressed.disconnect()
|
||||
self.app.collection.view.clicked.disconnect()
|
||||
|
||||
self.canvas.vis_connect('mouse_press', self.on_canvas_click)
|
||||
self.canvas.vis_connect('mouse_move', self.on_canvas_move)
|
||||
self.canvas.vis_connect('mouse_release', self.on_canvas_click_release)
|
||||
self.canvas.vis_connect('key_press', self.on_canvas_key)
|
||||
|
||||
|
||||
def disconnect_canvas_event_handlers(self):
|
||||
self.canvas.vis_disconnect('mouse_press', self.on_canvas_click)
|
||||
self.canvas.vis_disconnect('mouse_move', self.on_canvas_move)
|
||||
self.canvas.vis_disconnect('mouse_release', self.on_canvas_click_release)
|
||||
self.canvas.vis_disconnect('key_press', self.on_canvas_key)
|
||||
self.canvas.vis_disconnect('key_release', self.on_canvas_key_release)
|
||||
|
||||
# we restore the key and mouse control to FlatCAMApp method
|
||||
self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
|
||||
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||
self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||
self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||
self.app.plotcanvas.vis_connect('mouse_double_click', self.app.on_double_click_over_plot)
|
||||
|
||||
self.app.collection.view.clicked.connect(self.app.collection.on_mouse_down)
|
||||
|
||||
def clear(self):
|
||||
@ -4870,145 +4653,6 @@ class FlatCAMExcEditor(QtCore.QObject):
|
||||
# Update cursor
|
||||
self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color='black', size=20)
|
||||
|
||||
|
||||
def on_canvas_key(self, event):
|
||||
"""
|
||||
event.key has the key.
|
||||
|
||||
:param event:
|
||||
:return:
|
||||
"""
|
||||
self.key = event.key.name
|
||||
self.modifiers = QtWidgets.QApplication.keyboardModifiers()
|
||||
|
||||
if self.modifiers == Qt.ControlModifier:
|
||||
# save (update) the current geometry and return to the App
|
||||
if self.key == 'S':
|
||||
self.app.editor2object()
|
||||
return
|
||||
|
||||
# toggle the measurement tool
|
||||
if self.key == 'M':
|
||||
self.app.measurement_tool.run()
|
||||
return
|
||||
|
||||
# Abort the current action
|
||||
if event.key.name == 'Escape':
|
||||
# TODO: ...?
|
||||
# self.on_tool_select("select")
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
|
||||
|
||||
self.delete_utility_geometry()
|
||||
|
||||
self.replot()
|
||||
# self.select_btn.setChecked(True)
|
||||
# self.on_tool_select('select')
|
||||
self.select_tool('select')
|
||||
return
|
||||
|
||||
# Delete selected object
|
||||
if event.key.name == 'Delete':
|
||||
self.launched_from_shortcuts = True
|
||||
if self.selected:
|
||||
self.delete_selected()
|
||||
self.replot()
|
||||
else:
|
||||
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
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.add_drill_array_btn.setChecked(True)
|
||||
self.select_tool('add_array')
|
||||
return
|
||||
|
||||
# Copy
|
||||
if event.key.name == 'C':
|
||||
self.launched_from_shortcuts = True
|
||||
if self.selected:
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.copy_drill_btn.setChecked(True)
|
||||
self.on_tool_select('copy')
|
||||
self.active_tool.set_origin((self.snap_x, self.snap_y))
|
||||
else:
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to copy.")
|
||||
return
|
||||
|
||||
# Add Drill Hole Tool
|
||||
if event.key.name == 'D':
|
||||
self.launched_from_shortcuts = True
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.add_drill_btn.setChecked(True)
|
||||
self.select_tool('add')
|
||||
return
|
||||
|
||||
# Grid Snap
|
||||
if event.key.name == 'G':
|
||||
self.launched_from_shortcuts = True
|
||||
# make sure that the cursor shape is enabled/disabled, too
|
||||
if self.options['grid_snap'] is True:
|
||||
self.app.app_cursor.enabled = False
|
||||
else:
|
||||
self.app.app_cursor.enabled = True
|
||||
self.app.ui.grid_snap_btn.trigger()
|
||||
return
|
||||
|
||||
# Corner Snap
|
||||
if event.key.name == 'K':
|
||||
self.launched_from_shortcuts = True
|
||||
self.app.ui.corner_snap_btn.trigger()
|
||||
return
|
||||
|
||||
# Move
|
||||
if event.key.name == 'M':
|
||||
self.launched_from_shortcuts = True
|
||||
if self.selected:
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.move_drill_btn.setChecked(True)
|
||||
self.on_tool_select('move')
|
||||
self.active_tool.set_origin((self.snap_x, self.snap_y))
|
||||
else:
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to move.")
|
||||
return
|
||||
|
||||
# Resize Tool
|
||||
if event.key.name == 'R':
|
||||
self.launched_from_shortcuts = True
|
||||
self.select_tool('resize')
|
||||
return
|
||||
|
||||
# Select Tool
|
||||
if event.key.name == 'S':
|
||||
self.launched_from_shortcuts = True
|
||||
self.select_tool('select')
|
||||
return
|
||||
|
||||
# Propagate to tool
|
||||
response = None
|
||||
if self.active_tool is not None:
|
||||
response = self.active_tool.on_key(event.key)
|
||||
if response is not None:
|
||||
self.app.inform.emit(response)
|
||||
|
||||
# Show Shortcut list
|
||||
if event.key.name == '`':
|
||||
self.app.on_shortcut_list()
|
||||
return
|
||||
|
||||
def on_canvas_key_release(self, event):
|
||||
self.key = None
|
||||
|
||||
|
331
FlatCAMGUI.py
331
FlatCAMGUI.py
@ -12,6 +12,8 @@ from GUIElements import *
|
||||
import platform
|
||||
import webbrowser
|
||||
|
||||
from FlatCAMEditor import FCShapeTool
|
||||
|
||||
|
||||
class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
# Emitted when persistent window geometry needs to be retained
|
||||
@ -1522,7 +1524,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
# events from Vispy are of type KeyEvent
|
||||
else:
|
||||
key = event.key
|
||||
|
||||
if self.app.call_source == 'app':
|
||||
if modifiers == QtCore.Qt.ControlModifier:
|
||||
if key == QtCore.Qt.Key_A:
|
||||
self.app.on_selectall()
|
||||
@ -1782,6 +1784,333 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
self.app.on_toggle_notebook()
|
||||
|
||||
return
|
||||
elif self.app.call_source == 'geo_editor':
|
||||
if modifiers == QtCore.Qt.ControlModifier:
|
||||
# save (update) the current geometry and return to the App
|
||||
if key == QtCore.Qt.Key_S or key == 'S':
|
||||
self.app.editor2object()
|
||||
return
|
||||
|
||||
# toggle the measurement tool
|
||||
if key == QtCore.Qt.Key_M or key == 'M':
|
||||
self.app.measurement_tool.run()
|
||||
return
|
||||
|
||||
elif modifiers == QtCore.Qt.ShiftModifier:
|
||||
pass
|
||||
elif modifiers == QtCore.Qt.AltModifier:
|
||||
pass
|
||||
else:
|
||||
# Finish the current action. Use with tools that do not
|
||||
# complete automatically, like a polygon or path.
|
||||
if key == QtCore.Qt.Key_Enter or key == 'Enter':
|
||||
if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
|
||||
self.app.geo_editor.active_tool.click(
|
||||
self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
|
||||
self.app.geo_editor.active_tool.make()
|
||||
if self.app.geo_editor.active_tool.complete:
|
||||
self.app.geo_editor.on_shape_complete()
|
||||
self.app.inform.emit("[success]Done.")
|
||||
# automatically make the selection tool active after completing current action
|
||||
self.app.geo_editor.select_tool('select')
|
||||
return
|
||||
|
||||
# Abort the current action
|
||||
if key == QtCore.Qt.Key_Escape or key == 'Escape':
|
||||
# TODO: ...?
|
||||
# self.on_tool_select("select")
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
|
||||
|
||||
self.app.geo_editor.delete_utility_geometry()
|
||||
self.app.geo_editor.replot()
|
||||
# self.select_btn.setChecked(True)
|
||||
# self.on_tool_select('select')
|
||||
self.app.geo_editor.select_tool('select')
|
||||
return
|
||||
|
||||
# Delete selected object
|
||||
if key == QtCore.Qt.Key_Delete or key == 'Delete':
|
||||
self.app.geo_editor.delete_selected()
|
||||
self.app.geo_editor.replot()
|
||||
|
||||
# Move
|
||||
if key == QtCore.Qt.Key_Space or key == 'Space':
|
||||
self.app.ui.geo_rotate_btn.setChecked(True)
|
||||
self.app.geo_editor.on_tool_select('rotate')
|
||||
self.app.geo_editor.active_tool.set_origin(
|
||||
self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
|
||||
|
||||
if key == QtCore.Qt.Key_1 or key== '1':
|
||||
self.app.on_zoom_fit(None)
|
||||
|
||||
if key == QtCore.Qt.Key_2 or key == '2':
|
||||
self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y])
|
||||
|
||||
if key == QtCore.Qt.Key_3 or key == '3':
|
||||
self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y])
|
||||
|
||||
# Arc Tool
|
||||
if key == QtCore.Qt.Key_A or key == 'A':
|
||||
self.app.geo_editor.select_tool('arc')
|
||||
|
||||
# Buffer
|
||||
if key == QtCore.Qt.Key_B or key == 'B':
|
||||
self.app.geo_editor.select_tool('buffer')
|
||||
|
||||
# Copy
|
||||
if key == QtCore.Qt.Key_C or key == 'C':
|
||||
self.app.ui.geo_copy_btn.setChecked(True)
|
||||
self.app.geo_editor.on_tool_select('copy')
|
||||
self.app.geo_editor.active_tool.set_origin(self.snap(self.x, self.y))
|
||||
self.app.inform.emit("Click on target point.")
|
||||
|
||||
# Substract Tool
|
||||
if key == QtCore.Qt.Key_E or key == 'E':
|
||||
if self.app.geo_editor.get_selected() is not None:
|
||||
self.app.geo_editor.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 key == QtCore.Qt.Key_G or key == 'G':
|
||||
self.app.ui.grid_snap_btn.trigger()
|
||||
|
||||
# make sure that the cursor shape is enabled/disabled, too
|
||||
if self.app.geo_editor.options['grid_snap'] is True:
|
||||
self.app.app_cursor.enabled = True
|
||||
else:
|
||||
self.app.app_cursor.enabled = False
|
||||
|
||||
# Paint
|
||||
if key == QtCore.Qt.Key_I or key == 'I':
|
||||
self.app.geo_editor.select_tool('paint')
|
||||
|
||||
# Corner Snap
|
||||
if key == QtCore.Qt.Key_K or key == 'K':
|
||||
self.app.geo_editor.on_corner_snap()
|
||||
|
||||
# Move
|
||||
if key == QtCore.Qt.Key_M or key == 'M':
|
||||
self.app.geo_editor.on_move_click()
|
||||
|
||||
# Polygon Tool
|
||||
if key == QtCore.Qt.Key_N or key == 'N':
|
||||
self.app.geo_editor.select_tool('polygon')
|
||||
|
||||
# Circle Tool
|
||||
if key == QtCore.Qt.Key_O or key == 'O':
|
||||
self.app.geo_editor.select_tool('circle')
|
||||
|
||||
# Path Tool
|
||||
if key == QtCore.Qt.Key_P or key == 'P':
|
||||
self.app.geo_editor.select_tool('path')
|
||||
|
||||
# Rectangle Tool
|
||||
if key == QtCore.Qt.Key_R or key == 'R':
|
||||
self.app.geo_editor.select_tool('rectangle')
|
||||
|
||||
# Substract Tool
|
||||
if key == QtCore.Qt.Key_S or key == 'S':
|
||||
if self.app.geo_editor.get_selected() is not None:
|
||||
self.app.geo_editor.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 key == QtCore.Qt.Key_T or key == 'T':
|
||||
self.app.geo_editor.select_tool('text')
|
||||
|
||||
# Substract Tool
|
||||
if key == QtCore.Qt.Key_U or key == 'U':
|
||||
if self.app.geo_editor.get_selected() is not None:
|
||||
self.app.geo_editor.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 key == QtCore.Qt.Key_X or key == 'X':
|
||||
if self.app.geo_editor.get_selected() is not None:
|
||||
self.app.geo_editor.cutpath()
|
||||
else:
|
||||
msg = 'Please first select a geometry item to be cutted\n' \
|
||||
'then select the geometry item that will be cutted\n' \
|
||||
'out of the first item. In the end press ~X~ key or\n' \
|
||||
'the toolbar button.' \
|
||||
|
||||
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_()
|
||||
|
||||
# Propagate to tool
|
||||
response = None
|
||||
if self.app.geo_editor.active_tool is not None:
|
||||
response = self.app.geo_editor.active_tool.on_key(event.key)
|
||||
if response is not None:
|
||||
self.app.inform.emit(response)
|
||||
|
||||
# Show Shortcut list
|
||||
if key == 'F3':
|
||||
self.app.on_shortcut_list()
|
||||
|
||||
elif self.app.call_source == 'exc_editor':
|
||||
if modifiers == QtCore.Qt.ControlModifier:
|
||||
# save (update) the current geometry and return to the App
|
||||
if key == QtCore.Qt.Key_S or key == 'S':
|
||||
self.app.editor2object()
|
||||
return
|
||||
|
||||
# toggle the measurement tool
|
||||
if key == QtCore.Qt.Key_M or key == 'M':
|
||||
self.app.measurement_tool.run()
|
||||
return
|
||||
|
||||
elif modifiers == QtCore.Qt.ShiftModifier:
|
||||
pass
|
||||
elif modifiers == QtCore.Qt.AltModifier:
|
||||
pass
|
||||
else:
|
||||
# Abort the current action
|
||||
if key == QtCore.Qt.Key_Escape or key == 'Escape':
|
||||
# TODO: ...?
|
||||
# self.on_tool_select("select")
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
|
||||
|
||||
self.app.exc_editor.delete_utility_geometry()
|
||||
|
||||
self.app.exc_editor.replot()
|
||||
# self.select_btn.setChecked(True)
|
||||
# self.on_tool_select('select')
|
||||
self.app.exc_editor.select_tool('select')
|
||||
return
|
||||
|
||||
# Delete selected object
|
||||
if key == QtCore.Qt.Key_Delete or key == 'Delete':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
if self.app.exc_editor.selected:
|
||||
self.app.exc_editor.delete_selected()
|
||||
self.app.exc_editor.replot()
|
||||
else:
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to delete.")
|
||||
return
|
||||
|
||||
if key == QtCore.Qt.Key_1 or key == '1':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.on_zoom_fit(None)
|
||||
|
||||
if key == QtCore.Qt.Key_2 or key == '2':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], [self.snap_x, self.snap_y])
|
||||
|
||||
if key == QtCore.Qt.Key_3 or key == '3':
|
||||
self.app.exc_editor.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 key == QtCore.Qt.Key_A or key == 'A':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.add_drill_array_btn.setChecked(True)
|
||||
self.app.exc_editor.select_tool('add_array')
|
||||
return
|
||||
|
||||
# Copy
|
||||
if key == QtCore.Qt.Key_C or key == 'C':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
if self.app.exc_editor.selected:
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.copy_drill_btn.setChecked(True)
|
||||
self.app.exc_editor.on_tool_select('copy')
|
||||
self.app.exc_editor.active_tool.set_origin(
|
||||
(self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
|
||||
else:
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to copy.")
|
||||
return
|
||||
|
||||
# Add Drill Hole Tool
|
||||
if key == QtCore.Qt.Key_D or key == 'D':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.add_drill_btn.setChecked(True)
|
||||
self.app.exc_editor.select_tool('add')
|
||||
return
|
||||
|
||||
# Grid Snap
|
||||
if key == QtCore.Qt.Key_G or key == 'G':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
# make sure that the cursor shape is enabled/disabled, too
|
||||
if self.app.exc_editor.options['grid_snap'] is True:
|
||||
self.app.app_cursor.enabled = False
|
||||
else:
|
||||
self.app.app_cursor.enabled = True
|
||||
self.app.ui.grid_snap_btn.trigger()
|
||||
return
|
||||
|
||||
# Corner Snap
|
||||
if key == QtCore.Qt.Key_K or key == 'K':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.ui.corner_snap_btn.trigger()
|
||||
return
|
||||
|
||||
# Move
|
||||
if key == QtCore.Qt.Key_M or key == 'M':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
if self.app.exc_editor.selected:
|
||||
self.app.inform.emit("Click on target point.")
|
||||
self.app.ui.move_drill_btn.setChecked(True)
|
||||
self.app.exc_editor.on_tool_select('move')
|
||||
self.app.exc_editor.active_tool.set_origin((self.snap_x, self.snap_y))
|
||||
else:
|
||||
self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to move.")
|
||||
return
|
||||
|
||||
# Resize Tool
|
||||
if key == QtCore.Qt.Key_R or key == 'R':
|
||||
self.app.exc_editor.launched_from_shortcuts = True
|
||||
self.app.exc_editor.select_tool('resize')
|
||||
return
|
||||
|
||||
# Propagate to tool
|
||||
response = None
|
||||
if self.app.exc_editor.active_tool is not None:
|
||||
response = self.app.exc_editor.active_tool.on_key(event.key)
|
||||
if response is not None:
|
||||
self.app.inform.emit(response)
|
||||
|
||||
# Show Shortcut list
|
||||
if key == QtCore.Qt.Key_F3 or key == 'F3':
|
||||
self.app.on_shortcut_list()
|
||||
return
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if event.mimeData().hasUrls:
|
||||
|
@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||
- changed the menu entry Toggle Grid name to Toggle Grid Snap
|
||||
- fixed errors in Toggle Axis
|
||||
- fixed error with shortcut key triggering twice the keyPressEvent when in the Project List View
|
||||
- moved all shortcut keys handlers from Editors to the keyPressEvent() handler from FLatCAMGUI
|
||||
|
||||
7.02.2019
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user