Commit 6f18a155 authored by Jan Möbius's avatar Jan Möbius

Convert to original plugin style

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12856 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f55dcc69
This diff is collapsed.
......@@ -40,18 +40,28 @@
* *
\*===========================================================================*/
#ifndef DECIMATER_PLUGIN_HH_INCLUDED
#define DECIMATER_PLUGIN_HH_INCLUDED
#ifndef DECIMATERPLUGIN_HH
#define DECIMATERPLUGIN_HH
//== INCLUDES =================================================================
#include <QObject>
#include <QMenuBar>
#include <QTimer>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include "DecimaterInfo.hh"
#include "DecimaterToolbarWidget.hh"
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
......@@ -64,48 +74,78 @@
#include <OpenMesh/Tools/Decimater/ModRoundnessT.hh>
#include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
//== CLASS DEFINITION =========================================================
class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface {
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(BackupInterface)
/** 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)
signals:
// BaseInterface
void updateView();
void updatedObject(int _id, const UpdateType _type);
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
// LoggingInterface
void log(Logtype _type, QString _message);
void log(QString _message);
// RPC Interface
void pluginExists( QString _pluginName , bool& _exists ) ;
void functionExists( QString _pluginName , QString _functionName , bool& _exists );
// ToolboxInterface
void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
// ScriptInterface
void scriptInfo( QString _functionName );
// BackupInterface
void createBackup(int _id, QString _name, UpdateType _type = UPDATE_ALL);
void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
public:
private slots:
// BaseInterface
void initializePlugin();
void pluginsInitialized();
void slotObjectUpdated( int _identifier , const UpdateType _type ); // BaseInterface
void slotObjectSelectionChanged( int _identifier ); // BaseInterface
public :
/// Default constructor
DecimaterPlugin() : tool_(0) {};
/// Default destructor
~DecimaterPlugin() {};
QString name() { return QString("DecimaterPlugin"); };
QString description() { return QString("Mesh Decimater Plugin"); };
/// Name of the Plugin
QString name(){ return (QString("Decimater")); };
private:
/// Description of the Plugin
QString description() { return (QString(tr("Mesh Decimation ..."))); };
private :
/// Widget for Toolbox
DecimaterToolbarWidget* tool_;
QIcon* toolIcon_;
typedef OpenMesh::Decimater::DecimaterT< TriMesh > DecimaterType;
typedef OpenMesh::Decimater::ModAspectRatioT< DecimaterType >::Handle ModAspectRatioH;
typedef OpenMesh::Decimater::ModEdgeLengthT< DecimaterType >::Handle ModEdgeLengthH;
typedef OpenMesh::Decimater::ModHausdorffT< DecimaterType >::Handle ModHausdorffH;
......@@ -114,39 +154,38 @@ private:
typedef OpenMesh::Decimater::ModNormalFlippingT< DecimaterType >::Handle ModNormalFlippingH;
typedef OpenMesh::Decimater::ModQuadricT< DecimaterType >::Handle ModQuadricH;
typedef OpenMesh::Decimater::ModRoundnessT< DecimaterType >::Handle ModRoundnessH;
private slots:
// BaseInterface
void initializePlugin();
void slotObjectUpdated(int _identifier , const UpdateType _type);
void slotObjectSelectionChanged(int _identifier);
/// initialization called from button in toolbox
void slot_init();
/// decimating called from button in toolbox
void slot_decimate();
// slider / spinbox updates
void slotUpdateNumTriangles();
/// roundness slider - spinbox sync
void updateRoundness(int _value);
void updateRoundness(double _value);
/// slider / spinbox updates
void updateDistance ();
void updateNormalDev ();
void updateVertices ();
void updateNormalDev(int _value);
void updateAspectRatio(int _value);
void updateAspectRatio(double _value);
void updateNumTriangles(int _value);
/// update number of vertices information
void slotUpdateNumVertices();
// checkbox updates
void cbUpdateDistance(int _state);
void cbUpdateNormalDev(int _state);
void cbUpdateAspectRatio(int _state);
void cbUpdateEdgeLength(int _state);
void cbUpdateNumTriangles(int _state);
//===========================================================================
/** @name Scripting Functions
* @{ */
//===========================================================================
public slots:
void decimate(int _objID, QVariantMap _constraints);
public slots:
QString version() { return QString("1.0"); };
/** @} */
QString version() { return QString("0.1"); };
};
#endif
#endif //DECIMATERPLUGIN_HH
......@@ -36,7 +36,7 @@
* *
* $Revision: 10745 $ *
* $LastChangedBy: moebius $ *
* $Date: 2011-01-26 10:23:50 +0100 (Wed, 26 Jan 2011) $ *
* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26 Jan 2011) $ *
* *
\*===========================================================================*/
......
......@@ -34,14 +34,12 @@
/*===========================================================================*\
* *
* $Revision: 11270 $ *
* $LastChangedBy: wilden $ *
* $Date: 2011-04-11 15:13:21 +0200 (Mo, 11 Apr 2011) $ *
* $Revision: 10745 $ *
* $LastChangedBy: moebius $ *
* $Date: 2011-01-26 10:23:50 +0100 (Mi, 26 Jan 2011) $ *
* *
\*===========================================================================*/
#ifndef DECIMATERTOOLBARWIDGET_HH
#define DECIMATERTOOLBARWIDGET_HH
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>386</height>
<width>364</width>
<height>290</height>
</rect>
</property>
<property name="windowTitle">
......@@ -15,226 +15,223 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="DecimationOrder">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Decimation Order</string>
<string>Constraints</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="rbByDistance">
<property name="text">
<string>by Distance</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="cbDistance">
<property name="text">
<string>Distance</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="distance">
<property name="decimals">
<number>3</number>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cbNormalDev">
<property name="toolTip">
<string>Restrict Normal Deviation</string>
</property>
<property name="statusTip">
<string>Restrict Normal Deviation</string>
</property>
<property name="text">
<string>Normal Dev.</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="normalDeviationSlider">
<property name="toolTip">
<string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Maximal normal deviation between &lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;original normal and normals after &lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;decimation step defined in degrees.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Restrict Normal Deviation</string>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="value">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="normalDeviation">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string comment="Maximal normal deviation between original normal and normals after decimation step defined in degrees.">&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Maximal normal deviation between &lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;original normal and normals after &lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;decimation step defined in degrees.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Restrict Normal deviation</string>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cbRoundness">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Roundness</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="roundnessSlider">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="roundness">
<property name="enabled">
<bool>true</bool>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbVertices">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>#Vertices</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSlider" name="verticesCountSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>5000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="verticesCount">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99999</number>
</property>
<property name="value">
<number>5000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="rbByNormalDeviation">
<property name="text">
<string>by Normal Deviation</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Current number of vertices:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="currentNumVertices">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;not available&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QRadioButton" name="rbByEdgeLength">
<property name="text">
<string>by Edge Length</string>
</property>
<attribute name="buttonGroup">
<string>buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="Constraints">
<property name="title">
<string>Constraints</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="cbDistance">
<property name="text">
<string>Distance</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="distance">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Maximum Hausdorff distance after a collapse to the original mesh.</string>
</property>
<property name="statusTip">
<string>Maximum Hausdorff distance after a collapse to the original mesh.</string>
</property>
<property name="whatsThis">
<string>Maximum Hausdorff distance after a collapse to the original mesh.</string>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cbNormalDev">
<property name="text">
<string>Normal Dev.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="normalDevSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>180</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="normalDev">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>180</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cbAspectRatio">
<property name="text">
<string>Aspect Ratio</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="aspectRatioSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>120</number>
</property>
<property name="maximum">
<number>1500</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="aspectRatio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>15.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbEdgeLength">
<property name="text">
<string>Edge Length</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="edgeLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Collapse smallest edge first, but don't collapse edges longer than given value</string>
</property>
<property name="statusTip">
<string>Collapse smallest edge first, but don't collapse edges longer than given value</string>
</property>
<property name="whatsThis">
<string>Collapse smallest edge first, but
don't collapse edges longer than given value</string>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="cbNumTriangles">
<widget class="QPushButton" name="pbDecimate">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>#Triangles</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSlider" name="numTrianglesSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="tracking">
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="numTriangles">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Stop when the given number of triangles is reached</string>
</property>
<property name="statusTip">
<string>Stop when the given number of triangles is reached</string>
</property>
<property name="whatsThis">
<string>Stop when the given number of triangles is reached</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>