Commit 3b91c9ac authored by Jan Möbius's avatar Jan Möbius

More work on the pluginProgramming page

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13789 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6170e61e
......@@ -59,13 +59,11 @@ void ExamplePlugin::exampleFunction() {
} else {
// Something went wrong when creating the object.
std::cerr << "Unable to create object" << std::endl;
}
}
\endcode
Of course you have to add the includes for the ObjectTypes you want to use to your list of includes.
Of course you have to add the includes for the ObjectTypes you want to use to your list of includes. A list of available
ObjectTypes can be found here: \ref datatypes
*/
......@@ -5,7 +5,7 @@
* - \ref plugin_sec
* - \ref plugin_startup
* - \ref plugin_prog_sec
* - \ref geometryData
* - \ref plugin_prog_geometryData
* \section tuts Tutorials
* - \ref ex1
* - \ref ex1c
......@@ -47,12 +47,20 @@
* and connected to the core. For details about the individual interfaces see the
* \ref interfaces "Plugin Interfaces Documentation".
*
* \section geometryData Handling geometry data within a plugin
*
* \subsection addingAndRemovingGeometry Adding and removing mesh objects in OpenFlipper
* \section plugin_prog_geometryData Handling geometry data within a plugin
*
* \subsection addingEmptyObjects Adding empty objects to the scene
* To add empty objects to the scene, you have to use the LoadSaveInterface. The details are shown in the
* following example: \ref adding_empty_objects.
*
* \subsection LoadingExistingObjects Loading data from files in OpenFlipper
*
* Usually the user loads existing data via the Load Entry in the File menu. Nevertheless it is possible
* to load data from within a plugin( although it is not recommended).
*
* If you want to load geometry data from a file or simply add objects to the scene
* from within a plugin, it has to implement the \ref LoadSavePlugin.
* from within a plugin, it has to implement the \ref loadSaveInterfacePage.
*
* LoadSaveInterface::load( QString _file, DataType _type, int& _id) tries to
* load file with file name _file of type _type, _id contains the new created
......@@ -60,51 +68,62 @@
* the necessary scene graph nodes such that the developer generally does
* not need to know in detail how to create and add the required nodes to the scene.
*
* Otherwise if a file has been loaded externally, slot
*
* LoadSaveInterface::openedFile (int _id) is called.
*
* When removing objects from the scene, the plugin simply has to emit signal
*
* LoadSaveInterface::deleteObject(int _id)
* Otherwise if a file has been loaded externally, the slot LoadSaveInterface::openedFile (int _id) is called.
*
* or
* \subsection RemovingObjectsFromScene Removing data from the scene
* When removing objects from the scene, the plugin simply has to emit signal\n
* LoadSaveInterface::deleteObject(int _id)\n
* or \n
* LoadSaveInterface::deleteAllObjects() in order to clear the scene.
*
* LoadSaveInterface::deleteAllObjects() in order to clear the scene.
*
* \subsection pluginFunctions OpenFlipper's plugin functions
*
* As a plugin in most cases operates on geometry data, developers might want to know how to gain access to mesh data
* from within a plugin. In our tutorial \ref ex2 we roughly mentioned that the communication between OpenFlipper
* and it's plugins is accomplished through either one of the provided \ref interfaces or the \ref PluginFunctions.
* \subsection GettingObjectsFromScene Getting and enumerating objects in the scene
*
* For example iterating over all objects is managed via the ObjectIterator.
* Iterating over all objects is managed via the ObjectIterator.
*
* <code>
* \code
* for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::SOURCE_OBJECTS);<br />
* o_it != PluginFunctions::objectsEnd(); ++o_it) { ... }
* </code>
* \endcode
*
* See \ref OpenFlipperIterators for details.
*
* Possible restrictions are \c ALL_OBJECTS (to iterate over all objects in the scene), \c TARGET_OBJECTS (objects
* that were marked as target) and \c SOURCE_OBJECTS.
*
* Another way to get handles to scene objects is to use the functions \c PluginFunctions::getObject() or
* PluginFunctions::getPickedObject(). These functions provide a pointer to either a \ref BaseObjectData
* or \ref BaseObject object. As in \ref ex2 one can easily test the type of an object by calling
* or \ref BaseObject object. As in \ref ex2 one can easily test the type of an object by calling:
*
* \code
* // If you have a BaseObjectData or BaseObject pointer
* DataType typeA = object->dataType()
*
* // with an object iterator
* DataType typeB = o_it->dataType()
* \endcode
*
* \c o_it->dataType(DATA_TYPE)
* There are also boolean function where you can check for a specific type:
*
* \code
* // If you have a BaseObjectData or BaseObject pointer
* bool isTriangleMesh = object->dataType(DATA_TRIANGLE_MESH)
*
* // with an object iterator
* bool isPolyMesh = o_it->dataType(DATA_POLY_MESH)
* \endcode
*
* where \c o_it is an object iterator and \c DATA_TYPE is one of the data types specified in \ref OpenFlipper/common/Types.hh.
* \c o_it->dataType(DATA_TRIANGLE_MESH) for example will return true if the object is a triangle mesh.
*
* The mesh data itself can be obtained by calling the appropriate handle plugin function. For example if we consider
* a triangle mesh, we get a handle to the mesh itself by calling
*
* <code>TriMesh* mesh = PluginFunctions::triMesh(*o_it);</code>
* \code
* TriMesh* mesh = PluginFunctions::triMesh(*o_it);
* \endcode
*
* See \ref PluginFunctions for a complete overview.
*
* where \c o_it once again is our object iterator. See \ref PluginFunctions for a complete overview.
* \subsection pluginFunctions OpenFlipper's plugin functions
*
* As a plugin in most cases operates on geometry data, developers might want to know how to gain access to mesh data
* from within a plugin. In our tutorial \ref ex2 we roughly mentioned that the communication between OpenFlipper
* and it's plugins is accomplished through either one of the provided \ref interfaces or the \ref PluginFunctions.
*
* \subsection updatingObjects Updating objects
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment