Commit edfa13e1 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - removed property manager

[ADD] - modules now cann specify a type
[CHANGE] - containers now can list their data sets
parent d03ffdcb
......@@ -13,7 +13,6 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtNavGLWidget.h
WPropertyManager.h
guiElements/WQtPushButton.h
datasetbrowser/WPropertyWidget.h
datasetbrowser/WPropertyBoolWidget.h
......
......@@ -55,8 +55,7 @@
WMainWindow::WMainWindow() :
QMainWindow(),
m_iconManager(),
m_propertyManager()
m_iconManager()
{
setupGUI();
}
......@@ -101,24 +100,27 @@ void WMainWindow::setupGUI()
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "axial", this, 160, "axialPos" ) );
m_navAxial->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
connect( m_navAxial.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
// TODO(ebaum): adopt!
/*connect( m_navAxial.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );*/
}
if( !( WPreferences::getPreference( "qt4gui.hideCoronal", &hideWidget ) && hideWidget) )
{
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "coronal", this, 200, "coronalPos" ) );
m_navCoronal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
connect( m_navCoronal.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
// TODO(ebaum): adopt!
/*connect( m_navCoronal.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );*/
}
if( !( WPreferences::getPreference( "qt4gui.hideSagittal", &hideWidget ) && hideWidget) )
{
m_navSagittal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "sagittal", this, 160, "sagittalPos" ) );
m_navSagittal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
connect( m_navSagittal.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
// TODO(ebaum): adopt!
/*connect( m_navSagittal.get(), SIGNAL( navSliderValueChanged( QString, int ) ),
&m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );*/
}
}
......@@ -146,7 +148,8 @@ void WMainWindow::setupGUI()
addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "Default Subject" );
connect( m_datasetBrowser, SIGNAL( dataSetBrowserEvent( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// TODO(ebaum): adopt!
//connect( m_datasetBrowser, SIGNAL( dataSetBrowserEvent( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
}
void WMainWindow::setupPermanentToolBar()
......@@ -199,9 +202,10 @@ void WMainWindow::setupPermanentToolBar()
m_permanentToolBar->addWidget( coronalButton );
m_permanentToolBar->addWidget( sagittalButton );
connect( axialButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
connect( coronalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
connect( sagittalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// TODO(ebaum): adopt!
// connect( axialButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// connect( coronalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
// connect( sagittalButton, SIGNAL( pushButtonToggled( QString, bool ) ), &m_propertyManager, SLOT( slotBoolChanged( QString, bool ) ) );
addToolBar( Qt::TopToolBarArea, m_permanentToolBar );
......@@ -286,11 +290,6 @@ boost::signals2::signal1< void, std::string >* WMainWindow::getPickSignal()
return m_mainGLWidget->getPickSignal();
}
WPropertyManager* WMainWindow::getPropertyManager()
{
return &m_propertyManager;
}
WIconManager* WMainWindow::getIconManager()
{
return &m_iconManager;
......
......@@ -46,7 +46,6 @@
#include "WQtToolBar.h"
#include "WIconManager.h"
#include "WPropertyManager.h"
#include "datasetbrowser/WQtDatasetBrowser.h"
#include "../../kernel/WModule.h"
......@@ -90,12 +89,6 @@ public:
*/
WQtToolBar* getCompatiblesToolBar();
/**
* Return property manager
*/
WPropertyManager* getPropertyManager();
/**
* Return icon manager
*/
......@@ -190,8 +183,6 @@ private:
WIconManager m_iconManager; //!< manager to provide icons in the gui thread
WPropertyManager m_propertyManager; //!< transmit gui interactions to connected modules
QMenuBar* m_menuBar; //!< The main menu bar of the GUI.
QWidget* m_centralwidget; //!< the central widget of the docking facility. This can not be moved.
......
......@@ -164,9 +164,6 @@ int WQt4Gui::run()
void WQt4Gui::slotAddDatasetOrModuleToBrowser( boost::shared_ptr< WModule > module )
{
// get properties from the module and register them
m_mainWindow->getPropertyManager()->connectProperties( module->getProperties2() );
// create a new event for this and insert it into event queue
QCoreApplication::postEvent( m_mainWindow->getDatasetBrowser(), new WModuleAssocEvent( module ) );
}
......
......@@ -164,6 +164,11 @@ void WModule::setAssociatedContainer( boost::shared_ptr< WModuleContainer > cont
m_isUsable( m_initialized() && m_isAssociated() );
}
MODULE_TYPE WModule::getType() const
{
return MODULE_ARBITRARY;
}
const std::set<boost::shared_ptr< WModuleInputConnector > >& WModule::getInputConnectors() const
{
return m_inputConnectors;
......
......@@ -37,6 +37,7 @@
#include "WModuleConnectorSignals.h"
#include "WModuleSignals.h"
#include "WModuleTypes.h"
#include "../dataHandler/WDataSet.h"
#include "../dataHandler/WDataSetSingle.h"
......@@ -216,6 +217,14 @@ public:
*/
virtual const char** getXPMIcon() const;
/**
* Gets the type of the module. This is useful for FAST differentiation between several modules like standard modules and data
* modules which play a special role in OpenWalnut/Kernel.
*
* \return the Type. If you do not overwrite this method, it will return MODULE_ARBITRARY.
*/
virtual MODULE_TYPE getType() const;
protected:
/**
......
......@@ -27,6 +27,7 @@
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include "WModule.h"
#include "exceptions/WModuleUninitialized.h"
......@@ -36,10 +37,13 @@
#include "../common/WThreadedRunner.h"
#include "WKernel.h"
#include "WModuleFactory.h"
#include "WModuleTypes.h"
#include "WModuleInputConnector.h"
#include "WModuleOutputConnector.h"
#include "WBatchLoader.h"
#include "../modules/data/WMData.h"
#include "WModuleContainer.h"
WModuleContainer::WModuleContainer( std::string name, std::string description ):
......@@ -156,10 +160,40 @@ void WModuleContainer::remove( boost::shared_ptr< WModule > module )
module->setAssociatedContainer( boost::shared_ptr< WModuleContainer >() );
// TODO(ebaum): remove signal subscriptions
// TODO(ebaum): remove progress from combiner
// TODO(ebaum): flat or deep removal? What to do with associated modules?
}
WModuleContainer::DataModuleListType WModuleContainer::getDataModules( int subjectId, bool onlyTextures )
{
DataModuleListType l;
boost::shared_lock<boost::shared_mutex> slock = boost::shared_lock<boost::shared_mutex>( m_moduleSetLock );
// iterate module list
for( std::set< boost::shared_ptr< WModule > >::iterator iter = m_modules.begin(); iter != m_modules.end(); ++iter )
{
// is this module a data module?
if ( ( *iter )->getType() == MODULE_DATA )
{
boost::shared_ptr< WMData > dm = boost::shared_static_cast< WMData >( *iter );
// now check the contained dataset ( isTexture and whether it is ready )
if ( dm->isReady()() && ( !onlyTextures || dm->getDataSet()->isTexture() ) )
{
// assume we have one subject only. Nobody took care to store the subject ID somewhere!
// TODO(ebaum): add subject id check if available
l.insert( dm );
}
}
}
slock.unlock();
// now sort the list using the sorter
return l;
}
void WModuleContainer::stop()
{
WLogger::getLogger()->addLogMessage( "Stopping pending threads." , "ModuleContainer (" + getName() + ")", LL_INFO );
......
......@@ -35,12 +35,12 @@
#include <boost/signals2/signal.hpp>
#include <boost/function.hpp>
#include "WModuleSignals.h"
class WThreadedRunner;
class WBatchLoader;
class WModule;
class WMData;
/**
* Class able to contain other modules. It manages several tasks like finding appropriate modules, managing data modules and
......@@ -154,11 +154,11 @@ public:
void loadDataSetsSynchronously( std::vector< std::string > fileNames );
/**
* Add the specified thread to the list of pending jobs. Only this ensures, that ALL pending threads got stopped before the
* Add the specified thread to the list of pending jobs. Only this ensures, that ALL pending threads get stopped before the
* container gets stopped.
*
* \note use this to register threads whenever you start threads belonging to this container. This avoids shutting down the
* container while other threads depend upon them.
* container while other threads depend upon it.
*
* \param thread the thread to add
*/
......@@ -179,6 +179,27 @@ public:
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Simple type for WMData pointer lists.
*/
typedef std::set< boost::shared_ptr< WMData > > DataModuleListType;
//////////////////////////////////////////////////////////////////////////////////////////////
// These methods are used to propagate the global data textures to all modules.
// This should be done in a better way in the future but works for now and decouples it from
// the GUI.
//////////////////////////////////////////////////////////////////////////////////////////////
/**
* Returns a vector of pointers to the loaded data modules for a given subject.
*
* \param subjectId The ID of the subject to get the list for.
* \param onlyTextures True if only textures should be returned.
*
* \return the list of data modules.
*/
DataModuleListType getDataModules( int subjectId, bool onlyTextures = false );
protected:
/**
......
......@@ -28,9 +28,9 @@
#include <typeinfo>
#include "../common/WLogger.h"
#include "../modules/data/WMData.h" // this is the ONLY module with a special meaning.
#include "../modules/coordinateSystem/WMCoordinateSystem.h"
#include "../modules/boundingBox/WMBoundingBox.h"
#include "../modules/data/WMData.h"
#include "../modules/distanceMap/WMDistanceMapIsosurface.h"
#include "../modules/distanceMap/WMDistanceMap.h"
#include "../modules/connectomeView/WMConnectomeView.h"
......
......@@ -22,92 +22,6 @@
//
//---------------------------------------------------------------------------
#ifndef WPROPERTYMANAGER_H
#define WPROPERTYMANAGER_H
#include "WModuleTypes.h"
#include <string>
#include <vector>
#include <boost/thread/mutex.hpp>
#include <QtCore/QObject>
#include "../../common/WProperties2.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. Creates an empty property manager.
*/
WPropertyManager();
/**
* Destructor.
*/
virtual ~WPropertyManager();
/**
* Add a property to the list of managed properties.
*
* \param properties the property to add.
*/
void connectProperties( boost::shared_ptr< WProperties2 > properties );
public slots:
/**
* Slot function that writes a boolean value to all properties objects that contain an entry
* with that name.
*
* \param name the name of the property to set the bool for.
* \param value the bool value to set.
*/
void slotBoolChanged( QString name, bool value );
/**
* Slot function that writes a integer value to all properties objects that contain an entry
* with that name
*
* \param name the name of the property to set the value for.
* \param value the value to set.
*/
void slotIntChanged( QString name, int value );
/**
* slot function that writes a float value to all properties objects that contain an entry
* with that name
*
* \param name the name of the property to set the value for.
* \param value the value to set.
*/
void slotFloatChanged( QString name, float value );
/**
* slot function that writes a string value to all properties objects that contain an entry
* with that name
*
* \param name the name of the property to set the value for.
* \param value the value to set.
*/
void slotStringChanged( QString name, QString value );
protected:
private:
/**
* Mutex used to lock the properties.
*/
boost::mutex m_PropertiesLock;
/**
* List of all properties actually connected with this manager instance.
*/
std::vector< boost::shared_ptr< WProperties2 > > m_connectedProperties;
};
#endif // WPROPERTYMANAGER_H
......@@ -22,76 +22,15 @@
//
//---------------------------------------------------------------------------
#include <iostream>
#include <string>
#ifndef WMODULETYPES_H
#define WMODULETYPES_H
#include <boost/thread/locks.hpp>
#include "WPropertyManager.h"
WPropertyManager::WPropertyManager()
{
}
WPropertyManager::~WPropertyManager()
{
}
void WPropertyManager::connectProperties( boost::shared_ptr< WProperties2 > properties )
{
// make sure only one property gets connected at a time
boost::mutex::scoped_lock lock( m_PropertiesLock );
m_connectedProperties.push_back( properties );
}
void WPropertyManager::slotBoolChanged( QString name, bool value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropBool()->set( value );
}
}
}
void WPropertyManager::slotIntChanged( QString name, int value )
typedef enum
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropInt()->set( value );
}
}
MODULE_ARBITRARY, // used for ALL modules which do not play a special role (like data modules).
MODULE_DATA // this flag denotes data modules only ( modules which derive from WMData )
}
MODULE_TYPE;
void WPropertyManager::slotFloatChanged( QString name, float value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
#endif // WMODULETYPES_H
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropDouble()->set( value );
}
}
}
void WPropertyManager::slotStringChanged( QString name, QString value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropString()->set( value.toStdString() );
}
}
}
......@@ -69,6 +69,11 @@ boost::shared_ptr< WDataSet > WMData::getDataSet()
return m_dataSet;
}
MODULE_TYPE WMData::getType() const
{
return MODULE_DATA;
}
void WMData::connectors()
{
// initialize connectors
......
......@@ -84,6 +84,14 @@ public:
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Gets the type of the module. This is useful for FAST differentiation between several modules like standard modules and data
* modules which play a special role in OpenWalnut/Kernel.
*
* \return the Type. This will return MODULE_DATA.
*/
virtual MODULE_TYPE getType() const;
protected:
/**
* \par Description
......
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