Developer Documentation
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")
107 signals:
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 
143 private 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 (QString _job );
160 
161 public :
162 
164  DecimaterPlugin();
165 
168 
170  QString name(){ return (QString("Decimater")); };
171 
173  QString description() { return (QString(tr("Mesh Decimation ..."))); };
174 
175 
176 private :
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 
213 private slots:
214 
216  void slot_decimate();
217  void slot_decimate_finished(QString _jobId); //postprocess after threads finished
218 
220  void slot_initialize();
221  void slot_initialize_object(int obj_id, bool clear = false);
222 
223 private 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 
238  void slotUpdateNumVertices();
239  void slotUpdateNumTriangles();
240 
241  void slotMixedCounterValueChanged(double);
242  void slotMixedSliderValueChanged(int);
243  void slotDisableDecimation();
244 
245 private:
246  void initialize_object(BaseObjectData *obj);
247 
248 //===========================================================================
251 //===========================================================================
252 
253 public slots:
254 
261  void decimate(int _objID, QVariantMap _constraints);
262 
272  void decimate(int _objID, QString _constraints);
273 
274 public slots:
275  QString version() { return QString("1.0"); };
276 
277 };
Interface class for exporting functions to python.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void canceledJob(QString _job)
A job has been canceled.
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
Logtype
Log types for Message Window.
Use Normal deviation to control decimation.
void slot_decimate()
decimating called from button in toolbox
Interface for all Plugins which do logging to the logging window of the framework.
void slotUpdateNumVertices()
update number of vertices information
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
void decimate(int _objID, QVariantMap _constraints)
decimate an object
DecimaterToolbarWidget * tool_
Widget for Toolbox.
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
void slotUpdateDistance()
slider / spinbox updates
Mesh decimation module computing collapse priority based on error quadrics.
Definition: ModQuadricT.hh:75
Update type class.
Definition: UpdateType.hh:59
void slot_initialize()
init called from button in toolbox
Use Roundness of triangles to control decimation.
QString description()
Description of the Plugin.
Use edge length to control decimation.
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles
Interface for all Plugins which provide scriptable Functions.
QString name()
Name of the Plugin.
DecimaterPlugin()
Default constructor.
Use Hausdorff distance to control decimation.
Use aspect ratio to control decimation.
~DecimaterPlugin()
Default destructor.
Interface class for Thread handling.
Interface class from which all plugins have to be created.
Interface class for backup handling.
Interface for all plugins which want to Load or Save files and create Objects.