Commit 0cdaf0ac authored by Jan Möbius's avatar Jan Möbius
Browse files

Document backup creation in type plugins

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5f8f3ebe
......@@ -170,6 +170,48 @@ of the new type. The type itself has to be defined in the ObjectTypes subdirecto
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.
\section Backups
Backups are very specific to the underlying data structures of certain types. Therefore the type
plugins also manage backups. Backups itself are managed by perObjectData objects based on
the BackupData class.
When the slot gets called, we first have to check, if an BackupData is already available. If not,
we create one. Than the backup is generated and passed to the backup data attached to the object.
You have to derive your backups from the BaseBackup class, where you only need to implement the
apply function and your constructor. In the following example, this class is named TriMeshBackup.
void TypeTriangleMeshPlugin::generateBackup( int _id, QString _name, UpdateType _type ){
// Get the object corresponding to the id
BaseObjectData* object = 0;
PluginFunctions::getObject(_id, object);
TriMeshObject* meshObj = PluginFunctions::triMeshObject(object);
// Safety check
if ( meshObj != 0 ){
//get backup object data
BackupData* backupData = 0;
// If a backup data has already been attached, get it, otherwise create it.
if ( object->hasObjectData( OBJECT_BACKUPS ) )
backupData = dynamic_cast< BackupData* >(object->objectData(OBJECT_BACKUPS));
//add backup data
backupData = new BackupData(object);
object->setObjectData(OBJECT_BACKUPS, backupData);
// Create a new backup
TriMeshBackup* backup = new TriMeshBackup(meshObj, _name, _type);
// Store it in the backup data
backupData->storeBackup( backup );
To use the TypeInterface:
<li> include TypeInterface.hh in your plugins header file
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