Developer Documentation
Loading...
Searching...
No Matches
DecimaterPlugin.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#pragma once
43
44//== INCLUDES =================================================================
45
55
57
59
60#include "DecimaterInfo.hh"
61
62#include "DecimaterToolbarWidget.hh"
63
64#include "DecimateThread.hh"
65
76#include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
77
79
80#include <ACG/Utils/SmartPointer.hh>
81#include <vector>
82
83#include <QObject>
84#include <QMenuBar>
85#include <QTimer>
86
87
88//== CLASS DEFINITION =========================================================
89
93{
94 Q_OBJECT
95 Q_INTERFACES(BaseInterface)
96 Q_INTERFACES(ToolboxInterface)
97 Q_INTERFACES(BackupInterface)
98 Q_INTERFACES(LoggingInterface)
99 Q_INTERFACES(ScriptInterface)
100 Q_INTERFACES(RPCInterface)
101 Q_INTERFACES(LoadSaveInterface)
102 Q_INTERFACES(ProcessInterface)
103 Q_INTERFACES(PythonInterface)
104
105
106 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Decimater")
107signals:
108
109 // BaseInterface
110 void updateView();
111 void updatedObject(int _id, const UpdateType& _type);
112 void setSlotDescription(QString _slotName, QString _slotDescription,
113 QStringList _parameters, QStringList _descriptions);
114
115 // LoggingInterface
116 void log(Logtype _type, QString _message);
117 void log(QString _message);
118
119 // RPC Interface
120 void pluginExists( QString _pluginName , bool& _exists ) ;
121 void functionExists( QString _pluginName , QString _functionName , bool& _exists );
122
123 // ToolboxInterface
124 void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
125
126 // ScriptInterface
127 void scriptInfo( QString _functionName );
128
129 // BackupInterface
130 void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
131
132 // ProcessInterface
133 void startJob( QString _jobId, QString _description , int _min , int _max , bool _blocking = false);
134 void cancelJob(QString _jobId );
135 void finishJob(QString _jobId );
136 void setJobState(QString, int);
137 void setJobName(QString _jobId, QString _name );
138 void setJobDescription(QString _jobId, QString _text );
139
140 //self defined signals
141 void jobCanceled(QString _jobId);
142
143private slots:
144 // BaseInterface
145 void initializePlugin();
146 void pluginsInitialized();
147
148 void slotObjectUpdated( int _identifier , const UpdateType& _type ); // BaseInterface
149 void slotObjectSelectionChanged( int _identifier ); // BaseInterface
150
151 void objectDeleted(int _id); //LoadSaveInterface
152
153 void slotAboutToRestore(int _id); //BackupInterface
154
155 // Tell system that this plugin runs without ui
156 void noguiSupported( ) {} ;
157
158 // ProcessInterface
159 void canceledJob (const QString &_job );
160
161public :
162
165
168
170 QString name(){ return (QString("Decimater")); };
171
173 QString description() { return (QString(tr("Mesh Decimation ..."))); };
174
175
176private :
177 typedef DecimateThread::BaseDecimaterType BaseDecimaterType;
178 typedef DecimateThread::DecimaterType DecimaterType;
179 typedef DecimateThread::McDecimaterType McDecimaterType;
180 typedef DecimateThread::MixedDecimaterType MixedDecimaterType;
181
190
193
194 //saves the decimater and the object id
196 {
197 ptr::shared_ptr<BaseDecimaterType> decimater;
198 int objId;
199 ModAspectRatioH hModAspectRatio;
200 ModEdgeLengthH hModEdgeLength;
201 ModHausdorffH hModHausdorff;
202 ModIndependentH hModIndependent;
203 ModNormalDeviationH hModNormalDeviation;
204 ModNormalFlippingH hModNormalFlipping;
205 ModQuadricH hModQuadric;
206 ModRoundnessH hModRoundness;
207 };
208 std::vector< ptr::shared_ptr<DecimaterInit> > decimater_objects_;
209 QIcon* toolIcon_;
210
211 int runningJobs_;
212
213private slots:
214
216 void slot_decimate();
217 void slot_decimate_finished(const QString &_jobId); //postprocess after threads finished
218
220 void slot_initialize();
221 void slot_initialize_object(int obj_id, bool clear = false);
222
223private slots:
225 void slotUpdateRoundness(int _value);
226 void slotUpdateRoundness(double _value);
227 void slotUpdateAspectRatio(int _value);
228 void slotUpdateAspectRatio(double _value);
229
231 void slotUpdateDistance ();
232 void slotUpdateNormalDev ();
233 void slotUpdateVertices ();
234 void slotUpdateTriangles ();
235 void slotUpdateEdgeLength ();
236
240
241 void slotMixedCounterValueChanged(double);
242 void slotMixedSliderValueChanged(int);
243 void slotDisableDecimation();
244
245private:
246 void initialize_object(BaseObjectData *obj);
247
248//===========================================================================
251//===========================================================================
252
253public slots:
254
261 void decimate(int _objID, QVariantMap _constraints);
262
272 void decimate(int _objID, QString _constraints);
273
274public slots:
275 QString version() { return QString("1.0"); };
276
277};
Logtype
Log types for Message Window.
Interface class for backup handling.
Interface class from which all plugins have to be created.
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
void decimate(int _objID, QVariantMap _constraints)
decimate an object
QString description()
Description of the Plugin.
void slotUpdateDistance()
slider / spinbox updates
void slot_decimate()
decimating called from button in toolbox
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles
~DecimaterPlugin()
Default destructor.
void slotUpdateNumVertices()
update number of vertices information
QString name()
Name of the Plugin.
void slot_initialize()
init called from button in toolbox
DecimaterToolbarWidget * tool_
Widget for Toolbox.
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
DecimaterPlugin()
Default constructor.
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which do logging to the logging window of the framework.
Use aspect ratio to control decimation.
Use edge length to control decimation.
Use Hausdorff distance to control decimation.
Use Normal deviation to control decimation.
Mesh decimation module computing collapse priority based on error quadrics.
Use Roundness of triangles to control decimation.
Interface class for Thread handling.
Interface class for exporting functions to python.
Interface to call functions across plugins.
Interface for all Plugins which provide scriptable Functions.
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Update type class.
Definition UpdateType.hh:59
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.