Commit e02a81ae authored by Alexander Wiebel's avatar Alexander Wiebel

[FIX #33 (old #520)] handle missing file correctly

parent 96cd8d7e
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <osg/StateSet> #include <osg/StateSet>
#include "core/common/WAssert.h" #include "core/common/WAssert.h"
#include "core/common/WPathHelper.h"
#include "core/common/WThreadedFunction.h" #include "core/common/WThreadedFunction.h"
#include "core/dataHandler/WDataSetScalar.h" #include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h" #include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
...@@ -111,6 +112,9 @@ void WMAtlasSurfaces::properties() ...@@ -111,6 +112,9 @@ void WMAtlasSurfaces::properties()
WPropertyBase::PropertyChangeNotifierType propertyCallback = boost::bind( &WMAtlasSurfaces::propertyChanged, this ); WPropertyBase::PropertyChangeNotifierType propertyCallback = boost::bind( &WMAtlasSurfaces::propertyChanged, this );
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() ); m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_labelFile = m_properties->addProperty( "Label file", "", boost::filesystem::path( "" ), m_propCondition );
WPropertyHelper::PC_PATHEXISTS::addTo( m_labelFile );
m_propCreateRoiTrigger = m_properties->addProperty( "Create Roi", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition ); m_propCreateRoiTrigger = m_properties->addProperty( "Create Roi", "Press!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
WModule::properties(); WModule::properties();
...@@ -137,10 +141,27 @@ void WMAtlasSurfaces::moduleMain() ...@@ -137,10 +141,27 @@ void WMAtlasSurfaces::moduleMain()
break; break;
} }
if( m_dataSet != m_input->getData() ) if( m_dataSet != m_input->getData() || m_labelFile->changed() )
{ {
// acquire data from the input connector // acquire data from the input connector
m_dataSet = m_input->getData(); m_dataSet = m_input->getData();
if( m_labelFile->get( true ) == boost::filesystem::path( "" ) )
{
std::string fn = m_dataSet->getFileName();
std::string ext( ".nii.gz" );
std::string csvExt( ".csv" );
fn.replace( fn.find( ext ), ext.size(), csvExt );
m_labelFile->set( fn );
}
if( !boost::filesystem::exists( m_labelFile->get() ) )
{
wlog::warn( "Atlas Surfaces" ) << "Expected label file does not exist! (" << m_labelFile->get().string() << ")";
continue;
}
loadLabels( m_labelFile->get( true ).string() );
switch( ( *m_dataSet ).getValueSet()->getDataType() ) switch( ( *m_dataSet ).getValueSet()->getDataType() )
{ {
case W_DT_UNSIGNED_CHAR: case W_DT_UNSIGNED_CHAR:
...@@ -186,12 +207,6 @@ void WMAtlasSurfaces::createSurfaces() ...@@ -186,12 +207,6 @@ void WMAtlasSurfaces::createSurfaces()
{ {
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() ); boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
std::string fn = m_dataSet->getFileName();
std::string ext( ".nii.gz" );
std::string csvExt( ".csv" );
fn.replace( fn.find( ext ), ext.size(), csvExt );
loadLabels( fn );
boost::shared_ptr<WProgressCombiner> newProgress = boost::shared_ptr<WProgressCombiner>( new WProgressCombiner() ); boost::shared_ptr<WProgressCombiner> newProgress = boost::shared_ptr<WProgressCombiner>( new WProgressCombiner() );
boost::shared_ptr<WProgress>pro = boost::shared_ptr<WProgress>( new WProgress( "dummy", m_dataSet->getMax() ) ); boost::shared_ptr<WProgress>pro = boost::shared_ptr<WProgress>( new WProgress( "dummy", m_dataSet->getMax() ) );
m_progress->addSubProgress( pro ); m_progress->addSubProgress( pro );
...@@ -231,6 +246,7 @@ void WMAtlasSurfaces::createSurfaces() ...@@ -231,6 +246,7 @@ void WMAtlasSurfaces::createSurfaces()
m_possibleSelections->addItem( label, "" ); m_possibleSelections->addItem( label, "" );
} }
m_properties->removeProperty( m_aMultiSelection ); // clear before re-adding
m_aMultiSelection = m_properties->addProperty( "Regions", "Regions", m_possibleSelections->getSelectorAll(), m_aMultiSelection = m_properties->addProperty( "Regions", "Regions", m_possibleSelections->getSelectorAll(),
m_propCondition ); m_propCondition );
} }
......
...@@ -179,6 +179,7 @@ private: ...@@ -179,6 +179,7 @@ private:
* A property allowing the user to select multiple elements of a list. * A property allowing the user to select multiple elements of a list.
*/ */
WPropSelection m_aMultiSelection; WPropSelection m_aMultiSelection;
WPropFilename m_labelFile; //!< The labels will be read from this file.
/** /**
* A list of items that can be selected using m_aSingleSelection or m_aMultiSelection. * A list of items that can be selected using m_aSingleSelection or m_aMultiSelection.
......
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