Commit 61eaa9a3 authored by sumpfralle's avatar sumpfralle

added keyboard shortcuts for moving and rotating the 3d view

changed "lightning" shortcut from "l" to "i" (to allow vi-like navigation)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@524 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 50e2f2ba
...@@ -7,6 +7,7 @@ Version 0.3.0 - UNRELEASED ...@@ -7,6 +7,7 @@ Version 0.3.0 - UNRELEASED
* allow non-square profiles for the support grid * allow non-square profiles for the support grid
* added ability to create support grids with different x/y grid distance * added ability to create support grids with different x/y grid distance
* added x/y offsets to support grid options * added x/y offsets to support grid options
* added 3D view movement and rotation with a keyboard in addition to the mouse
* switched default tool size from radius to diameter * switched default tool size from radius to diameter
* fixed performance issue when using a support grid * fixed performance issue when using a support grid
* fixed empty toolpath after transforming the model * fixed empty toolpath after transforming the model
......
...@@ -320,11 +320,29 @@ class ModelViewWindowGL: ...@@ -320,11 +320,29 @@ class ModelViewWindowGL:
get_state = getattr(event, "get_state") get_state = getattr(event, "get_state")
except AttributeError: except AttributeError:
return return
if not (0 <= keyval <= 255): # define arrow keys and "vi"-like navigation keys
# e.g. "shift" key move_keys_dict = {
return gtk.keysyms.Left: (1, 0),
if chr(keyval) in ('l', 'm', 's'): gtk.keysyms.Down: (0, -1),
if (chr(keyval) == 'l'): gtk.keysyms.Up: (0, 1),
gtk.keysyms.Right: (-1, 0),
ord("h"): (1, 0),
ord("j"): (0, -1),
ord("k"): (0, 1),
ord("l"): (-1, 0),
ord("H"): (1, 0),
ord("J"): (0, -1),
ord("K"): (0, 1),
ord("L"): (-1, 0),
}
def get_char(value):
# avoid exceptions
if 0 <= value <= 255:
return chr(value)
else:
return None
if get_char(keyval) in ('i', 'm', 's'):
if (chr(keyval) == 'i'):
key = "view_light" key = "view_light"
elif (chr(keyval) == 'm'): elif (chr(keyval) == 'm'):
key = "view_polygon" key = "view_polygon"
...@@ -337,7 +355,37 @@ class ModelViewWindowGL: ...@@ -337,7 +355,37 @@ class ModelViewWindowGL:
# re-init gl settings # re-init gl settings
self.glsetup() self.glsetup()
self.paint() self.paint()
elif get_char(keyval) in ("+", "-"):
if chr(keyval) == "+":
scale = 0.8
else:
scale = 1.25
self.camera.scale_distance(scale)
self._paint_ignore_busy()
elif keyval in move_keys_dict.keys():
move_x, move_y = move_keys_dict[keyval]
if get_state() == gtk.gdk.SHIFT_MASK:
# shift key pressed -> rotation
base = 0
factor = 10
self.camera.rotate_camera_by_screen(base, base,
base - factor * move_x, base - factor * move_y)
else:
# no shift key -> moving
obj_dim = []
obj_dim.append(self.settings.get("maxx") \
- self.settings.get("minx"))
obj_dim.append(self.settings.get("maxy") \
- self.settings.get("miny"))
obj_dim.append(self.settings.get("maxz") \
- self.settings.get("minz"))
max_dim = max(obj_dim)
factor = 50
self.camera.move_camera_by_screen(move_x * factor,
move_y * factor, max_dim)
self._paint_ignore_busy()
else: else:
# see dir(gtk.keysyms)
#print "Key pressed: %s (%s)" % (chr(keyval), get_state()) #print "Key pressed: %s (%s)" % (chr(keyval), get_state())
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment