Commit ec6b144b authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[CHANGE] Put our WBoundingBox (which is essentially an osg bounding box, but...

[CHANGE] Put our WBoundingBox (which is essentially an osg bounding box, but proper encapsulated) more in use, so some code has simplified much more, and readability has increased a lot! Please use our WBoundingBox!
parent cc30cfbf
......@@ -148,6 +148,19 @@ public:
using osg::BoundingBoxImpl< VT >::contains;
/**
* Gives the front lower left aka minimum corner.
*
* \return Minimum corner.
*/
const vec_type& getMin() const;
/**
* Gives the back upper right aka maximum corner.
*
* \return Maximum corner.
*/
const vec_type& getMax() const;
protected:
private:
......@@ -271,6 +284,18 @@ inline std::ostream& operator<<( std::ostream& out, const WBoundingBoxImpl< VT >
return out;
}
template< class VT >
inline const typename WBoundingBoxImpl< VT >::vec_type& WBoundingBoxImpl< VT >::getMin() const
{
return osg::BoundingBoxImpl< VT >::_min;
}
template< class VT >
inline const typename WBoundingBoxImpl< VT >::vec_type& WBoundingBoxImpl< VT >::getMax() const
{
return osg::BoundingBoxImpl< VT >::_max;
}
typedef WBoundingBoxImpl< wmath::WVector3D > WBoundingBox;
#endif // WBOUNDINGBOX_H
......@@ -28,6 +28,7 @@
#include <cstddef>
#include <utility>
#include "../common/WBoundingBox.h"
#include "../common/WProperties.h"
#include "../common/math/WPosition.h"
#include "WExportDataHandler.h"
......@@ -61,7 +62,7 @@ public:
/**
* Returns the two positions representing the bounding box of the grid.
*/
virtual std::pair< wmath::WPosition, wmath::WPosition > getBoundingBox() const = 0;
virtual WBoundingBox getBoundingBox() const = 0;
/**
* Returns a pointer to the information properties object of the grid. The grid intends these properties to not be modified.
......
......@@ -28,6 +28,7 @@
#include <utility>
#include "../common/WAssert.h"
#include "../common/WBoundingBox.h"
#include "../common/exceptions/WOutOfBounds.h"
#include "../common/math/WLinearAlgebraFunctions.h"
#include "WGridRegular3D.h"
......@@ -933,33 +934,19 @@ bool WGridRegular3D::enclosesRotated( wmath::WPosition const& pos ) const
return true;
}
std::pair< wmath::WPosition, wmath::WPosition > WGridRegular3D::getBoundingBox() const
WBoundingBox WGridRegular3D::getBoundingBox() const
{
// Get the transformed corner points of the regular grid
std::vector< wmath::WPosition > cornerPs;
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, 0.0, 0.0 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, 0.0, 0.0 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, getNbCoordsY() - 1, 0.0 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, getNbCoordsY() - 1, 0.0 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, 0.0, getNbCoordsZ() - 1 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, 0.0, getNbCoordsZ() - 1 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
cornerPs.push_back( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
wmath::WPosition minBB( wlimits::MAX_DOUBLE, wlimits::MAX_DOUBLE, wlimits::MAX_DOUBLE );
wmath::WPosition maxBB( wlimits::MIN_DOUBLE, wlimits::MIN_DOUBLE, wlimits::MIN_DOUBLE );
// Check the components of the corner points separately against the components of the current maxBB and minBB
for( size_t posId = 0; posId < cornerPs.size(); ++posId)
{
for( size_t compId = 0; compId < 3; ++compId )
{
minBB[compId] = cornerPs[posId][compId] < minBB[compId] ? cornerPs[posId][compId] : minBB[compId];
maxBB[compId] = cornerPs[posId][compId] > maxBB[compId] ? cornerPs[posId][compId] : maxBB[compId];
}
}
WBoundingBox result;
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, 0.0, 0.0 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, 0.0, 0.0 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, getNbCoordsY() - 1, 0.0 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, getNbCoordsY() - 1, 0.0 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, 0.0, getNbCoordsZ() - 1 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, 0.0, getNbCoordsZ() - 1 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( 0.0, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
result.expandBy( transformPosition3DWithMatrix4D( m_matrix, wmath::WPosition( getNbCoordsX() - 1, getNbCoordsY() - 1, getNbCoordsZ() - 1 ) ) );
return std::make_pair( minBB, maxBB );
return result;
}
void WGridRegular3D::translate( wmath::WPosition translate )
......
......@@ -36,8 +36,9 @@
#include "../common/math/WMatrix.h"
#include "../common/math/WPosition.h"
#include "../common/math/WVector3D.h"
#include "WGrid.h"
#include "../common/WBoundingBox.h"
#include "WExportDataHandler.h"
#include "WGrid.h"
/**
* A grid that has parallelepiped cells which all have the same proportion. I.e.
......@@ -222,9 +223,9 @@ public:
wmath::WPosition getOrigin() const;
/**
* Returns the two positions representing the bounding box of the grid.
* \return The two positions representing the bounding box of the grid.
*/
std::pair< wmath::WPosition, wmath::WPosition > getBoundingBox() const;
WBoundingBox getBoundingBox() const;
/**
* Returns the i-th position on the grid.
......
......@@ -51,9 +51,9 @@ public:
/**
* Returns dummy bounding box.
*/
virtual std::pair< wmath::WPosition, wmath::WPosition > getBoundingBox() const
virtual WBoundingBox getBoundingBox() const
{
return std::make_pair( wmath::WPosition( 0, 0, 0 ), wmath::WPosition( 1, 1, 1 ) );
return WBoundingBox( wmath::WPosition( 0, 0, 0 ), wmath::WPosition( 1, 1, 1 ) );
}
};
......
......@@ -40,8 +40,11 @@
#include "WGEUtils.h"
osg::ref_ptr< osg::Geode > wge::generateBoundingBoxGeode( const wmath::WPosition& pos1, const wmath::WPosition& pos2, const WColor& color )
osg::ref_ptr< osg::Geode > wge::generateBoundingBoxGeode( const WBoundingBox& bb, const WColor& color )
{
const wmath::WPosition& pos1 = bb.getMin();
const wmath::WPosition& pos2 = bb.getMax();
WAssert( pos1[0] <= pos2[0] && pos1[1] <= pos2[1] && pos1[2] <= pos2[2], "pos1 does not seem to be the frontLowerLeft corner of the BB!" );
using osg::ref_ptr;
ref_ptr< osg::Vec3Array > vertices = ref_ptr< osg::Vec3Array >( new osg::Vec3Array );
......@@ -153,10 +156,9 @@ osg::ref_ptr< osg::Geometry > wge::createUnitCube( const WColor& color )
return cube;
}
osg::ref_ptr< osg::Node > wge::generateSolidBoundingBoxNode( const wmath::WPosition& pos1, const wmath::WPosition& pos2, const WColor& color,
bool threeDTexCoords )
osg::ref_ptr< osg::Node > wge::generateSolidBoundingBoxNode( const WBoundingBox& bb, const WColor& color, bool threeDTexCoords )
{
WAssert( pos1[0] <= pos2[0] && pos1[1] <= pos2[1] && pos1[2] <= pos2[2], "pos1 doesn't seem to be the frontLowerLeft corner of the BB!" );
WAssert( bb.valid(), "Invalid bounding box!" );
// create a uni cube
osg::ref_ptr< osg::Geode > cube = new osg::Geode();
......@@ -175,8 +177,8 @@ osg::ref_ptr< osg::Node > wge::generateSolidBoundingBoxNode( const wmath::WPosit
// transform the cube to match the bbox
osg::Matrixd transformM;
osg::Matrixd scaleM;
transformM.makeTranslate( pos1 );
scaleM.makeScale( pos2 - pos1 );
transformM.makeTranslate( bb.getMin() );
scaleM.makeScale( bb.getMax() - bb.getMin() );
// apply transformation to bbox
osg::ref_ptr< osg::MatrixTransform > transform = new osg::MatrixTransform();
......
......@@ -51,31 +51,24 @@ namespace wge
/**
* Generates an OSG geode for the bounding box.
*
* \param pos1 Front lower left corner
* \param pos2 Back upper right corner
* \param bb The axis aligned bounding box to generate a geode from.
* \param color The color in which the bounding box should be generated
*
* \return The OSG geode containing the 12 edges of the box.
*/
osg::ref_ptr< osg::Geode > WGE_EXPORT generateBoundingBoxGeode( const wmath::WPosition& pos1,
const wmath::WPosition& pos2,
const WColor& color );
osg::ref_ptr< osg::Geode > WGE_EXPORT generateBoundingBoxGeode( const WBoundingBox& bb, const WColor& color );
/**
* Generates an OSG node for the specified bounding box. It uses solid faces. This actually returns a MatrixTransform node and is especially
* useful for shader based raytracing.
*
* \param pos1 Front lower left corner
* \param pos2 Back upper right corner
* \param bb The axis aligned bounding box
* \param color The color in which the bounding box should be generated
* \param threeDTexCoords True if 3D texture coordinates should be created.
*
* \return The OSG node containing the 12 edges of the box.
*/
osg::ref_ptr< osg::Node > WGE_EXPORT generateSolidBoundingBoxNode( const wmath::WPosition& pos1,
const wmath::WPosition& pos2,
const WColor& color,
bool threeDTexCoords = true );
osg::ref_ptr< osg::Node > WGE_EXPORT generateSolidBoundingBoxNode( const WBoundingBox& bb, const WColor& color, bool threeDTexCoords = true );
/**
* Creates a osg::Geometry containing an unit cube, having 3D texture coordinates.
......
......@@ -198,9 +198,9 @@ void WMNavSlices::moduleMain()
);
setMaxMinFromBoundingBox();
m_sagittalPos->set( 0.5 * ( m_bb.first[0] + m_bb.second[0] ) );
m_coronalPos->set( 0.5 * ( m_bb.first[1] + m_bb.second[1] ) );
m_axialPos->set( 0.5 * ( m_bb.first[2] + m_bb.second[2] ) );
m_sagittalPos->set( 0.5 * ( m_bb.xMin() + m_bb.xMax() ) );
m_coronalPos->set( 0.5 * ( m_bb.yMin() + m_bb.yMax() ) );
m_axialPos->set( 0.5 * ( m_bb.zMin() + m_bb.zMax() ) );
create();
......@@ -366,10 +366,10 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
// z slice
if ( pickInfo.getViewerName() == "Axial View" )
{
width = m_bb.second[0] - m_bb.first[0] + 1;
height = m_bb.second[1] - m_bb.first[1] + 1;
left = m_bb.first[0];
top = m_bb.first[1];
width = m_bb.xMax() - m_bb.xMin() + 1;
height = m_bb.yMax() - m_bb.yMin() + 1;
left = m_bb.xMin();
top = m_bb.yMin();
aspectR = static_cast< double >( m_axialWidgetWidth ) / static_cast< double >( m_axialWidgetHeight );
{
......@@ -394,10 +394,10 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
yPos = ( ( y - ( static_cast< double >( m_axialWidgetHeight ) - sizeY ) / 2 ) / sizeY ) * height + top;
}
xPos = xPos < m_bb.first[0] ? m_bb.first[0] : xPos;
xPos = xPos > m_bb.second[0] ? m_bb.second[0] : xPos;
yPos = yPos < m_bb.first[1] ? m_bb.first[1] : yPos;
yPos = yPos > m_bb.second[1] ? m_bb.second[1] : yPos;
xPos = xPos < m_bb.xMin() ? m_bb.xMin() : xPos;
xPos = xPos > m_bb.xMax() ? m_bb.xMax() : xPos;
yPos = yPos < m_bb.yMin() ? m_bb.yMin() : yPos;
yPos = yPos > m_bb.yMax() ? m_bb.yMax() : yPos;
m_sagittalPos->set( xPos );
m_coronalPos->set( yPos );
......@@ -406,10 +406,10 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
// x slice
if ( pickInfo.getViewerName() == "Sagittal View" )
{
width = m_bb.second[1] - m_bb.first[1] + 1;
height = m_bb.second[2] - m_bb.first[2] + 1;
left = m_bb.first[1];
top = m_bb.first[2];
width = m_bb.yMax() - m_bb.yMin() + 1;
height = m_bb.zMax() - m_bb.zMin() + 1;
left = m_bb.yMin();
top = m_bb.zMin();
aspectR = static_cast< double >( m_sagittalWidgetWidth ) / static_cast< double >( m_sagittalWidgetHeight );
{
......@@ -433,11 +433,11 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
xPos = ( ( x - ( static_cast< double >( m_sagittalWidgetWidth ) - sizeX ) / 2 ) / sizeX ) * width + left;
yPos = ( ( y - ( static_cast< double >( m_sagittalWidgetHeight ) - sizeY ) / 2 ) / sizeY ) * height + top;
}
xPos = m_bb.second[1] - xPos + left;
xPos = xPos < m_bb.first[1] ? m_bb.first[1] : xPos;
xPos = xPos > m_bb.second[1] ? m_bb.second[1] : xPos;
yPos = yPos < m_bb.first[2] ? m_bb.first[2] : yPos;
yPos = yPos > m_bb.second[2] ? m_bb.second[2] : yPos;
xPos = m_bb.yMax() - xPos + left;
xPos = xPos < m_bb.yMin() ? m_bb.yMin() : xPos;
xPos = xPos > m_bb.yMax() ? m_bb.yMax() : xPos;
yPos = yPos < m_bb.zMin() ? m_bb.zMin() : yPos;
yPos = yPos > m_bb.zMax() ? m_bb.zMax() : yPos;
m_coronalPos->set( xPos );
m_axialPos->set( yPos );
......@@ -446,10 +446,10 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
// y slice
if ( pickInfo.getViewerName() == "Coronal View" )
{
width = m_bb.second[0] - m_bb.first[0] + 1;
height = m_bb.second[2] - m_bb.first[2] + 1;
left = m_bb.first[0];
top = m_bb.first[2];
width = m_bb.xMax() - m_bb.xMin() + 1;
height = m_bb.zMax() - m_bb.zMin() + 1;
left = m_bb.xMin();
top = m_bb.zMin();
aspectR = static_cast< double >( m_coronalWidgetWidth ) / static_cast< double >( m_coronalWidgetHeight );
{
......@@ -473,10 +473,10 @@ void WMNavSlices::setSlicePosFromPick( WPickInfo pickInfo )
xPos = ( ( x - ( static_cast< double >( m_coronalWidgetWidth ) - sizeX ) / 2 ) / sizeX ) * width + left;
yPos = ( ( y - ( static_cast< double >( m_coronalWidgetHeight ) - sizeY ) / 2 ) / sizeY ) * height + top;
}
xPos = xPos < m_bb.first[0] ? m_bb.first[0] : xPos;
xPos = xPos > m_bb.second[0] ? m_bb.second[0] : xPos;
yPos = yPos < m_bb.first[2] ? m_bb.first[2] : yPos;
yPos = yPos > m_bb.second[2] ? m_bb.second[2] : yPos;
xPos = xPos < m_bb.xMin() ? m_bb.xMin() : xPos;
xPos = xPos > m_bb.xMax() ? m_bb.xMax() : xPos;
yPos = yPos < m_bb.zMin() ? m_bb.zMin() : yPos;
yPos = yPos > m_bb.zMax() ? m_bb.zMax() : yPos;
m_sagittalPos->set( xPos );
m_axialPos->set( yPos );
......@@ -563,27 +563,21 @@ void WMNavSlices::setMaxMinFromBoundingBox()
if ( tex.size() > 0 )
{
std::pair< wmath::WPosition, wmath::WPosition > bb = tex[0]->getGrid()->getBoundingBox();
WBoundingBox bb = tex[0]->getGrid()->getBoundingBox();
for( size_t i = 1; i < tex.size(); ++i )
{
std::pair< wmath::WPosition, wmath::WPosition > bbTmp = tex[i]->getGrid()->getBoundingBox();
bb.first[0] = bb.first[0] < bbTmp.first[0] ? bb.first[0] : bbTmp.first[0];
bb.first[1] = bb.first[1] < bbTmp.first[1] ? bb.first[1] : bbTmp.first[1];
bb.first[2] = bb.first[2] < bbTmp.first[2] ? bb.first[2] : bbTmp.first[2];
bb.second[0] = bb.second[0] > bbTmp.second[0] ? bb.second[0] : bbTmp.second[0];
bb.second[1] = bb.second[1] > bbTmp.second[1] ? bb.second[1] : bbTmp.second[1];
bb.second[2] = bb.second[2] > bbTmp.second[2] ? bb.second[2] : bbTmp.second[2];
bb.expandBy( tex[i]->getGrid()->getBoundingBox() );
}
m_bb = bb;
m_sagittalPos->setMin( bb.first[0] );
m_sagittalPos->setMax( bb.second[0] );
m_coronalPos->setMin( bb.first[1] );
m_coronalPos->setMax( bb.second[1] );
m_axialPos->setMin( bb.first[2] );
m_axialPos->setMax( bb.second[2] );
m_sagittalPos->setMin( bb.xMin() );
m_sagittalPos->setMax( bb.xMax() );
m_coronalPos->setMin( bb.yMin() );
m_coronalPos->setMax( bb.yMax() );
m_axialPos->setMin( bb.zMin() );
m_axialPos->setMax( bb.zMax() );
}
}
......@@ -616,10 +610,10 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
case 0:
{
std::vector< wmath::WPosition > vertices;
vertices.push_back( wmath::WPosition( xPos, m_bb.first[1], m_bb.first[2] ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.first[1], m_bb.second[2] ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.second[1], m_bb.second[2] ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.second[1], m_bb.first[2] ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.yMin(), m_bb.zMin() ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.yMin(), m_bb.zMax() ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.yMax(), m_bb.zMax() ) );
vertices.push_back( wmath::WPosition( xPos, m_bb.yMax(), m_bb.zMin() ) );
for( size_t i = 0; i < nbVerts; ++i )
{
sliceVertices->push_back( vertices[i] );
......@@ -660,10 +654,10 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
case 1:
{
std::vector< wmath::WPosition > vertices;
vertices.push_back( wmath::WPosition( m_bb.first[0], yPos, m_bb.first[2] ) );
vertices.push_back( wmath::WPosition( m_bb.first[0], yPos, m_bb.second[2] ) );
vertices.push_back( wmath::WPosition( m_bb.second[0], yPos, m_bb.second[2] ) );
vertices.push_back( wmath::WPosition( m_bb.second[0], yPos, m_bb.first[2] ) );
vertices.push_back( wmath::WPosition( m_bb.xMin(), yPos, m_bb.zMin() ) );
vertices.push_back( wmath::WPosition( m_bb.xMin(), yPos, m_bb.zMax() ) );
vertices.push_back( wmath::WPosition( m_bb.xMax(), yPos, m_bb.zMax() ) );
vertices.push_back( wmath::WPosition( m_bb.xMax(), yPos, m_bb.zMin() ) );
for( size_t i = 0; i < nbVerts; ++i )
{
sliceVertices->push_back( vertices[i] );
......@@ -702,10 +696,10 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createGeometry( int slice )
case 2:
{
std::vector< wmath::WPosition > vertices;
vertices.push_back( wmath::WPosition( m_bb.first[0], m_bb.first[1], zPos ) );
vertices.push_back( wmath::WPosition( m_bb.first[0], m_bb.second[1], zPos ) );
vertices.push_back( wmath::WPosition( m_bb.second[0], m_bb.second[1], zPos ) );
vertices.push_back( wmath::WPosition( m_bb.second[0], m_bb.first[1], zPos ) );
vertices.push_back( wmath::WPosition( m_bb.xMin(), m_bb.yMin(), zPos ) );
vertices.push_back( wmath::WPosition( m_bb.xMin(), m_bb.yMax(), zPos ) );
vertices.push_back( wmath::WPosition( m_bb.xMax(), m_bb.yMax(), zPos ) );
vertices.push_back( wmath::WPosition( m_bb.xMax(), m_bb.yMin(), zPos ) );
for( size_t i = 0; i < nbVerts; ++i )
{
sliceVertices->push_back( vertices[i] );
......@@ -773,12 +767,12 @@ osg::ref_ptr<osg::Geometry> WMNavSlices::createCrossGeometry( int slice )
osg::Vec3Array* crossVertices = new osg::Vec3Array;
osg::Vec3Array* colorArray = new osg::Vec3Array;
float minx = m_bb.first[0];
float miny = m_bb.first[1];
float minz = m_bb.first[2];
float maxx = m_bb.second[0];
float maxy = m_bb.second[1];
float maxz = m_bb.second[2];
float minx = m_bb.xMin();
float miny = m_bb.yMin();
float minz = m_bb.zMin();
float maxx = m_bb.xMax();
float maxy = m_bb.yMax();
float maxz = m_bb.zMax();
std::vector< wmath::WPosition > vertices;
......@@ -1132,10 +1126,10 @@ void WMNavSlices::updateViewportMatrix()
currentScene = viewer->getScene();
//aspectR = viewer->getCamera()->getViewport()->aspectRatio();
left = m_bb.first[0];
top = m_bb.first[1];
width = m_bb.second[0] - m_bb.first[0];
height = m_bb.second[1] - m_bb.first[1];
left = m_bb.xMin();
top = m_bb.yMin();
width = m_bb.xMax() - m_bb.xMin();
height = m_bb.yMax() - m_bb.yMin();
aspectR = static_cast< double >( m_axialWidgetWidth ) / static_cast< double >( m_axialWidgetHeight );
{
......@@ -1164,9 +1158,9 @@ void WMNavSlices::updateViewportMatrix()
osg::Matrix tm;
tm.makeTranslate( osg::Vec3(
-0.5 * ( m_bb.first[ 0 ] + m_bb.second[ 0 ] ),
-0.5 * ( m_bb.first[ 1 ] + m_bb.second[ 1 ] ),
-m_bb.second[ 2 ] + m_bb.first[ 2 ] - 0.5 ) );
-0.5 * ( m_bb.xMin() + m_bb.xMax() ),
-0.5 * ( m_bb.yMin() + m_bb.yMax() ),
-m_bb.zMax() + m_bb.zMin() - 0.5 ) );
sm.makeScale( scale, scale, scale );
tm *= sm;
......@@ -1180,8 +1174,8 @@ void WMNavSlices::updateViewportMatrix()
osg::Matrix tm;
tm.makeTranslate( osg::Vec3(
-0.5 * ( m_bb.second[ 0 ] + m_bb.first[ 0 ] ),
-0.5 * ( m_bb.second[ 1 ] + m_bb.first[ 1 ] ) ,
-0.5 * ( m_bb.xMax() + m_bb.xMin() ),
-0.5 * ( m_bb.yMax() + m_bb.yMin() ) ,
0 ) );
rm.makeRotate( 90.0 * 3.141 / 180, 1.0, 0.0, 0.0 );
sm.makeScale( -scale, scale, scale );
......@@ -1199,10 +1193,10 @@ void WMNavSlices::updateViewportMatrix()
currentScene = viewer->getScene();
aspectR = viewer->getCamera()->getViewport()->aspectRatio();
left = m_bb.first[1];
top = m_bb.first[2];
width = m_bb.second[1] - m_bb.first[1];
height = m_bb.second[2] - m_bb.first[2];
left = m_bb.yMin();
top = m_bb.zMin();
width = m_bb.yMax() - m_bb.yMin();
height = m_bb.zMax() - m_bb.zMin();
aspectR = static_cast< double >( m_sagittalWidgetWidth ) / static_cast< double >( m_sagittalWidgetHeight );
{
......@@ -1229,9 +1223,9 @@ void WMNavSlices::updateViewportMatrix()
osg::Matrix tm;
tm.makeTranslate( osg::Vec3(
m_bb.second[ 0 ] - m_bb.first[ 0 ] + 0.5,
-0.5 * ( m_bb.first[ 1 ] + m_bb.second[ 1 ] ),
-0.5 * ( m_bb.first[ 2 ] + m_bb.second[ 2 ] ) ) );
m_bb.xMax() - m_bb.xMin() + 0.5,
-0.5 * ( m_bb.yMin() + m_bb.yMax() ),
-0.5 * ( m_bb.zMin() + m_bb.zMax() ) ) );
rm.makeRotate( 90.0 * 3.141 / 180, 0.0, 1.0, 0.0 );
rm2.makeRotate( 90.0 * 3.141 / 180, 0.0, 0.0, 1.0 );
sm.makeScale( scale, scale, scale );
......@@ -1250,8 +1244,8 @@ void WMNavSlices::updateViewportMatrix()
tm.makeTranslate( osg::Vec3(
0.0,
-0.5 * ( m_bb.second[ 1 ] + m_bb.first[ 1 ] ),
-0.5 * ( m_bb.second[ 2 ] + m_bb.first[ 2 ] ) ) );
-0.5 * ( m_bb.yMax() + m_bb.yMin() ),
-0.5 * ( m_bb.zMax() + m_bb.zMin() ) ) );
rm.makeRotate( -90.0 * 3.141 / 180, 0.0, 0.0, 1.0 );
sm.makeScale( scale, scale, scale );
......@@ -1268,10 +1262,10 @@ void WMNavSlices::updateViewportMatrix()
currentScene = viewer->getScene();
aspectR = viewer->getCamera()->getViewport()->aspectRatio();
left = m_bb.first[0];
top = m_bb.first[2];
width = m_bb.second[0] - m_bb.first[0];
height = m_bb.second[2] - m_bb.first[2];
left = m_bb.xMin();
top = m_bb.zMin();
width = m_bb.xMax() - m_bb.xMin();
height = m_bb.zMax() - m_bb.zMin();
aspectR = static_cast< double >( m_coronalWidgetWidth ) / static_cast< double >( m_coronalWidgetHeight );
{
......@@ -1297,9 +1291,9 @@ void WMNavSlices::updateViewportMatrix()
osg::Matrix tm;
tm.makeTranslate( osg::Vec3(
-0.5 * ( m_bb.first[ 0 ] + m_bb.second[ 0 ] ),
m_bb.second[ 1 ] - m_bb.first[ 1 ] + 0.5,
-0.5 * ( m_bb.first[ 2 ] + m_bb.second[ 2 ] ) ) );
-0.5 * ( m_bb.xMin() + m_bb.xMax() ),
m_bb.yMax() - m_bb.yMin() + 0.5,
-0.5 * ( m_bb.zMin() + m_bb.zMax() ) ) );
rm.makeRotate( -90.0 * 3.141 / 180, 1.0, 0.0, 0.0 );
sm.makeScale( scale, scale, scale );
......@@ -1316,11 +1310,11 @@ void WMNavSlices::updateViewportMatrix()
tm.makeTranslate( osg::Vec3(
-0.5 * ( m_bb.second[ 0 ] + m_bb.first[ 0 ] ),
-0.5 * ( m_bb.xMax() + m_bb.xMin() ),
0,
-0.5 * ( m_bb.second[ 2 ] + m_bb.first[ 2 ] ) ) );
-0.5 * ( m_bb.zMax() + m_bb.zMin() ) ) );
sm.makeScale( -scale, scale, scale );
tm2.makeTranslate( osg::Vec3( 0.0, -2 * ( m_bb.second[ 1 ] - m_bb.first[ 1 ] ), 0.0 ) ); //move away from viewer
tm2.makeTranslate( osg::Vec3( 0.0, -2 * ( m_bb.yMax() - m_bb.yMin() ), 0.0 ) ); //move away from viewer
tm *= sm;
tm *= tm2;
......