Commit 44bba81c authored by schurade's avatar schurade
Browse files

[FIX] some work on coordinate system and coordinate transformation, coordinate...

[FIX] some work on coordinate system and coordinate transformation, coordinate system module using dataSetAdded variable for update instead of textureChanged
parent 07a8ecba
......@@ -28,18 +28,23 @@ using wmath::WVector3D;
using wmath::WPosition;
using wmath::WMatrix;
WGridRegular3D::WGridRegular3D( double originX, double originY, double originZ,
unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
WGridRegular3D::WGridRegular3D( unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
double originX, double originY, double originZ,
const WVector3D& directionX,
const WVector3D& directionY,
const WVector3D& directionZ )
const WVector3D& directionZ,
double offsetX, double offsetY, double offsetZ )
: WGrid( nbPosX * nbPosY * nbPosZ ),
m_origin( WPosition( originX, originY, originZ ) ),
m_nbPosX( nbPosX ), m_nbPosY( nbPosY ), m_nbPosZ( nbPosZ ),
m_directionX( directionX ),
m_directionY( directionY ),
m_directionZ( directionZ ),
m_matrix( 4, 4 )
m_offsetX( offsetX ),
m_offsetY( offsetY ),
m_offsetZ( offsetZ ),
m_matrix( 4, 4 ),
m_matrixInverse( 3, 3 )
{
m_matrix( 0, 0 ) = directionX[0];
m_matrix( 0, 1 ) = directionY[0];
......@@ -55,14 +60,22 @@ WGridRegular3D::WGridRegular3D( double originX, double originY, double originZ,
m_matrix( 2, 3 ) = originZ;
m_matrix( 3, 3 ) = 1.;
m_matrixInverse = invertMatrix3x3( m_matrix );
}
WGridRegular3D::WGridRegular3D( unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
const WMatrix< double >& mat )
const WMatrix< double >& mat,
double offsetX, double offsetY, double offsetZ )
: WGrid( nbPosX * nbPosY * nbPosZ ),
m_nbPosX( nbPosX ),
m_nbPosY( nbPosY ), m_nbPosZ( nbPosZ ),
m_matrix( wmath::WMatrix<double>( mat ) )
m_nbPosY( nbPosY ),
m_nbPosZ( nbPosZ ),
m_offsetX( offsetX ),
m_offsetY( offsetY ),
m_offsetZ( offsetZ ),
m_matrix( wmath::WMatrix<double>( mat ) ),
m_matrixInverse( 3, 3 )
{
assert( mat.getNbRows() == 4 && mat.getNbCols() == 4 );
// only affine transformations are allowed
......@@ -75,11 +88,13 @@ WGridRegular3D::WGridRegular3D( unsigned int nbPosX, unsigned int nbPosY, unsign
m_directionZ = WVector3D( mat( 0, 2 ) / mat( 3, 3 ), mat( 1, 2 ) / mat( 3, 3 ), mat( 2, 2 ) / mat( 3, 3 ) );
m_matrix = mat;
m_matrixInverse = invertMatrix3x3( m_matrix );
}
WGridRegular3D::WGridRegular3D( double originX, double originY, double originZ,
unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
WGridRegular3D::WGridRegular3D( unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
double originX, double originY, double originZ,
double offsetX, double offsetY, double offsetZ )
: WGrid( nbPosX * nbPosY * nbPosZ ),
m_origin( WPosition( originX, originY, originZ ) ),
......@@ -89,7 +104,11 @@ WGridRegular3D::WGridRegular3D( double originX, double originY, double originZ,
m_directionX( WVector3D( offsetX, 0., 0. ) ),
m_directionY( WVector3D( 0., offsetY, 0. ) ),
m_directionZ( WVector3D( 0., 0., offsetZ ) ),
m_matrix( 4, 4 )
m_offsetX( offsetX ),
m_offsetY( offsetY ),
m_offsetZ( offsetZ ),
m_matrix( 4, 4 ),
m_matrixInverse( 3, 3 )
{
m_matrix( 0, 0 ) = offsetX;
m_matrix( 1, 1 ) = offsetY;
......@@ -111,7 +130,11 @@ WGridRegular3D::WGridRegular3D( unsigned int nbPosX, unsigned int nbPosY, unsign
m_directionX( WVector3D( offsetX, 0., 0. ) ),
m_directionY( WVector3D( 0., offsetY, 0. ) ),
m_directionZ( WVector3D( 0., 0., offsetZ ) ),
m_matrix( 4, 4 )
m_offsetX( offsetX ),
m_offsetY( offsetY ),
m_offsetZ( offsetZ ),
m_matrix( 4, 4 ),
m_matrixInverse( 3, 3 )
{
m_matrix( 0, 0 ) = offsetX;
m_matrix( 1, 1 ) = offsetY;
......@@ -133,3 +156,49 @@ wmath::WMatrix<double> WGridRegular3D::getTransformationMatrix() const
{
return m_matrix;
}
wmath::WVector3D WGridRegular3D::multMatrixWithVector3D( wmath::WMatrix<double> mat, wmath::WVector3D vec )
{
wmath::WVector3D result;
result[0] = mat( 0, 0 ) * vec[0] + mat( 0, 1 ) * vec[1] + mat( 0, 2 ) * vec[2];
result[1] = mat( 1, 0 ) * vec[0] + mat( 1, 1 ) * vec[1] + mat( 1, 2 ) * vec[2];
result[2] = mat( 2, 0 ) * vec[0] + mat( 2, 1 ) * vec[1] + mat( 2, 2 ) * vec[2];
return result;
}
wmath::WMatrix<double> WGridRegular3D::invertMatrix3x3( wmath::WMatrix<double> mat )
{
double det = mat( 0, 0 ) * mat( 1, 1 ) * mat( 2, 2 ) +
mat( 0, 1 ) * mat( 1, 2 ) * mat( 2, 0 ) +
mat( 0, 2 ) * mat( 1, 0 ) * mat( 2, 1 ) -
mat( 0, 2 ) * mat( 1, 1 ) * mat( 2, 0 ) -
mat( 0, 1 ) * mat( 1, 0 ) * mat( 2, 2 ) -
mat( 0, 0 ) * mat( 1, 2 ) * mat( 2, 1 );
wmath::WMatrix<double> r( 3, 3 );
r( 0, 0 ) = ( mat( 1, 1 ) * mat( 2, 2 ) - mat( 1, 2 ) * mat( 2, 1 ) ) / det;
r( 1, 0 ) = ( mat( 1, 2 ) * mat( 2, 0 ) - mat( 1, 0 ) * mat( 2, 2 ) ) / det;
r( 2, 0 ) = ( mat( 1, 0 ) * mat( 2, 1 ) - mat( 1, 1 ) * mat( 2, 0 ) ) / det;
r( 0, 1 ) = ( mat( 0, 2 ) * mat( 2, 1 ) - mat( 0, 1 ) * mat( 2, 2 ) ) / det;
r( 1, 1 ) = ( mat( 0, 0 ) * mat( 2, 2 ) - mat( 0, 2 ) * mat( 2, 0 ) ) / det;
r( 2, 1 ) = ( mat( 0, 1 ) * mat( 2, 0 ) - mat( 0, 0 ) * mat( 2, 1 ) ) / det;
r( 0, 2 ) = ( mat( 0, 1 ) * mat( 1, 2 ) - mat( 0, 2 ) * mat( 1, 1 ) ) / det;
r( 1, 2 ) = ( mat( 0, 2 ) * mat( 1, 0 ) - mat( 0, 0 ) * mat( 1, 2 ) ) / det;
r( 2, 2 ) = ( mat( 0, 0 ) * mat( 1, 1 ) - mat( 0, 1 ) * mat( 1, 0 ) ) / det;
return r;
}
osg::Vec3 WGridRegular3D::transformTexCoord( osg::Vec3 point )
{
wmath::WVector3D p( point.x() - 0.5 , point.y() - 0.5, point.z() - 0.5 );
wmath::WVector3D r( multMatrixWithVector3D( m_matrixInverse , p ) );
r[0] = r[0] * m_offsetX + 0.5;
r[1] = r[1] * m_offsetY + 0.5;
r[2] = r[2] * m_offsetZ + 0.5;
return osg::Vec3( r[0], r[1], r[2] );
}
......@@ -29,6 +29,8 @@
#include "../math/WVector3D.h"
#include "../math/WMatrix.hpp"
#include <osg/Vec3>
#include "WGrid.h"
/**
......@@ -50,11 +52,12 @@ public:
* samples in the different coordinate directions as vector.
*/
WGridRegular3D(
double originX, double originY, double originZ,
unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
double originX, double originY, double originZ,
const wmath::WVector3D& directionX,
const wmath::WVector3D& directionY,
const wmath::WVector3D& directionZ );
const wmath::WVector3D& directionZ,
double offsetX, double offsetY, double offsetZ );
/**
* Defines the number of samples in each coordinate direction as ints,
......@@ -65,7 +68,8 @@ public:
*/
WGridRegular3D(
unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
const wmath::WMatrix< double >& mat );
const wmath::WMatrix< double >& mat,
double offsetX, double offsetY, double offsetZ );
/**
* Defines the position of the origin of the grid, the number of
......@@ -73,8 +77,8 @@ public:
* samples in the different coordinate directions as scalar.
*/
WGridRegular3D(
double originX, double originY, double originZ,
unsigned int nbPosX, unsigned int nbPosY, unsigned int nbPosZ,
double originX, double originY, double originZ,
double offsetX, double offsetY, double offsetZ );
/**
......@@ -177,6 +181,21 @@ public:
*/
wmath::WMatrix<double> getTransformationMatrix() const;
/**
*
*/
wmath::WVector3D multMatrixWithVector3D( wmath::WMatrix<double> mat, wmath::WVector3D vec );
/**
*
*/
wmath::WMatrix<double> invertMatrix3x3( wmath::WMatrix<double> mat );
/**
*
*/
osg::Vec3 transformTexCoord( osg::Vec3 point );
protected:
private:
wmath::WPosition m_origin;
......@@ -189,12 +208,18 @@ private:
wmath::WVector3D m_directionY;
wmath::WVector3D m_directionZ;
double m_offsetX;
double m_offsetY;
double m_offsetZ;
/**
* Matrix storing the transformation of the grid. This is redundant.
* Please use m_origin and m_direction? for all normal computations.
* Use matrix only where you really need a matrix for multiplication.
*/
wmath::WMatrix<double> m_matrix;
wmath::WMatrix<double> m_matrixInverse;
};
#endif // WGRIDREGULAR3D_H
......@@ -89,7 +89,7 @@ boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
unsigned int order = ( ( vDim == 1 ) ? 0 : 1 ); // TODO(all): Does recognize vectors and scalars only so far.
unsigned int countVoxels = columns * rows * frames;
// nifti_image_infodump( header );
nifti_image_infodump( header );
switch( header->datatype )
{
......@@ -123,13 +123,13 @@ boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
{
// method 3 (affine transform)
newGrid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D(
columns, rows, frames, convertMatrix( header->sto_xyz ) ) );
columns, rows, frames, convertMatrix( header->sto_xyz ), header->dx, header->dy, header->dz ) );
}
else if( header->qform_code > 0 )
{
// method 2 (rigid body transform)
newGrid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D(
columns, rows, frames, convertMatrix( header->qto_xyz ) ) );
columns, rows, frames, convertMatrix( header->qto_xyz ), header->dx, header->dy, header->dz ) );
}
else
{
......
......@@ -79,10 +79,10 @@ public:
void testInstantiation( void )
{
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 3, 3, 3, 1., 1., 1. ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 0., 0., 0., 3, 3, 3, 1., 1., 1. ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 0., 0., 0., 3, 3, 3,
WVector3D( 3., 1., 2. ), WVector3D( 1., 3., 2. ), WVector3D( 1., 2., 3. ) ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 3, 3, 3, WMatrix< double >( 4, 4 ) ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 3, 3, 3, 0., 0., 0., 1., 1., 1. ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 3, 3, 3, 0., 0., 0.,
WVector3D( 3., 1., 2. ), WVector3D( 1., 3., 2. ), WVector3D( 1., 2., 3. ), 1., 1., 1. ) );
TS_ASSERT_THROWS_NOTHING( WGridRegular3D grid( 3, 3, 3, WMatrix< double >( 4, 4 ), 1., 1., 1. ) );
}
/**
......@@ -93,14 +93,14 @@ public:
WGridRegular3D grid( 3, 3, 3, 1., 1., 1. );
TS_ASSERT_EQUALS( grid.size(), 27 );
WGridRegular3D grid2( 0., 0., 0., 3, 3, 3, 1., 1., 1. );
WGridRegular3D grid2( 3, 3, 3, 0., 0., 0., 1., 1., 1. );
TS_ASSERT_EQUALS( grid2.size(), 27 );
WGridRegular3D grid3( 0., 0., 0., 3, 3, 3,
WVector3D( 3., 1., 2. ), WVector3D( 1., 3., 2. ), WVector3D( 1., 2., 3. ) );
WGridRegular3D grid3( 3, 3, 3, 0., 0., 0.,
WVector3D( 3., 1., 2. ), WVector3D( 1., 3., 2. ), WVector3D( 1., 2., 3. ), 1., 1., 1. );
TS_ASSERT_EQUALS( grid3.size(), 27 );
WGridRegular3D grid4( 3, 3, 3, WMatrix< double >( 4, 4 ) );
WGridRegular3D grid4( 3, 3, 3, WMatrix< double >( 4, 4 ), 1., 1., 1. );
TS_ASSERT_EQUALS( grid4.size(), 27 );
}
......@@ -132,7 +132,7 @@ public:
TS_ASSERT_EQUALS( grid.m_matrix( 3, 2 ), 0. );
TS_ASSERT_EQUALS( grid.m_matrix( 3, 3 ), 1. );
WGridRegular3D grid2( 1.1, 2.2, 3.3, 3, 3, 3, 1.11, 2.22, 3.33 );
WGridRegular3D grid2( 3, 3, 3, 1.1, 2.2, 3.3, 1.11, 2.22, 3.33 );
TS_ASSERT_EQUALS( grid2.size(), 27 );
TS_ASSERT_EQUALS( grid2.m_origin, WPosition( 1.1, 2.2, 3.3 ) );
TS_ASSERT_EQUALS( grid2.m_directionX, WVector3D( 1.11, 0., 0. ) );
......@@ -155,8 +155,8 @@ public:
TS_ASSERT_EQUALS( grid2.m_matrix( 3, 2 ), 0. );
TS_ASSERT_EQUALS( grid2.m_matrix( 3, 3 ), 1. );
WGridRegular3D grid3( 2.22, 3.33, 4.44, 3, 3, 3,
WVector3D( 3.1, 1.1, 2.1 ), WVector3D( 1.2, 3.2, 2.2 ), WVector3D( 1.3, 2.3, 3.3 ) );
WGridRegular3D grid3( 3, 3, 3, 2.22, 3.33, 4.44,
WVector3D( 3.1, 1.1, 2.1 ), WVector3D( 1.2, 3.2, 2.2 ), WVector3D( 1.3, 2.3, 3.3 ), 1., 1., 1. );
TS_ASSERT_EQUALS( grid3.size(), 27 );
TS_ASSERT_EQUALS( grid3.m_origin, WPosition( 2.22, 3.33, 4.44 ) );
TS_ASSERT_EQUALS( grid3.m_directionX, WVector3D( 3.1, 1.1, 2.1 ) );
......@@ -194,7 +194,7 @@ public:
mat( 3, 3 ) = 1;
double delta = 1e-8;
WGridRegular3D grid4( 3, 3, 3, mat );
WGridRegular3D grid4( 3, 3, 3, mat, 1., 1., 1. );
TS_ASSERT_EQUALS( grid4.size(), 27 );
TS_ASSERT_DELTA( grid4.m_origin[0], 1.4, delta );
TS_ASSERT_DELTA( grid4.m_origin[1], 2.4, delta );
......@@ -234,7 +234,7 @@ public:
double x = 1.2;
double y = 3.4;
double z = 5.6;
WGridRegular3D grid( 10, 10, 10, x, y, z );
WGridRegular3D grid( 10, 10, 10, 1., 1., 1., x, y, z );
TS_ASSERT_EQUALS( grid.getOffsetX(), x );
TS_ASSERT_EQUALS( grid.getOffsetY(), y );
TS_ASSERT_EQUALS( grid.getOffsetZ(), z );
......@@ -249,7 +249,7 @@ public:
WVector3D x( 3., 1., 2. );
WVector3D y( 2., 6., 4. );
WVector3D z( 3., 6., 9. );
WGridRegular3D grid( 0., 0., 0., 10, 10, 10, x, y, z );
WGridRegular3D grid( 10, 10, 10, 0., 0., 0., x, y, z, 1., 1., 1. );
TS_ASSERT_DELTA( grid.getOffsetX(), x.norm(), m_delta );
TS_ASSERT_DELTA( grid.getOffsetY(), y.norm(), m_delta );
TS_ASSERT_DELTA( grid.getOffsetZ(), z.norm(), m_delta );
......@@ -264,7 +264,7 @@ public:
WVector3D x( 3., 1., 2. );
WVector3D y( 2., 6., 4. );
WVector3D z( 3., 6., 9. );
WGridRegular3D grid( 0., 0., 0., 10, 10, 10, x, y, z );
WGridRegular3D grid( 10, 10, 10, 0., 0., 0., x, y, z, 1., 1., 1. );
TS_ASSERT_EQUALS( grid.getDirectionX(), x );
TS_ASSERT_EQUALS( grid.getDirectionY(), y );
TS_ASSERT_EQUALS( grid.getDirectionZ(), z );
......@@ -281,7 +281,7 @@ public:
TS_ASSERT_EQUALS( grid.getOrigin(), zeroOrigin );
WVector3D origin( 1.2, 3.4, 5.6 );
WGridRegular3D grid2( origin[0], origin[1], origin[2], 10, 10, 10, 1., 1., 1. );
WGridRegular3D grid2( 10, 10, 10, origin[0], origin[1], origin[2], 1., 1., 1. );
TS_ASSERT_EQUALS( grid2.getOrigin(), origin );
}
......@@ -307,7 +307,7 @@ public:
double z = orZ + iZ * ofZ;
WPosition expected( x, y, z );
WGridRegular3D grid( orX, orY, orZ, nX, nY, nZ, ofX, ofY, ofZ );
WGridRegular3D grid( nX, nY, nZ, orX, orY, orZ, ofX, ofY, ofZ );
TS_ASSERT_DELTA( grid.getPosition( iX, iY, iZ )[0], expected[0], m_delta );
TS_ASSERT_DELTA( grid.getPosition( iX, iY, iZ )[1], expected[1], m_delta );
......@@ -335,7 +335,7 @@ public:
WVector3D ofZ( 1., 2., 3. );
WPosition expected = WPosition( orX, orY, orZ ) + iX * ofX + iY * ofY + iZ * ofZ;
WGridRegular3D grid( orX, orY, orZ, nX, nY, nZ, ofX, ofY, ofZ );
WGridRegular3D grid( nX, nY, nZ, orX, orY, orZ, ofX, ofY, ofZ, 1., 1., 1. );
TS_ASSERT_DELTA( grid.getPosition( iX, iY, iZ )[0], expected[0], m_delta );
TS_ASSERT_DELTA( grid.getPosition( iX, iY, iZ )[1], expected[1], m_delta );
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include "WCoordConverter.h"
WCoordConverter::WCoordConverter( WMatrix<double> rotMat, WVector3D origin, WVector3D scale ) :
m_rotMat( rotMat ),
m_origin( origin ),
m_scale( scale )
{
}
WCoordConverter::~WCoordConverter()
{
}
WVector3D WCoordConverter::operator()( WVector3D in )
{
WVector3D out( in );
return out;
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCOORDCONVERTER_H
#define WCOORDCONVERTER_H
#include "../../math/WVector3D.h"
#include "../../math/WMatrix.hpp"
using wmath::WMatrix;
using wmath::WVector3D;
/**
* Class to provide conversion for a given coordinate in 3D space
*/
class WCoordConverter
{
public:
/**
* standard constructor
*/
WCoordConverter( WMatrix<double> rotMat, WVector3D origin = WVector3D( 0, 0 , 0 ), WVector3D scale = WVector3D( 1.0, 1.0 , 1.0 ) );
/**
* destructor
*/
virtual ~WCoordConverter();
/**
*
*/
WVector3D operator()( WVector3D in );
protected:
private:
wmath::WMatrix<double> m_rotMat;
wmath::WVector3D m_origin;
wmath::WVector3D m_scale;
};
#endif // WCOORDCONVERTER_H
......@@ -76,7 +76,7 @@ void WMCoordinateSystem::connectToGui()
void WMCoordinateSystem::properties()
{
m_properties->addBool( "textureChanged", false );
m_properties->addBool( "dataSetAdded", false );
m_properties->addInt( "axialPos", 80 );
m_properties->addInt( "coronalPos", 100 );
......@@ -134,19 +134,21 @@ void WMCoordinateSystem::createGeometry()
// osg::StateSet* rootState = m_rootNode->getOrCreateStateSet();
m_rootNode->setUpdateCallback( new coordinateNodeCallback( boost::shared_dynamic_cast<WMCoordinateSystem>( shared_from_this() ) ) );
m_rootNode->setUserData( this );
m_rootNode->setUpdateCallback( new coordinateNodeCallback );
}
void WMCoordinateSystem::updateGeometry()
{
boost::shared_lock< boost::shared_mutex > slock;
slock = boost::shared_lock< boost::shared_mutex >( m_updateLock );
// *******************************************************************************************************
if ( !m_properties->getValue< bool > ( "textureChanged" ) || !WKernel::getRunningKernel()->getGui()->isInitialized()() )
if ( !m_properties->getValue< bool > ( "dataSetAdded" ) || !WKernel::getRunningKernel()->getGui()->isInitialized()() )
{
return;
}
m_properties->setValue( "textureChanged", false );
boost::shared_lock< boost::shared_mutex > slock;
slock = boost::shared_lock< boost::shared_mutex >( m_updateLock );
// *******************************************************************************************************
m_properties->setValue( "dataSetAdded", false );
findBoundingBox();
......
......@@ -139,30 +139,20 @@ private:
* lock to prevent concurrent threads trying to update the osg node
*/
boost::shared_mutex m_updateLock;
};
class coordinateNodeCallback : public osg::NodeCallback
{
public:
explicit coordinateNodeCallback( boost::shared_ptr< WMCoordinateSystem > module )
{
m_module = module;
}
virtual void operator()( osg::Node* node, osg::NodeVisitor* nv )
class coordinateNodeCallback : public osg::NodeCallback
{
if ( m_module )
public:
virtual void operator()( osg::Node* node, osg::NodeVisitor* nv )
{
m_module->updateGeometry();
osg::ref_ptr< WMCoordinateSystem > module = static_cast< WMCoordinateSystem* > ( node->getUserData() );
if ( module )
{
module->updateGeometry();
}
traverse( node, nv );
}
traverse( node, nv );
}
private:
boost::shared_ptr< WMCoordinateSystem > m_module;
};
};
#endif // WMCOORDINATESYSTEM_H
......@@ -48,7 +48,7 @@ void WRulerOrtho::addLabel( osg::Vec3 position, std::string text )
osg::ref_ptr<osgText::Text> label = osg::ref_ptr<osgText::Text>( new osgText::Text() );
osg::ref_ptr<osg::Geode> labelGeode = osg::ref_ptr<osg::Geode>( new osg::Geode() );
labelGeode->addDrawable( label );
label->setCharacterSize( 5 );
label->setCharacterSize( 8 );
//testLabel->setFont( "/fonts/arial.ttf" );
label->setText( text );
label->setAxisAlignment( osgText::Text::SCREEN );
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.