Commit ca1526cf authored by Jan Möbius's avatar Jan Möbius

Tutorial to add empty ojects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11371 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6c016e3a
/*! \page adding_empty_objects Adding empty Objects in a plugin
\section adding_empty_objects_overview Overview
OpenFlipper provides a set of datatypes (\ref datatypes_integrated ). While the load and save functions
automatically generate objects for the loaded data, it is also useful to generate objects of a specific datatype and
fill them with custom data. This page describes how a plugin can create a new object.
\section adding_empty_objects_creating Creating a new object
Your plugin has to implement a part of the \ref loadSaveInterfacePage.
So you have to derive from that interface and add the LoadSaveInterface::addEmptyObject signal to your plugin:
\code
//includes
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
...
class ExamplePlugin::QObject, ... , LoadSaveInterface, ...
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
...
Q_INTERFACES(LoadSaveInterface)
signals:
// LoadSaveInterface
void addEmptyObject( DataType _type, int& _id);
...
\endcode
To generate the object you can implement the following in one of your functions:
\code
void ExamplePlugin::exampleFunction() {
// Variable which will store the id of the newly created object.
int newObjectId = -1;
// Emit the signal, that we want to create a new object of the specified type plane
emit addEmptyObject(DATA_PLANE, newObjectId);
// Get the newly created object
PlaneObject* object = PluginFunctions::getObject(newObjectId);
if(object) {
// Now you can use the object as usual, e.g. Get the node
PlaneNode* planeNode = object->planeNode();
// change it
planeNode->setPosition(origin,normal);
planeNode->setSize(kinectinfo_->getMaxDepth() / 2, kinectinfo_->getMaxDepth() / 2);
// ...
} 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.
*/
......@@ -2,6 +2,9 @@
\section datatypes_intro Datatypes in OpenFlipper
OpenFlipper supports a variety of datatypes. The default ones shipped with it are listed in the following section.
It is also possible to extend OpenFlipper with additional datatypes. this is described in the section \ref datatypes_adding_custom.
\section datatypes_integrated Integrated data types
The following datatypes are available in OpenFlipper:
......@@ -23,4 +26,8 @@ The following datatypes are available in OpenFlipper:
\image html type_coordsys_thumb.png
- \subpage CameraType "Camera"
\image html type_Camera_thumb.png
\section datatypes_adding_custom Adding custom datatypes
TODO: How to create a custom datatype
*/
......@@ -164,4 +164,5 @@
*
* \subpage pluginExamples Programming examples for OpenFlipper plugins
* \subpage interfaces Plugin Interfaces
* \subpage adding_empty_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