Commit 9a164d9d authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[FIX] fixed crash that appeared when deactivating fiber data. Now the WMData

differentiates between textures an non textures in ints behavior.
parent e27c84c4
......@@ -42,7 +42,8 @@
#include "WMData.h"
WMData::WMData():
WModule()
WModule(),
m_isTexture()
{
// initialize members
}
......@@ -112,17 +113,34 @@ void WMData::properties()
void WMData::propertyChanged( boost::shared_ptr< WPropertyBase > property )
{
if ( property == m_threshold )
if( m_isTexture )
{
m_dataSet->getTexture()->setThreshold( m_threshold->get() );
}
else if ( property == m_opacity )
{
m_dataSet->getTexture()->setOpacity( m_opacity->get() );
if ( property == m_threshold )
{
m_dataSet->getTexture()->setThreshold( m_threshold->get() );
}
else if ( property == m_opacity )
{
m_dataSet->getTexture()->setOpacity( m_opacity->get() );
}
else if ( property == m_active )
{
m_dataSet->getTexture()->setGloballyActive( m_active->get() );
}
}
else if ( property == m_active )
else
{
m_dataSet->getTexture()->setGloballyActive( m_active->get() );
if ( property == m_active )
{
if( m_active->get() )
{
m_output->updateData( m_dataSet );
}
else
{
m_output->updateData( boost::shared_ptr< WDataSet >() );
}
}
}
}
......@@ -155,6 +173,19 @@ void WMData::moduleMain()
// load it now
std::string suffix = getSuffix( fileName );
if( suffix == ".fib"
|| suffix == ".cnt"
|| suffix == ".asc"
|| suffix == ".edf" )
{
// hide other properties since they make no sense fo these data set types.
m_filename->setHidden();
m_interpolation->setHidden();
m_threshold->setHidden();
m_opacity->setHidden();
m_active->setHidden();
}
if( suffix == ".nii"
//#ifndef _MSC_VER
|| suffix == ".gz"
......@@ -168,6 +199,9 @@ void WMData::moduleMain()
suffix = getSuffix( p.string() );
assert( suffix == ".nii" && "currently only nii files may be gzipped" );
}
m_isTexture = true;
WLoaderNIfTI niiLoader( fileName );
m_dataSet = niiLoader.load();
}
......@@ -198,18 +232,6 @@ void WMData::moduleMain()
throw WDHException( "Unknown file type: '" + suffix + "'" );
}
if( suffix == ".fib"
|| suffix == ".cnt"
|| suffix == ".asc"
|| suffix == ".edf" )
{
// hide other properties since they make no sense fo these data set types.
m_filename->setHidden();
m_interpolation->setHidden();
m_threshold->setHidden();
m_opacity->setHidden();
}
debugLog() << "Loading data done.";
// i am interested in the active property ( manually subscribe signal )
......
......@@ -158,6 +158,8 @@ protected:
*/
WPropInt m_opacity;
bool m_isTexture; //!< Indicates whether the loaded dataSet will be available as texture.
/**
* Called whenever a property changes.
*
......
......@@ -40,6 +40,7 @@
WMFiberDisplay::WMFiberDisplay()
: WModule(),
m_noData( new WCondition, true ),
m_osgNode( osg::ref_ptr< osg::Group >() )
{
m_shader = osg::ref_ptr< WShader > ( new WShader( "fake-tubes" ) );
......@@ -84,14 +85,17 @@ void WMFiberDisplay::moduleMain()
// -> recalculate
debugLog() << "Data changed on " << m_fiberInput->getCanonicalName();
m_dataset = m_fiberInput->getData();
// ensure the data is valid (not NULL)
if ( !m_fiberInput->getData().get() ) // ok, the output has been reset, so we can ignore the "data change"
{
m_noData.set( true );
debugLog() << "Data reset on " << m_fiberInput->getCanonicalName() << ". Ignoring.";
continue;
}
m_dataset = m_fiberInput->getData();
m_noData.set( false );
infoLog() << "Fiber dataset for display with: " << m_dataset->size() << " fibers loaded.";
......@@ -114,6 +118,17 @@ void WMFiberDisplay::update()
{
boost::shared_lock<boost::shared_mutex> slock;
slock = boost::shared_lock<boost::shared_mutex>( m_updateLock );
if( m_noData.changed() )
{
if( m_noData.get( true ) )
{
m_osgNode->setNodeMask( 0x0 );
}
else
{
m_osgNode->setNodeMask( 0xFFFFFFFF );
}
}
if ( WKernel::getRunningKernel()->getRoiManager()->isDirty() )
{
......
......@@ -117,6 +117,8 @@ private:
WPropBool m_coloring; //!< Enable/Disable global (true) or local (false) coloring of the fiber tracts
WPropBool m_useTubesProp; //!< Property indicating whether to use tubes for the fibers tracts.
WBoolFlag m_noData; //!< Flag indicating whether there is data to display.
/**
* Input connector for a fiber dataset.
*/
......
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