Developer Documentation
|
The ContextMenuInterface can be used by plugins to add menu entries to OpenFlippers UI. The entries will be added to OpenFlippers contextMenus in the glView (see image). You can choose between context menus for objects, nodes or the background.
The given context menu entries will be shown when the user right clicks on the corresponding primitive (node,object) in the GL viewer.
To use the ContextMenuInterface:
Usually you should implement the BaseInterface::pluginsInitialized() function from BaseInterface. In this function you can setup your menus.
You have to create a QAction. The signals and slots of your actions have to be connected to your plugin. Just connect them as usual. Only visibility of the menu is handled by the core. You can also add submenus to the context menus. Just add the action for the menu ( menu->menuAction() )
Before a menu of the requested type is shown, an update function for the specific type will be invoked by the core depending on your type of context menu ( ContextMenuInterface::slotUpdateContextMenu(), ContextMenuInterface::slotUpdateContextMenuNode(), ContextMenuInterface::slotUpdateContextMenuBackground() ). In this function you can update entries based on the object that was clicked on. The id of the node or the object is provided by these update functions.
The following code shows a simple example to create a menu entry in the context menu.
Signals and slots of your menus (e.g. from an action inside it) can be directly connected to signals and slots in your plugin. Therefore the embedding of your menus into the OpenFlippers context menu list is fully transparent.