Commit 7d78039b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - adopted writeNIfTI module to new properties

parent 21f1ce87
......@@ -123,7 +123,9 @@ WPropString WProperties2::addProperty( std::string name, std::string description
WPropFilename WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial, bool hide )
{
return addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, hide );
WPropFilename p = addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, hide );
p->addConstraint( WPVFilename::PropertyConstraint::create( PC_NOTEMPTY ) );
return p;
}
WPropList WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_LIST& initial, bool hide )
......@@ -181,7 +183,9 @@ WPropString WProperties2::addProperty( std::string name, std::string description
WPropFilename WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial,
boost::shared_ptr< WCondition > condition, bool hide )
{
return addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, hide );
WPropFilename p = addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, hide );
p->addConstraint( WPVFilename::PropertyConstraint::create( PC_NOTEMPTY ) );
return p;
}
WPropList WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_LIST& initial,
......@@ -242,7 +246,9 @@ WPropString WProperties2::addProperty( std::string name, std::string description
WPropFilename WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_PATH& initial,
WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
{
return addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, notifier, hide );
WPropFilename p = addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, notifier, hide );
p->addConstraint( WPVFilename::PropertyConstraint::create( PC_NOTEMPTY ) );
return p;
}
WPropList WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_LIST& initial,
......@@ -310,7 +316,9 @@ WPropFilename WProperties2::addProperty( std::string name, std::string descripti
boost::shared_ptr< WCondition > condition,
WPropertyBase::PropertyChangeNotifierType notifier, bool hide )
{
return addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, notifier, hide );
WPropFilename p = addProperty< WPVBaseTypes::PV_PATH >( name, description, initial, condition, notifier, hide );
p->addConstraint( WPVFilename::PropertyConstraint::create( PC_NOTEMPTY ) );
return p;
}
WPropList WProperties2::addProperty( std::string name, std::string description, const WPVBaseTypes::PV_LIST& initial,
......
......@@ -74,7 +74,6 @@ const std::string WMPrototypeBoxManipulation::getDescription() const
return "Just a prtotype for box manipulation";
}
void WMPrototypeBoxManipulation::moduleMain()
{
// use the m_input "data changed" flag
......@@ -111,17 +110,6 @@ void WMPrototypeBoxManipulation::connectors()
void WMPrototypeBoxManipulation::properties()
{
m_properties->addBool( "textureChanged", false, true );
// m_active get initialized in WModule and is available for all modules.
}
void WMPrototypeBoxManipulation::slotPropertyChanged( std::string propertyName )
{
if( propertyName == "active" )
{
}
else
{
std::cout << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
}
......@@ -67,12 +67,6 @@ public:
*/
virtual const std::string getDescription() const;
/**
* Determine what to do if a property was changed.
* \param propertyName Name of the property.
*/
void slotPropertyChanged( std::string propertyName );
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
......
......@@ -102,6 +102,7 @@ const std::string WMWriteNIfTI::getDescription() const
void WMWriteNIfTI::moduleMain()
{
// use the m_input "data changed" flag
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
// signal ready state
......@@ -110,7 +111,6 @@ void WMWriteNIfTI::moduleMain()
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
{
sleep( 3 ); // TODO(wiebel): remove this
// acquire data from the input connector
m_dataSet = m_input->getData();
if ( !m_dataSet )
......@@ -121,7 +121,6 @@ void WMWriteNIfTI::moduleMain()
m_moduleState.wait();
continue;
}
assert( m_dataSet );
// this waits for m_moduleState to fire. By default, this is only the m_shutdownFlag condition.
// NOTE: you can add your own conditions to m_moduleState using m_moduleState.add( ... )
......@@ -140,31 +139,21 @@ void WMWriteNIfTI::connectors()
// add it to the list of connectors. Please note, that a connector NOT added via addConnector will not work as expected.
addConnector( m_input );
// call WModules initialization
WModule::connectors();
}
void WMWriteNIfTI::properties()
{
( m_properties->addString( "File Name" ) )->connect( boost::bind( &WMWriteNIfTI::slotPropertyChanged, this, _1 ) );
}
m_filename = m_properties2->addProperty( "Filename", "Filename where to write the nifty file to.", WKernel::getAppPathObject() );
void WMWriteNIfTI::slotPropertyChanged( std::string propertyName )
{
if( propertyName == "File Name" )
{
writeToFile( m_properties->getValue< std::string >( propertyName ) );
}
else
{
std::cout << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
// bind a custom callback, triggered whenever the filename changes
m_filename->getCondition()->subscribeSignal( boost::bind( &WMWriteNIfTI::writeToFile, this ) );
}
void WMWriteNIfTI::writeToFile( std::string fileName )
void WMWriteNIfTI::writeToFile()
{
infoLog() << "Writing Data to " << m_filename->get().file_string();
nifti_image *outField = nifti_simple_init_nim();
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
......@@ -207,12 +196,12 @@ void WMWriteNIfTI::writeToFile( std::string fileName )
outField->data = static_cast<void*>( data );
if( nifti_set_filenames( outField, fileName.c_str(), 0, 1 ) )
if( nifti_set_filenames( outField, m_filename->get().file_string().c_str(), 0, 1 ) )
{
throw WException( "NIfTI filename Problem" );
}
nifti_image_write( outField );
nifti_image_free( outField );
infoLog() << "Writing data completed." << std::endl;
infoLog() << "Writing data completed.";
}
......@@ -72,12 +72,6 @@ public:
*/
virtual const std::string getDescription() const;
/**
* Determine what to do if a property was changed.
* \param propertyName Name of the property.
*/
void slotPropertyChanged( std::string propertyName );
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
......@@ -111,9 +105,13 @@ protected:
private:
/**
* This performs all work neccessary to actually write the data to the file
* \param fileName The data set will be written to this file.
*/
void writeToFile( std::string fileName );
void writeToFile();
/**
* The filename property -> where to write the nifty file
*/
WPropFilename m_filename;
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
boost::shared_ptr< WDataSetSingle > m_dataSet; //!< Pointer providing access to the treated data set in the whole module.
......
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