Developer Documentation
|
The BaseInterface has to be used by every plugin in OpenFlipper. As the minimum a plugin has to implement the BaseInterface::name() and BaseInterface::description() functions from this interface.
To use the BaseInterface:
The OpenFlipper startup process consists of several steps, which are shown in this image:
OpenFlipper first starts its core system. Therefore it loads the settings, parses command line options and initializes the QT library. Afterwards the object and scenegraph management are initialized. The next step creates the core user interface and the logging system. Now the plugins are loaded in the following way:
Afterwards the plugin initialization is complete and the core sets up the final gui.
The objects in OpenFlippers scene are stored and managed in OpenFlippers core. If a plugin changes one of the objects, it has to notify the core about that change. In turn OpenFlipper will then notify all other plugins about this change. This functionality is provided by the signals and slots for update handling .
If you change data you have to emit one of BaseInterface::updatedObject(int) or BaseInterface::updatedObject(int,const UpdateType&).
BaseInterface::updatedObject(int) forces an update of the whole object while BaseInterface::updatedObject(int,const UpdateType&) can be restricted to a part of the object ( Geometry,Selection, ... ; see UpdateType ) and is therefore faster and should be preferred.
Both signals get the id of the object that has been updated or -1 if all should be updated( you should not use -1 if you know what object changed!).
If the signal is emitted, the core calls BaseInterface::slotObjectUpdated( int , const UpdateType& ) of every plugin. You can implement this slot if you need to react on object changes.
After all plugins have been informed, the node itself gets updated. This means that for the corresponding object the update function is called (BaseObjectData::update() ). This function is implemented by every object type in OpenFlipper and has to take care of reacting to modifications of the object. E.g. the TriMeshObject, this could mean, that the OpenMesh data has changed (UPDATE_GEOMETRY). The object would than trigger an update of the rendering buffers which are used to draw the mesh.
For more details about the UpdateType read the documentation about UpdateType and predefined update types. A description for adding custom update types at runtime is available here.
It is also possible to insert custom nodes into the scenegraph. If you changed these nodes, you also have to inform the core. This is achieved by the BaseInterface::nodeVisibilityChanged() function. As nodes are usually attached to objects in the scene, you should pass the id of the object to the function or -1 if its a global node.
If the complete scene gets cleared, the slot BaseInterface::slotAllCleared() will be executed after all objects have been removed from the scene. A more fine grained information about objects added or removed from the scene is available via the Load/Save Interface .
There are three additional slots that are called by the core, if the object selection(source/target BaseInterface::slotObjectSelectionChanged() ), the object visibility(Show/Hide BaseInterface::slotVisibilityChanged()) or other properties changed (e.g. name BaseInterface::slotObjectPropertiesChanged() )
OpenFlipper manages the scene updates in its core. If objects get updated the scene will be automatically redrawn. Nevertheless, you can force an update of the scene by emitting the signal BaseInterface::updateView(). OpenFlipper restricts the number of redraws to avoid useless updates. In the Options you can set a maximal frame rate or disable the restriction. The following image shows how the updates process is managed:
If the view (viewer position /viewing direction) has been changed, the slot BaseInterface::slotViewChanged() will be called, before anything gets rendered. If you need to modify renderings or anything else depending on the current view, you can use this slot and adapt to the new view (e.g. modifying a shader).
There are some basic functions for managing plugins. The BaseInterface::description() function can be used to provide a description for the plugin which will be printed along with the plugin name. The BaseInterface::name() function has to return the name of the plugin. This name will also be used inside the scripting system. Additionally it is possible to provide a plugin version number with BaseInterface::version().
OpenFlippers scripting system can use all public slots defined in your plugin. If it should also provide a small text description for your functions, you could set them with BaseInterface::setSlotDescription(). Even if you do not implement scripting functions in your plugin, the core will then be able to provide this information to the user.
Along with the scripting, OpenFlipper provides a batch mode, running without any user interface. If your plugin will work without an user interface (e.g. only scripting functions), you can define a slot BaseInterface::noguiSupported(). This empty slot is used to tell the core, that the plugin can work in batch mode. Otherwise it will not be loaded when running a batch file.