SmootherPlugin.hh 7.12 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
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 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40 41 42
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
43 44 45 46 47
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
48
\*===========================================================================*/
Jan Möbius's avatar
Jan Möbius committed
49

Jan Möbius's avatar
 
Jan Möbius committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
//=============================================================================
//
// 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>
68
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
Jan Möbius's avatar
 
Jan Möbius committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
#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
 */
85
class SmootherPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface, ScriptInterface
Jan Möbius's avatar
 
Jan Möbius committed
86 87 88 89 90 91
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(BackupInterface)
  Q_INTERFACES(LoggingInterface)
92
  Q_INTERFACES(ScriptInterface)
Jan Möbius's avatar
 
Jan Möbius committed
93

Matthias Möller's avatar
Matthias Möller committed
94 95 96 97
#if QT_VERSION >= 0x050000
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Smoother")
#endif

Jan Möbius's avatar
 
Jan Möbius committed
98 99
signals:

Dirk Wilden's avatar
Dirk Wilden committed
100
  // BaseInterface
Jan Möbius's avatar
 
Jan Möbius committed
101 102
  void updateView();

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

Dirk Wilden's avatar
Dirk Wilden committed
105 106 107 108 109 110
  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
111 112
  
  // ToolboxInterface
Dirk Wilden's avatar
Dirk Wilden committed
113
  void addToolbox( QString _name  , QWidget* _widget, QIcon* _icon );
114 115
  
  // BackupInterface
Dirk Wilden's avatar
Dirk Wilden committed
116
  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
Dirk Wilden's avatar
Dirk Wilden committed
117

118 119 120
  // ScriptInterface
  void scriptInfo(QString _functionName);
  
Jan Möbius's avatar
 
Jan Möbius committed
121 122
public :

Dirk Wilden's avatar
Dirk Wilden committed
123
  /// default constructor
Jan Möbius's avatar
Jan Möbius committed
124
  SmootherPlugin();
Jan Möbius's avatar
 
Jan Möbius committed
125

Dirk Wilden's avatar
Dirk Wilden committed
126
  /// default destructor
Jan Möbius's avatar
 
Jan Möbius committed
127 128 129 130 131 132 133 134
  ~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
135 136
private slots:

Jan Möbius's avatar
Jan Möbius committed
137 138
  void initializePlugin(); // BaseInterface
  
Dirk Wilden's avatar
Dirk Wilden committed
139 140
  /// Second initialization stage
  void pluginsInitialized();
Jan Möbius's avatar
 
Jan Möbius committed
141

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

Jan Möbius's avatar
 
Jan Möbius committed
145 146 147 148
private :

  /// Widget for Toolbox
  SmootherToolbarWidget* tool_;
Dirk Wilden's avatar
Dirk Wilden committed
149
  QIcon* toolIcon_;
Jan Möbius's avatar
 
Jan Möbius committed
150 151 152

private slots:

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

Dirk Wilden's avatar
Dirk Wilden committed
156 157 158 159 160 161
//===========================================================================
/** @name Scripting Functions
  * @{ */
//===========================================================================
public slots:

Jan Möbius's avatar
Jan Möbius committed
162 163
   /** \brief smooth an object
    *
164 165 166 167 168 169
    * @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
    * @param _respectFeatures Keep features
Jan Möbius's avatar
Jan Möbius committed
170 171
    *
    */
172
   void smooth(int _objectId , int _iterations , QString _direction , QString _continuity, double _maxDistance = -1.0, bool _respectFeatures = true);
Jan Möbius's avatar
 
Jan Möbius committed
173

Jan Möbius's avatar
Jan Möbius committed
174 175
   /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
176 177 178
public slots:
   QString version() { return QString("1.0"); };

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

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

181 182
private:
   typedef OpenMesh::Smoother::JacobiLaplaceSmootherT< TriMesh > SmootherType;
Jan Möbius's avatar
 
Jan Möbius committed
183 184 185
};

#endif //SMOOTHERPLUGIN_HH