Commit fb016cc9 authored by schurade's avatar schurade

[CHANGE] add a pointer to WModule to dataset tree items, this way we can...

[CHANGE] add a pointer to WModule to dataset tree items, this way we can directly access the properties of a dataset in the datasetbrowser
parent 22819a65
......@@ -29,6 +29,7 @@
#include <vector>
#include "../common/WThreadedRunner.h"
#include "../kernel/WModule.h"
#include "qt4/signalslib.hpp"
/**
......@@ -45,10 +46,11 @@ public:
virtual ~WGUI();
virtual bool isInitalized() = 0;
/**
*
*/
virtual boost::signal0 < void >* addDatasetToBrowser( std::string name, int subjectId ) = 0;
virtual void addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId ) = 0;
/**
* getter functions for all signals provided by the gui
......
......@@ -68,13 +68,12 @@ void WQt4Gui::threadMain()
// TODO(ebaum): how to handle return codes?
}
boost::signal0 < void >* WQt4Gui::addDatasetToBrowser( std::string name, int subjectId )
void WQt4Gui::addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId )
{
m_gui->getDatasetBrowser()->addDataset( name, subjectId );
// TODO(schurade): add the return here
return 0;
m_gui->getDatasetBrowser()->addDataset( module, subjectId );
}
bool WQt4Gui::isInitalized()
{
return m_isInitialized;
......
......@@ -55,7 +55,7 @@ public:
*/
bool isInitalized();
boost::signal0 < void >* addDatasetToBrowser( std::string name, int SubjectId = 0 );
void addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId );
/**
* getter functions for the signales proved by the gui
......
......@@ -103,10 +103,10 @@ WQtSubjectTreeItem* WQtDatasetBrowser::addSubject( std::string name )
}
WQtDatasetTreeItem* WQtDatasetBrowser::addDataset( std::string name, int subjectId )
WQtDatasetTreeItem* WQtDatasetBrowser::addDataset( boost::shared_ptr< WModule > module, int subjectId )
{
WQtSubjectTreeItem* subject = ( WQtSubjectTreeItem* )m_treeWidget->topLevelItem( subjectId );
return subject->addDatasetItem( name );
return subject->addDatasetItem( module );
}
void WQtDatasetBrowser::selectTreeItem()
......
......@@ -70,7 +70,7 @@ public:
/**
* adds a dataset entry to any given subject in the tree widget
*/
WQtDatasetTreeItem* addDataset( std::string name, int subjectId = 0 );
WQtDatasetTreeItem* addDataset( boost::shared_ptr< WModule > module, int subjectId = 0 );
/**
* helper funtion to connect all qt widgets with their functions
......
......@@ -24,9 +24,11 @@
#include "WQtDatasetTreeItem.h"
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent )
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module )
: QTreeWidgetItem( parent )
{
m_module = module;
this->setCheckState( 0, Qt::Checked );
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
}
......
......@@ -26,6 +26,7 @@
#define WQTDATASETTREEITEM_H
#include <QtGui/QTreeWidgetItem>
#include "../../../kernel/WModule.h"
#include "../signalslib.hpp"
/**
......@@ -37,7 +38,7 @@ public:
/**
* standard constructor
*/
explicit WQtDatasetTreeItem( QTreeWidgetItem * parent );
explicit WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module );
/**
* destructor
......@@ -60,6 +61,8 @@ private:
* TODO(schurade): change this to a signal with parameters
*/
boost::signal0< void > m_signalSelect;
boost::shared_ptr< WModule >m_module;
};
#endif // WQTDATASETTREEITEM_H
......@@ -37,9 +37,11 @@ WQtSubjectTreeItem::~WQtSubjectTreeItem()
}
WQtDatasetTreeItem* WQtSubjectTreeItem::addDatasetItem( std::string name )
WQtDatasetTreeItem* WQtSubjectTreeItem::addDatasetItem( boost::shared_ptr< WModule > module )
{
WQtDatasetTreeItem* ds = new WQtDatasetTreeItem( this );
WQtDatasetTreeItem* ds = new WQtDatasetTreeItem( this, module );
std::string name = module->getProperties()->getValueString( "name" );
ds->setText( 0, QString( name.c_str() ) );
return ds;
......
......@@ -50,7 +50,7 @@ public:
/**
* add a dataset item below this subject in the tree
*/
WQtDatasetTreeItem* addDatasetItem( std::string name );
WQtDatasetTreeItem* addDatasetItem( boost::shared_ptr< WModule > module );
protected:
private:
......
......@@ -34,6 +34,7 @@
#include <boost/thread/xtime.hpp>
#include "WModule.h"
#include "../modules/data/WDataModule.hpp"
#include "../modules/navigationSlices/WNavigationSliceModule.h"
#include "../common/WException.h"
......@@ -47,7 +48,7 @@
WKernel* kernel = NULL;
WKernel::WKernel( int argc, char* argv[], boost::shared_ptr< WGUI > gui )
: m_Gui( gui )
: m_gui( gui )
{
std::cout << "Initializing Kernel" << std::endl;
......@@ -88,22 +89,22 @@ WKernel* WKernel::getRunningKernel()
boost::shared_ptr<WGraphicsEngine> WKernel::getGraphicsEngine() const
{
return m_GraphicsEngine;
return m_graphicsEngine;
}
boost::shared_ptr<WDataHandler> WKernel::getDataHandler() const
{
return m_DataHandler;
return m_dataHandler;
}
boost::shared_ptr< WGUI > WKernel::getGui()
{
return m_Gui;
return m_gui;
}
void WKernel::setGui( boost::shared_ptr< WGUI > gui )
{
m_Gui = gui;
m_gui = gui;
}
int WKernel::getArgumentCount() const
......@@ -121,11 +122,11 @@ int WKernel::run()
WLogger::getLogger()->addLogMessage( "Starting Kernel", "Kernel", LL_DEBUG );
// TODO(ebaum): add separate graphics thread here
m_GraphicsEngine->run();
m_graphicsEngine->run();
// run Gui
// TODO(all): clean up this option handler mess
m_Gui->run();
m_gui->run();
// run? data handler stuff?
......@@ -146,10 +147,10 @@ int WKernel::run()
}
// TODO(schurade): this must be moved somewhere else, and realize the wait loop in another fashion
while ( !m_Gui->isInitalized() )
while ( !m_gui->isInitalized() )
{
}
m_Gui->getLoadButtonSignal()->connect( boost::bind( &WKernel::doLoadDataSets, this, _1 ) );
m_gui->getLoadButtonSignal()->connect( boost::bind( &WKernel::doLoadDataSets, this, _1 ) );
for( std::list<boost::shared_ptr<WModule> >::iterator list_iter = m_modules.begin(); list_iter != m_modules.end();
++list_iter )
......@@ -159,7 +160,7 @@ int WKernel::run()
// wait
// TODO(ebaum): this is not the optimal. It would be better to quit OSG, GE and so on in the right order.
m_Gui->wait( false );
m_gui->wait( false );
m_FinishRequested = true;
// wait for modules to finish
......@@ -170,7 +171,7 @@ int WKernel::run()
}
// finally GE
m_GraphicsEngine->wait( true );
m_graphicsEngine->wait( true );
// how to get QT return code from its thread?
return 0;
......@@ -195,10 +196,10 @@ void WKernel::init()
// initialize graphics engine
// this also includes initialization of WGEScene and OpenSceneGraph
m_GraphicsEngine = boost::shared_ptr<WGraphicsEngine>( new WGraphicsEngine( m_shaderPath ) );
m_graphicsEngine = boost::shared_ptr<WGraphicsEngine>( new WGraphicsEngine( m_shaderPath ) );
// initialize Datahandler
m_DataHandler = boost::shared_ptr<WDataHandler>( new WDataHandler() );
m_dataHandler = boost::shared_ptr<WDataHandler>( new WDataHandler() );
}
bool WKernel::findAppPath()
......@@ -282,12 +283,16 @@ bool WKernel::isFinishRequested() const
void WKernel::doLoadDataSets( std::vector< std::string > fileNames )
{
m_DataHandler->loadDataSets( fileNames );
m_dataHandler->loadDataSets( fileNames );
boost::shared_ptr< WModule > module = boost::shared_ptr< WModule >( new WDataModule<int>() );
m_gui->addDatasetToBrowser( module, 0 );
}
boost::shared_ptr<WDataHandler> WKernel::getDataHandler()
{
return m_DataHandler;
return m_dataHandler;
}
std::string WKernel::getAppPath()
......
......@@ -155,17 +155,17 @@ protected:
/**
* Pointer to an initialized graphics engine.
*/
boost::shared_ptr<WGraphicsEngine> m_GraphicsEngine;
boost::shared_ptr<WGraphicsEngine> m_graphicsEngine;
/**
* The Gui.
*/
boost::shared_ptr<WGUI> m_Gui;
boost::shared_ptr<WGUI> m_gui;
/**
* The Datahandler.
*/
boost::shared_ptr<WDataHandler> m_DataHandler;
boost::shared_ptr<WDataHandler> m_dataHandler;
private:
/**
......
......@@ -37,10 +37,11 @@
#include "WModule.h"
WModule::WModule():
WThreadedRunner()
WThreadedRunner(),
m_properties()
{
// initialize members
m_Initialized = false;
m_initialized = false;
}
WModule::~WModule()
......@@ -61,7 +62,7 @@ void WModule::addConnector( boost::shared_ptr<WModuleOutputConnector> con )
void WModule::removeConnectors()
{
m_Initialized = false;
m_initialized = false;
// remove connections and their signals
for( std::set<boost::shared_ptr<WModuleInputConnector> >::iterator listIter = m_InputConnectors.begin();
......@@ -85,6 +86,11 @@ void WModule::connectors()
{
}
void WModule::properties()
{
}
void WModule::initialize()
{
// doing it twice is not allowed
......@@ -97,9 +103,9 @@ void WModule::initialize()
throw WModuleConnectorInitFailed( s.str() );
}
m_Initialized = true;
connectors();
m_initialized = true;
}
void WModule::cleanup()
......@@ -138,7 +144,7 @@ const t_GenericSignalHandlerType WModule::getSignalHandler( MODULE_CONNECTOR_SIG
bool WModule::isInitialized() const
{
return m_Initialized;
return m_initialized;
}
void WModule::notifyConnectionEstablished( boost::shared_ptr<WModuleConnector> /*here*/,
......@@ -159,3 +165,11 @@ void WModule::notifyDataChange( boost::shared_ptr<WModuleConnector> /*input*/,
// By default this callback does nothing. Overwrite it in your module.
}
WProperties* WModule::getProperties()
{
return &m_properties;
}
void WModule::connectToGui()
{
}
......@@ -34,6 +34,8 @@
#include "../common/WThreadedRunner.h"
#include "WModuleConnectorSignals.h"
#include "WProperties.h"
class WModuleConnector;
class WModuleInputConnector;
class WModuleOutputConnector;
......@@ -71,23 +73,28 @@ public:
*/
virtual const std::string getDescription() const = 0;
/**
/**
* Gives back an input connectors.
*
*
* \return the input connectors.
*/
const std::set<boost::shared_ptr<WModuleInputConnector> >& getInputConnectors() const;
/**
/**
* Gives back a output connectors.
*
*
* \return the output connectors.
*/
const std::set<boost::shared_ptr<WModuleOutputConnector> >& getOutputConnectors() const;
/**
/**
* Return a pointer to the properties object of the module
*/
WProperties* getProperties();
/**
* Determines whether the module instance is properly initialized.
*
*
* \return true if properly initialized.
*/
bool isInitialized() const;
......@@ -96,7 +103,7 @@ public:
* Takes all the relevant GUI signals and connects them to own member functions.
* NOTE: this is only temporal. See ticket 142.
*/
virtual void connectToGui() = 0;
virtual void connectToGui();
protected:
......@@ -111,50 +118,58 @@ protected:
//
// **************************************************************************************************************************
/**
/**
* Initialize connectors in this function. This function must not be called multiple times for one module instance.
* The module container manages calling those functions -> so just implement it.
*/
virtual void connectors();
/**
/**
* Initialize properties in this function. This function must not be called multiple times for one module instance.
* The module container manages calling those functions -> so just implement it. Once initialized the number and type
* of all properties should be set.
*/
virtual void properties();
/**
* Manages connector initialization. Gets called by module container.
*
* \throw WModuleConnectorInitFailed if called multiple times.
*/
void initialize();
/**
/**
* Removes connectors and cleans up.
*/
void cleanup();
/**
/**
* Set of input connectors associated with this module.
* NOTE: we need a thread safe list implementation!
*/
std::set<boost::shared_ptr<WModuleInputConnector> > m_InputConnectors;
/**
/**
* Set of output connectors associated with this module.
*/
std::set<boost::shared_ptr<WModuleOutputConnector> > m_OutputConnectors;
/**
/**
* Adds the specified connector to the list of inputs.
*
*
* \param con the connector.
*/
void addConnector( boost::shared_ptr<WModuleInputConnector> con );
/**
/**
* Adds the specified connector to the list of outputs.
*
*
* \param con the connector.
*/
void addConnector( boost::shared_ptr<WModuleOutputConnector> con );
/**
/**
* Removes all connectors properly. It disconnects the connectors and cleans the connectors list.
*/
void removeConnectors();
......@@ -166,55 +181,60 @@ protected:
//
// **************************************************************************************************************************
/**
/**
* Gives the signal handler function responsible for a given signal. Modules defining own signal handlers should overwrite
* this function. This function is protected since boost::functions are callable, which is what is not wanted here. Just
* signals should call them.
*
*
* \param signal the signal to get the handler for.
*
*
* \return the signal handler for "signal".
*/
virtual const t_GenericSignalHandlerType getSignalHandler( MODULE_CONNECTOR_SIGNAL signal );
/**
/**
* Gets called whenever a connector gets connected to the specified input.
*
*
* \param here the connector of THIS module that got connected to "there"
* \param there the connector that has been connected with the connector "here" of this module.
*/
virtual void notifyConnectionEstablished( boost::shared_ptr<WModuleConnector> here,
boost::shared_ptr<WModuleConnector> there );
/**
/**
* Gets called whenever a connection between a remote and local connector gets closed.
*
*
* \param here the connector of THIS module getting disconnected.
* \param there the connector of the other module getting disconnected.
*/
virtual void notifyConnectionClosed( boost::shared_ptr<WModuleConnector> here, boost::shared_ptr<WModuleConnector> there );
/**
/**
* Gets called when the data on one input connector changed.
*
*
* \param input the input connector receiving the change.
* \param output the output connector sending the change notification.
*/
virtual void notifyDataChange( boost::shared_ptr<WModuleConnector> input,
boost::shared_ptr<WModuleConnector> output );
private:
/**
* the property object for the module
*/
WProperties m_properties;
/**
/**
* True if everything is initialized and ready to be used.
*/
bool m_Initialized;
bool m_initialized;
/**
private:
/**
* Lock for m_InputConnectors.
*/
// boost::shared_mutex m_InputConnectorsLock;
/**
/**
* Lock for m_OutputConnectors.
*/
// boost::shared_mutex m_OutputConnectorsLock;
......
......@@ -80,7 +80,7 @@ void WProperties::addString( std::string name, std::string value, std::string sh
WProperty* WProperties::findProp( std::string name )
{
if ( m_propertyList.count( name) != 0)
if ( m_propertyList.count( name) != 0 )
{
return m_propertyList[name];
}
......@@ -93,7 +93,7 @@ WProperty* WProperties::findProp( std::string name )
}
std::string WProperties::getValueString( std::string prop )
std::string WProperties::getValueString( const std::string prop )
{
if ( findProp( prop ) )
{
......
......@@ -54,7 +54,7 @@ public:
void addDouble( std::string name, double value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
void addString( std::string name, std::string value = "", std::string shortDesc = "", std::string longDesc = "" );
std::string getValueString( std::string prop );
std::string getValueString( const std::string prop );
template < typename T > void setValue( std::string prop, const T& arg )
{
......
......@@ -31,9 +31,12 @@
typedef enum
{
P_BOOL = 0,
P_UNDEFINED,
P_BOOL,
P_CHAR,
P_UNSIGNED_CHAR,
P_INT,
P_UNSIGNED_INT,
P_FLOAT,
P_DOUBLE,
P_STRING
......
......@@ -79,14 +79,14 @@ protected:
*/
virtual void threadMain();
/**
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
/**
* Receive DATA_CHANGE notifications.
*
*
* \param input the input connector that got the change signal. Typically it is one of the input connectors from this module.
* \param output the output connector that sent the signal. Not part of this module instance.
*/
......@@ -110,6 +110,7 @@ WDataModule<T>::WDataModule():
// Implement WModule::initializeConnectors instead.
// initialize members
m_properties.addString( "name", "not initialized" );
}
template < typename T >
......
......@@ -50,8 +50,7 @@
#include "../../graphicsEngine/WShader.h"
WNavigationSliceModule::WNavigationSliceModule():
WModule(),
m_properties()
WModule()
{
// WARNING: initializing connectors inside the constructor will lead to an exception.
// Implement WModule::initializeConnectors instead.
......@@ -60,18 +59,7 @@ WNavigationSliceModule::WNavigationSliceModule():
std::string shaderPath = WKernel::getRunningKernel()->getGraphicsEngine()->getShaderPath();
m_shader = boost::shared_ptr< WShader > ( new WShader( "slice", shaderPath ) );
m_properties.addBool( "textureAssigned", false );
m_properties.addInt( "axialPos", 80 );
m_properties.addInt( "coronalPos", 100 );
m_properties.addInt( "sagittalPos", 80 );
m_properties.addInt( "maxAxial", 160 );
m_properties.addInt( "maxCoronal", 200 );