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)
connect(tool_->roundness,SIGNAL(valueChanged(double) ),this,SLOT(updateRoundness(double)) );
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;
}
......@@ -84,7 +87,7 @@ void DecimaterPlugin::pluginsInitialized() {
emit setSlotDescription("decimate(int,Object)","Decimate a given object",
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()
}
//decimate
if ( tool_->cbTriangles->isChecked() )
decimater->decimater()->decimate_to( tool_->triangleCount->value() ); // do decimation
if ( tool_->cbVertices->isChecked() )
decimater->decimater()->decimate_to( tool_->verticesCount->value() ); // do decimation
else
decimater->decimater()->decimate(); // do decimation
......@@ -244,11 +247,11 @@ void DecimaterPlugin::decimate(int _objID, QVariantMap _constraints){
bool triangleCount = false;
int triangles = 0;
if ( _constraints.contains("triangles") ){
if ( _constraints.contains("vertices") ){
bool ok;
int value = _constraints["triangles"].toInt(&ok);
int value = _constraints["vertices"].toInt(&ok);
if (ok){
triangleCount = true;
......@@ -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 @@
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/common/Types.hh>
......@@ -55,13 +56,14 @@
/** Plugin for Decimater Support
*/
class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface
class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, BackupInterface, RPCInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(BackupInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(RPCInterface)
signals:
......@@ -75,9 +77,16 @@ signals:
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 );
private slots:
// BaseInterface
void pluginsInitialized();
void slotObjectUpdated( int _identifier ); // BaseInterface
void slotObjectSelectionChanged( int _identifier ); // BaseInterface
public :
......@@ -110,6 +119,9 @@ private slots:
void updateRoundness(int _value);
void updateRoundness(double _value);
/// update number of vertices information
void slotUpdateNumVertices();
//===========================================================================
/** @name Scripting Functions
* @{ */
......
......@@ -37,3 +37,9 @@ DecimaterToolbarWidget::DecimaterToolbarWidget(QWidget *parent)
{
setupUi(this);
}
void DecimaterToolbarWidget::showEvent (QShowEvent *_event)
{
QWidget::showEvent ( _event );
emit showing();
}
......@@ -39,8 +39,15 @@ class DecimaterToolbarWidget : public QWidget, public Ui::DecimaterToolbar
{
Q_OBJECT
signals:
// emitted when the widget will get visible
void showing();
public:
DecimaterToolbarWidget(QWidget *parent = 0);
protected:
void showEvent (QShowEvent *_event);
};
#endif //DECIMATERTOOLBARWIDGET_HH
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DecimaterToolbar</class>
<widget class="QWidget" name="DecimaterToolbar" >
<property name="geometry" >
<widget class="QWidget" name="DecimaterToolbar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>218</height>
<width>295</width>
<height>290</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Constraints</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QCheckBox" name="cbDistance" >
<property name="text" >
<string>Distance</string>
</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>
</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>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<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>
</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>&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>
</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="3" column="0" >
<widget class="QCheckBox" name="cbTriangles" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>#Triangles</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSlider" name="triangleCountSlider" >
<property name="maximum" >
<number>100000</number>
</property>
<property name="value" >
<number>5000</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
&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="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 row="3" column="2" >
<widget class="QSpinBox" name="triangleCount" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="maximum" >
<number>99999</number>
</property>
<property name="value" >
<number>5000</number>
</property>
</widget>
<item>
<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 row="2" column="2" >
<widget class="QDoubleSpinBox" name="roundness" >
<property name="enabled" >
<item>
<widget class="QPushButton" name="pbDecimate">
<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="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 name="text">
<string>Decimate</string>
</property>
</widget>
</item>
......@@ -191,18 +230,21 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QPushButton" name="pbDecimate" >
<property name="enabled" >
<bool>true</bool>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="text" >
<string>Decimate</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections>
......@@ -212,11 +254,11 @@ p, li { white-space: pre-wrap; }
<receiver>normalDeviation</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>179</x>
<y>71</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>258</x>
<y>76</y>
</hint>
......@@ -228,43 +270,43 @@ p, li { white-space: pre-wrap; }
<receiver>normalDeviationSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>232</x>
<y>81</y>
</hint>