[opengtl-commits] [535] * emit a signal when configuration is changed

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 535
Author:   cyrille
Date:     2008-12-10 00:08:24 +0100 (Wed, 10 Dec 2008)

Log Message:
-----------
* emit a signal when configuration is changed
* use the proxy to change the parameters of the kernel

Modified Paths:
--------------
    trunk/libQtGTL/QtShiva/CMakeLists.txt
    trunk/libQtGTL/QtShiva/ParametersWidget.cpp
    trunk/libQtGTL/QtShiva/ParametersWidget.h
    trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
    trunk/libQtGTL/QtShiva/ParametersWidget_p.h
    trunk/libQtGTL/QtShiva/Proxy_p.cpp
    trunk/libQtGTL/QtShiva/Proxy_p.h


Modified: trunk/libQtGTL/QtShiva/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/QtShiva/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/CMakeLists.txt	2008-12-09 23:08:24 UTC (rev 535)
@@ -13,6 +13,7 @@
   SpinBoxSliderConnector_p.cpp
   TriangleColorSelector_p.cpp
   RgbaDialog_p.cpp
+  Proxy_p.cpp
   )
 
 qt4_wrap_ui(libQtShiva_SRCS UiRgbaDialog.ui)

Modified: trunk/libQtGTL/QtShiva/ParametersWidget.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidget.cpp	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/ParametersWidget.cpp	2008-12-09 23:08:24 UTC (rev 535)
@@ -43,3 +43,5 @@
   d->kernel = _kernel;
   d->regenerateWidget();
 }
+
+#include "ParametersWidget.moc"

Modified: trunk/libQtGTL/QtShiva/ParametersWidget.h
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidget.h	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/ParametersWidget.h	2008-12-09 23:08:24 UTC (rev 535)
@@ -28,11 +28,14 @@
 
 namespace QtShiva {
   class ParametersWidget : public QWidget {
+    Q_OBJECT
     public:
       ParametersWidget( QWidget* );
       ~ParametersWidget();
     public:
       void setKernel( OpenShiva::Kernel* _kernel );
+    signals:
+      void configurationChanged();
     private:
       struct Private;
       Private* const d;

Modified: trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp	2008-12-09 23:08:24 UTC (rev 535)
@@ -33,6 +33,7 @@
 #include <QSlider>
 
 #include "SpinBoxSliderConnector_p.h"
+#include "Proxy_p.h"
 
 using namespace QtShiva;
 
@@ -108,6 +109,7 @@
   // Label
   QLabel* label = new QLabel( _parameterEntry->name().c_str(), _parent);
   _gridLayout->addWidget(label, _layoutIndex, 0, 1, 1);
+  Proxy* proxy = new Proxy( _parent, _parameterEntry->name(), kernel );
   switch( _parameterEntry->widgetType() )
   {
     case GTLCore::Metadata::ParameterEntry::IntegerWidget:
@@ -123,7 +125,10 @@
       
       connect( spinBox, SIGNAL(valueChanged(int)), horizontalSlider, SLOT(setValue(int)));
       connect( horizontalSlider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
+      connect( spinBox, SIGNAL(valueChanged(int)), self, SIGNAL(configurationChanged()));
       
+      connect( spinBox, SIGNAL(valueChanged(int)), proxy, SLOT(setIntValue(int)));
+      
       int min = _parameterEntry->minimumValue().asInt32();
       int max = _parameterEntry->maximumValue().asInt32();
       int val = _parameterEntry->defaultValue().asInt32();
@@ -151,7 +156,8 @@
       horizontalSlider->setMaximum( 1000 );
       
       SpinBoxSliderConnector* connector = new SpinBoxSliderConnector( _parent, doubleSpinBox, horizontalSlider);
-      connect( connector, SIGNAL(valueChanged(double)), this, SLOT(updateKernelParameters()));
+      connect( connector, SIGNAL(valueChanged(double)), self, SIGNAL(configurationChanged()));
+      connect( connector, SIGNAL(valueChanged(double)), proxy, SLOT(setDoubleValue(double)));
       
       // Set parameters
       doubleSpinBox->setMinimum( _parameterEntry->minimumValue().asFloat() );
@@ -168,9 +174,4 @@
   }
 }
 
-void ParametersWidget::Private::updateKernelParameters()
-{
-  
-}
-
 #include "ParametersWidget_p.moc"

Modified: trunk/libQtGTL/QtShiva/ParametersWidget_p.h
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidget_p.h	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/ParametersWidget_p.h	2008-12-09 23:08:24 UTC (rev 535)
@@ -41,8 +41,6 @@
       QGridLayout* selfLayout;
       // Functions
       void regenerateWidget();
-    private slots:
-      void updateKernelParameters();
     private:
       void createParameterEntryWidget( QWidget* _parent, QGridLayout* _gridLayout, int _layoutIndex, const GTLCore::Metadata::ParameterEntry* _parameterEntry );
   };

Modified: trunk/libQtGTL/QtShiva/Proxy_p.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/Proxy_p.cpp	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/Proxy_p.cpp	2008-12-09 23:08:24 UTC (rev 535)
@@ -19,8 +19,11 @@
 
 #include "Proxy_p.h"
 
+#include <GTLCore/Value.h>
 #include <OpenShiva/Kernel.h>
 
+using namespace QtShiva;
+
 Proxy::Proxy( QObject* parent, const GTLCore::String& _name, OpenShiva::Kernel* _kernel ) : QObject( parent ), m_name(_name), m_kernel( _kernel )
 {
   
@@ -30,14 +33,14 @@
 {
 }
 
-void Proxy::setInt( int v )
+void Proxy::setIntValue( int v )
 {
-  _kernel->setParameter( m_name, v );
+  m_kernel->setParameter( m_name, v );
 }
 
-void Proxy::setFloatValue( float v )
+void Proxy::setDoubleValue( double v )
 {
-  _kernel->setParameter( m_name, v );
+  m_kernel->setParameter( m_name, (float)v );
 }
 
 #include "Proxy_p.moc"

Modified: trunk/libQtGTL/QtShiva/Proxy_p.h
===================================================================
--- trunk/libQtGTL/QtShiva/Proxy_p.h	2008-12-09 19:03:30 UTC (rev 534)
+++ trunk/libQtGTL/QtShiva/Proxy_p.h	2008-12-09 23:08:24 UTC (rev 535)
@@ -20,6 +20,7 @@
 #ifndef _QTSHIVA_PROXY_P_H_
 #define _QTSHIVA_PROXY_P_H_
 
+#include <QObject>
 #include <GTLCore/String.h>
 
 namespace OpenShiva {
@@ -33,8 +34,8 @@
       Proxy( QObject* parent, const GTLCore::String& _name, OpenShiva::Kernel* _kernel );
       ~Proxy();
     public slots:
-      void setInt( int );
-      void setFloatValue( float );
+      void setIntValue( int );
+      void setDoubleValue( double );
     private:
       GTLCore::String m_name;
       OpenShiva::Kernel* m_kernel;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/