Continuing the discussion from How to precisely rotate 3D view using shortcut:
After some searching around the forum, I found a way to do it making a shortcut key i j k l for pitch up down and yaw left and right with increment 1 degree for each button press by using this code snippet in the .slicerrc.py file
Will leave this here for future reference and anybody who have the same problem
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
threeDView.setPitchRollYawIncrement(1)
def step_direction(direction = 'left'):
if direction == 'left':
threeDView.yawDirection = threeDView.YawLeft
threeDView.yaw()
if direction == 'right':
threeDView.yawDirection = threeDView.YawRight
threeDView.yaw()
if direction == 'up':
threeDView.pitchDirection = threeDView.PitchUp
threeDView.pitch()
if direction == 'down':
threeDView.pitchDirection = threeDView.PitchDown
threeDView.pitch()
shortcuts = [
("j", lambda: step_direction('left')),
("l", lambda: step_direction('right')),
("i", lambda: step_direction('up')),
("k", lambda: step_direction('down'))
]
for (shortcutKey, callback) in shortcuts:
shortcut = qt.QShortcut(slicer.util.mainWindow())
shortcut.setKey(qt.QKeySequence(shortcutKey))
shortcut.connect( "activated()", callback)