[opengtl-commits] [541] * fix creation of subgroup widgets |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 541
Author: cyrille
Date: 2008-12-12 18:55:43 +0100 (Fri, 12 Dec 2008)
Log Message:
-----------
* fix creation of subgroup widgets
* set color parameter in the kernel when changed by widget
Modified Paths:
--------------
trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
trunk/libQtGTL/QtShiva/Proxy_p.cpp
Modified: trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
+++ trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp 2008-12-12 17:55:43 UTC (rev 541)
@@ -20,12 +20,13 @@
#include "ParametersWidget_p.h"
#include <OpenShiva/Kernel.h>
-#include <OpenShiva/KernelMetadata.h>
+#include <OpenShiva/Metadata.h>
#include <GTLCore/Value.h>
#include <GTLCore/Metadata/Entry.h>
#include <GTLCore/Metadata/Group.h>
#include <GTLCore/Metadata/ParameterEntry.h>
+#include <QDebug>
#include <QDoubleSpinBox>
#include <QGridLayout>
#include <QLabel>
@@ -86,13 +87,16 @@
int groupPosInGrid = 0;
foreach( const GTLCore::Metadata::Entry* groupEntry, gr->entries() )
{
- if( const GTLCore::Metadata::ParameterEntry* gpe = entry->asParameterEntry() )
+ if( const GTLCore::Metadata::ParameterEntry* gpe = groupEntry->asParameterEntry() )
{
createParameterEntryWidget( groupWidget, groupWidgetGridLayout, groupPosInGrid, gpe );
++groupPosInGrid;
+ } else {
+ qDebug() << "Non parameter entry: " << groupEntry->name().c_str() ;
}
}
- tabWidget->addTab( groupWidget, gr->name().c_str() );
+ QString caption = ( ( gr->label() == "" ) ? gr->name() : gr->label() ).c_str();
+ tabWidget->addTab( groupWidget, caption );
}
}
@@ -108,7 +112,8 @@
void ParametersWidget::Private::createParameterEntryWidget( QWidget* _parent, QGridLayout* _gridLayout, int _layoutIndex, const GTLCore::Metadata::ParameterEntry* _parameterEntry )
{
// Label
- QLabel* label = new QLabel( _parameterEntry->name().c_str(), _parent);
+ QString caption = ( ( _parameterEntry->label() == "" ) ? _parameterEntry->name() : _parameterEntry->label() ).c_str();
+ QLabel* label = new QLabel( caption + ":", _parent);
_gridLayout->addWidget(label, _layoutIndex, 0, 1, 1);
Proxy* proxy = new Proxy( _parent, _parameterEntry->name(), kernel );
switch( _parameterEntry->widgetType() )
@@ -180,6 +185,7 @@
double b = (*valArr)[2].asFloat() * 255;
colorButton->setCurrentColor( QColor(r,g,b ) );
_gridLayout->addWidget(colorButton, _layoutIndex, 1, 1, 1);
+ connect( colorButton, SIGNAL(colorChanged(const QColor&)), proxy, SLOT(setColor(const QColor&)));
}
break;
}
Modified: trunk/libQtGTL/QtShiva/Proxy_p.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/Proxy_p.cpp 2008-12-12 17:54:03 UTC (rev 540)
+++ trunk/libQtGTL/QtShiva/Proxy_p.cpp 2008-12-12 17:55:43 UTC (rev 541)
@@ -19,6 +19,10 @@
#include "Proxy_p.h"
+#include <QColor>
+
+#include <GTLCore/Type.h>
+#include <GTLCore/TypesManager.h>
#include <GTLCore/Value.h>
#include <OpenShiva/Kernel.h>
@@ -43,9 +47,14 @@
m_kernel->setParameter( m_name, (float)v );
}
-void Proxy::setColor( const QColor& )
+#include <cstdlib>
+void Proxy::setColor( const QColor& c )
{
-
+ std::vector< GTLCore::Value > cv;
+ cv.push_back( c.red() / 255.0f );
+ cv.push_back( c.green() / 255.0f );
+ cv.push_back( c.blue() / 255.0f );
+ m_kernel->setParameter( m_name, GTLCore::Value( cv, GTLCore::TypesManager::getVector( GTLCore::Type::Float, 3 ) ) );
}
#include "Proxy_p.moc"