- Editors: activated an old function that was no longer active: each tool can have it's own set of shortcut keys, the Editor general shortcut keys that are letters are overridden

- Gerber and Geometry editors, when using the Backspace keys for certain tools, they will backtrack one point but now the utility geometry is immediately updated
This commit is contained in:
Marius Stanciu 2019-04-14 02:10:31 +03:00
parent 4100e98ebe
commit 081231aca4
4 changed files with 264 additions and 240 deletions

View File

@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
- Gerber Editor: Remade the processing of 'clear_geometry' (geometry generated by polygons made with Gerber LPC command) to work if more than one such polygon exists
- Gerber Editor: a disabled/enabled sequence for the VisPy cursor on Gerber edit make the graphics better
- Editors: activated an old function that was no longer active: each tool can have it's own set of shortcut keys, the Editor general shortcut keys that are letters are overridden
- Gerber and Geometry editors, when using the Backspace keys for certain tools, they will backtrack one point but now the utility geometry is immediately updated
13.04.2019

View File

@ -2003,18 +2003,18 @@ class FCArc(FCShapeTool):
return ""
def on_key(self, key):
if key == 'o':
if key == 'D' or key == QtCore.Qt.Key_D:
self.direction = 'cw' if self.direction == 'ccw' else 'ccw'
return 'Direction: ' + self.direction.upper()
return _('Direction: %s') % self.direction.upper()
if key == 'p':
if key == 'M' or key == QtCore.Qt.Key_M:
if self.mode == 'c12':
self.mode = '12c'
elif self.mode == '12c':
self.mode = '132'
else:
self.mode = 'c12'
return 'Mode: ' + self.mode
return _('Mode: %s') % self.mode
def utility_geometry(self, data=None):
if len(self.points) == 1: # Show the radius
@ -2233,9 +2233,14 @@ class FCPolygon(FCShapeTool):
self.draw_app.app.inform.emit(_("[success] Done. Polygon completed."))
def on_key(self, key):
if key == 'backspace':
if key == 'Backspace' or key == QtCore.Qt.Key_Backspace:
if len(self.points) > 0:
self.points = self.points[0:-1]
# Remove any previous utility shape
self.draw_app.tool_shape.clear(update=False)
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
self.draw_app.draw_utility_geometry(geo=geo)
return _("Backtracked one point ...")
class FCPath(FCPolygon):
@ -2260,9 +2265,14 @@ class FCPath(FCPolygon):
return None
def on_key(self, key):
if key == 'backspace':
if key == 'Backspace' or key == QtCore.Qt.Key_Backspace:
if len(self.points) > 0:
self.points = self.points[0:-1]
# Remove any previous utility shape
self.draw_app.tool_shape.clear(update=False)
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
self.draw_app.draw_utility_geometry(geo=geo)
return _("Backtracked one point ...")
class FCSelect(DrawTool):

View File

@ -527,9 +527,14 @@ class FCRegion(FCShapeTool):
self.draw_app.plot_all()
def on_key(self, key):
if key == 'backspace':
if key == 'Backspace' or key == QtCore.Qt.Key_Backspace:
if len(self.points) > 0:
self.points = self.points[0:-1]
# Remove any previous utility shape
self.draw_app.tool_shape.clear(update=False)
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
self.draw_app.draw_utility_geometry(geo=geo)
return _("Backtracked one point ...")
class FCTrack(FCRegion):
@ -560,9 +565,14 @@ class FCTrack(FCRegion):
return None
def on_key(self, key):
if key == 'backspace':
if key == 'Backspace' or key == QtCore.Qt.Key_Backspace:
if len(self.points) > 0:
self.points = self.points[0:-1]
# Remove any previous utility shape
self.draw_app.tool_shape.clear(update=False)
geo = self.utility_geometry(data=(self.draw_app.snap_x, self.draw_app.snap_y))
self.draw_app.draw_utility_geometry(geo=geo)
return _("Backtracked one point ...")
class FCScale(FCShapeTool):

View File

@ -1952,6 +1952,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# events from Vispy are of type KeyEvent
else:
key = event.key
# Propagate to tool
response = None
if self.app.call_source == 'app':
if modifiers == QtCore.Qt.ControlModifier:
if key == QtCore.Qt.Key_A:
@ -2380,6 +2384,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key_3 or key == '3':
self.app.on_select_tab('tool')
if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() == False:
response = self.app.geo_editor.active_tool.on_key(key=key)
if response is not None:
self.app.inform.emit(response)
else:
# Arc Tool
if key == QtCore.Qt.Key_A or key == 'A':
self.app.geo_editor.select_tool('arc')
@ -2500,13 +2509,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.app.geo_editor.transform_tool.on_flipy()
return
# Propagate to tool
response = None
if self.app.geo_editor.active_tool is not None:
response = self.app.geo_editor.active_tool.on_key(key=key)
if response is not None:
self.app.inform.emit(response)
# Show Shortcut list
if key == 'F3':
self.app.on_shortcut_list()
@ -2599,6 +2601,13 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.app.on_select_tab('tool')
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.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() == False:
response = self.app.grb_editor.active_tool.on_key(key=key)
if response is not None:
self.app.inform.emit(response)
else:
# Add Array of pads
if key == QtCore.Qt.Key_A or key == 'A':
self.app.grb_editor.launched_from_shortcuts = True
@ -2701,13 +2710,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.app.on_zoom_fit(None)
return
# Propagate to tool
response = None
if self.app.grb_editor.active_tool is not None:
response = self.app.grb_editor.active_tool.on_key(key=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()