Developer Documentation
Loading...
Searching...
No Matches
Load/Save Interface



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);
Predefined datatypes.
Definition DataTypes.hh:83
virtual void load(QString _filename, DataType _type, int &_id)
Load object from file with a specific DataType.

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

emit LoadSaveInterface::save(int _id , QString _filename );
virtual void save(int _id, QString _filename)
Save object to a file.

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:

virtual void addEmptyObject(DataType _type, int &_id)

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

emit LoadSaveInterface::copyObject( int _oldId, int& _newId);
virtual void 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

virtual void deleteObject(int _id)
Delete an object This signal can be called from any thread. .

or clear the whole scene with:

virtual void deleteAllObjects()
Delete all Objects.

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)