Commit 67c7be29 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - the nav gl widgets now use WPropertyIntWidgets to provide the slider.

- additionally corrected the max value of the coronal slice which was wront
- removed unused maxCoronal,maxSaghital and maxAxial properties
parent b50e3a55
......@@ -109,19 +109,19 @@ void WMainWindow::setupGUI()
bool hideWidget;
if( !( WPreferences::getPreference( "qt4gui.hideAxial", &hideWidget ) && hideWidget) )
{
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "axial", this, 160, "Axial Slice" ) );
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "axial", this, "Axial Slice" ) );
m_navAxial->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideCoronal", &hideWidget ) && hideWidget) )
{
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "coronal", this, 200, "Coronal Slice" ) );
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "coronal", this, "Coronal Slice" ) );
m_navCoronal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideSagittal", &hideWidget ) && hideWidget) )
{
m_navSagittal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "sagittal", this, 160, "Sagittal Slice" ) );
m_navSagittal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "sagittal", this, "Sagittal Slice" ) );
m_navSagittal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
}
......
......@@ -37,21 +37,18 @@
#include "WQtNavGLWidget.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, std::string sliderTitle )
: QDockWidget( title, parent )
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle )
: QDockWidget( title, parent ),
m_propWidget( NULL )
{
m_sliderTitle = QString( sliderTitle.c_str() );
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
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();
m_layout = new QVBoxLayout();
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
m_glWidget->setFixedSize( 150, 150 );
......@@ -101,22 +98,18 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, st
m_scene->setMatrix( m );
}
layout->addWidget( m_glWidget.get() );
layout->addWidget( m_slider );
m_layout->addWidget( m_glWidget.get() );
panel->setLayout( layout );
panel->setLayout( m_layout );
setWidget( panel );
connect( m_slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderValueChanged( int ) ) );
}
WQtNavGLWidget::~WQtNavGLWidget()
{
if( m_slider )
if ( m_propWidget )
{
delete m_slider;
m_slider = 0;
delete m_propWidget;
}
}
......@@ -138,39 +131,9 @@ boost::shared_ptr<WQtGLWidget>WQtNavGLWidget::getGLWidget()
return m_glWidget;
}
void WQtNavGLWidget::sliderValueChanged( int value )
{
if ( m_sliderProp )
{
m_sliderProp->set( value );
}
emit navSliderValueChanged( m_sliderTitle, value );
}
void WQtNavGLWidget::setSliderProperty( WPropInt prop )
{
m_sliderProp = prop;
m_sliderProp->getCondition()->subscribeSignal( boost::bind( &WQtNavGLWidget::handleChangedPropertyValue, this ) );
}
bool WQtNavGLWidget::event( QEvent* event )
{
// a property changed
if ( event->type() == WQT_PROPERTY_CHANGED_EVENT )
{
if( m_slider )
{
m_slider->setValue( m_sliderProp->get() );
}
return true;
}
return QWidget::event( event );
}
void WQtNavGLWidget::handleChangedPropertyValue()
{
// post an event to handle it in the gui thread
QCoreApplication::postEvent( this, new WPropertyChangedEvent() );
m_propWidget = new WPropertyIntWidget( prop, NULL, parentWidget() );
m_layout->addWidget( m_propWidget );
}
......@@ -32,6 +32,7 @@
#include "../../common/WPropertyVariable.h"
#include "../../graphicsEngine/WGEGroupNode.h"
#include "datasetbrowser/WPropertyIntWidget.h"
#include "WQtGLWidget.h"
......@@ -48,10 +49,9 @@ public:
*
* \param title Title will be displayed above the widget
* \param parent The widget that manages this widget
* \param maxValue Maximum value for the corresponding nav slice slider
* \param sliderTitle Name of the slider corresponding to the property it manipulates
*/
explicit WQtNavGLWidget( QString title, QWidget* parent, int maxValue = 100, std::string sliderTitle="pos" );
explicit WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle="pos" );
/**
* destructor.
......@@ -88,34 +88,17 @@ protected:
*/
virtual void closeEvent( QCloseEvent* event );
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
* processes property change events.
*
* \note QT Doc says: use event() for custom events.
* \param event the event that got transmitted.
*
* \return true if the event got handled properly.
*/
virtual bool event( QEvent* event );
private:
/**
* The property which is controlled by the slider
*/
WPropInt m_sliderProp;
/**
* The slider's title.
*/
QString m_sliderTitle;
/**
* The slider representing the property.
* \todo this has to be replaced by a WPropertyIntWidget!
* The property widget representing the slice slider.
*/
QSlider *m_slider;
WPropertyIntWidget* m_propWidget;
/**
* My GL widget.
......@@ -132,24 +115,10 @@ private:
*/
void handleChangedPropertyValue();
private slots:
/**
* Slot getting called whenever the slider gets moved.
*
* \param value the new value of the slider.
*/
void sliderValueChanged( int value );
signals:
/**
* Signals a value change event inside the slider.
*
* \param name name of the slider.
* \param value value of the slider.
* Layout of this widget.
*/
void navSliderValueChanged( QString name, int value );
QVBoxLayout* m_layout;
};
#endif // WQTNAVGLWIDGET_H
......@@ -125,7 +125,7 @@ void WMNavSlices::properties()
m_axialPos->setMax( 160 );
m_coronalPos = m_properties->addProperty( "Coronal Slice", "Position of coronal slice.", 100 );
m_coronalPos->setMin( 0 );
m_coronalPos->setMax( 160 );
m_coronalPos->setMax( 200 );
m_sagittalPos = m_properties->addProperty( "Sagittal Slice", "Position of sagittal slice.", 80 );
m_sagittalPos->setMin( 0 );
m_sagittalPos->setMax( 160 );
......@@ -133,10 +133,6 @@ void WMNavSlices::properties()
m_axialPos->setHidden();
m_coronalPos->setHidden();
m_sagittalPos->setHidden();
m_maxAxial = m_properties->addProperty( "maxAxial", "Max position of axial slice.", 160, true );
m_maxCoronal = m_properties->addProperty( "maxCoronal", "Max position of coronal slice.", 200, true );
m_maxSagittal = m_properties->addProperty( "maxSagittal", "Max position of sagittal slice.", 160, true );
}
void WMNavSlices::notifyDataChange( boost::shared_ptr<WModuleConnector> input,
......
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