Commit 6eecf4f3 authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: Show current number of vertices in tool box.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6676 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3272ab6d
...@@ -74,6 +74,9 @@ bool DecimaterPlugin::initializeToolbox(QWidget*& _widget) ...@@ -74,6 +74,9 @@ bool DecimaterPlugin::initializeToolbox(QWidget*& _widget)
connect(tool_->roundness,SIGNAL(valueChanged(double) ),this,SLOT(updateRoundness(double)) ); connect(tool_->roundness,SIGNAL(valueChanged(double) ),this,SLOT(updateRoundness(double)) );
connect(tool_->roundnessSlider,SIGNAL(valueChanged(int) ),this,SLOT(updateRoundness(int)) ); connect(tool_->roundnessSlider,SIGNAL(valueChanged(int) ),this,SLOT(updateRoundness(int)) );
// Force update if the Toolbox gets visible
connect(tool_, SIGNAL(showing()), this, SLOT( slotUpdateNumVertices() ) );
return true; return true;
} }
...@@ -84,7 +87,7 @@ void DecimaterPlugin::pluginsInitialized() { ...@@ -84,7 +87,7 @@ void DecimaterPlugin::pluginsInitialized() {
emit setSlotDescription("decimate(int,Object)","Decimate a given object", emit setSlotDescription("decimate(int,Object)","Decimate a given object",
QString("objectId,constraints").split(","), QString("objectId,constraints").split(","),
QString("ID of an object; Object that can has one or more constraint properties (distance,normal_deviation,roundness,triangles)").split(";")); QString("ID of an object; Object that can has one or more constraint properties (distance,normal_deviation,roundness,vertices)").split(";"));
} }
...@@ -156,8 +159,8 @@ void DecimaterPlugin::slot_decimate() ...@@ -156,8 +159,8 @@ void DecimaterPlugin::slot_decimate()
} }
//decimate //decimate
if ( tool_->cbTriangles->isChecked() ) if ( tool_->cbVertices->isChecked() )
decimater->decimater()->decimate_to( tool_->triangleCount->value() ); // do decimation decimater->decimater()->decimate_to( tool_->verticesCount->value() ); // do decimation
else else
decimater->decimater()->decimate(); // do decimation decimater->decimater()->decimate(); // do decimation
...@@ -244,11 +247,11 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){ ...@@ -244,11 +247,11 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){
bool triangleCount = false; bool triangleCount = false;
int triangles = 0; int triangles = 0;
if ( _constraints.contains("triangles") ){ if ( _constraints.contains("vertices") ){
bool ok; bool ok;
int value = _constraints["triangles"].toInt(&ok); int value = _constraints["vertices"].toInt(&ok);
if (ok){ if (ok){
triangleCount = true; triangleCount = true;
...@@ -281,5 +284,53 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){ ...@@ -281,5 +284,53 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Q_EXPORT_PLUGIN2( DecimaterPlugin , DecimaterPlugin ); void DecimaterPlugin::slotUpdateNumVertices()
{
// Only update if tool is visible
if ( !tool_->isVisible() ) {
return;
}
int current = 0;
int div = 0;
bool ok;
emit functionExists( "info" , "vertexCount(int)", ok ) ;
if (!ok)
{
tool_->currentNumVertices->setText ("<not available>");
return;
}
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS,DataType(DATA_TRIANGLE_MESH)) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
current += RPC::callFunctionValue<int> ("info" , "vertexCount",o_it->id());
div++;
}
if (div <= 0)
tool_->currentNumVertices->setText ("<not available>");
else
tool_->currentNumVertices->setText (QString::number(current / div));
}
//-----------------------------------------------------------------------------
void DecimaterPlugin::slotObjectSelectionChanged(int /*_identifier*/)
{
slotUpdateNumVertices ();
}
//-----------------------------------------------------------------------------
void DecimaterPlugin::slotObjectUpdated(int /*_identifier*/)
{
slotUpdateNumVertices ();
}
//-----------------------------------------------------------------------------
Q_EXPORT_PLUGIN2(DecimaterPlugin , DecimaterPlugin );
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh> #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh> #include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
...@@ -55,13 +56,14 @@ ...@@ -55,13 +56,14 @@
/** Plugin for Decimater Support /** Plugin for Decimater Support
*/ */
class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface, RPCInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(BaseInterface) Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface) Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(BackupInterface) Q_INTERFACES(BackupInterface)
Q_INTERFACES(LoggingInterface) Q_INTERFACES(LoggingInterface)
Q_INTERFACES(RPCInterface)
signals: signals:
...@@ -75,9 +77,16 @@ signals: ...@@ -75,9 +77,16 @@ signals:
void log(Logtype _type, QString _message); void log(Logtype _type, QString _message);
void log(QString _message); void log(QString _message);
// RPC Interface
void pluginExists( QString _pluginName , bool& _exists ) ;
void functionExists( QString _pluginName , QString _functionName , bool& _exists );
private slots: private slots:
// BaseInterface // BaseInterface
void pluginsInitialized(); void pluginsInitialized();
void slotObjectUpdated( int _identifier ); // BaseInterface
void slotObjectSelectionChanged( int _identifier ); // BaseInterface
public : public :
...@@ -110,6 +119,9 @@ private slots: ...@@ -110,6 +119,9 @@ private slots:
void updateRoundness(int _value); void updateRoundness(int _value);
void updateRoundness(double _value); void updateRoundness(double _value);
/// update number of vertices information
void slotUpdateNumVertices();
//=========================================================================== //===========================================================================
/** @name Scripting Functions /** @name Scripting Functions
* @{ */ * @{ */
......
...@@ -37,3 +37,9 @@ DecimaterToolbarWidget::DecimaterToolbarWidget(QWidget *parent) ...@@ -37,3 +37,9 @@ DecimaterToolbarWidget::DecimaterToolbarWidget(QWidget *parent)
{ {
setupUi(this); setupUi(this);
} }
void DecimaterToolbarWidget::showEvent (QShowEvent *_event)
{
QWidget::showEvent ( _event );
emit showing();
}
...@@ -39,8 +39,15 @@ class DecimaterToolbarWidget : public QWidget, public Ui::DecimaterToolbar ...@@ -39,8 +39,15 @@ class DecimaterToolbarWidget : public QWidget, public Ui::DecimaterToolbar
{ {
Q_OBJECT Q_OBJECT
signals:
// emitted when the widget will get visible
void showing();
public: public:
DecimaterToolbarWidget(QWidget *parent = 0); DecimaterToolbarWidget(QWidget *parent = 0);
protected:
void showEvent (QShowEvent *_event);
}; };
#endif //DECIMATERTOOLBARWIDGET_HH #endif //DECIMATERTOOLBARWIDGET_HH
......
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DecimaterToolbar</class> <class>DecimaterToolbar</class>
<widget class="QWidget" name="DecimaterToolbar" > <widget class="QWidget" name="DecimaterToolbar">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>311</width> <width>295</width>
<height>218</height> <height>290</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="groupBox_2" > <widget class="QGroupBox" name="groupBox_2">
<property name="title" > <property name="title">
<string>Constraints</string> <string>Constraints</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="0" > <item>
<widget class="QCheckBox" name="cbDistance" > <layout class="QGridLayout" name="gridLayout">
<property name="text" > <item row="0" column="0">
<string>Distance</string> <widget class="QCheckBox" name="cbDistance">
</property> <property name="text">
</widget> <string>Distance</string>
</item> </property>
<item row="1" column="0" > </widget>
<widget class="QCheckBox" name="cbNormalDev" > </item>
<property name="toolTip" > <item row="0" column="2">
<string>Restrict Normal Deviation</string> <widget class="QDoubleSpinBox" name="distance">
</property> <property name="decimals">
<property name="statusTip" > <number>3</number>
<string>Restrict Normal Deviation</string> </property>
</property> <property name="maximum">
<property name="text" > <double>10000.000000000000000</double>
<string>Normal Dev.</string> </property>
</property> <property name="singleStep">
</widget> <double>1.000000000000000</double>
</item> </property>
<item row="1" column="2" > <property name="value">
<widget class="QSpinBox" name="normalDeviation" > <double>0.000000000000000</double>
<property name="enabled" > </property>
<bool>true</bool> </widget>
</property> </item>
<property name="toolTip" > <item row="1" column="0">
<string comment="Maximal normal deviation between original normal and normals after decimation step defined in degrees." >&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> <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>
</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; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> &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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Maximal normal deviation between &lt;/p> &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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">original normal and normals after &lt;/p> &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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">decimation step defined in degrees.&lt;/p>&lt;/body>&lt;/html></string> &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>
<property name="statusTip" > <property name="statusTip">
<string>Restrict Normal deviation</string> <string>Restrict Normal Deviation</string>
</property> </property>
<property name="maximum" > <property name="maximum">
<number>180</number> <number>180</number>
</property> </property>
<property name="value" > <property name="value">
<number>10</number> <number>10</number>
</property> </property>
</widget> <property name="orientation">
</item> <enum>Qt::Horizontal</enum>
<item row="2" column="0" > </property>
<widget class="QCheckBox" name="cbRoundness" > </widget>
<property name="enabled" > </item>
<bool>true</bool> <item row="1" column="2">
</property> <widget class="QSpinBox" name="normalDeviation">
<property name="text" > <property name="enabled">
<string>Roundness</string> <bool>true</bool>
</property> </property>
<property name="checkable" > <property name="toolTip">
<bool>true</bool> <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;
</property> p, li { white-space: pre-wrap; }
<property name="checked" > &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;
<bool>false</bool> &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;
</property> &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;
</widget> &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>
</item> </property>
<item row="2" column="1" > <property name="statusTip">
<widget class="QSlider" name="roundnessSlider" > <string>Restrict Normal deviation</string>
<property name="maximum" > </property>
<number>100</number> <property name="maximum">
</property> <number>180</number>
<property name="value" > </property>
<number>50</number> <property name="value">
</property> <number>10</number>
<property name="orientation" > </property>
<enum>Qt::Horizontal</enum> </widget>
</property> </item>
</widget> <item row="2" column="0">
</item> <widget class="QCheckBox" name="cbRoundness">
<item row="3" column="0" > <property name="enabled">
<widget class="QCheckBox" name="cbTriangles" > <bool>true</bool>
<property name="enabled" > </property>
<bool>true</bool> <property name="text">
</property> <string>Roundness</string>
<property name="text" > </property>
<string>#Triangles</string> <property name="checkable">
</property> <bool>true</bool>
</widget> </property>
</item> <property name="checked">
<item row="3" column="1" > <bool>false</bool>
<widget class="QSlider" name="triangleCountSlider" > </property>
<property name="maximum" > </widget>
<number>100000</number> </item>
</property> <item row="2" column="1">
<property name="value" > <widget class="QSlider" name="roundnessSlider">
<number>5000</number> <property name="maximum">
</property> <number>100</number>
<property name="orientation" > </property>
<enum>Qt::Horizontal</enum> <property name="value">
</property> <number>50</number>
</widget> </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="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="maximum">
<number>99999</number>
</property>
<property name="value">
<number>5000</number>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="3" column="2" > <item>
<widget class="QSpinBox" name="triangleCount" > <layout class="QHBoxLayout" name="horizontalLayout">
<property name="enabled" > <item>
<bool>true</bool> <widget class="QLabel" name="label_3">
</property> <property name="text">
<property name="maximum" > <string>Current number of vertices:</string>
<number>99999</number> </property>
</property> </widget>
<property name="value" > </item>
<number>5000</number> <item>
</property> <widget class="QLabel" name="currentNumVertices">
</widget> <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>
<item row="2" column="2" > <item>
<widget class="QDoubleSpinBox" name="roundness" > <widget class="QPushButton" name="pbDecimate">
<property name="enabled" > <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="decimals" > <property name="text">
<number>2</number> <string>Decimate</string>
</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="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="1" >
<widget class="QSlider" name="normalDeviationSlider" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Maximal normal deviation between &lt;/p>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">original normal and normals after &lt;/p>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">decimation step defined in degrees.&lt;/p>&lt;/body>&lt;/html></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> </property>
</widget> </widget>