Commit b7cfe1cd authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - the nav slice widgets now have the proper camera orientation

parent 35724d0a
......@@ -25,13 +25,13 @@
#include <set>
#include <osg/ShapeDrawable>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include "WGEGroupNode.h"
WGEGroupNode::WGEGroupNode():
osg::Group(),
osg::MatrixTransform(),
m_insertionQueueDirty( false ),
m_removalQueueDirty( false )
{
......@@ -40,6 +40,10 @@ WGEGroupNode::WGEGroupNode():
// setup an update callback
m_nodeUpdater = osg::ref_ptr< SafeUpdaterCallback >( new SafeUpdaterCallback() );
setUpdateCallback( m_nodeUpdater );
osg::Matrix m;
m.makeIdentity();
setMatrix( m );
}
WGEGroupNode::~WGEGroupNode()
......
......@@ -29,17 +29,18 @@
#include <boost/thread.hpp>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/NodeCallback>
/**
* Class to wrap around the osg Group node and providing a thread safe add/removal mechanism. Please be sure to use
* addUpdateCallback() to set your own update callbacks instead of setUpdateCallback, as this class already has set a callback,
* which would be overwritten by a subsequent call to setUpdateCallback().
* which would be overwritten by a subsequent call to setUpdateCallback(). It is derived from osg::MatrixTransform to allow easy transformations
* of a whole bunch of nodes.
*
* \ingroup GE
*/
class WGEGroupNode: public osg::Group
class WGEGroupNode: public osg::MatrixTransform
{
public:
......
......@@ -56,28 +56,25 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, st
m_scene = new WGEScene();
m_scene->setDataVariance( osg::Object::DYNAMIC );
m_glWidget->getViewer()->setScene( m_scene );
//
// TODO(wiebel): set the view direction of the camera correctly
//
// m_glWidget->getViewer()->getCamera()->setProjectionMatrix( osg::Matrix::ortho( -200.0, 200.0, -200.0, 200.0, 0.0, 1000.0) );
// std::cout << title.toStdString() << " ..................." << std::endl;
// osg::Vec3d center( 80., 100., 80. );
// if( title == QString( "axial" ) )
// {
// std::cout << "ax..." << std::endl;
// m_glWidget->getViewer()->getCamera()->setViewMatrix( osg::Matrix::lookAt( osg::Vec3d( -100., 0., 0. ), center, osg::Vec3d( 0., 0., 1. ) ) );
// }
// if( title == QString( "sagittal" ) )
// {
// std::cout << "sa..." << std::endl;
// m_glWidget->getViewer()->getCamera()->setViewMatrix( osg::Matrix::lookAt( osg::Vec3d( 0., -100., 0. ), center, osg::Vec3d( 0., 0., 1. ) ) );
// }
// if( title == QString( "coronal" ) )
// {
// std::cout << "cor..." << std::endl;
// m_glWidget->getViewer()->getCamera()->setViewMatrix( osg::Matrix::lookAt( osg::Vec3d( 0., 0., -100. ), center, osg::Vec3d( 1., 0., 0. ) ) );
// }
if( title == QString( "axial" ) )
{
osg::Matrix m;
m.makeRotate( 90.0, 1.0, 0.0, 0.0 );
m_scene->setMatrix( m );
}
if( title == QString( "coronal" ) )
{
osg::Matrix m;
m.makeIdentity();
m_scene->setMatrix( m );
}
if( title == QString( "sagittal" ) )
{
osg::Matrix m;
m.makeRotate( -90.0, 0.0, 0.0, 1.0 );
m_scene->setMatrix( m );
}
layout->addWidget( m_glWidget.get() );
layout->addWidget( slider );
......
......@@ -161,7 +161,7 @@ void WMNavSlices::moduleMain()
boost::shared_ptr< WGEViewer > viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" );
if ( viewer )
{
viewer->getScene()->remove( m_xSliceNode );
viewer->getScene()->remove( m_zSliceNode );
}
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" );
......@@ -173,7 +173,7 @@ void WMNavSlices::moduleMain()
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" );
if ( viewer )
{
viewer->getScene()->remove( m_zSliceNode );
viewer->getScene()->remove( m_xSliceNode );
}
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
......@@ -220,7 +220,7 @@ void WMNavSlices::create()
boost::shared_ptr< WGEViewer > viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "axial" );
if ( viewer )
{
viewer->getScene()->insert( m_xSliceNode );
viewer->getScene()->insert( m_zSliceNode );
}
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "sagittal" );
......@@ -232,7 +232,7 @@ void WMNavSlices::create()
viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewerByName( "coronal" );
if ( viewer )
{
viewer->getScene()->insert( m_zSliceNode );
viewer->getScene()->insert( m_xSliceNode );
}
}
......
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