Commit 94060cb1 authored by Alexander Wiebel's avatar Alexander Wiebel

[FIX #455] changed order in WFiberSelector constructor.

- additionally renamed a function widely used in the slection process
parent 1a2c68cc
......@@ -125,7 +125,7 @@ void WROI::signalRoiChange()
}
}
void WROI::addChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier )
void WROI::addROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier )
{
boost::unique_lock< boost::shared_mutex > lock;
lock = boost::unique_lock< boost::shared_mutex >( m_associatedNotifiersLock );
......@@ -133,7 +133,7 @@ void WROI::addChangeNotifier( boost::shared_ptr< boost::function< void() > > not
lock.unlock();
}
void WROI::removeChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier )
void WROI::removeROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier )
{
boost::unique_lock< boost::shared_mutex > lock;
lock = boost::unique_lock< boost::shared_mutex >( m_associatedNotifiersLock );
......
......@@ -113,14 +113,14 @@ public:
*
* \param notifier the notifier function
*/
void addChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
void addROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
/**
* Remove a specified notifier from the list of default notifiers which get connected to each roi.
*
* \param notifier the notifier function
*/
void removeChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
void removeROIChangeNotifier( boost::shared_ptr< boost::function< void() > > notifier );
protected:
......
......@@ -40,11 +40,8 @@ WFiberSelector::WFiberSelector( boost::shared_ptr< const WDataSetFibers > fibers
std::vector< osg::ref_ptr< WROI > >rois = WKernel::getRunningKernel()->getRoiManager()->getRois();
for ( size_t i = 0; i < rois.size(); ++i )
{
slotAddRoi( rois[i] );
( rois[i] )->getProperties()->getProperty( "Dirty" )->toPropBool()->set( true );
}
m_changeRoiSignal
= boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WFiberSelector::setDirty, this ) ) );
m_assocRoiSignal =
boost::shared_ptr< boost::function< void( osg::ref_ptr< WROI > ) > >(
......@@ -61,6 +58,12 @@ WFiberSelector::WFiberSelector( boost::shared_ptr< const WDataSetFibers > fibers
new boost::function< void( boost::shared_ptr< WRMBranch > ) > (
boost::bind( &WFiberSelector::slotRemoveBranch, this, _1 ) ) );
WKernel::getRunningKernel()->getRoiManager()->addRemoveBranchNotifier( m_removeBranchSignal );
for ( size_t i = 0; i < rois.size(); ++i )
{
slotAddRoi( rois[i] );
( rois[i] )->getProperties()->getProperty( "Dirty" )->toPropBool()->set( true );
}
}
WFiberSelector::~WFiberSelector()
......@@ -70,14 +73,17 @@ WFiberSelector::~WFiberSelector()
WKernel::getRunningKernel()->getRoiManager()->removeRemoveBranchNotifier( m_removeBranchSignal );
// We need the following because not all ROIs are removed per slot below
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
std::list< boost::shared_ptr< WSelectorRoi > > rois = ( *iter )->getROIs();
for ( std::list< boost::shared_ptr< WSelectorRoi > >::iterator roiIter = rois.begin(); roiIter != rois.end(); ++roiIter )
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
( *roiIter )->getRoi()->removeChangeNotifier( m_changeRoiSignal );
std::list< boost::shared_ptr< WSelectorRoi > > rois = ( *iter )->getROIs();
for ( std::list< boost::shared_ptr< WSelectorRoi > >::iterator roiIter = rois.begin(); roiIter != rois.end(); ++roiIter )
{
( *roiIter )->getRoi()->removeROIChangeNotifier( m_changeRoiSignal );
}
}
}
m_branches.clear();
}
void WFiberSelector::slotAddRoi( osg::ref_ptr< WROI > roi )
......@@ -101,17 +107,14 @@ void WFiberSelector::slotAddRoi( osg::ref_ptr< WROI > roi )
boost::shared_ptr< WSelectorRoi> sroi = boost::shared_ptr< WSelectorRoi>( new WSelectorRoi( roi, m_fibers, m_kdTree ) );
branch->addRoi( sroi );
m_changeRoiSignal
= boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WFiberSelector::setDirty, this ) ) );
sroi->getRoi()->addChangeNotifier( m_changeRoiSignal );
sroi->getRoi()->addROIChangeNotifier( m_changeRoiSignal );
setDirty();
}
void WFiberSelector::slotRemoveRoi( osg::ref_ptr< WROI > roi )
{
roi->removeChangeNotifier( m_changeRoiSignal );
roi->removeROIChangeNotifier( m_changeRoiSignal );
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
( *iter )->removeRoi( roi );
......
......@@ -49,7 +49,8 @@ void WRMBranch::properties()
m_dirty->setHidden( true );
m_isNot = m_properties->addProperty( "NOT", "description", false, boost::bind( &WRMBranch::propertyChanged, this ) );
m_bundleColor = m_properties->addProperty( "Bundle Color", "description", WColor( 1.0, 0.0, 0.0, 1.0 ),
boost::bind( &WRMBranch::propertyChanged, this ) );
boost::bind( &WRMBranch::propertyChanged, this ) );
m_changeRoiSignal = boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WRMBranch::setDirty, this ) ) );
}
void WRMBranch::propertyChanged()
......@@ -61,8 +62,7 @@ void WRMBranch::propertyChanged()
void WRMBranch::addRoi( osg::ref_ptr< WROI > roi )
{
m_rois.push_back( roi );
m_changeRoiSignal = boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WRMBranch::setDirty, this ) ) );
roi->addChangeNotifier( m_changeRoiSignal );
roi->addROIChangeNotifier( m_changeRoiSignal );
setDirty();
}
......@@ -81,7 +81,7 @@ bool WRMBranch::contains( osg::ref_ptr< WROI > roi )
void WRMBranch::removeRoi( osg::ref_ptr< WROI > roi )
{
roi->removeChangeNotifier( m_changeRoiSignal );
roi->removeROIChangeNotifier( m_changeRoiSignal );
for( std::list< osg::ref_ptr< WROI > >::iterator iter = m_rois.begin(); iter != m_rois.end(); ++iter )
{
if ( ( *iter ) == roi )
......
......@@ -38,6 +38,9 @@ WSelectorBranch::WSelectorBranch( boost::shared_ptr< const WDataSetFibers > fibe
m_changeSignal =
boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WSelectorBranch::setDirty, this ) ) );
m_branch->addChangeNotifier( m_changeSignal );
m_changeRoiSignal =
boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WSelectorBranch::setDirty, this ) ) );
}
WSelectorBranch::~WSelectorBranch()
......@@ -47,17 +50,14 @@ WSelectorBranch::~WSelectorBranch()
// We need the following because not all ROIs are removed per slot below
for ( std::list< boost::shared_ptr< WSelectorRoi > >::iterator roiIter = m_rois.begin(); roiIter != m_rois.end(); ++roiIter )
{
( *roiIter )->getRoi()->removeChangeNotifier( m_changeRoiSignal );
( *roiIter )->getRoi()->removeROIChangeNotifier( m_changeRoiSignal );
}
}
void WSelectorBranch::addRoi( boost::shared_ptr< WSelectorRoi > roi )
{
m_rois.push_back( roi );
m_changeRoiSignal =
boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WSelectorBranch::setDirty, this ) ) );
roi->getRoi()->addChangeNotifier( m_changeRoiSignal );
roi->getRoi()->addROIChangeNotifier( m_changeRoiSignal );
}
std::list< boost::shared_ptr< WSelectorRoi > > WSelectorBranch::getROIs()
......@@ -68,7 +68,7 @@ std::list< boost::shared_ptr< WSelectorRoi > > WSelectorBranch::getROIs()
void WSelectorBranch::setDirty()
{
m_dirty = true;
if ( m_branch->getProperties()->getProperty( "Bundle Color" )->toPropColor()->changed() )
if( m_branch->getProperties()->getProperty( "Bundle Color" )->toPropColor()->changed() )
{
colorChanged();
}
......@@ -76,11 +76,11 @@ void WSelectorBranch::setDirty()
void WSelectorBranch::removeRoi( osg::ref_ptr< WROI > roi )
{
roi->removeChangeNotifier( m_changeRoiSignal );
for( std::list< boost::shared_ptr< WSelectorRoi > >::iterator iter = m_rois.begin(); iter != m_rois.end(); ++iter )
{
if ( ( *iter )->getRoi() == roi )
{
( *iter )->getRoi()->removeROIChangeNotifier( m_changeRoiSignal );
m_rois.erase( iter );
break;
}
......
......@@ -45,12 +45,12 @@ WSelectorRoi::WSelectorRoi( osg::ref_ptr< WROI > roi, boost::shared_ptr< const W
m_changeRoiSignal
= boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WSelectorRoi::setDirty, this ) ) );
m_roi->addChangeNotifier( m_changeRoiSignal );
m_roi->addROIChangeNotifier( m_changeRoiSignal );
}
WSelectorRoi::~WSelectorRoi()
{
m_roi->removeChangeNotifier( m_changeRoiSignal );
m_roi->removeROIChangeNotifier( m_changeRoiSignal );
}
void WSelectorRoi::setDirty()
......@@ -64,7 +64,6 @@ void WSelectorRoi::recalculate()
if ( osg::dynamic_pointer_cast<WROIBox>( m_roi ).get() )
{
//std::cout << "roi recalc" << std::endl;
m_boxMin.resize( 3 );
m_boxMax.resize( 3 );
......
......@@ -216,9 +216,9 @@ void WMArbitraryPlane::moduleMain()
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( &( *m_s1 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( &( *m_s2 ) );
m_s0->removeChangeNotifier( m_changeRoiSignal );
m_s1->removeChangeNotifier( m_changeRoiSignal );
m_s2->removeChangeNotifier( m_changeRoiSignal );
m_s0->removeROIChangeNotifier( m_changeRoiSignal );
m_s1->removeROIChangeNotifier( m_changeRoiSignal );
m_s2->removeROIChangeNotifier( m_changeRoiSignal );
con.disconnect();
......@@ -252,9 +252,9 @@ void WMArbitraryPlane::initPlane()
m_changeRoiSignal
= boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WMArbitraryPlane::setDirty, this ) ) );
m_s0->addChangeNotifier( m_changeRoiSignal );
m_s1->addChangeNotifier( m_changeRoiSignal );
m_s2->addChangeNotifier( m_changeRoiSignal );
m_s0->addROIChangeNotifier( m_changeRoiSignal );
m_s1->addROIChangeNotifier( m_changeRoiSignal );
m_s2->addROIChangeNotifier( m_changeRoiSignal );
}
void WMArbitraryPlane::updatePlane()
......
......@@ -168,18 +168,18 @@ void WMDatasetManipulator::init()
using boost::function;
m_changeRoiSignal
= boost::shared_ptr< function< void() > >( new function< void() >( boost::bind( &WMDatasetManipulator::manipulatorMoved, this ) ) );
m_knobCenter->addChangeNotifier( m_changeRoiSignal );
m_knobx1->addChangeNotifier( m_changeRoiSignal );
m_knobx2->addChangeNotifier( m_changeRoiSignal );
m_knoby1->addChangeNotifier( m_changeRoiSignal );
m_knoby2->addChangeNotifier( m_changeRoiSignal );
m_knobz1->addChangeNotifier( m_changeRoiSignal );
m_knobz2->addChangeNotifier( m_changeRoiSignal );
m_knobCenter->addROIChangeNotifier( m_changeRoiSignal );
m_knobx1->addROIChangeNotifier( m_changeRoiSignal );
m_knobx2->addROIChangeNotifier( m_changeRoiSignal );
m_knoby1->addROIChangeNotifier( m_changeRoiSignal );
m_knoby2->addROIChangeNotifier( m_changeRoiSignal );
m_knobz1->addROIChangeNotifier( m_changeRoiSignal );
m_knobz2->addROIChangeNotifier( m_changeRoiSignal );
m_changeRotRoiSignal
= boost::shared_ptr< function< void() > >( new function< void() >( boost::bind( &WMDatasetManipulator::manipulatorRotMoved, this ) ) );
m_knobRotCenter->addChangeNotifier( m_changeRotRoiSignal );
m_knobRot->addChangeNotifier( m_changeRotRoiSignal );
m_knobRotCenter->addROIChangeNotifier( m_changeRotRoiSignal );
m_knobRot->addROIChangeNotifier( m_changeRotRoiSignal );
setManipulatorMode();
}
......@@ -459,15 +459,15 @@ void WMDatasetManipulator::moduleMain()
}
}
m_knobCenter->removeChangeNotifier( m_changeRoiSignal );
m_knobx1->removeChangeNotifier( m_changeRoiSignal );
m_knobx2->removeChangeNotifier( m_changeRoiSignal );
m_knoby1->removeChangeNotifier( m_changeRoiSignal );
m_knoby2->removeChangeNotifier( m_changeRoiSignal );
m_knobz1->removeChangeNotifier( m_changeRoiSignal );
m_knobz2->removeChangeNotifier( m_changeRoiSignal );
m_knobCenter->removeROIChangeNotifier( m_changeRoiSignal );
m_knobx1->removeROIChangeNotifier( m_changeRoiSignal );
m_knobx2->removeROIChangeNotifier( m_changeRoiSignal );
m_knoby1->removeROIChangeNotifier( m_changeRoiSignal );
m_knoby2->removeROIChangeNotifier( m_changeRoiSignal );
m_knobz1->removeROIChangeNotifier( m_changeRoiSignal );
m_knobz2->removeROIChangeNotifier( m_changeRoiSignal );
m_knobRotCenter->removeChangeNotifier( m_changeRotRoiSignal );
m_knobRot->removeChangeNotifier( m_changeRotRoiSignal );
m_knobRotCenter->removeROIChangeNotifier( m_changeRotRoiSignal );
m_knobRot->removeROIChangeNotifier( m_changeRotRoiSignal );
}
......@@ -203,11 +203,11 @@ void WMOverlayAtlas::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
m_s0->removeChangeNotifier( m_changeRoiSignal );
m_s1->removeChangeNotifier( m_changeRoiSignal );
m_s2->removeChangeNotifier( m_changeRoiSignal );
m_s3->removeChangeNotifier( m_changeRoiSignal );
m_s4->removeChangeNotifier( m_changeRoiSignal );
m_s0->removeROIChangeNotifier( m_changeRoiSignal );
m_s1->removeROIChangeNotifier( m_changeRoiSignal );
m_s2->removeROIChangeNotifier( m_changeRoiSignal );
m_s3->removeROIChangeNotifier( m_changeRoiSignal );
m_s4->removeROIChangeNotifier( m_changeRoiSignal );
}
void WMOverlayAtlas::init()
......@@ -263,11 +263,11 @@ void WMOverlayAtlas::init()
m_changeRoiSignal =
boost::shared_ptr< boost::function< void() > >( new boost::function< void() >( boost::bind( &WMOverlayAtlas::manipulatorMoved, this ) ) );
m_s0->addChangeNotifier( m_changeRoiSignal );
m_s1->addChangeNotifier( m_changeRoiSignal );
m_s2->addChangeNotifier( m_changeRoiSignal );
m_s3->addChangeNotifier( m_changeRoiSignal );
m_s4->addChangeNotifier( m_changeRoiSignal );
m_s0->addROIChangeNotifier( m_changeRoiSignal );
m_s1->addROIChangeNotifier( m_changeRoiSignal );
m_s2->addROIChangeNotifier( m_changeRoiSignal );
m_s3->addROIChangeNotifier( m_changeRoiSignal );
m_s4->addROIChangeNotifier( m_changeRoiSignal );
toggleManipulators();
}
......
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