Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FileInterface Class Reference

Interface class for file handling. More...

#include <OpenFlipper/BasePlugin/FileInterface.hh>

Inheritance diagram for FileInterface:
FileBVHPlugin FileHeightFieldPNGPlugin FileLightPlugin FileOBJPlugin FileOFFPlugin FileOMPlugin FileOpenVolumeMeshPlugin FilePlaPlugin FilePLYPlugin FilePolyLinePlugin FilePTSPlugin FileScriptPlugin FileSKLPlugin FileSPHPlugin FileSTLPlugin FileViewPlugin FileVTKPlugin

Public Member Functions

Widgets
virtual ~FileInterface ()
 Destructor.
virtual QWidget * saveOptionsWidget (QString _currentFilter)=0
virtual QWidget * loadOptionsWidget (QString _currentFilter)=0
Supported types
virtual DataType supportedType ()=0
 Return your supported object type( e.g. DATA_TRIANGLE_MESH )
virtual QString getLoadFilters ()=0
virtual QString getSaveFilters ()=0

Load Save Implementation

virtual void openedFile (int _id)
 This signal has to be emitted if an object has been loaded from a file.
virtual int addEmpty ()
 Create an empty object.
virtual int loadObject (QString _filename)=0
 Load an object from the given file.
virtual int loadObject (QString _filename, DataType _type)
 Load an object from the given file.
virtual bool saveObject (int _id, QString _filename)=0
 Save an object from the given file.
virtual bool saveObjects (IdList _ids, QString _filename)
 Save multiple objects to one file.

Detailed Description

Interface class for file handling.

Detailed description

Loading and saving of files in OpenFlipper is handled via the file plugins. These have to implement this class.

Definition at line 63 of file FileInterface.hh.

Member Function Documentation

virtual int FileInterface::addEmpty ( )
inlinevirtualslot

Create an empty object.

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

Returns
Id of the new Object
Todo:
Add an addEmpty function with a given type as an attribute. The plugin should then create only an empty object of the given type. It can be assumed that there is only one type given at a time.

Definition at line 148 of file FileInterface.hh.

virtual QString FileInterface::getLoadFilters ( )
pure virtual

Return the Qt Filters for File dialogs when loading files (e.g. "Off files ( *.off )" )

virtual QString FileInterface::getSaveFilters ( )
pure virtual

Get the Qt Filters for Filedialogs when saving files (e.g. "Off files ( *.off )" )

virtual int FileInterface::loadObject ( QString  _filename)
pure virtualslot

Load an object from the given file.

The Core will call this slot if you should load a file. The core will check if you support the given file type depending on the provided filters and dataTypes ( see supportedType and getLoadFilters )

If loading fails, you have to return -1. If you created an empty object and then your load procedure fails, you should remove the newly generated object.

if you just opened a file and did not create any object, return 0 here, telling the core that it was successfully loaded but no new object has been created!

virtual int FileInterface::loadObject ( QString  _filename,
DataType  _type 
)
inlinevirtualslot

Load an object from the given file.

The Core will call this slot if you should load a file. The core will check if you support the given file type depending on the provided filters and dataTypes ( see supportedType and getLoadFilters )

if you just opened a file and did not create any object, return 0 here, telling the core that it was successfully loaded but no new object has been created!

If loading fails, you have to return -1. If you created an empty object and then your load procedure fails, you should remove the newly generated object.

If the Plugin is able to open the file in different DataTypes one of these DataTypes can be forced with this function.

This forcing is used for example by the recent files function for choosing between poly or triangle mesh loading.

Definition at line 187 of file FileInterface.hh.

virtual QWidget* FileInterface::loadOptionsWidget ( QString  _currentFilter)
pure virtual

You can provide a special widget showing options for loading your file types depending on the current filter

_currentFilter: one filter from loadFilters

Return 0 when you don't need one

virtual void FileInterface::openedFile ( int  _id)
inlinevirtualsignal

This signal has to be emitted if an object has been loaded from a file.

Every time a new object is added to the scene from a file, this signal has to be emitted. Emit this signal once each time a file has been completely processed.

Parameters
_idId of the new object

Definition at line 137 of file FileInterface.hh.

virtual bool FileInterface::saveObject ( int  _id,
QString  _filename 
)
pure virtualslot

Save an object from the given file.

The Core will call this slot if you should save an object to a file. The core will check if you support the given object depending on the provided dataTypes ( see supportedType ). Additionally to the filename you get the id of the object to save

virtual bool FileInterface::saveObjects ( IdList  _ids,
QString  _filename 
)
inlinevirtualslot

Save multiple objects to one file.

The Core will call this slot if the user wants to save multiple files in one file. The core will check if you support the given object depending on the provided dataTypes ( see supportedType ). Additionally to the filename you get ids of the objects to save

Definition at line 205 of file FileInterface.hh.

virtual QWidget* FileInterface::saveOptionsWidget ( QString  _currentFilter)
pure virtual

You can provide a special widget showing options for saving your file types depending on the current filter

_currentFilter: one filter from saveFilters

Return 0 when you don't need one

virtual DataType FileInterface::supportedType ( )
pure virtual

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

If you support multiple DataTypes you can combine them bitwise here. The function is used from the load and save code to check if your plugin can handle an object of a given dataType.


The documentation for this class was generated from the following file: