TypeInterface Class Reference

Interface class for type definitions. More...

#include <OpenFlipper/BasePlugin/TypeInterface.hh>

List of all members.

Public Slots

virtual bool registerType ()=0
virtual int addEmpty ()=0
 Create an empty object.
virtual DataType supportedType ()=0
 Return your supported object type( e.g. DATA_TRIANGLE_MESH ).

Signals

virtual void emptyObjectAdded (int)
 Emit this signal if an empty object has been created.

Public Member Functions

virtual ~TypeInterface ()
 Destructor.

Detailed Description

Interface class for type definitions.

This interface is used to register new types in OpenFlipper. The type plugins are loaded before all other plugins. They have only the registerType function which registers the type to the core. The type itself has to be defined in the ObjectTypes subdirectory.

Example using custom data types

Adding a custom data type to OpenFlipper needs the following requirements in order to work:

See detailed examples for each of the three points for already existing data types in OpenFlipperRoot/ObjectTypes.

Once the object class is specified, the type plugin will be responsible for its handling including

So, type plugins usually consist of only few lines of code. Here an example of a type plugin handling an example object data type as mentioned above:

 bool MyDataTypePlugin::registerType() {

     addDataType("MyDataType",tr("MyDataType"));
     setTypeIcon( "MyDataType", "myDataType.png");

     return true;
 }

 int MyDataTypePlugin::addEmpty() {

     // Create new object
     MyObject* object = new MyObject();

     object->setName( QString("My Object %1.mob").arg(objectCount) );
     object->update();
     object->show();

     // Tell core that an object has been added
     emit emptyObjectAdded ( object->id() );

     return object->id();
 }

Now, each time a plugin emits addEmptyObject(DATA_MY_DATA), the addEmpty() function will add the object to the scenegraph and return the newly created object's id.

Definition at line 110 of file TypeInterface.hh.


Member Function Documentation

virtual int TypeInterface::addEmpty (  )  [pure virtual, slot]

Create an empty object.

When this slot is called you have to create an object of your supported type.

Parameters:
_type Data type of object that will be created
Returns:
Id of the new Object
virtual void TypeInterface::emptyObjectAdded ( int   )  [inline, virtual, signal]

Emit this signal if an empty object has been created.

Parameters:
_id Id of the added object

Definition at line 117 of file TypeInterface.hh.

virtual DataType TypeInterface::supportedType (  )  [pure virtual, slot]

Return your supported object type( e.g. DATA_TRIANGLE_MESH ).

If you support multiple datatypes you can use the bitwise or to combine them here. The function is used from addEmpty to check if your plugin can create an object of a given dataType.

Referenced by Core::loadPlugin().


The documentation for this class was generated from the following file:
Generated on Wed Jun 23 11:36:08 2010 for DeveloperDocumentation by  doxygen 1.6.3