Developer Documentation
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 #ifndef FILEOMPLUGIN_HH
45 #define FILEOMPLUGIN_HH
46 
47 #include <QObject>
48 class QCheckBox;
49 class QComboBox;
50 
59 
62 
65 {
66  Q_OBJECT
67  Q_INTERFACES(FileInterface)
68  Q_INTERFACES(LoadSaveInterface)
69  Q_INTERFACES(LoggingInterface)
70  Q_INTERFACES(BaseInterface)
71  Q_INTERFACES(ScriptInterface)
72 
73  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-FileOM")
74 
75  signals:
76  void openedFile( int _id );
77  void addEmptyObject( DataType _type, int& _id);
78  void load(QString _filename, DataType _type, int& _id);
79  void save(int _id , QString _filename );
80  void log(Logtype _type, QString _message);
81  void log(QString _message);
82  void updateView();
83  void updatedObject(int _identifier, const UpdateType& _type);
84 
85  void deleteObject( int _id );
86 
87  private slots:
88 
89  void fileOpened( int /*_id*/ ){};
90 
91  void noguiSupported( ) {} ;
92 
93  void initializePlugin();
94 
96  void handleTrimeshDialog();
97 
99  void slotLoadDefault();
100 
102  void slotSaveDefault();
103 
104  public :
105 
106  FileOMPlugin();
107 
108  ~FileOMPlugin() {};
109 
110  QString name() { return (QString("FileOM")); };
111  QString description( ) { return (QString(tr("Load/Save OM-Files"))); };
112 
114 
115  QString getSaveFilters();
116  QString getLoadFilters();
117 
118  QWidget* saveOptionsWidget(QString /*_currentFilter*/);
119  QWidget* loadOptionsWidget(QString /*_currentFilter*/);
120 
121  public slots:
122 
124  int loadObject(QString _filename);
125 
127  int loadPolyMeshObject(QString _filename);
128 
130  int loadTriMeshObject(QString _filename);
131 
132  bool saveObject(int _id, QString _filename);
133 
134  QString version() { return QString("1.0"); };
135 
136  private :
137 
139  template <class MeshT>
140  void backupTextureCoordinates(MeshT& _mesh);
141 
142  private :
143 
144  //Option Widgets
145  QWidget* loadOptions_;
146  QWidget* saveOptions_;
147 
148  QCheckBox* saveBinary_;
149 
150  QCheckBox* saveVertexNormal_;
151  QCheckBox* saveVertexTexCoord_;
152  QCheckBox* saveVertexColor_;
153  QCheckBox* saveFaceColor_;
154  QCheckBox* saveFaceNormal_;
155  QPushButton* saveDefaultButton_;
156 
157  QComboBox* triMeshHandling_;
158  QCheckBox* loadVertexNormal_;
159  QCheckBox* loadVertexTexCoord_;
160  QCheckBox* loadVertexColor_;
161  QCheckBox* loadFaceColor_;
162  QCheckBox* loadFaceNormal_;
163  QPushButton* loadDefaultButton_;
164  int trimeshOptions_;
165 };
166 
167 #endif //FILEOMPLUGIN_HH
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
Definition: FileOM.cc:426
int loadTriMeshObject(QString _filename)
Loads a triangle mesh.
Definition: FileOM.cc:260
QString name()
Return a name for the plugin.
Definition: FileOM.hh:110
QString getLoadFilters()
Definition: FileOM.cc:91
Logtype
Log types for Message Window.
QString getSaveFilters()
Definition: FileOM.cc:97
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FileOM.cc:103
FileOMPlugin()
Constructor.
Definition: FileOM.cc:62
QString description()
Return a description of what the plugin is doing.
Definition: FileOM.hh:111
void initializePlugin()
Initialize Plugin.
Definition: FileOM.cc:86
void noguiSupported()
Definition: FileOM.hh:91
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition: FileOM.cc:110
int loadPolyMeshObject(QString _filename)
Always loads mesh as polymesh.
Definition: FileOM.cc:337
Update type class.
Definition: UpdateType.hh:59
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition: FileOM.cc:662
Interface for all Plugins which provide scriptable Functions.
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition: FileOM.cc:237
QWidget * saveOptionsWidget(QString)
Definition: FileOM.cc:559
Interface class from which all plugins have to be created.
Interface class for file handling.
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition: FileOM.cc:676
Interface for all plugins which want to Load or Save files and create Objects.
QWidget * loadOptionsWidget(QString)
Definition: FileOM.cc:606