Developer Documentation
Load/Save Interface


loadSaveInterface.png


The LoadSaveInterface can be used by plugins to add new objects to the scene either by creating empty objects or by loading them from files. The interface also triggers saving of existing objects to files.

Load/Save Files

You can load a file from within your plugin via

emit LoadSaveInterface::load(QString _filename, DataType _type, int& _id);

and to save an object to a file, call LoadSaveInterface::

emit LoadSaveInterface::save(int _id , QString _filename );

The corresponding File Plugin will than be activated and load or save the object. for load, the id of the new object is returned.

Creating/Copying Objects

To add objects to the scene you can use the following two functions:

This will create a new object of the given DataType and return the id of it, while

emit LoadSaveInterface::copyObject( int _oldId, int& _newId);

will copy the given object and return the new object id.

Deleting Objects

You can delete a specific object via

or clear the whole scene with:

Object Information

Additionally the interface informs plugins if new objects have been added to the scenes or if previous objects have been removed. LoadSaveInterface::fileOpened( int _id ) will be triggered each time an object is loaded from a file. If simply an empty object has been added, the slot LoadSaveInterface::addedEmptyObject( int _id ) will be called. If an object gets deleted, the LoadSaveInterface::objectDeleted( int _id ) will be called immediately before the object is removed from the scenegraph. So if this function is invoked, the object still exists. All plugins get informed via this slot.

If you want to know if the whole scene got cleared, use BaseInterface::slotAllCleared( ).

Usage

To use the LoadSaveInterface:

  • include LoadSaveInterface.hh in your plugins header file
  • derive your plugin from the class LoadSaveInterface
  • add Q_INTERFACES(LoadSaveInterface) to your plugin class
  • And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)