Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FileOM.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef FILEOMPLUGIN_HH
51 #define FILEOMPLUGIN_HH
52 
53 #include <QObject>
54 class QCheckBox;
55 class QComboBox;
56 
65 
68 
71 {
72  Q_OBJECT
73  Q_INTERFACES(FileInterface)
74  Q_INTERFACES(LoadSaveInterface)
75  Q_INTERFACES(LoggingInterface)
76  Q_INTERFACES(BaseInterface)
77  Q_INTERFACES(ScriptInterface)
78 
79 #if QT_VERSION >= 0x050000
80  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-FileOM")
81 #endif
82 
83  signals:
84  void openedFile( int _id );
85  void addEmptyObject( DataType _type, int& _id);
86  void load(QString _filename, DataType _type, int& _id);
87  void save(int _id , QString _filename );
88  void log(Logtype _type, QString _message);
89  void log(QString _message);
90  void updateView();
91  void updatedObject(int _identifier, const UpdateType& _type);
92 
93  void deleteObject( int _id );
94 
95  private slots:
96 
97  void fileOpened( int /*_id*/ ){};
98 
99  void noguiSupported( ) {} ;
100 
101  void initializePlugin();
102 
104  void handleTrimeshDialog();
105 
107  void slotLoadDefault();
108 
110  void slotSaveDefault();
111 
112  public :
113 
114  FileOMPlugin();
115 
116  ~FileOMPlugin() {};
117 
118  QString name() { return (QString("FileOM")); };
119  QString description( ) { return (QString(tr("Load/Save OM-Files"))); };
120 
122 
123  QString getSaveFilters();
124  QString getLoadFilters();
125 
126  QWidget* saveOptionsWidget(QString /*_currentFilter*/);
127  QWidget* loadOptionsWidget(QString /*_currentFilter*/);
128 
129  public slots:
130 
132  int loadObject(QString _filename);
133 
135  int loadPolyMeshObject(QString _filename);
136 
138  int loadTriMeshObject(QString _filename);
139 
140  bool saveObject(int _id, QString _filename);
141 
142  QString version() { return QString("1.0"); };
143 
144  private :
145 
147  template <class MeshT>
148  void backupTextureCoordinates(MeshT& _mesh);
149 
150  private :
151 
152  //Option Widgets
153  QWidget* loadOptions_;
154  QWidget* saveOptions_;
155 
156  QCheckBox* saveBinary_;
157 
158  QCheckBox* saveVertexNormal_;
159  QCheckBox* saveVertexTexCoord_;
160  QCheckBox* saveVertexColor_;
161  QCheckBox* saveFaceColor_;
162  QCheckBox* saveFaceNormal_;
163  QPushButton* saveDefaultButton_;
164 
165  QComboBox* triMeshHandling_;
166  QCheckBox* loadVertexNormal_;
167  QCheckBox* loadVertexTexCoord_;
168  QCheckBox* loadVertexColor_;
169  QCheckBox* loadFaceColor_;
170  QCheckBox* loadFaceNormal_;
171  QPushButton* loadDefaultButton_;
172  int trimeshOptions_;
173 };
174 
175 #endif //FILEOMPLUGIN_HH
QString getLoadFilters()
Definition: FileOM.cc:101
QWidget * saveOptionsWidget(QString)
Definition: FileOM.cc:569
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
Definition: FileOM.cc:436
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition: FileOM.cc:686
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which provide scriptable Functions.
Interface for all Plugins which do logging to the logging window of the framework.
FileOMPlugin()
Constructor.
Definition: FileOM.cc:72
Update type class.
Definition: UpdateType.hh:70
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition: FileOM.cc:672
Interface class from which all plugins have to be created.
QString getSaveFilters()
Definition: FileOM.cc:107
Logtype
Log types for Message Window.
void noguiSupported()
Definition: FileOM.hh:99
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FileOM.cc:113
Interface class for file handling.
Predefined datatypes.
Definition: DataTypes.hh:96
int loadPolyMeshObject(QString _filename)
Always loads mesh as polymesh.
Definition: FileOM.cc:347
int loadTriMeshObject(QString _filename)
Loads a triangle mesh.
Definition: FileOM.cc:270
void initializePlugin()
Initialize Plugin.
Definition: FileOM.cc:96
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition: FileOM.cc:120
QWidget * loadOptionsWidget(QString)
Definition: FileOM.cc:616
QString description()
Return a description of what the plugin is doing.
Definition: FileOM.hh:119
QString name()
Return a name for the plugin.
Definition: FileOM.hh:118
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition: FileOM.cc:247