Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Picking Interface/Mouse Picking/Pick Mode Toolbars

# Functionality

OpenFlipper uses several different ActionModes. These include, Light interaction (Changing lights), Move interaction (navigating through the scene) and the picking interaction. The picking interaction is separated into different pick modes. These modes are usually defined by plugins and are used to restrict the mouse interaction to one plugin. E.g. if the current picking mode is "vertex selection", all other plugins that react on mouse events, but are not responsible for the "vertex selection" will ignore these events.

# Managing Pick Modes

Pick modes can be created in your plugin initialization. You can add them as visible pick modes (visible in the context menus of objects) or as hidden pick modes PickingInterface::addHiddenPickMode() ( This should be preferred! ). You can also set a special cursor that will be used when your pick mode is active via PickingInterface::setPickModeCursor(). If you need to enable mouse tracking in your mode, you can use PickingInterface::setPickModeMouseTracking(). This will result in mouse events even if no button is pressed.

// When the plugin gets initialized
void ExamplePlugin::pluginsInitialized() {
// Add pick mode
emit addPickMode("ExamplePlugin Pick Mode");
}
// Triggered when the pick mode got changed.
void ExamplePlugin::slotPickModeChanged(const std::string& _mode) {
// Enable a button depending on the current pick mode
button_->setEnabled(_mode == "ExamplePlugin Pick Mode");
}
// From MouseInterface
void ExamplePlugin::slotMouseEvent(QMouseEvent* _event) {
// Check if your pick mode is currently active
if ( PluginFunctions::pickMode() == "ExamplePlugin Pick Mode" && PluginFunctions::actionMode() == Viewer::PickingMode ) {
// Do something
}
}

A change of the current pick mode can be detected by the PickingInterface::slotPickModeChanged() function.

# PickMode Toolbars

Additionally it is possible to show a special toolbar in OpenFlippers viewer when your pick mode is active. This is especially Useful, when you can change the interaction type by buttons in the bar, e.g. select vertices or faces. Every time your pick mode is activated, your toolbar will be visible at the top of the viewer. Use the functions PickingInterface::setPickModeToolbar() and PickingInterface::removePickModeToolbar() for controlling these toolbars. The embedding is fully transparent so that you can manage your toolbar and connect signals and slots as usual.

// When the plugin gets initialized
void ExamplePlugin::pluginsInitialized() {
// Global variable QToolBar* pickToolbar_
pickToolbar_ = new QToolBar(tr("Example Pickmode Toolbar"));
pickToolbar_->setAttribute(Qt::WA_AlwaysShowToolTips, true);
QActionGroup* pickToolBarActions = new QActionGroup(pickToolbar_);
QAction* action = new QAction(tr("Action"),pickToolBarActions);
action->setStatusTip(tr("Action description"));
action->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"icon.png") );
action->setCheckable(true);
pickToolbar_->addAction(action);
// Connect to a local slot. The embedding is transparent, so you can connect all your actions and toolbars as usual.
connect(pickToolBarActions, SIGNAL(triggered(QAction*)), this, SLOT(slotPickToolbarAction(QAction*)) );
emit setPickModeToolbar ("ExamplePlugin Pick Mode", pickToolbar_);
}

# Usage

To use the PickingInterface:

- include PickingInterface.hh in your plugins header file
- derive your plugin from the class PickingInterface
- add Q_INTERFACES(PickingInterface) 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)