Commit 88a38bab authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - now the slices do not crash anymore if the viewer is not available

parent cdecbfd1
......@@ -291,7 +291,10 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
}
else
{
m_navAxial->setSliderProperty( prop->toPropInt() );
if( m_navAxial )
{
m_navAxial->setSliderProperty( prop->toPropInt() );
}
}
prop = module->getProperties2()->findProperty( "coronalPos" );
......@@ -303,7 +306,10 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
}
else
{
m_navCoronal->setSliderProperty( prop->toPropInt() );
if( m_navCoronal )
{
m_navCoronal->setSliderProperty( prop->toPropInt() );
}
}
prop = module->getProperties2()->findProperty( "sagittalPos" );
......@@ -315,7 +321,10 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
}
else
{
m_navSagittal->setSliderProperty( prop->toPropInt() );
if( m_navSagittal )
{
m_navSagittal->setSliderProperty( prop->toPropInt() );
}
}
}
}
......
......@@ -32,6 +32,7 @@
#include "WQtNavGLWidget.h"
#include "../../graphicsEngine/WGEViewer.h"
#include "../../graphicsEngine/WGEScene.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, std::string sliderTitle )
: QDockWidget( title, parent )
......@@ -52,7 +53,7 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, st
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
m_glWidget->initialize();
m_scene = new WGEGroupNode();
m_scene = new WGEScene();
m_scene->setDataVariance( osg::Object::DYNAMIC );
m_glWidget->getViewer()->setScene( m_scene );
//
......
......@@ -156,10 +156,26 @@ void WMNavSlices::moduleMain()
waitForStop();
// clean up stuff
// NOTE: ALLAWAYS remove your osg nodes!
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" )->getScene()->remove( m_xSliceNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" )->getScene()->remove( m_ySliceNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" )->getScene()->remove( m_zSliceNode );
// NOTE: ALAWAYS remove your osg nodes!
// Please, please always check for NULL
boost::shared_ptr< WGEViewer > viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" );
if ( viewer )
{
viewer->getScene()->remove( m_xSliceNode );
}
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" );
if ( viewer )
{
viewer->getScene()->remove( m_ySliceNode );
}
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" );
if ( viewer )
{
viewer->getScene()->remove( m_zSliceNode );
}
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
// deregister from WSubject's change condition
......@@ -200,10 +216,24 @@ void WMNavSlices::create()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
// Please, please always check for NULL
boost::shared_ptr< WGEViewer > viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" );
if ( viewer )
{
viewer->getScene()->insert( m_xSliceNode );
}
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" );
if ( viewer )
{
viewer->getScene()->insert( m_ySliceNode );
}
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" )->getScene()->insert( m_xSliceNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" )->getScene()->insert( m_ySliceNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" )->getScene()->insert( m_zSliceNode );
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" );
if ( viewer )
{
viewer->getScene()->insert( m_zSliceNode );
}
}
osg::Vec3 wv3D2ov3( wmath::WVector3D v ) // WVector3D to osg::Vec3 conversion
......
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