FileInterface.hh 4.65 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
61
62
63

   public :


Dirk Wilden's avatar
Dirk Wilden committed
64

Dirk Wilden's avatar
Dirk Wilden committed
65
      /** You can provide a special widget showing options for saving your file types
Dirk Wilden's avatar
Dirk Wilden committed
66
67
68
69
       *  depending on the current filter
       *
       *  _currentFilter: one filter from saveFilters
       *
70
       *  Return 0 when you dont need one
Dirk Wilden's avatar
Dirk Wilden committed
71
       */
Dirk Wilden's avatar
Dirk Wilden committed
72
      virtual QWidget* saveOptionsWidget(QString /*_currentFilter*/) = 0;
Dirk Wilden's avatar
Dirk Wilden committed
73

Dirk Wilden's avatar
Dirk Wilden committed
74
      /** You can provide a special widget showing options for loading your file types
Dirk Wilden's avatar
Dirk Wilden committed
75
76
77
78
       *  depending on the current filter
       *
       *  _currentFilter: one filter from loadFilters
       *
79
       *  Return 0 when you dont need one
Dirk Wilden's avatar
Dirk Wilden committed
80
       */
Dirk Wilden's avatar
Dirk Wilden committed
81
      virtual QWidget* loadOptionsWidget(QString /*_currentFilter*/) = 0;
82

Jan Möbius's avatar
   
Jan Möbius committed
83
84
85
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
//===========================================================================
/** @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
* @{ */
//===========================================================================

118
119
public slots:

Jan Möbius's avatar
   
Jan Möbius committed
120
121
122
123
124
125
126
127
128
129
130
131
132
      /** \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
133
      virtual int loadObject(QString /*_filename*/) = 0;
134

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

Jan Möbius's avatar
   
Jan Möbius committed
144
/** @} */
145

Jan Möbius's avatar
 
Jan Möbius committed
146
147
148
};

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

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