KeyboardAction
with their default accelerator keys.
KeyboardAction |
Key | Description | Associated function |
DRAW_AXIS | A | Toggles the display of the world axis | QGLViewer::toggleDrawAxis() |
DRAW_GRID | G | Toggles the display of the XY grid | QGLViewer::toggleDrawGrid() |
DISPLAY_FPS | F | Toggles the display of the frame rate | QGLViewer::toggleDisplayFPS() |
ENABLE_TEXT | ? | Toggles the display of all the text | QGLViewer::toggleEnableText() |
STEREO | S | Toggles the stereo display | QGLViewer::toggleStereoDisplay() |
HELP | H | Displays a help window | QGLViewer::help() |
EXIT | Escape | Quits the application | qApp->quit |
CAMERA_MODE | Space | Switches between the FLY and REVOLVE camera mode | camera()->toggleMode() |
ANIMATION | Return | Starts/stops the animation loop | QGLViewer::toggleAnimationMode() |
SAVE_SCREENSHOT | Ctrl+S | Opens the save screenshot dialog box | QGLViewer::saveSnapshot() |
FULL_SCREEN | Alt+Return | Toggles the full screen mode | QGLViewer::toggleFullScreen() |
EDIT_CAMERA_PATHS | C | Toggles the camera key frame path editor | toggleCameraPathEditor() |
DISPLAY_Z_BUFFER | Z | Toggles z-buffer display | QGLViewer::toggleDisplayZBuffer() |
INCREASE_FLYSPEED DECREASE_FLYSPEED |
+ / - | Increases or decreases the camera fly speed. | camera()->setFlySpeed() |
MOVE_CAMERA_LEFT MOVE_CAMERA_RIGHT MOVE_CAMERA_UP MOVE_CAMERA_DOWN |
Left, right up and down arrow keys |
Moves the camera, parallel to the screen. Displacement amplitude is proportionnal to flySpeed() |
camera()->frame()->translate(...) |
See setKeyFrameKey() andsetPlayKeyFramePathStateKey() |
F1...F12 | Plays/Pauses camera key frame path (if defined) Reset the path when Fx is quickly press twice. |
camera()->playKeyFramePath(i) camera()->resetKeyFramePath(i) |
See setKeyFrameKey() andsetAddKeyFrameStateKey() |
Alt+(F1...F12) | Defines a new camera key frame for path 1..12. Deletes the path when Fx is quickly press twice. |
camera()->addKeyFrame(i) camera()->deleteKeyFrame(i) |
Use QGLViewer::setKeyboardAccelerator(Action, Key)
to redefine one of these default
accelerators (probably in your init()
function). Action
is defined by the
KeyboardAction
enum, described in the above table, while Key
is provided as a
QKeySequence
. Setting 0
as the accelerator key value disables the
associated KeyboardAction
:
void Viewer::init() { // Alt+M toggles camera mode setKeyboardAccelerator(CAMERA_MODE, ALT+Key_M); // Press 'Q' to exit application setKeyboardAccelerator(EXIT, Key_Q); // Key sequences can also be given, using QString setKeyboardAccelerator(SAVE_SCREENSHOT, QString("Ctrl+X,Ctrl+S")); // The DISPLAY_Z_BUFFER action is disabled setKeyboardAccelerator(DISPLAY_Z_BUFFER, 0); }You can retrieve the current accelerator key value with
keyboardAccelerator(Action)
.
Current bindings are displayed in the help window "Keyboard" tab.
void QGLViewer::keyPressEvent(QKeyEvent *e)
method:
void Viewer::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Qt::Key_R : reset(); updateGL(); break; // and so on... // Call the original method to handle other keys default: QGLViewer::keyPressEvent(e); } }You should then use
setKeyDescription()
to add a short description of your keyboard
accelerator in the help
window Keyboard
tab. See the keyboardAndMouse example for a practical illustration.
Note that if you setKeyDescription()
for a keyboard accelerator that is
already binded to one of the KeyboardAction
, the original accelerator will be
disabled and replaced by yours. Modify the original accelerator using
setKeyboardAccelerator()
before calling setKeyDescription()
, in
order to prevent these conflicts.
QAccel
object to your viewer, thus enabling
complex key sequences accelerators.
Camera
holds 12 KeyFrameInterpolator
, that are binded to the
F1...F12
keys by default. The following bindings are defined:
Alt+Fx
adds a new keyFrame to path x.Fx
will then make the Camera play/pause the associated path (or will simply
restore the saved position if only one keyFrame was defined for this path).Fx
twice resets the interpolation:
Alt+Fx+Fx
deletes path x.Fx+Fx
resets path x to its starting point.setKeyFrameKey(const int nb, const int key)
(default are F1...F12
for
path 0..11), setAddKeyFrameStateKey(const ushort skey)
(default is Alt
) andsetPlayKeyFramePathStateKey(const ushort skey)
(default is Qt::NoButton
).