SmootherPlugin.hh 6.49 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-2014 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

Jan Möbius's avatar
 
Jan Möbius committed
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>
Jan Möbius's avatar
 
Jan Möbius committed
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
Jan Möbius's avatar
 
Jan Möbius committed
79 80 81 82 83 84
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(BackupInterface)
  Q_INTERFACES(LoggingInterface)
85
  Q_INTERFACES(ScriptInterface)
Jan Möbius's avatar
 
Jan Möbius committed
86

Matthias Möller's avatar
Matthias Möller committed
87 88 89 90
#if QT_VERSION >= 0x050000
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Smoother")
#endif

Jan Möbius's avatar
 
Jan Möbius committed
91 92
signals:

Dirk Wilden's avatar
Dirk Wilden committed
93
  // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
94 95
  void updateView();

96
  void updatedObject(int, const UpdateType&);
Jan Möbius's avatar
 
Jan Möbius committed
97

Dirk Wilden's avatar
Dirk Wilden committed
98 99 100 101 102 103
  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
104 105
  
  // ToolboxInterface
Dirk Wilden's avatar
Dirk Wilden committed
106
  void addToolbox( QString _name  , QWidget* _widget, QIcon* _icon );
107 108
  
  // BackupInterface
Dirk Wilden's avatar
Dirk Wilden committed
109
  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
Dirk Wilden's avatar
Dirk Wilden committed
110

111 112 113
  // ScriptInterface
  void scriptInfo(QString _functionName);
  
Jan Möbius's avatar
 
Jan Möbius committed
114 115
public :

Dirk Wilden's avatar
Dirk Wilden committed
116
  /// default constructor
Jan Möbius's avatar
Jan Möbius committed
117
  SmootherPlugin();
Jan Möbius's avatar
 
Jan Möbius committed
118

Dirk Wilden's avatar
Dirk Wilden committed
119
  /// default destructor
Jan Möbius's avatar
 
Jan Möbius committed
120 121 122 123 124 125 126 127
  ~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
128 129
private slots:

Jan Möbius's avatar
Jan Möbius committed
130 131
  void initializePlugin(); // BaseInterface
  
Dirk Wilden's avatar
Dirk Wilden committed
132 133
  /// Second initialization stage
  void pluginsInitialized();
Jan Möbius's avatar
 
Jan Möbius committed
134

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

Jan Möbius's avatar
 
Jan Möbius committed
138 139 140 141
private :

  /// Widget for Toolbox
  SmootherToolbarWidget* tool_;
Dirk Wilden's avatar
Dirk Wilden committed
142
  QIcon* toolIcon_;
Jan Möbius's avatar
 
Jan Möbius committed
143 144 145

private slots:

Dirk Wilden's avatar
Dirk Wilden committed
146
  /// Slot connected to the smooth button in the toolbox
Jan Möbius's avatar
 
Jan Möbius committed
147 148
  void slot_smooth();

Dirk Wilden's avatar
Dirk Wilden committed
149 150 151 152 153 154
//===========================================================================
/** @name Scripting Functions
  * @{ */
//===========================================================================
public slots:

Jan Möbius's avatar
Jan Möbius committed
155 156 157 158 159 160 161 162 163
   /** \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
164
   void smooth(int _objectId , int _iterations , QString _direction , QString _continuity, double _maxDistance = -1.0);
Jan Möbius's avatar
 
Jan Möbius committed
165

Jan Möbius's avatar
Jan Möbius committed
166 167
   /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
168 169 170
public slots:
   QString version() { return QString("1.0"); };

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

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

173 174
private:
   typedef OpenMesh::Smoother::JacobiLaplaceSmootherT< TriMesh > SmootherType;
Jan Möbius's avatar
 
Jan Möbius committed
175 176 177
};

#endif //SMOOTHERPLUGIN_HH