DecimaterPlugin.hh 7.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
\*===========================================================================*/

/*===========================================================================*\
*                                                                            *
Jan Möbius's avatar
Jan Möbius committed
37 38 39
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
40 41 42
*                                                                            *
\*===========================================================================*/

43 44 45 46 47 48 49 50
#ifndef DECIMATERPLUGIN_HH
#define DECIMATERPLUGIN_HH

//== INCLUDES =================================================================

#include <QObject>
#include <QMenuBar>
#include <QTimer>
51 52 53 54

#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
55 56 57
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
58 59 60 61 62

#include <OpenFlipper/common/Types.hh>

#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>

63 64
#include "DecimaterInfo.hh"

65 66 67 68 69 70 71 72
#include "DecimaterToolbarWidget.hh"

#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalFlippingT.hh>
#include <OpenMesh/Tools/Decimater/ModHausdorffT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
#include <OpenMesh/Tools/Decimater/ModEdgeLengthT.hh>
73
#include <OpenMesh/Tools/Decimater/ModAspectRatioT.hh>
Jan Möbius's avatar
Jan Möbius committed
74 75
#include <OpenMesh/Tools/Decimater/ModRoundnessT.hh>
#include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
76

77 78
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>

79 80 81

//== CLASS DEFINITION =========================================================

82 83 84 85 86 87 88 89 90 91 92
/** Plugin for Decimater Support
 */
class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, RPCInterface
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(BackupInterface)
  Q_INTERFACES(LoggingInterface)
  Q_INTERFACES(ScriptInterface)
  Q_INTERFACES(RPCInterface)
93 94 95 96 97

signals:

  // BaseInterface
  void updateView();
98
  void updatedObject(int _id, const UpdateType& _type);
99 100
  void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                          QStringList _parameters, QStringList _descriptions);
101 102 103 104 105

  // LoggingInterface
  void log(Logtype _type, QString _message);
  void log(QString _message);

106 107 108 109
  // RPC Interface
  void pluginExists( QString _pluginName , bool& _exists  ) ;
  void functionExists( QString _pluginName , QString _functionName , bool& _exists  );
  
110 111
  // ToolboxInterface
  void addToolbox( QString _name  , QWidget* _widget, QIcon* _icon );
112 113 114 115
  
  // ScriptInterface
  void scriptInfo( QString _functionName );
  
116
  // BackupInterface
117
  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
118

119 120 121 122 123
private slots:
    // BaseInterface
    void initializePlugin();
    void pluginsInitialized();
    
124
    void slotObjectUpdated( int _identifier , const UpdateType& _type ); // BaseInterface
125
    void slotObjectSelectionChanged( int _identifier ); // BaseInterface
126

127 128 129
public :

  /// Default constructor
130
  DecimaterPlugin();
131 132

  /// Default destructor
133 134
  ~DecimaterPlugin() {};

135 136
  /// Name of the Plugin
  QString name(){ return (QString("Decimater")); };
137

138 139 140 141
  /// Description of the Plugin
  QString description() { return (QString(tr("Mesh Decimation ..."))); };

private :
142 143 144 145

  /// Widget for Toolbox
  DecimaterToolbarWidget* tool_;
  QIcon* toolIcon_;
146
  
147
  typedef OpenMesh::Decimater::DecimaterT< TriMesh > DecimaterType;
148
  
Jan Möbius's avatar
Jan Möbius committed
149 150 151 152
  typedef OpenMesh::Decimater::ModAspectRatioT< DecimaterType >::Handle     ModAspectRatioH;
  typedef OpenMesh::Decimater::ModEdgeLengthT< DecimaterType >::Handle      ModEdgeLengthH;
  typedef OpenMesh::Decimater::ModHausdorffT< DecimaterType >::Handle       ModHausdorffH;
  typedef OpenMesh::Decimater::ModIndependentSetsT< DecimaterType >::Handle ModIndependentH;
153
  typedef OpenMesh::Decimater::ModNormalDeviationT< DecimaterType >::Handle ModNormalDeviationH;
Jan Möbius's avatar
Jan Möbius committed
154 155 156
  typedef OpenMesh::Decimater::ModNormalFlippingT< DecimaterType >::Handle  ModNormalFlippingH;
  typedef OpenMesh::Decimater::ModQuadricT< DecimaterType >::Handle         ModQuadricH;
  typedef OpenMesh::Decimater::ModRoundnessT< DecimaterType >::Handle       ModRoundnessH;
157
  
158 159 160 161 162
private slots:

  /// decimating called from button in toolbox
  void slot_decimate();

163 164 165
  /// roundness slider - spinbox sync
  void updateRoundness(int    _value);
  void updateRoundness(double _value);
166 167
  void updateAspectRatio(int _value);
  void updateAspectRatio(double _value);
168 169 170 171 172

  /// slider / spinbox updates
  void updateDistance ();
  void updateNormalDev ();
  void updateVertices ();
173 174
  void updateTriangles ();
  void updateEdgeLength ();
175

176 177
  /// update number of vertices information
  void slotUpdateNumVertices();
178
  void slotUpdateNumTriangles();
179

180 181 182 183
//===========================================================================
/** @name Scripting Functions
  * @{ */
//===========================================================================
184

185
public slots:
Jan Möbius's avatar
Jan Möbius committed
186 187 188

  /** \brief decimate an object
   *
Jan Möbius's avatar
Jan Möbius committed
189
   * @param _objID       Id of the object that should be decimated
Jan Möbius's avatar
Jan Möbius committed
190 191 192
   * @param _constraints List of constraints for the decimater
   *
   */
193
  void decimate(int _objID, QVariantMap _constraints);
194

Jan Möbius's avatar
Jan Möbius committed
195 196
  /** @} */

197
public slots:
198 199 200
   QString version() { return QString("1.0"); };


Jan Möbius's avatar
Jan Möbius committed
201

202 203 204

};

205
#endif //DECIMATERPLUGIN_HH