SmootherPlugin.hh 6.39 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
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
*                           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/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

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

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
//=============================================================================
//
// SmootherPlugin
//
//=============================================================================

#ifndef SMOOTHERPLUGIN_HH
#define SMOOTHERPLUGIN_HH

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

#include <QObject>
#include <QMenuBar>
#include <QTimer>

#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
61
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>

#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>

#include <OpenMesh/Tools/Smoother/JacobiLaplaceSmootherT.hh>

#include "SmootherToolbarWidget.hh"


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


/** Plugin for Smoother Support
 */
78
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface, ScriptInterface
79 80 81 82 83 84
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(BackupInterface)
  Q_INTERFACES(LoggingInterface)
85
  Q_INTERFACES(ScriptInterface)
86 87 88

signals:

Dirk Wilden's avatar
Dirk Wilden committed
89
  // BaseInterface
90 91
  void updateView();

92
  void updatedObject(int, const UpdateType&);
93

Dirk Wilden's avatar
Dirk Wilden committed
94 95 96 97 98 99
  void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                          QStringList _parameters, QStringList _descriptions);

  // LoggingInterface
  void log(Logtype _type, QString _message);
  void log(QString _message);
Jan Möbius's avatar
Jan Möbius committed
100 101
  
  // ToolboxInterface
Dirk Wilden's avatar
Dirk Wilden committed
102
  void addToolbox( QString _name  , QWidget* _widget, QIcon* _icon );
103 104
  
  // BackupInterface
Dirk Wilden's avatar
Dirk Wilden committed
105
  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
Dirk Wilden's avatar
Dirk Wilden committed
106

107 108 109
  // ScriptInterface
  void scriptInfo(QString _functionName);
  
110 111
public :

Dirk Wilden's avatar
Dirk Wilden committed
112
  /// default constructor
Jan Möbius's avatar
Jan Möbius committed
113
  SmootherPlugin();
114

Dirk Wilden's avatar
Dirk Wilden committed
115
  /// default destructor
116 117 118 119 120 121 122 123
  ~SmootherPlugin() {};

  /// Name of the Plugin
  QString name(){ return (QString("Smoother")); };

  /// Description of the Plugin
  QString description() { return (QString("Mesh Smoothing ...")); };

Dirk Wilden's avatar
Dirk Wilden committed
124 125
private slots:

Jan Möbius's avatar
Jan Möbius committed
126 127
  void initializePlugin(); // BaseInterface
  
Dirk Wilden's avatar
Dirk Wilden committed
128 129
  /// Second initialization stage
  void pluginsInitialized();
130

Jan Möbius's avatar
Jan Möbius committed
131
  /// Tell system that this plugin runs without ui
132 133
  void noguiSupported( ) {} ;

134 135 136 137
private :

  /// Widget for Toolbox
  SmootherToolbarWidget* tool_;
Dirk Wilden's avatar
Dirk Wilden committed
138
  QIcon* toolIcon_;
139 140 141

private slots:

Dirk Wilden's avatar
Dirk Wilden committed
142
  /// Slot connected to the smooth button in the toolbox
143 144
  void slot_smooth();

Dirk Wilden's avatar
Dirk Wilden committed
145 146 147 148 149 150
//===========================================================================
/** @name Scripting Functions
  * @{ */
//===========================================================================
public slots:

Jan Möbius's avatar
Jan Möbius committed
151 152 153 154 155 156 157 158 159
   /** \brief smooth an object
    *
    * @param _objectId    Id of the object that should be smoothed
    * @param _iterations  Number of iterations
    * @param _direction   Tangential or normal?
    * @param _continuity  Continuity selection
    * @param _maxDistance Maximal distance after smoothing
    *
    */
Dirk Wilden's avatar
Dirk Wilden committed
160
   void smooth(int _objectId , int _iterations , QString _direction , QString _continuity, double _maxDistance = -1.0);
161

Jan Möbius's avatar
Jan Möbius committed
162 163
   /** @} */

164 165 166
public slots:
   QString version() { return QString("1.0"); };

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

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

169 170
private:
   typedef OpenMesh::Smoother::JacobiLaplaceSmootherT< TriMesh > SmootherType;
171 172 173
};

#endif //SMOOTHERPLUGIN_HH