Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Mouse Interface


mouseInterface.png


The mouse interface can be used to receive mouse events which occur in the glViewer.

There are 4 main viewer modes:

You can add handlers for these mouse events in your plugin. Remember that all plugins receive these signals.
The picking action is only a global mode which is divided into several other picking modes that can be managed through the PickingInterface. If you react on mouse events, you should check if the current picking mode is yours and of course define such a mode for your plugin.

void MousePlugin::slotMouseEvent(QMouseEvent* _event) {
// Check if your pick mode is currently active
if ( PluginFunctions::pickMode() == "YourPickMode" && PluginFunctions::actionMode() == Viewer::PickingMode ) {
// If double click has been performed
if (_event->type() == QEvent::MouseButtonDblClick) {
unsigned int node_idx, target_idx;
OpenMesh::Vec3d hitPoint;
// Get picked object's identifier by picking in scenegraph
if ( PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING,_event->pos(), node_idx, target_idx, &hitPoint) ) {
BaseObjectData* object;
// Get picked object
if ( PluginFunctions::getPickedObject(node_idx, object) ) {
// Do something with the object
}
}
}
}
}

See our tutorial Implementing mouse and keyboard interaction for an example of how to use mouse and keyboard events within a plugin.

To use the MouseInterface:

  • include MouseInterface.hh in your plugins header file
  • derive your plugin from the class MouseInterface
  • add Q_INTERFACES(MouseInterface) to your plugin class
  • And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)