Commit 42e5c66d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] fiber display now is able to immediately update its output on roi...

[CHANGE] fiber display now is able to immediately update its output on roi change. But be careful. This might put quite a load on your CPU.
parent cc4f8c3d
......@@ -34,7 +34,8 @@
WFiberSelector::WFiberSelector( boost::shared_ptr< const WDataSetFibers > fibers ) :
m_fibers( fibers ),
m_size( fibers->size() ),
m_dirty( true )
m_dirty( true ),
m_dirtyCondition( boost::shared_ptr< WCondition >( new WCondition() ) )
{
boost::shared_ptr< std::vector< float > > verts = m_fibers->getVertices();
m_kdTree = boost::shared_ptr< WKdTree >( new WKdTree( verts->size() / 3, &( ( *verts )[0] ) ) );
......@@ -191,4 +192,10 @@ void WFiberSelector::setDirty()
{
recalculate();
m_dirty = true;
m_dirtyCondition->notify();
}
WCondition::SPtr WFiberSelector::getDirtyCondition()
{
return m_dirtyCondition;
}
......@@ -29,6 +29,7 @@
#include <vector>
#include "../dataHandler/WDataSetFibers.h"
#include "../common/WCondition.h"
#include "WSelectorRoi.h"
#include "WSelectorBranch.h"
......@@ -85,6 +86,13 @@ public:
*/
void setDirty();
/**
* Condition that fires upon a recalculation of the fiber selection.
*
* \return the condition
*/
WCondition::SPtr getDirtyCondition();
protected:
/**
* listener function for inserting rois
......@@ -134,6 +142,11 @@ private:
boost::shared_ptr< boost::function< void( osg::ref_ptr< WROI > ) > > m_removeRoiSignal; //!< Signal that can be used to update the selector
boost::shared_ptr< boost::function< void( boost::shared_ptr< WRMBranch > ) > > m_removeBranchSignal; //!< Signal for updating the selector
boost::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the selector
/**
* Condition that fires on setDirty.
*/
WCondition::SPtr m_dirtyCondition;
};
inline size_t WFiberSelector::size()
......
......@@ -177,6 +177,8 @@ void WMFiberDisplay::properties()
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 );
m_permanentUpdate = m_properties->addProperty( "Direct Update", "If enabled, the output fibers immediately update when changing the selection.",
false );
}
......@@ -260,6 +262,13 @@ void WMFiberDisplay::inputUpdated()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->removeChild( m_osgNode.get() );
++*progress;
m_fiberSelector = boost::shared_ptr<WFiberSelector>( new WFiberSelector( m_dataset ) );
// register dirty notifier
m_roiUpdateConnection.disconnect();
m_roiUpdateConnection = m_fiberSelector->getDirtyCondition()->subscribeSignal(
boost::bind( &WMFiberDisplay::roiUpdate, this )
);
++*progress;
create();
progress->finish();
......@@ -428,3 +437,11 @@ void WMFiberDisplay::updateOutput()
m_dataset->getBoundingBox() ) );
m_fiberOutput->updateData( newOutput );
}
void WMFiberDisplay::roiUpdate()
{
if( m_permanentUpdate->get( true ) )
{
updateOutput();
}
}
......@@ -182,7 +182,7 @@ private:
/**
* Point to a fiber selector, which is an adapater between the roi manager and the this module
*/
boost::shared_ptr< WFiberSelector>m_fiberSelector;
boost::shared_ptr< WFiberSelector > m_fiberSelector;
/**
* stores pointer to the fiber drawer
......@@ -265,6 +265,21 @@ private:
* create a selection box to cull the fibers
*/
void initCullBox();
/**
* Immediately update the output of the fiberDisplay on ROI change.
*/
WPropBool m_permanentUpdate;
/**
* Connection to the roi dirty signal.
*/
boost::signals2::connection m_roiUpdateConnection;
/**
* Called when updating the selection.
*/
void roiUpdate();
};
inline const std::string WMFiberDisplay::getName() const
......
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