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

[CHANGE] - filenames now get transferred using WPropFilename

- WMData now uses the new properties
parent 874fe16a
......@@ -84,6 +84,15 @@ public:
*/
boost::shared_ptr< WPropertyBase > getProperty( std::string name );
/**
* Searches the property with a given name. It does not throw any exception. It simply returns NULL if it can't be found.
*
* \param name the name of the property to search
*
* \return the property or NULL if not found.
*/
boost::shared_ptr< WPropertyBase > findProperty( std::string name );
/**
* Iterator over all property elements. This locks the property set for writing. endIteration() frees the lock.
*
......@@ -725,15 +734,6 @@ public:
private:
/**
* Searches the property with a given name. It does not throw any exception. It simply returns NULL if it can't be found.
*
* \param name the name of the property to search
*
* \return the property or NULL if not found.
*/
boost::shared_ptr< WPropertyBase > findProperty( std::string name );
/**
* The set of proerties. This uses the operators ==,<,> WProperty to determine equalnes.
*/
......
......@@ -93,7 +93,7 @@ WPropString WPropertyBase::toPropString()
return boost::shared_static_cast< WPVString >( shared_from_this() );
}
WPropFilename WPropertyBase::toPropPath()
WPropFilename WPropertyBase::toPropFilename()
{
return boost::shared_static_cast< WPVFilename >( shared_from_this() );
}
......
......@@ -81,7 +81,7 @@ public:
*
* \param hidden true if it should be hidden.
*/
void setHidden( bool hidden );
void setHidden( bool hidden = true );
/**
* Gets the real WPropertyVariable type of this instance.
......@@ -127,7 +127,7 @@ public:
*
* \return the property as path property
*/
WPropFilename toPropPath();
WPropFilename toPropFilename();
/**
* Helper converts this instance to its native type.
......
......@@ -37,7 +37,7 @@ WPropertyManager::~WPropertyManager()
{
}
void WPropertyManager::connectProperties( boost::shared_ptr< WProperties > properties )
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 );
......@@ -51,17 +51,22 @@ void WPropertyManager::slotBoolChanged( QString name, bool value )
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropBool()->set( value );
}
}
}
void WPropertyManager::slotIntChanged( QString name, int value )
{
boost::mutex::scoped_lock lock( m_PropertiesLock );
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropInt()->set( value );
}
}
}
......@@ -71,7 +76,10 @@ void WPropertyManager::slotFloatChanged( QString name, float value )
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value );
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropDouble()->set( value );
}
}
}
......@@ -81,6 +89,9 @@ void WPropertyManager::slotStringChanged( QString name, QString value )
for ( size_t i = 0; i < m_connectedProperties.size(); ++i )
{
m_connectedProperties[i]->setValue( name.toStdString(), value.toStdString() );
if ( m_connectedProperties[i]->existsProperty( name.toStdString() ) )
{
m_connectedProperties[i]->getProperty( name.toStdString() )->toPropString()->set( value.toStdString() );
}
}
}
......@@ -32,7 +32,7 @@
#include <QtCore/QObject>
#include "../../common/WProperties.h"
#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
......@@ -57,7 +57,7 @@ public:
*
* \param properties the property to add.
*/
void connectProperties( boost::shared_ptr< WProperties > properties );
void connectProperties( boost::shared_ptr< WProperties2 > properties );
public slots:
......@@ -107,7 +107,7 @@ private:
/**
* List of all properties actually connected with this manager instance.
*/
std::vector< boost::shared_ptr< WProperties > > m_connectedProperties;
std::vector< boost::shared_ptr< WProperties2 > > m_connectedProperties;
};
#endif // WPROPERTYMANAGER_H
......@@ -165,7 +165,7 @@ int WQt4Gui::run()
void WQt4Gui::slotAddDatasetOrModuleToBrowser( boost::shared_ptr< WModule > module )
{
// get properties from the module and register them
m_mainWindow->getPropertyManager()->connectProperties( module->getProperties() );
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 ) );
......
......@@ -340,7 +340,6 @@ void WQtDatasetBrowser::selectTreeItem()
}
}
// TODO(seralph): remove the above stuff if all modules use wpropertyvariable instead of wproperty
WQtDSBWidget* tab = new WQtDSBWidget( "Settings" );
if ( props.get() )
......@@ -365,7 +364,7 @@ void WQtDatasetBrowser::selectTreeItem()
tab->addProp( ( *iter )->toPropString() );
break;
case PV_PATH:
tab->addProp( ( *iter )->toPropPath() );
tab->addProp( ( *iter )->toPropFilename() );
break;
case PV_LIST:
WLogger::getLogger()->addLogMessage( "This property type \"PV_LIST\" is not yet supported by the GUI.", "DatasetBrowser",
......@@ -415,27 +414,14 @@ void WQtDatasetBrowser::changeTreeItem()
if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == DATASET )
{
boost::shared_ptr< WModule >module =( static_cast< WQtDatasetTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
if ( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) )
{
module->getProperties()->setValue<bool>( "active", true );
}
else
{
module->getProperties()->setValue<bool>( "active", false );
}
module->getProperties2()->getProperty( "active" )->toPropBool()->set( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
else if ( m_treeWidget->selectedItems().size() == 1 && m_treeWidget->selectedItems().at( 0 )->type() == MODULE )
{
boost::shared_ptr< WModule >module =( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
if ( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) )
{
module->getProperties()->setValue<bool>( "active", true );
}
else
{
module->getProperties()->setValue<bool>( "active", false );
}
module->getProperties2()->getProperty( "active" )->toPropBool()->set( m_treeWidget->selectedItems().at( 0 )->checkState( 0 ) );
}
}
......@@ -444,71 +430,6 @@ void WQtDatasetBrowser::addTabWidgetContent( WQtDSBWidget* content )
m_tabWidget->addTab( content, content->getName() );
}
void WQtDatasetBrowser::slotSetIntProperty( QString name, int value )
{
getPropOfSelected()->setValue<int>( name.toStdString(), value );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::slotSetDoubleProperty( QString name, double value )
{
getPropOfSelected()->setValue<double>( name.toStdString(), value );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::slotSetBoolProperty( QString name, bool value )
{
getPropOfSelected()->setValue<bool>( name.toStdString(), value );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
}
void WQtDatasetBrowser::slotSetStringProperty( QString name, QString value )
{
getPropOfSelected()->setValue<std::string>( name.toStdString(), value.toStdString() );
if ( name == "Name")
{
m_treeWidget->selectedItems().at( 0 )->setText( 0, value );
}
}
boost::shared_ptr< WProperties > WQtDatasetBrowser::getPropOfSelected()
{
boost::shared_ptr< WModule > module;
boost::shared_ptr< WProperties > props;
if ( m_treeWidget->selectedItems().size() != 0 )
{
switch ( m_treeWidget->selectedItems().at( 0 )->type() )
{
case SUBJECT:
break;
case DATASET:
module = ( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties();
break;
case MODULE:
module = ( static_cast< WQtModuleTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getModule();
props = module->getProperties();
break;
case MODULEHEADER:
break;
case ROIHEADER:
break;
case ROI:
case SUBROI:
props = ( static_cast< WQtRoiTreeItem* >( m_treeWidget->selectedItems().at( 0 ) ) )->getRoi()->getProperties();
break;
default:
break;
}
}
return props;
}
std::vector< boost::shared_ptr< WDataSet > > WQtDatasetBrowser::getDataSetList( int subjectId, bool onlyTextures )
{
int c = getFirstSubject();
......@@ -527,7 +448,7 @@ std::vector< boost::shared_ptr< WDataSet > > WQtDatasetBrowser::getDataSetList(
if ( dm->isReady()() && ( !onlyTextures || dm->getDataSet()->isTexture() ) )
{
if ( dm->getProperties()->getValue<bool>( "active" ) )
if ( dm->getProperties2()->getProperty( "active" )->toPropBool()->get() )
{
moduleList.push_back( dm->getDataSet() );
}
......
......@@ -145,39 +145,6 @@ public:
*/
boost::shared_ptr< WRMROIRepresentation > getSelectedRoi();
public slots:
/**
* slot to connect dynamically created controls
*
* \param name The name of the control
* \param value
*/
void slotSetIntProperty( QString name, int value );
/**
* slot to connect dynamically created controls
*
* \param name The name of the control
* \param value The value of the property
*/
void slotSetDoubleProperty( QString name, double value );
/**
* slot to connect dynamically created controls
*
* \param name The name of the control
* \param value
*/
void slotSetBoolProperty( QString name, bool value );
/**
* slot to connect dynamically created controls
*
* \param name The name of the control
* \param value
*/
void slotSetStringProperty( QString name, QString value );
protected:
/**
......@@ -203,13 +170,6 @@ protected:
*/
void createCompatibleButtons( boost::shared_ptr< WModule >module );
/**
* returns a pointer to the properties object of the currently selected tree item
*
* \return the properties
*/
boost::shared_ptr< WProperties > getPropOfSelected();
/**
* Reference to the main window of the application.
*/
......
......@@ -40,7 +40,7 @@ WQtTreeItem::WQtTreeItem( QTreeWidgetItem * parent, WTreeItemType type, boost::s
m_module = module;
m_name = module->getName();
if ( module->getProperties()->getValue< bool > ( "active" ) )
if ( module->getProperties2()->getProperty( "active" )->toPropBool()->get() )
{
this->setCheckState( 0, Qt::Checked );
}
......
......@@ -62,7 +62,13 @@ void WBatchLoader::threadMain()
boost::shared_ptr< WModule > mod = WModuleFactory::getModuleFactory()->create(
WModuleFactory::getModuleFactory()->getPrototypeByName( "Data Module" )
);
mod->getProperties()->setValue( "filename" , ( *iter ) );
boost::shared_ptr< WPropertyBase > p = mod->getProperties2()->findProperty( "filename" );
if ( p.get() )
{
p->toPropFilename()->set( *iter );
}
m_targetContainer->add( mod );
// serialize loading of a couple of data sets
mod->isReady().wait();
......
......@@ -63,6 +63,7 @@ WModule::WModule():
// initialize members
m_properties = boost::shared_ptr< WProperties >( new WProperties() );
m_properties2 = boost::shared_ptr< WProperties2 >( new WProperties2() );
m_active = m_properties2->addProperty( "active", "Determines whether the module should be activated.", true, true );
m_container = boost::shared_ptr< WModuleContainer >();
m_progress = boost::shared_ptr< WProgressCombiner >( new WProgressCombiner() );
......
......@@ -433,6 +433,11 @@ protected:
*/
std::set<boost::shared_ptr< WModuleOutputConnector > > m_outputConnectors;
/**
* True whenever the module should be active
*/
WPropBool m_active;
private:
/**
......
......@@ -88,16 +88,26 @@ void WMData::properties()
// properties
// filename of file to load and handle
m_properties->addString( "filename", "", true );
m_properties->addString( "Name" );
( m_properties->addBool( "active", true, true ) )->connect( boost::bind( &WMData::slotPropertyChanged, this, _1 ) );
( m_properties->addBool( "Interpolation", true ) )->connect( boost::bind( &WMData::slotPropertyChanged, this, _1 ) );
( m_properties->addInt( "Threshold", 0 ) )->connect( boost::bind( &WMData::slotPropertyChanged, this, _1 ) );
( m_properties->addInt( "Opacity %", 100 ) )->connect( boost::bind( &WMData::slotPropertyChanged, this, _1 ) );
m_properties->setMax( "Opacity %", 100 );
m_filename = m_properties2->addProperty( "filename", "The file to load.", WKernel::getAppPathObject(), true );
m_dataName = m_properties2->addProperty( "Name", "The name of the dataset.", std::string( "" ) );
// use this callback for the other properties
WPropertyBase::PropertyChangeNotifierType propertyCallback = boost::bind( &WMData::propertyChanged, this, _1 );
// several other properties
m_interpolation = m_properties2->addProperty( "Interpolation", "Is interpolation active?", true, propertyCallback );
m_threshold = m_properties2->addProperty( "Threshold", "The value threshold.", 0, propertyCallback );
m_opacity =m_properties2->addProperty( "Opacity %", "The opacity of this data on other surfaces.", 100, propertyCallback );
m_opacity->setMax( 100 );
m_opacity->setMin( 0 );
}
void WMData::slotPropertyChanged( std::string propertyName )
void WMData::propertyChanged( boost::shared_ptr< WPropertyBase > property )
{
}
/*void WMData::slotPropertyChanged( std::string propertyName )
{
if ( propertyName == "Threshold" )
{
......@@ -107,7 +117,7 @@ void WMData::slotPropertyChanged( std::string propertyName )
{
m_dataSet->getTexture()->setAlpha( m_properties->getValue<float>( "Opacity %" ) / 100.0 );
}
}
}*/
void WMData::notifyConnectionEstablished( boost::shared_ptr<WModuleConnector> here,
boost::shared_ptr<WModuleConnector> there )
......@@ -122,11 +132,6 @@ void WMData::notifyConnectionClosed( boost::shared_ptr<WModuleConnector> here, b
getName(), LL_DEBUG );
}
void WMData::notifyDataChange( boost::shared_ptr<WModuleConnector> /*input*/, boost::shared_ptr<WModuleConnector> /*output*/ )
{
// not used here, since data modules can not receive an input.
}
void WMData::notifyStop()
{
// not used here. It gets called whenever the module should stop running.
......@@ -135,10 +140,10 @@ void WMData::notifyStop()
void WMData::moduleMain()
{
using wiotools::getSuffix;
std::string fileName = m_properties->getValue< std::string >( "filename" );
std::string fileName = m_filename->get().string();
debugLog() << "Loading data from \"" << fileName << "\".";
m_properties->setValue( "Name", fileName );
m_dataName->set( fileName );
// load it now
std::string suffix = getSuffix( fileName );
......@@ -182,11 +187,10 @@ void WMData::moduleMain()
|| suffix == ".edf" )
{
// hide other properties since they make no sense fo these data set types.
m_properties->hideProperty( "filename" ); // File name is got via m_dataSet->getFileName()
m_properties->hideProperty( "active" );
m_properties->hideProperty( "Interpolation" );
m_properties->hideProperty( "Threshold" );
m_properties->hideProperty( "Opacity %" );
m_filename->setHidden();
m_interpolation->setHidden();
m_threshold->setHidden();
m_opacity->setHidden();
}
debugLog() << "Loading data done.";
......@@ -197,3 +201,4 @@ void WMData::moduleMain()
// go to idle mode
waitForStop(); // WThreadedRunner offers this for us. It uses boost::condition to avoid wasting CPU cycles with while loops.
}
......@@ -121,25 +121,41 @@ protected:
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.
* Gets called when the module should quit. This is from WThreadedRunner.
*/
virtual void notifyDataChange( boost::shared_ptr< WModuleConnector > input,
boost::shared_ptr< WModuleConnector > output );
virtual void notifyStop();
/**
* Gets called when the module should quit. This is from WThreadedRunner.
* The filename to load.
*/
virtual void notifyStop();
WPropFilename m_filename;
/**
* The name of the dataset. Usually the filename.
*/
WPropString m_dataName;
/**
* Interpolation?
*/
WPropBool m_interpolation;
/**
* Threshold value for this data.
*/
WPropInt m_threshold;
/**
* Opacity value for this data.
*/
WPropInt m_opacity;
/**
* Gets signaled from the properties object when something was changed
* Called whenever a property changes.
*
* \param propertyName the name of the property that actually changed.
* \param property the property that has been changed
*/
void slotPropertyChanged( std::string propertyName );
void propertyChanged( boost::shared_ptr< WPropertyBase > property );
private:
......
......@@ -104,26 +104,9 @@ void WMNavSlices::connectors()
void WMNavSlices::properties()
{
m_properties->addBool( "textureChanged", false, true );
//( m_properties->addBool( "active", true, true ) )->connect( boost::bind( &WMNavSlices::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "active", true, true );
m_properties->addInt( "axialPos", 80 );
m_properties->addInt( "coronalPos", 100 );
m_properties->addInt( "sagittalPos", 80 );
m_properties->addInt( "maxAxial", 160, true );
m_properties->addInt( "maxCoronal", 200, true );
m_properties->addInt( "maxSagittal", 160, true );
m_properties->addBool( "showAxial", true );
m_properties->addBool( "showCoronal", true );
m_properties->addBool( "showSagittal", true );
// NOTE: the appropriate type of addProperty is chosen by the type of the specified initial value.
// So if you specify a bool as initial value, addProperty will create a WPropBool.
m_textureChanged = m_properties2->addProperty( "textureChanged", "Denotes changing textures.", false, true );
m_active = m_properties2->addProperty( "active", "Determines whether the module should be activated.", true, true );
m_showAxial = m_properties2->addProperty( "showAxial", "Determines whether the axial slice should be visible.", true, true );
m_showCoronal = m_properties2->addProperty( "showCoronal", "Determines whether the coronal slice should be visible.", true, true );
m_showSagittal = m_properties2->addProperty( "showSagittal", "Determines whether the sagittal slice should be visible.", true, true );
......@@ -204,9 +187,9 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
{
float maxDim = 255.0;
float xSlice = ( float )( m_properties->getValue< int >( "sagittalPos" ) );
float ySlice = ( float )( m_properties->getValue< int >( "coronalPos" ) );
float zSlice = ( float )( m_properties->getValue< int >( "axialPos" ) );
float xSlice = ( float )( m_sagittalPos->get() );
float ySlice = ( float )( m_coronalPos->get() );
float zSlice = ( float )( m_axialPos->get() );
float xPos = xSlice + 0.5f;
float yPos = ySlice + 0.5f;
......@@ -334,13 +317,13 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
}
else
{
float maxX = ( float )( m_properties->getValue<int>( "maxSagittal") );
float maxY = ( float )( m_properties->getValue<int>( "maxCoronal") );
float maxZ = ( float )( m_properties->getValue<int>( "maxAxial") );
float maxX = ( float )( m_maxSagittal->get() );
float maxY = ( float )( m_maxCoronal->get() );
float maxZ = ( float )( m_maxAxial->get() );
m_properties->setMax( "sagittalPos", maxX );
m_properties->setMax( "coronalPos", maxY );
m_properties->setMax( "axialPos", maxZ );
m_sagittalPos->setMax( maxX );
m_coronalPos->setMax( maxY );
m_axialPos->setMax( maxZ );
float texX = xSlice / maxX;
float texY = ySlice / maxY;
......@@ -417,7 +400,7 @@ void WMNavSlices::updateGeometry()
std::vector< boost::shared_ptr< WDataSet > > dsl = WKernel::getRunningKernel()->getGui()->getDataSetList( 0, true );
bool noTexture = ( dsl.size() == 0 );
if ( m_properties->getValue<bool>( "showAxial" ) && !noTexture )
if ( m_showAxial->get() && !noTexture )
{
m_zSliceNode->setNodeMask( 0xFFFFFFFF );
}
......@@ -426,7 +409,7 @@ void WMNavSlices::updateGeometry()
m_zSliceNode->setNodeMask( 0x0 );
}
if ( m_properties->getValue<bool>( "showCoronal" ) && !noTexture )
if ( m_showCoronal->get() && !noTexture )