FileInterface.hh 4.81 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
15
//
Jan Möbius's avatar
 
Jan Möbius committed
16
17
18
19
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
20
//
Jan Möbius's avatar
 
Jan Möbius committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




//
// C++ Interface: BasePlugin
//
38
// Description:
Jan Möbius's avatar
 
Jan Möbius committed
39
40
41
42
43
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//

44
45
#ifndef FILEINTERFACE_HH
#define FILEINTERFACE_HH
Jan Möbius's avatar
 
Jan Möbius committed
46
47
48

 #include <QtGui>
 #include <OpenFlipper/common/Types.hh>
49

Jan Möbius's avatar
 
Jan Möbius committed
50
 /** \brief Interface class for file and object handling
51
52
  *
  * This interface class has to be fully implemented. When you want to support save and load
Jan Möbius's avatar
 
Jan Möbius committed
53
54
55
56
57
58
59
  * for an object type you have to implement all functions in this class. The core manages the
  * load and save interaction and gives the load and save actions to your plugin. The decision
  * which plugin is called for saving an object depends on your supportedTypes() and the filters
  * defined by your plugin.
 */

class FileInterface {
60

Jan Möbius's avatar
Jan Möbius committed
61
62
63
64
65
//===========================================================================
/** @name Widgets
* @{ */
//===========================================================================
  public :
Dirk Wilden's avatar
Dirk Wilden committed
66

Jan Möbius's avatar
Jan Möbius committed
67
68
69
70
71
72
73
74
    /** 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 dont need one
      */
    virtual QWidget* saveOptionsWidget(QString /*_currentFilter*/) = 0;
Dirk Wilden's avatar
Dirk Wilden committed
75

Jan Möbius's avatar
Jan Möbius committed
76
77
78
79
80
81
82
83
84
    /** 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 dont need one
      */
    virtual QWidget* loadOptionsWidget(QString /*_currentFilter*/) = 0;
}
85

Jan Möbius's avatar
   
Jan Möbius committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//===========================================================================
/** @name Supported types
* @{ */
//===========================================================================

public:

  /** Return the name of your supported type (e.g. "Triangle Mesh"
   */
  virtual QString typeName() = 0;

  /** Return your supported object type( e.g. DATA_TRIANGLE_MESH )
   *
   * TODO : Support for adding new datatypes at runtime
   */
  virtual DataType supportedType() = 0;


  /** Return the Qt Filters for Filedialogs when loading files (e.g. "Off files ( *.off )" )
   *
   */
  virtual QString getLoadFilters() = 0;

  /** Get the Qt Filters for Filedialogs when saving files (e.g. "Off files ( *.off )" )
   *
   */
  virtual QString getSaveFilters() = 0;

/** @} */

//===========================================================================
/** @name Load Save Implementation
* @{ */
//===========================================================================

121
122
public slots:

Jan Möbius's avatar
   
Jan Möbius committed
123
124
125
126
127
128
129
130
131
132
133
134
135
      /** \brief Create an empty object
       *
       * When this slot is called you have to create an object of your supported type.
       * @return Id of the new Object
       */
      virtual int addEmpty() = 0;

      /** \brief 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 )
       */
Dirk Wilden's avatar
Dirk Wilden committed
136
      virtual int loadObject(QString /*_filename*/) = 0;
137

Jan Möbius's avatar
   
Jan Möbius committed
138
139
140
141
142
143
144
      /** \brief 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
       */
Dirk Wilden's avatar
Dirk Wilden committed
145
      virtual bool saveObject(int /*_id*/, QString /*_filename*/) = 0;
146

Jan Möbius's avatar
   
Jan Möbius committed
147
/** @} */
148

Jan Möbius's avatar
 
Jan Möbius committed
149
150
151
};

Q_DECLARE_INTERFACE(FileInterface,"OpenFlipper.FileInterface/0.3")
152

Jan Möbius's avatar
 
Jan Möbius committed
153
#endif // FILEINTERFACE_HH