Commit 33e5c76f authored by schurade's avatar schurade

[ADD] some major overhaul of the system how modules connect to the gui

parent 42b8afe2
......@@ -126,6 +126,7 @@ ENDIF ( NOT CMAKE_BUILD_TYPE STREQUAL "Static" )
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/bin/shaders)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modules/navigationSlices/slice.vs ${CMAKE_BINARY_DIR}/bin/shaders/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modules/navigationSlices/slice.fs ${CMAKE_BINARY_DIR}/bin/shaders/)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modules/navigationSlices/functions.fs ${CMAKE_BINARY_DIR}/bin/shaders/)
# Special targets:
#-------------------------------------------------------------------------------------------------------------
......
......@@ -58,15 +58,14 @@ public:
virtual std::vector< boost::shared_ptr< WModule > >getDataSetList( int subjectId ) = 0;
/**
* getter functions for all signals provided by the gui
* getter functions for the signales proved by the gui
*/
virtual boost::signal1< void, std::vector< std::string > >* getLoadButtonSignal() = 0;
virtual boost::signal1< void, int >* getAxialSliderSignal() = 0;
virtual boost::signal1< void, int >* getCoronalSliderSignal() = 0;
virtual boost::signal1< void, int >* getSagittalSliderSignal() = 0;
virtual boost::signal1< void, bool >* getAxialButtonSignal() = 0;
virtual boost::signal1< void, bool >* getCoronalButtonSignal() = 0;
virtual boost::signal1< void, bool >* getSagittalButtonSignal() = 0;
/**
* this function allows modules to register their property object with the gui
*/
virtual void connectProperties( WProperties* properties ) = 0;
protected:
bool m_isInitialized;
......
......@@ -13,10 +13,12 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtNavGLWidget.h
WPropertyManager.h
datasetbrowser/WQtCheckBox.h
datasetbrowser/WQtDatasetBrowser.h
datasetbrowser/WQtDSBWidget.h
datasetbrowser/WQtLineEdit.h
datasetbrowser/WQtSliderWithEdit.h
datasetbrowser/WQtNumberEdit.h
datasetbrowser/WQtTreeWidget.h
)
......
......@@ -41,6 +41,7 @@
WMainWindow::WMainWindow()
{
m_propertyManager = new WPropertyManager();
}
WMainWindow::~WMainWindow()
......@@ -74,15 +75,15 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
mainWindow->setCentralWidget( widget.get() );
// initially 3 views
m_navAxial = new WQtNavGLWidget( "axial", 160 );
m_navAxial = new WQtNavGLWidget( "axial", 160, "axialPos" );
m_glWidgets.push_back( m_navAxial->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial );
m_navCoronal = new WQtNavGLWidget( "coronal", 200 );
m_navCoronal = new WQtNavGLWidget( "coronal", 200, "coronalPos" );
m_glWidgets.push_back( m_navCoronal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal );
m_navSagittal = new WQtNavGLWidget( "sagittal", 160 );
m_navSagittal = new WQtNavGLWidget( "sagittal", 160, "sagittalPos" );
m_glWidgets.push_back( m_navSagittal->getGLWidget() );
mainWindow->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal );
......@@ -98,6 +99,16 @@ void WMainWindow::setupGUI( QMainWindow *mainWindow )
connect( m_toolBar->getAxiButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleAxial( bool ) ) );
connect( m_toolBar->getCorButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleCoronal( bool ) ) );
connect( m_toolBar->getSagButton(), SIGNAL( toggled( bool ) ), this, SLOT( toggleSagittal( bool ) ) );
connect( m_navAxial, SIGNAL( navSliderValueChanged( std::string, int ) ),
m_propertyManager, SLOT( slotIntChanged( std::string, int ) ) );
connect( m_navCoronal, SIGNAL( navSliderValueChanged( std::string, int ) ),
m_propertyManager, SLOT( slotIntChanged( std::string, int ) ) );
connect( m_navSagittal, SIGNAL( navSliderValueChanged( std::string, int ) ),
m_propertyManager, SLOT( slotIntChanged( std::string, int ) ) );
connect( m_datasetBrowser, SIGNAL( dataSetBrowserEvent( std::string, bool ) ),
m_propertyManager, SLOT( slotBoolChanged( std::string, bool ) ) );
}
......@@ -141,17 +152,17 @@ void WMainWindow::openLoadDialog()
void WMainWindow::toggleAxial( bool check )
{
m_axiSignal( check );
m_propertyManager->slotBoolChanged( "showAxial", check );
}
void WMainWindow::toggleCoronal( bool check )
{
m_corSignal( check );
m_propertyManager->slotBoolChanged( "showCoronal", check );
}
void WMainWindow::toggleSagittal( bool check )
{
m_sagSignal( check );
m_propertyManager->slotBoolChanged( "showSagittal", check );
}
boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal()
......@@ -159,36 +170,7 @@ boost::signal1< void, std::vector< std::string > >* WMainWindow::getLoaderSignal
return &m_loaderSignal;
}
boost::signal1< void, bool >* WMainWindow::getAxiSignal()
{
return &m_axiSignal;
}
boost::signal1< void, bool >* WMainWindow::getCorSignal()
{
return &m_corSignal;
}
boost::signal1< void, bool >* WMainWindow::getSagSignal()
WPropertyManager* WMainWindow::getPropertyManager()
{
return &m_sagSignal;
return m_propertyManager;
}
WQtNavGLWidget* WMainWindow::getNavAxial()
{
return m_navAxial;
}
WQtNavGLWidget* WMainWindow::getNavCoronal()
{
return m_navCoronal;
}
WQtNavGLWidget* WMainWindow::getNavSagittal()
{
return m_navSagittal;
}
......@@ -40,6 +40,7 @@
#include "WQtNavGLWidget.h"
#include "WQtRibbonMenu.h"
#include "WPropertyManager.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
// forward declarations
class WQtGLWidget;
......@@ -81,15 +82,12 @@ public:
/**
*
*/
boost::signal1< void, std::vector< std::string > >* getLoaderSignal();
boost::signal1< void, bool >* getAxiSignal();
boost::signal1< void, bool >* getCorSignal();
boost::signal1< void, bool >* getSagSignal();
WPropertyManager* getPropertyManager();
WQtNavGLWidget* getNavAxial();
WQtNavGLWidget* getNavCoronal();
WQtNavGLWidget* getNavSagittal();
/**
*
*/
boost::signal1< void, std::vector< std::string > >* getLoaderSignal();
public slots:
/**
......@@ -104,6 +102,8 @@ public slots:
private:
QIcon m_mainWindowIcon;
WPropertyManager* m_propertyManager;
QWidget* m_centralwidget;
WQtRibbonMenu* m_toolBar;
......@@ -115,9 +115,6 @@ private:
WQtNavGLWidget* m_navSagittal;
boost::signal1< void, std::vector< std::string > > m_loaderSignal;
boost::signal1< void, bool > m_axiSignal;
boost::signal1< void, bool > m_corSignal;
boost::signal1< void, bool > m_sagSignal;
};
#endif // WMAINWINDOW_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WPropertyManager.h"
WPropertyManager::WPropertyManager()
{
}
WPropertyManager::~WPropertyManager()
{
}
void WPropertyManager::connectProperties( WProperties* properties )
{
m_connectedProperties.push_back( properties );
}
void WPropertyManager::slotBoolChanged( std::string name, bool value )
{
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name, value );
}
}
void WPropertyManager::slotIntChanged( std::string name, int value )
{
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name, value );
}
}
void WPropertyManager::slotFloatChanged( std::string name, float value )
{
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name, value );
}
}
void WPropertyManager::slotStringChanged( std::string name, std::string value )
{
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name, value );
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYMANAGER_H
#define WPROPERTYMANAGER_H
#include <string>
#include <vector>
#include <QtCore/QObject>
#include "../../kernel/WProperties.h"
/**
* Class that implements a list for pointers to properties objects from modules
* Gui elemements will connect to its slots and write values to coresponding properties
*/
class WPropertyManager : public QObject
{
Q_OBJECT
public:
/**
* standard constructor
*/
WPropertyManager();
/**
* destructor
*/
virtual ~WPropertyManager();
/**
* adds a property pointer to the list
*/
void connectProperties( WProperties* properties );
public slots:
/**
* slot function that writes a boolean value to all properties objects that contain an entry
* with that name
*/
void slotBoolChanged( std::string name, bool value );
/**
* slot function that writes a integer value to all properties objects that contain an entry
* with that name
*/
void slotIntChanged( std::string name, int value );
/**
* slot function that writes a float value to all properties objects that contain an entry
* with that name
*/
void slotFloatChanged( std::string name, float value );
/**
* slot function that writes a string value to all properties objects that contain an entry
* with that name
*/
void slotStringChanged( std::string name, std::string value );
protected:
private:
std::vector<WProperties*>m_connectedProperties;
};
#endif // WPROPERTYMANAGER_H
......@@ -88,32 +88,7 @@ boost::signal1< void, std::vector< std::string > >* WQt4Gui::getLoadButtonSignal
return m_gui->getLoaderSignal();
}
boost::signal1< void, int >* WQt4Gui::getAxialSliderSignal()
void WQt4Gui::connectProperties( WProperties* properties )
{
return m_gui->getNavAxial()->getboostSignal();
}
boost::signal1< void, int >* WQt4Gui::getCoronalSliderSignal()
{
return m_gui->getNavCoronal()->getboostSignal();
}
boost::signal1< void, int >* WQt4Gui::getSagittalSliderSignal()
{
return m_gui->getNavSagittal()->getboostSignal();
}
boost::signal1< void, bool >* WQt4Gui::getAxialButtonSignal()
{
return m_gui->getAxiSignal();
}
boost::signal1< void, bool >* WQt4Gui::getCoronalButtonSignal()
{
return m_gui->getCorSignal();
}
boost::signal1< void, bool >* WQt4Gui::getSagittalButtonSignal()
{
return m_gui->getSagSignal();
m_gui->getPropertyManager()->connectProperties( properties );
}
......@@ -39,7 +39,6 @@ class WMainWindow;
class WQt4Gui : public WGUI
{
public:
/**
* Default Constructor.
*/
......@@ -67,15 +66,10 @@ public:
*/
boost::signal1< void, std::vector< std::string > >* getLoadButtonSignal();
boost::signal1< void, int >* getAxialSliderSignal();
boost::signal1< void, int >* getCoronalSliderSignal();
boost::signal1< void, int >* getSagittalSliderSignal();
boost::signal1< void, bool >* getAxialButtonSignal();
boost::signal1< void, bool >* getCoronalButtonSignal();
boost::signal1< void, bool >* getSagittalButtonSignal();
/**
* this function allows modules to register their property object with the gui
*/
virtual void connectProperties( WProperties* properties );
protected:
......@@ -84,6 +78,7 @@ protected:
*/
virtual void threadMain();
private:
WMainWindow* m_gui;
};
......
......@@ -22,15 +22,19 @@
//
//---------------------------------------------------------------------------
#include <string>
#include <QtGui/QDockWidget>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
#include "WQtNavGLWidget.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, int maxValue )
WQtNavGLWidget::WQtNavGLWidget( QString title, int maxValue, std::string sliderTitle )
: QDockWidget( title )
{
m_sliderTitle = sliderTitle;
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
......@@ -57,18 +61,18 @@ WQtNavGLWidget::~WQtNavGLWidget()
{
}
boost::shared_ptr<WQtGLWidget>WQtNavGLWidget::getGLWidget()
void WQtNavGLWidget::setSliderTitle( std::string title )
{
return m_glWidget;
m_sliderTitle = title;
}
boost::signal1< void, int >*WQtNavGLWidget::getboostSignal()
boost::shared_ptr<WQtGLWidget>WQtNavGLWidget::getGLWidget()
{
return &m_boostSignal;
return m_glWidget;
}
void WQtNavGLWidget::sliderValueChanged( int value )
{
m_boostSignal( value );
emit navSliderValueChanged( m_sliderTitle, value );
}
......@@ -25,7 +25,7 @@
#ifndef WQTNAVGLWIDGET_H
#define WQTNAVGLWIDGET_H
#include "signalslib.hpp"
#include <string>
#include "WQtGLWidget.h"
......@@ -41,7 +41,7 @@ public:
/**
* default constructor
*/
explicit WQtNavGLWidget( QString title, int maxValue = 100 );
explicit WQtNavGLWidget( QString title, int maxValue = 100, std::string sliderTitle="pos" );
/**
* destructor
......@@ -54,17 +54,21 @@ public:
boost::shared_ptr<WQtGLWidget>getGLWidget();
/**
* \return pointer to boost signal for slider value
*
*/
boost::signal1< void, int >* getboostSignal();
void setSliderTitle( std::string title );
protected:
private:
std::string m_sliderTitle;
boost::shared_ptr<WQtGLWidget> m_glWidget;
boost::signal1< void, int > m_boostSignal;
private slots:
void sliderValueChanged( int value );
signals:
void navSliderValueChanged( std::string name, int value );
};
#endif // WQTNAVGLWIDGET_H
......@@ -37,11 +37,6 @@ WQtCheckBox::~WQtCheckBox()
{
}
boost::signal2< void, std::string, bool >*WQtCheckBox::getboostSignal()
{
return &m_boostSignal;
}
void WQtCheckBox::setName( std::string name )
{
m_name = name;
......@@ -49,5 +44,5 @@ void WQtCheckBox::setName( std::string name )
void WQtCheckBox::emitStateChanged()
{
m_boostSignal( m_name, this->isChecked() );
emit checkBoxStateChanged( m_name, this->isChecked() );
}
......@@ -27,7 +27,6 @@
#include <string>
#include "../signalslib.hpp"
#include <QtGui/QCheckBox>
/**
......@@ -48,11 +47,6 @@ public:
*/
virtual ~WQtCheckBox();
/**
* \return the boost signal object
*/
boost::signal2< void, std::string, bool >* getboostSignal();
/**
* setter for name
*/
......@@ -61,10 +55,13 @@ public:
private:
std::string m_name;
boost::signal2< void, std::string, bool > m_boostSignal;
public slots:
void emitStateChanged();
signals:
void checkBoxStateChanged( std::string name, bool value );
};
#endif // WQTCHECKBOX_H
......@@ -121,7 +121,8 @@ void WQtDatasetBrowser::selectTreeItem()
case P_BOOL:
{
WQtCheckBox* box = tab1->addCheckBox( propIt->second->getName(), propIt->second->getValue<bool>() );
box->getboostSignal()->connect( boost::bind( &WQtDatasetBrowser::slotSetBoolProperty, this, _1, _2 ) );
connect( box, SIGNAL( checkBoxStateChanged( std::string, bool ) ),
this, SLOT( slotSetBoolProperty( std::string, bool ) ) );
break;
}
case P_CHAR:
......@@ -132,7 +133,8 @@ void WQtDatasetBrowser::selectTreeItem()
{
WQtSliderWithEdit* slider = tab1->addSliderInt( propIt->second->getName(), propIt->second->getValue<int>(),
propIt->second->getMin<int>(), propIt->second->getMax<int>() );
slider->getboostSignal()->connect( boost::bind( &WQtDatasetBrowser::slotSetIntProperty, this, _1, _2 ) );
connect( slider, SIGNAL( signalNumberWithName( std::string, int ) ),
this, SLOT( slotSetIntProperty( std::string, int ) ) );
break;
}
case P_UNSIGNED_INT:
......@@ -144,7 +146,8 @@ void WQtDatasetBrowser::selectTreeItem()
case P_STRING:
{
WQtLineEdit* edit = tab1->addLineEdit( propIt->second->getName(), propIt->second->getValue<std::string>() );
edit->getboostSignal()->connect( boost::bind( &WQtDatasetBrowser::slotSetStringProperty, this, _1, _2 ) );
connect( edit, SIGNAL( lineEditStateChanged( std::string, std::string ) ),
this, SLOT( slotSetStringProperty( std::string, std::string ) ) );
break;
}
default:
......@@ -173,6 +176,7 @@ void WQtDatasetBrowser::changeTreeItem()
{
module->getProperties()->setValue<bool>( "active", false );
}
emit dataSetBrowserEvent( "textureChanged", true );
selectTreeItem();
}
......@@ -185,6 +189,8 @@ void WQtDatasetBrowser::slotSetIntProperty( std::string name, int value )
{
boost::shared_ptr< WModule >module =( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
module->getProperties()->setValue<int>( name, value );
emit dataSetBrowserEvent( "textureChanged", true );
}
void WQtDatasetBrowser::slotSetBoolProperty( std::string name, bool value )
......