Commit 32e12e56 authored by Alexander Wiebel's avatar Alexander Wiebel

[ADD] nav widget slider are now updated with changing property value

parent 8bef783e
......@@ -26,7 +26,6 @@
#include <iostream>
#include <QtGui/QDockWidget>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include <QtGui/QKeyEvent>
......@@ -42,10 +41,10 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, st
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
QSlider *slider = new QSlider( Qt::Horizontal );
slider->setMaximum( maxValue );
slider->setValue( maxValue / 2 );
slider->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
m_slider = new QSlider( Qt::Horizontal );
m_slider->setMaximum( maxValue );
m_slider->setValue( maxValue / 2 );
m_slider->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
QWidget* panel = new QWidget( this );
QVBoxLayout* layout = new QVBoxLayout();
......@@ -99,17 +98,22 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, st
}
layout->addWidget( m_glWidget.get() );
layout->addWidget( slider );
layout->addWidget( m_slider );
panel->setLayout( layout );
setWidget( panel );
connect( slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderValueChanged( int ) ) );
connect( m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderValueChanged( int ) ) );
}
WQtNavGLWidget::~WQtNavGLWidget()
{
if( m_slider )
{
delete m_slider;
m_slider = 0;
}
}
void WQtNavGLWidget::closeEvent( QCloseEvent* event )
......@@ -142,5 +146,13 @@ void WQtNavGLWidget::sliderValueChanged( int value )
void WQtNavGLWidget::setSliderProperty( WPropInt prop )
{
m_sliderProp = prop;
m_sliderProp->getCondition()->subscribeSignal( boost::bind( &WQtNavGLWidget::handleChangedPropertyValue, this ) );
}
void WQtNavGLWidget::handleChangedPropertyValue()
{
if( m_slider )
{
m_slider->setValue( m_sliderProp->get() );
}
}
......@@ -28,6 +28,7 @@
#include <string>
#include <QtGui/QDockWidget>
#include <QtGui/QSlider>
#include "../../common/WPropertyVariable.h"
#include "../../graphicsEngine/WGEGroupNode.h"
......@@ -99,6 +100,8 @@ private:
*/
QString m_sliderTitle;
QSlider *m_slider; //!< A pointer to the slider widget.
/**
* My GL widget.
*/
......@@ -109,6 +112,11 @@ private:
*/
osg::ref_ptr< WGEGroupNode > m_scene;
/**
* Update slider if property changed.
*/
void handleChangedPropertyValue();
private slots:
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment