Commit fbb297a2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX #15] - fixes remove-crash. Never ever ever never ever use an osg derived...

[FIX #15] - fixes remove-crash. Never ever ever never ever use an osg derived object in conjunction with boost::shared_ptr
parent 8dd66a63
......@@ -145,29 +145,29 @@ void WMDatasetManipulator::init()
WPosition center = bb.center();
m_knobCenter = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobx1 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobx2 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knoby1 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knoby2 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobz1 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobz2 = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobCenter = new WROISphere( center, 2.5 );
m_knobx1 = new WROISphere( center, 2.5 );
m_knobx2 = new WROISphere( center, 2.5 );
m_knoby1 = new WROISphere( center, 2.5 );
m_knoby2 = new WROISphere( center, 2.5 );
m_knobz1 = new WROISphere( center, 2.5 );
m_knobz2 = new WROISphere( center, 2.5 );
m_knobRotCenter = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobRot = boost::shared_ptr<WROISphere>( new WROISphere( center, 2.5 ) );
m_knobRotCenter = new WROISphere( center, 2.5 );
m_knobRot = new WROISphere( center, 2.5 );
setManipulatorsFromBoundingBox();
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobCenter ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobx1 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobx2 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knoby1 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knoby2 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobz1 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobz2 ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobCenter );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobx1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobx2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knoby1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knoby2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobz1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobz2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobRotCenter ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( &( *m_knobRot ) );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobRotCenter );
WGraphicsEngine::getGraphicsEngine()->getScene()->insert( m_knobRot );
using boost::function;
m_changeRoiSignal
......@@ -188,6 +188,33 @@ void WMDatasetManipulator::init()
setManipulatorMode();
}
void WMDatasetManipulator::shutdown()
{
// remove the notifier
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->removeROIChangeNotifier( m_changeRotRoiSignal );
m_knobRot->removeROIChangeNotifier( m_changeRotRoiSignal );
// remove knobs from OSG
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobCenter );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobx1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobx2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knoby1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knoby2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobz1 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobz2 );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobRotCenter );
WGraphicsEngine::getGraphicsEngine()->getScene()->remove( m_knobRot );
}
void WMDatasetManipulator::setManipulatorsFromBoundingBox()
{
WGridRegular3D g( m_grid->getNbCoordsX(), m_grid->getNbCoordsY(), m_grid->getNbCoordsZ(), *m_transform );
......@@ -510,15 +537,7 @@ void WMDatasetManipulator::moduleMain()
}
}
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->removeROIChangeNotifier( m_changeRotRoiSignal );
m_knobRot->removeROIChangeNotifier( m_changeRotRoiSignal );
// cleanup
shutdown();
}
......@@ -110,6 +110,11 @@ private:
*/
void init();
/**
* Removes the knobs and cleans up.
*/
void shutdown();
/**
* reacts to movements of the manipulator knobs
*/
......@@ -159,13 +164,13 @@ private:
boost::shared_ptr< boost::function< void() > > m_changeRotRoiSignal; //!< Signal that can be used to update the rotation manipulator
boost::shared_ptr< boost::function< void() > > m_changeRoiSignal; //!< Signal that can be used to update the translation manipulator
boost::shared_ptr<WROISphere> m_knobCenter; //!< stores pointer to the center manipulator
boost::shared_ptr<WROISphere> m_knobx1; //!< stores pointer to manipulator 1
boost::shared_ptr<WROISphere> m_knobx2; //!< stores pointer to manipulator 2
boost::shared_ptr<WROISphere> m_knoby1; //!< stores pointer to manipulator 1
boost::shared_ptr<WROISphere> m_knoby2; //!< stores pointer to manipulator 2
boost::shared_ptr<WROISphere> m_knobz1; //!< stores pointer to manipulator 1
boost::shared_ptr<WROISphere> m_knobz2; //!< stores pointer to manipulator 2
osg::ref_ptr<WROISphere> m_knobCenter; //!< stores pointer to the center manipulator
osg::ref_ptr<WROISphere> m_knobx1; //!< stores pointer to manipulator 1
osg::ref_ptr<WROISphere> m_knobx2; //!< stores pointer to manipulator 2
osg::ref_ptr<WROISphere> m_knoby1; //!< stores pointer to manipulator 1
osg::ref_ptr<WROISphere> m_knoby2; //!< stores pointer to manipulator 2
osg::ref_ptr<WROISphere> m_knobz1; //!< stores pointer to manipulator 1
osg::ref_ptr<WROISphere> m_knobz2; //!< stores pointer to manipulator 2
WPosition m_posCenter; //!< stores the old position of the manipulator
WPosition m_posx1; //!< stores the old position of the manipulator
......@@ -183,8 +188,8 @@ private:
WPosition m_posz1Orig; //!< stores the old position of the manipulator
WPosition m_posz2Orig; //!< stores the old position of the manipulator
boost::shared_ptr<WROISphere> m_knobRotCenter; //!< stores pointer to the center manipulator
boost::shared_ptr<WROISphere> m_knobRot; //!< stores pointer to manipulator 1
osg::ref_ptr<WROISphere> m_knobRotCenter; //!< stores pointer to the center manipulator
osg::ref_ptr<WROISphere> m_knobRot; //!< stores pointer to manipulator 1
WPosition m_posRotCenter; //!< stores the old position of the manipulator
WPosition m_posRot; //!< stores the old position of the manipulator
......
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