Developer Documentation

FilePLY.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 FILEPLYPLUGIN_HH
45 #define FILEPLYPLUGIN_HH
46
47 #include <QObject>
48 #include <QCheckBox>
49 #include <QSpinBox>
50
51 class QLabel ;
52 class QComboBox;
53
54 #include <OpenFlipper/common/Types.hh>
55 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
56 #include <OpenFlipper/BasePlugin/FileInterface.hh>
57 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
58 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
59 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
60 #include <OpenFlipper/BasePlugin/TypeInterface.hh>
61 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
62
63 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
64 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
65
66 class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface,
67 LoggingInterface, ScriptInterface
68 {
69 Q_OBJECT
70 Q_INTERFACES(FileInterface)
71 Q_INTERFACES(LoadSaveInterface)
72 Q_INTERFACES(LoggingInterface)
73 Q_INTERFACES(BaseInterface)
74 Q_INTERFACES(ScriptInterface)
75
76 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-PLY")
77
78 signals:
79 void openedFile( int _id );
80 void addEmptyObject( DataType _type, int& _id);
81 void load(QString _filename, DataType _type, int& _id);
82 void save(int _id , QString _filename );
83 void log(Logtype _type, QString _message);
84 void log(QString _message);
85 void updateView();
86 void updatedObject(int _identifier, const UpdateType& _type);
87
88 void deleteObject( int _id );
89
90 private slots:
91
92 void fileOpened( int /*_id*/ ){};
93
94 void noguiSupported( ) {} ;
95
96 void initializePlugin();
97
99 void handleTrimeshDialog();
100
102 void slotLoadDefault();
103
105 void slotSaveDefault();
106
107 public :
108
109 FilePLYPlugin();
110
111 ~FilePLYPlugin() {};
112
113 QString name() { return (QString("FilePLY")); };
114 QString description( ) { return (QString(tr("Load/Save PLY-Files"))); };
115
116 DataType supportedType();
117
118 QString getSaveFilters();
119 QString getLoadFilters();
120
121 QWidget* saveOptionsWidget(QString /*_currentFilter*/);
122 QWidget* loadOptionsWidget(QString /*_currentFilter*/);
123
124 public slots:
125
127 int loadObject(QString _filename);
128
130 int loadObject(QString _filename, DataType _type);
131
133 int loadPolyMeshObject(QString _filename, OpenMesh::IO::Options& _opt);
134
136 int loadTriMeshObject(QString _filename, OpenMesh::IO::Options& _opt);
137
138 bool saveObject(int _id, QString _filename);
139
140 QString version() { return QString("1.0"); };
141
142 private:
143
144 // Template functions
145
146 template <class MeshT>
147 void backupTextureCoordinates(MeshT& _mesh);
148
149 //Option Widgets
150 QWidget* loadOptions_;
151 QWidget* saveOptions_;
152
153 QCheckBox* saveBinary_;
154 QCheckBox* saveVertexNormal_;
155 QCheckBox* saveVertexColor_;
156 QCheckBox* saveVertexTexCoord_;
157 QCheckBox* saveFaceNormal_;
158 QCheckBox* saveFaceColor_;
159 QLabel* savePrecisionLabel_;
160 QSpinBox* savePrecision_;
161 QPushButton* saveDefaultButton_;
162
163 QComboBox* triMeshHandling_;
164 QCheckBox* loadVertexNormal_;
165 QCheckBox* loadVertexColor_;
166 QCheckBox* loadVertexTexCoord_;
167 QCheckBox* loadFaceNormal_;
168 QCheckBox* loadFaceColor_;
169 QPushButton* loadDefaultButton_;
170
171 int trimeshOptions_;
172 };
173
174 #if defined(INCLUDE_TEMPLATES) && !defined(FILEPLYPLUGIN_C)
175 #define FILEPLYPLUGIN_TEMPLATES
176 #include "FilePLYT_impl.hh"
177 #endif
178
179 #endif //FILEPLYPLUGIN_HH
FilePLYPlugin::slotSaveDefault
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition: FilePLY.cc:702
UpdateType
Update type class.
Definition: UpdateType.hh:60
TriangleMesh.hh
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:59
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
LoggingInterface.hh
FilePLYPlugin::slotLoadDefault
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition: FilePLY.cc:688
FilePLYPlugin::getSaveFilters
QString getSaveFilters()
Definition: FilePLY.cc:91
FilePLYPlugin::loadTriMeshObject
int loadTriMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Loads a triangle mesh.
Definition: FilePLY.cc:321
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
FilePLYPlugin::getLoadFilters
QString getLoadFilters()
Definition: FilePLY.cc:85
BaseInterface.hh
LoadSaveInterface.hh
FileInterface.hh
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
FilePLYPlugin::noguiSupported
void noguiSupported()
Definition: FilePLY.hh:94
FilePLYPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: FilePLY.hh:114
FilePLYPlugin::saveOptionsWidget
QWidget * saveOptionsWidget(QString)
Definition: FilePLY.cc:576
FilePLYPlugin::supportedType
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FilePLY.cc:97
FilePLYPlugin::backupTextureCoordinates
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
Definition: FilePLYT_impl.hh:56
OpenMesh::IO::Options
Set options for reader/writer modules.
Definition: Options.hh:90
TypeInterface.hh
FilePLYPlugin::handleTrimeshDialog
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition: FilePLY.cc:298
Types.hh
DataType
Predefined datatypes.
Definition: DataTypes.hh:83
FileInterface
Interface class for file handling.
Definition: FileInterface.hh:63
FilePLYPlugin
Definition: FilePLY.hh:66
FilePLYPlugin::loadPolyMeshObject
int loadPolyMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Always loads mesh as polymesh.
Definition: FilePLY.cc:406
FilePLYPlugin::name
QString name()
Return a name for the plugin.
Definition: FilePLY.hh:113
FilePLYPlugin::loadOptionsWidget
QWidget * loadOptionsWidget(QString)
Definition: FilePLY.cc:633
RPCInterface.hh
FilePLYPlugin::initializePlugin
void initializePlugin()
Initialize Plugin.
Definition: FilePLY.cc:80
FilePLYPlugin::loadObject
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition: FilePLY.cc:168
PolyMesh.hh
ScriptInterface.hh
FilePLYPlugin::FilePLYPlugin
FilePLYPlugin()
Constructor.
Definition: FilePLY.cc:56