Commit b7e9a1a1 authored by Isaak Lim's avatar Isaak Lim
Browse files

corrected the code for the MouseAndKeyPlugin tutorial

patch provided by Ansgar Prüne

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9ff1fb73
......@@ -57,10 +57,10 @@ MouseAndKeyPlugin::MouseAndKeyPlugin() :
void MouseAndKeyPlugin::initializePlugin() {
// Register keys
emit registerKey(Qt::Key_W, Qt::NoModifier, "Rotate object down");
emit registerKey(Qt::Key_S, Qt::NoModifier, "Rotate object up");
emit registerKey(Qt::Key_A, Qt::NoModifier, "Rotate object left");
emit registerKey(Qt::Key_D, Qt::NoModifier, "Rotate object right");
emit registerKey(Qt::Key_J, Qt::NoModifier, "Rotate object down");
emit registerKey(Qt::Key_K, Qt::NoModifier, "Rotate object up");
emit registerKey(Qt::Key_H, Qt::NoModifier, "Rotate object left");
emit registerKey(Qt::Key_L, Qt::NoModifier, "Rotate object right");
tool_ = new QWidget();
QSize size(300, 300);
......@@ -199,7 +199,7 @@ void MouseAndKeyPlugin::slotMouseEvent(QMouseEvent* _event) {
// Continue traversing scene graph
ACG::SceneGraph::MouseEventAction action(_event);
ACG::SceneGraph::MouseEventAction action(_event, PluginFunctions::viewerProperties().glState());
......@@ -218,28 +218,28 @@ void MouseAndKeyPlugin::slotKeyEvent( QKeyEvent* _event ) {
// Switch pressed keys
switch (_event->key())
case Qt::Key_W:
case Qt::Key_J:
object->manipulatorNode()->rotate(10.0, axis_x_);
case Qt::Key_S :
case Qt::Key_K :
object->manipulatorNode()->rotate(-10.0, axis_x_);
case Qt::Key_A :
case Qt::Key_H :
object->manipulatorNode()->rotate(10.0, axis_y_);
case Qt::Key_D :
case Qt::Key_L :
object->manipulatorNode()->rotate(-10.0, axis_y_);
......@@ -257,7 +257,7 @@ void MouseAndKeyPlugin::slotKeyEvent( QKeyEvent* _event ) {
transformMesh(object->manipulatorNode()->matrix(), (*PluginFunctions::polyMesh(object)));
// Tell core that object has been modified
emit updatedObject(object->id(), UPDATE_GEOMETRY);
// Update view
emit updateView();
......@@ -10,7 +10,7 @@
* - Hide object by right-clicking at it and selecting our defined action
* - Select an object by entering user defined pick mode and double-clicking
* at object in the scene
* - Rotate selected object by hitting the w,s,a,d keys on the keyboard
* - Rotate selected object by hitting the j,k,h,l keys on the keyboard
* For this purpose we will make use of the following \ref interfaces
......@@ -27,7 +27,7 @@
* over to what happens within these methods. When initializing our plugin
* we set the active object identifier to -1 since no object has been selected yet.
* We initialize the axis vectors that we'll need for the rotation later on.
* Then we tell OpenFlipper that we will use the w, a, s and d key on the
* Then we tell OpenFlipper that we will use the j, k, h and l key on the
* keyboard (so it'll call slotKeyEvent() each time one of
* the keys has been pressed). Note: OpenFlipper will show up a warning message in the log
* widget if the desired keys are already assigned to another plugin or core function.
......@@ -84,15 +84,16 @@
* \skip void MouseAndKeyPlugin::slotMouseEvent(QMouseEvent* _event) {
* \until } // End slotMouseEvent
* Next method is called whenever any of the keys w, s, a or d is pressed. If an object has
* Next method is called whenever any of the keys j, k, h or l is pressed. If an object has
* been selected (accordingly the member variable activeObject_ holds a valid objects
* identifier -as described before-) we try to get its handle by calling
* PluginFunctions::getPickedObject(). We then set the rotation matrix of the selected
* object's transform node (manipulatorNode) to hold a matrix that describes
* a rotation around the x (if w or s is pressed) or y axis (if a or d is pressed) by +/- 10 degrees.
* a rotation around the x (if j or k is pressed) or y axis (if h or l is pressed) by +/- 10 degrees.
* We then call the method transformMesh and pass the recently calculated matrix and
* a handle to the mesh (triangle or polygon). We have to
* inform OpenFlipper's core about the changes by calling BaseInterface::updatedObject(int).
* inform OpenFlipper's core about the changes by emitting the updatedObject signal and specifying
* that the geometry has changed.
* \dontinclude
* \skip void MouseAndKeyPlugin::slotKeyEvent( QKeyEvent* _event ) {
Supports Markdown
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