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) {
if (_event->type() == QEvent::MouseButtonDblClick) {
unsigned int node_idx, target_idx;
}
}
}
}
}
@ PICK_ANYTHING
pick any of the prior targets (should be implemented for all nodes)
const std::string pickMode()
Get the current Picking mode.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
Viewer::ActionMode actionMode()
Get the current Action mode.
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)