Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef DECIMATERPLUGIN_HH
51 #define DECIMATERPLUGIN_HH
52 
53 //== INCLUDES =================================================================
54 
63 
65 
67 
68 #include "DecimaterInfo.hh"
69 
70 #include "DecimaterToolbarWidget.hh"
71 
72 #include "DecimateThread.hh"
73 
76 #include <OpenMesh/Tools/Decimater/MixedDecimaterT.hh>
84 #include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
85 
87 
88 #include <ACG/Utils/SmartPointer.hh>
89 #include <vector>
90 
91 #include <QObject>
92 #include <QMenuBar>
93 #include <QTimer>
94 
95 
96 //== CLASS DEFINITION =========================================================
97 
101 {
102  Q_OBJECT
103  Q_INTERFACES(BaseInterface)
104  Q_INTERFACES(ToolboxInterface)
105  Q_INTERFACES(BackupInterface)
106  Q_INTERFACES(LoggingInterface)
107  Q_INTERFACES(ScriptInterface)
108  Q_INTERFACES(RPCInterface)
109  Q_INTERFACES(LoadSaveInterface)
110  Q_INTERFACES(ProcessInterface)
111 
112 #if QT_VERSION >= 0x050000
113  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Decimater")
114 #endif
115 signals:
116 
117  // BaseInterface
118  void updateView();
119  void updatedObject(int _id, const UpdateType& _type);
120  void setSlotDescription(QString _slotName, QString _slotDescription,
121  QStringList _parameters, QStringList _descriptions);
122 
123  // LoggingInterface
124  void log(Logtype _type, QString _message);
125  void log(QString _message);
126 
127  // RPC Interface
128  void pluginExists( QString _pluginName , bool& _exists ) ;
129  void functionExists( QString _pluginName , QString _functionName , bool& _exists );
130 
131  // ToolboxInterface
132  void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
133 
134  // ScriptInterface
135  void scriptInfo( QString _functionName );
136 
137  // BackupInterface
138  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
139 
140  // ProcessInterface
141  void startJob( QString _jobId, QString _description , int _min , int _max , bool _blocking = false);
142  void cancelJob(QString _jobId );
143  void finishJob(QString _jobId );
144  void setJobState(QString, int);
145  void setJobName(QString _jobId, QString _name );
146  void setJobDescription(QString _jobId, QString _text );
147 
148  //self defined signals
149  void jobCanceled(QString _jobId);
150 
151 private slots:
152  // BaseInterface
153  void initializePlugin();
154  void pluginsInitialized();
155 
156  void slotObjectUpdated( int _identifier , const UpdateType& _type ); // BaseInterface
157  void slotObjectSelectionChanged( int _identifier ); // BaseInterface
158 
159  void objectDeleted(int _id); //LoadSaveInterface
160 
161  void slotAboutToRestore(int _id); //BackupInterface
162 
163  // Tell system that this plugin runs without ui
164  void noguiSupported( ) {} ;
165 
166  // ProcessInterface
167  void canceledJob (QString _job );
168 
169 public :
170 
172  DecimaterPlugin();
173 
176 
178  QString name(){ return (QString("Decimater")); };
179 
181  QString description() { return (QString(tr("Mesh Decimation ..."))); };
182 
183 
184 private :
185  typedef DecimateThread::BaseDecimaterType BaseDecimaterType;
186  typedef DecimateThread::DecimaterType DecimaterType;
187  typedef DecimateThread::McDecimaterType McDecimaterType;
188  typedef DecimateThread::MixedDecimaterType MixedDecimaterType;
189 
198 
201 
202  //saves the decimater and the object id
204  {
205  ptr::shared_ptr<BaseDecimaterType> decimater;
206  int objId;
207  ModAspectRatioH hModAspectRatio;
208  ModEdgeLengthH hModEdgeLength;
209  ModHausdorffH hModHausdorff;
210  ModIndependentH hModIndependent;
211  ModNormalDeviationH hModNormalDeviation;
212  ModNormalFlippingH hModNormalFlipping;
213  ModQuadricH hModQuadric;
214  ModRoundnessH hModRoundness;
215  };
216  std::vector< ptr::shared_ptr<DecimaterInit> > decimater_objects_;
217  QIcon* toolIcon_;
218 
219  int runningJobs_;
220 
221 private slots:
222 
224  void slot_decimate();
225  void slot_decimate_finished(QString _jobId); //postprocess after threads finished
226 
228  void slot_initialize();
229  void slot_initialize_object(int obj_id, bool clear = false);
230 
231 private slots:
233  void slotUpdateRoundness(int _value);
234  void slotUpdateRoundness(double _value);
235  void slotUpdateAspectRatio(int _value);
236  void slotUpdateAspectRatio(double _value);
237 
239  void slotUpdateDistance ();
240  void slotUpdateNormalDev ();
241  void slotUpdateVertices ();
242  void slotUpdateTriangles ();
243  void slotUpdateEdgeLength ();
244 
246  void slotUpdateNumVertices();
247  void slotUpdateNumTriangles();
248 
249  void slotMixedCounterValueChanged(double);
250  void slotMixedSliderValueChanged(int);
251  void slotDisableDecimation();
252 
253 private:
254  void initialize_object(BaseObjectData *obj);
255 
256 //===========================================================================
259 //===========================================================================
260 
261 public slots:
262 
269  void decimate(int _objID, QVariantMap _constraints);
270 
273 public slots:
274  QString version() { return QString("1.0"); };
275 
276 };
277 
278 
279 #endif //DECIMATERPLUGIN_HH
Interface class from which all plugins have to be created.
Use Roundness of triangles to control decimation.
Use aspect ratio to control decimation.
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
Logtype
Log types for Message Window.
void slot_decimate()
decimating called from button in toolbox
Use edge length to control decimation.
Update type class.
Definition: UpdateType.hh:70
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void decimate(int _objID, QVariantMap _constraints)
decimate an object
Interface for all Plugins which do logging to the logging window of the framework.
Mesh decimation module computing collapse priority based on error quadrics.
Definition: ModQuadricT.hh:83
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
void slot_initialize()
init called from button in toolbox
Interface for all Plugins which provide scriptable Functions.
QString description()
Description of the Plugin.
void slotUpdateNumVertices()
update number of vertices information
Interface for all plugins which want to Load or Save files and create Objects.
Use Hausdorff distance to control decimation.
Interface class for Thread handling.
Use Normal deviation to control decimation.
~DecimaterPlugin()
Default destructor.
DecimaterToolbarWidget * tool_
Widget for Toolbox.
QString name()
Name of the Plugin.
Interface class for backup handling.
DecimaterPlugin()
Default constructor.
void slotUpdateDistance()
slider / spinbox updates
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
void canceledJob(QString _job)
A job has been canceled.
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles