Commit e834668f authored by schurade's avatar schurade
Browse files

[ADD] output connector for fiber display module

parent f606c298
......@@ -70,10 +70,13 @@ void WMFiberDisplay::connectors()
{
using boost::shared_ptr;
typedef WModuleInputData< const WDataSetFibers > FiberInputData; // just an alias
typedef WModuleOutputData< WDataSetFibers > FiberOutputData; // just an alias
m_fiberInput = shared_ptr< FiberInputData >( new FiberInputData( shared_from_this(), "fiberInput", "A loaded fiber dataset." ) );
m_fiberOutput = shared_ptr< FiberOutputData >( new FiberOutputData( shared_from_this(), "fiberOutput", "The selected fibers." ) );
addConnector( m_fiberInput );
addConnector( m_fiberOutput );
WModule::connectors(); // call WModules initialization
}
......@@ -169,13 +172,12 @@ void WMFiberDisplay::properties()
m_tubeThickness->setMin( 0 );
m_tubeThickness->setMax( 300 );
m_save = m_properties->addProperty( "Save", "Saves the selected fiber bundles.", false, m_propCondition );
m_saveFileName = m_properties->addProperty( "File name", "", WPathHelper::getAppPath() );
m_cullBoxGroup = m_properties->addPropertyGroup( "Box Culling", "Properties only related to the box culling.", m_propCondition );
m_activateCullBox = m_cullBoxGroup->addProperty( "Activate", "Activates the cull box", false, m_propCondition );
m_showCullBox = m_cullBoxGroup->addProperty( "Show cull box", "Shows/hides the cull box", false, m_propCondition );
m_insideCullBox = m_cullBoxGroup->addProperty( "Inside - outside", "Show fibers inside or outside the cull box", true, m_propCondition );
m_propUpdateOutputTrigger = m_properties->addProperty( "Update Output", "Update!", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
}
......@@ -227,6 +229,12 @@ void WMFiberDisplay::moduleMain()
m_cullBox->hide();
}
}
if ( m_propUpdateOutputTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
updateOutput();
m_propUpdateOutputTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false );
}
}
con.disconnect();
......@@ -388,12 +396,6 @@ void WMFiberDisplay::updateRenderModes()
}
}
void WMFiberDisplay::saveSelected()
{
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
m_dataset->saveSelected( m_saveFileName->getAsString(), active );
}
void WMFiberDisplay::updateTexture()
{
osg::StateSet* rootState = m_osgNode->getOrCreateStateSet();
......@@ -450,3 +452,41 @@ void WMFiberDisplay::updateCallback()
updateRenderModes();
}
void WMFiberDisplay::updateOutput()
{
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
boost::shared_ptr< std::vector< float > >vertices = boost::shared_ptr< std::vector< float > >( new std::vector< float >() );
boost::shared_ptr< std::vector< size_t > > lineStartIndexes = boost::shared_ptr< std::vector< size_t > > ( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > lineLengths = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > verticesReverse = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
std::pair< wmath::WPosition, wmath::WPosition > boundingBox = m_dataset->getBoundingBox();
size_t countLines = 0;
for ( size_t l = 0; l < active->size(); ++l )
{
if ( ( *active )[l] )
{
size_t pc = m_dataset->getLineStartIndexes()->at( l ) * 3;
lineStartIndexes->push_back( vertices->size() / 3 );
lineLengths->push_back( m_dataset->getLineLengths()->at( l ) );
for ( size_t j = 0; j < m_dataset->getLineLengths()->at( l ); ++j )
{
vertices->push_back( m_dataset->getVertices()->at( pc ) );
++pc;
vertices->push_back( m_dataset->getVertices()->at( pc ) );
++pc;
vertices->push_back( m_dataset->getVertices()->at( pc ) );
++pc;
verticesReverse->push_back( countLines );
}
++countLines;
}
}
boost::shared_ptr< WDataSetFibers> newOutput =
boost::shared_ptr< WDataSetFibers>( new WDataSetFibers( vertices, lineStartIndexes, lineLengths, verticesReverse, boundingBox ) );
m_fiberOutput->updateData( newOutput );
}
......@@ -39,6 +39,7 @@
#include "../../kernel/WFiberSelector.h"
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../kernel/WModuleOutputData.h"
/**
* Module for drawing fibers
......@@ -148,9 +149,6 @@ private:
WPropBool m_useTubesProp; //!< Property indicating whether to use tubes for the fibers tracts.
WPropBool m_useTextureProp; //!< Property indicating whether to use tubes for the fibers tracts.
WPropDouble m_tubeThickness; //!< Property determining the thickness of tubes .
WPropBool m_save; //!< this should be a button
WPropFilename m_saveFileName; //!< the filename for saving
WBoolFlag m_noData; //!< Flag indicating whether there is data to display.
WPropGroup m_cullBoxGroup; //!< property group for box culling
......@@ -158,11 +156,22 @@ private:
WPropBool m_showCullBox; //!< Enable/Disable showing of the cull box
WPropBool m_insideCullBox; //!< if true fibers inside the cull box are shown, outside if false
/**
* This property triggers the updating of the output connector, as it would be too slow to do on every
* selection change
*/
WPropTrigger m_propUpdateOutputTrigger;
/**
* Input connector for a fiber dataset.
*/
boost::shared_ptr< WModuleInputData< const WDataSetFibers > > m_fiberInput;
/**
* Output connector for a fiber dataset.
*/
boost::shared_ptr< WModuleOutputData< WDataSetFibers > > m_fiberOutput;
/**
* Pointer to the fiber data set
*/
......@@ -252,7 +261,7 @@ private:
/**
* saves the currently selected (active field from roi manager) fibers to a file
*/
void saveSelected();
void updateOutput();
/**
* creates and initializes the uniform parameters for the shader
......
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