Commit 4be8ffe2 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents 5481e05b 94e19258
//---------------------------------------------------------------------------
//
// 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 "WTypeTraits.h"
//---------------------------------------------------------------------------
//
// 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 WTYPETRAITS_H
#define WTYPETRAITS_H
#include <stdint.h>
/**
* All kinds of type traits and policies like type priorities and type combinations.
*/
namespace WTypeTraits
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Type promitions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Class for checking the "better" type if two integral types are known.
*
* \tparam T1 the first type
* \tparam T2 the second type
*/
template < typename T1, typename T2 >
class TypePromotion; // leaving this one empty is a good idea in most cases as there is no "natural order" in all c++ types.
/**
* Class for checking the "better" type if two integral types are known. Specialization if both types are equal
*
* \tparam T the types
*/
template < typename T >
class TypePromotion< T, T >
{
public:
typedef T Result; //!< if both types are the same, the "better" type is obvious.
};
// we assume macros to be evil but it helps us here!
#define CREATEPROMOTION( T1, T2, ResultType ) \
template <> \
class TypePromotion< T1, T2 > \
{ /*NOLINT*/ \
public: \
typedef ResultType Result; \
}; /*NOLINT*/ \
\
template <> \
class TypePromotion< T2, T1 > \
{ /*NOLINT*/ \
public: \
typedef ResultType Result; \
}; /*NOLINT*/ \
// Create the promotions we need. Please check this list. But do not change arbitrarily if you need a different mapping. Instead, specialize
// the template TypePromotion locally.
// Exclusion of this macro stuff from doxygen:
// \cond HIDDEN_SYMBOLS
// double is the better choice for these
CREATEPROMOTION( double, float, double )
CREATEPROMOTION( double, int64_t, double )
CREATEPROMOTION( double, int32_t, double )
CREATEPROMOTION( double, int16_t, double )
CREATEPROMOTION( double, int8_t, double )
CREATEPROMOTION( double, uint64_t, double )
CREATEPROMOTION( double, uint32_t, double )
CREATEPROMOTION( double, uint16_t, double )
CREATEPROMOTION( double, uint8_t, double )
// float is the better choice for these (?)
CREATEPROMOTION( float, int64_t, float )
CREATEPROMOTION( float, int32_t, float )
CREATEPROMOTION( float, int16_t, float )
CREATEPROMOTION( float, int8_t, float )
CREATEPROMOTION( float, uint64_t, float )
CREATEPROMOTION( float, uint32_t, float )
CREATEPROMOTION( float, uint16_t, float )
CREATEPROMOTION( float, uint8_t, float )
// int64_t is the better choice for these (?)
CREATEPROMOTION( int64_t, int32_t, int64_t )
CREATEPROMOTION( int64_t, int16_t, int64_t )
CREATEPROMOTION( int64_t, int8_t, int64_t )
CREATEPROMOTION( int64_t, uint64_t, double ) // ?
CREATEPROMOTION( int64_t, uint32_t, int64_t )
CREATEPROMOTION( int64_t, uint16_t, int64_t )
CREATEPROMOTION( int64_t, uint8_t, int64_t )
// int32_t is the better choice for these (?)
CREATEPROMOTION( int32_t, int16_t, int32_t )
CREATEPROMOTION( int32_t, int8_t, int32_t )
CREATEPROMOTION( int32_t, uint64_t, double ) // ?
CREATEPROMOTION( int32_t, uint32_t, int64_t ) // ?
CREATEPROMOTION( int32_t, uint16_t, int32_t )
CREATEPROMOTION( int32_t, uint8_t, int32_t )
// int16_t is the better choice for these (?)
CREATEPROMOTION( int16_t, int8_t, int16_t )
CREATEPROMOTION( int16_t, uint64_t, double ) // ?
CREATEPROMOTION( int16_t, uint32_t, int64_t ) // ?
CREATEPROMOTION( int16_t, uint16_t, int32_t ) // ?
CREATEPROMOTION( int16_t, uint8_t, int16_t )
// int8_t is the better choice for these (?)
CREATEPROMOTION( int8_t, uint64_t, double ) // ?
CREATEPROMOTION( int8_t, uint32_t, int64_t ) // ?
CREATEPROMOTION( int8_t, uint16_t, int32_t ) // ?
CREATEPROMOTION( int8_t, uint8_t, int16_t ) // ?
// uint64_t is the better choice for these (?)
CREATEPROMOTION( uint64_t, uint32_t, uint64_t )
CREATEPROMOTION( uint64_t, uint16_t, uint64_t )
CREATEPROMOTION( uint64_t, uint8_t, uint64_t )
// uint32_t is the better choice for these (?)
CREATEPROMOTION( uint32_t, uint16_t, uint32_t )
CREATEPROMOTION( uint32_t, uint8_t, uint32_t )
// uint16_t is the better choice for these (?)
CREATEPROMOTION( uint16_t, uint8_t, uint16_t )
// uint8_t is the better choice for these (?)
// promoted already
// Exclusion of this macro stuff from doxygen: end
// \endcond
}
#endif // WTYPETRAITS_H
//---------------------------------------------------------------------------
//
// 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 <string>
#include "WTypeMismatch.h"
WTypeMismatch::WTypeMismatch( const std::string& msg )
: WException( msg )
{
// init members
}
WTypeMismatch::~WTypeMismatch() throw()
{
// clean up
}
//---------------------------------------------------------------------------
//
// 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 WTYPEMISMATCH_H
#define WTYPEMISMATCH_H
#include <string>
#include "../WException.h"
#include "../WExportCommon.h"
/**
* Indicates invalid type of something. This is a general purpose exception wherever a dynamic cast fails for example.
*/
class OWCOMMON_EXPORT WTypeMismatch : public WException
{
public:
/**
* Default constructor.
* \param msg the exception message.
*/
explicit WTypeMismatch( const std::string& msg = "Types mismatching." );
/**
* Destructor.
*/
virtual ~WTypeMismatch() throw();
protected:
private:
};
#endif // WTYPEMISMATCH_H
......@@ -88,6 +88,8 @@ public:
/**
* Compute the cross product of the current WVector3D with the parameter.
* \param factor2 This vector will be multiplied with the current vector. (right hand side of the product)
*
* \return the crossproduct
*/
const WVector3D crossProduct( const WVector3D& factor2 ) const;
......
......@@ -28,7 +28,7 @@
#include <stdint.h>
/**
* Dataset types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense
* to keep the bit coding, but it doesn't hurt either
* \ingroup dataHandler
*/
......@@ -173,6 +173,17 @@ enum qformOrientation
Inferior_to_Superior
};
/**
* Data set types. Not complete! Only those used for distinctions so far.
* \ingroup dataHandler
*/
enum DataSetType
{
W_DATASET_NONE = 0,
W_DATASET_SINGLE = 1,
W_DATASET_SPHERICALHARMONICS = 2
};
/**
* \defgroup dataHandler Data Handler
*
......
......@@ -41,7 +41,7 @@ WDataSetSphericalHarmonics::WDataSetSphericalHarmonics( boost::shared_ptr< WValu
m_valueSet = boost::shared_dynamic_cast< WValueSet<double> >( newValueSet );
WAssert( newValueSet, "No value set given." );
WAssert( newGrid, "No grid given." );
WAssert( m_valueSet, "No WValueSet<double given." );
WAssert( m_valueSet, "No WValueSet<double> given." );
}
WDataSetSphericalHarmonics::WDataSetSphericalHarmonics()
......
......@@ -47,6 +47,11 @@ template< typename T > class WValueSet : public WValueSetBase
friend class WValueSetTest;
public:
/**
* The type of the single value in this value set.
*/
typedef T ValueT;
/**
* \class SubArray
*
......
//---------------------------------------------------------------------------
//
// 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 <string>
#include "WDHValueSetMismatch.h"
WDHValueSetMismatch::WDHValueSetMismatch( const std::string& msg )
: WDHException( msg )
{
// initialize members
}
WDHValueSetMismatch::~WDHValueSetMismatch() throw()
{
// cleanup
}
//---------------------------------------------------------------------------
//
// 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 WDHVALUESETMISMATCH_H
#define WDHVALUESETMISMATCH_H
#include <string>
#include "WDHException.h"
#include "../WExportDataHandler.h"
/**
* An exception that should be used whenever two valuesets are used which need to be of same size, dim, order or whatever.
*
* \ingroup dataHandler
*/
class OWDATAHANDLER_EXPORT WDHValueSetMismatch : public WDHException
{
public:
/**
* Constructs new exception.
* \param msg the reason for this exception.
*/
explicit WDHValueSetMismatch( const std::string& msg = "ValueSets do not match." );
/**
* Destroys this exception
*/
virtual ~WDHValueSetMismatch() throw();
protected:
private:
};
#endif // WDHVALUESETMISMATCH_H
......@@ -83,7 +83,7 @@ wmath::WMatrix< double > WReaderNIfTI::convertMatrix( const mat44& in )
return out;
}
boost::shared_ptr< WDataSet > WReaderNIfTI::load()
boost::shared_ptr< WDataSet > WReaderNIfTI::load( DataSetType dataSetType )
{
nifti_image* header = nifti_image_read( m_fname.c_str(), 0 );
......@@ -186,7 +186,7 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
// }
// else
if ( !description.compare( "WDataSetSphericalHarmonics" ) )
if ( description.compare( "WDataSetSphericalHarmonics" ) == 0 || dataSetType == W_DATASET_SPHERICALHARMONICS )
{
wlog::debug( "WReaderNIfTI" ) << "Load as spherical harmonics" << std::endl;
newDataSet = boost::shared_ptr< WDataSet >( new WDataSetSphericalHarmonics( newValueSet, newGrid ) );
......
......@@ -58,9 +58,11 @@ public:
/**
* Loads the dataset.
*
* \param dataSetType This parameter can be used to tell the function in advance how it should interprete the data.
*
* \return the dataset loaded.
*/
virtual boost::shared_ptr< WDataSet > load();
virtual boost::shared_ptr< WDataSet > load( DataSetType dataSetType = W_DATASET_NONE );
protected:
private:
......
......@@ -55,7 +55,7 @@ WGEGroupNode::~WGEGroupNode()
void WGEGroupNode::insert( osg::ref_ptr< osg::Node > node )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( INSERT, node ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( INSERT, node ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -63,7 +63,7 @@ void WGEGroupNode::insert( osg::ref_ptr< osg::Node > node )
void WGEGroupNode::remove( osg::ref_ptr< osg::Node > node )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( REMOVE, node ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( REMOVE, node ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -71,7 +71,7 @@ void WGEGroupNode::remove( osg::ref_ptr< osg::Node > node )
void WGEGroupNode::remove_if( boost::shared_ptr< WGEGroupNode::NodePredicate > predicate )
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( REMOVE_IF, predicate ) );
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( REMOVE_IF, predicate ) ) );
m_childOperationQueueDirty = true;
lock.unlock();
}
......@@ -79,7 +79,8 @@ void WGEGroupNode::remove_if( boost::shared_ptr< WGEGroupNode::NodePredicate > p
void WGEGroupNode::clear()
{
boost::unique_lock<boost::shared_mutex> lock = boost::unique_lock<boost::shared_mutex>( m_childOperationQueueLock );
m_childOperationQueue.push( new ChildOperation( CLEAR, osg::ref_ptr< osg::Node >() ) ); // this encodes the remove all feature
m_childOperationQueue.push( boost::shared_ptr< ChildOperation >( new ChildOperation( CLEAR, osg::ref_ptr< osg::Node >() ) ) );
// this encodes the remove all feature
m_childOperationQueueDirty = true;
lock.unlock();
}
......
......@@ -54,11 +54,6 @@ public:
*/
WGEGroupNode();
/**
* Destructor.
*/
virtual ~WGEGroupNode();
/**
* Adds the specified node to the child list of this node in a safe manner. OSG officially requires nodes to be added
* exclusively during update callbacks. Using this method it is ensured to be added during update cycle.
......@@ -96,6 +91,10 @@ public:
void clear();
protected:
/**
* Destructor.
*/
virtual ~WGEGroupNode();
/**
* Update callback which inserts and removes nodes from m_childRemovalQueue and m_childInsertionQueue to the group node.
......@@ -173,7 +172,7 @@ protected:
* Queue of childs that need to be added/removed during the next update cycle. It is a pair per operation, where the bool is denoting removal
* or insertion.
*/
std::queue< ChildOperation* > m_childOperationQueue;
std::queue< boost::shared_ptr< ChildOperation > > m_childOperationQueue;
/**
* Lock used for inserting and removing childs into the child insertion/removal queue.
......
......@@ -47,12 +47,12 @@ public:
*/
explicit WGEManagedGroupNode( boost::shared_ptr< WBoolFlag > active );
protected:
/**
* Destructor.
*/
virtual ~WGEManagedGroupNode();
protected:
private:
};
......
......@@ -162,6 +162,19 @@ std::string extractSuitableName( osgUtil::LineSegmentIntersector::Intersections:
return ""; // This line will not be reached.
}
void WPickHandler::updatePickInfoModifierKeys( WPickInfo* pickInfo )
{
if( m_shift )
{
pickInfo->setModifierKey( WPickInfo::SHIFT );
}
if ( m_ctrl )
{
pickInfo->setModifierKey( WPickInfo::STRG );
}
}
void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea )
{
osgUtil::LineSegmentIntersector::Intersections intersections;
......@@ -171,15 +184,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
WPickInfo pickInfo;
if( m_shift )
{
pickInfo.setModifierKey( WPickInfo::SHIFT );
}
if ( m_ctrl )
{
pickInfo.setModifierKey( WPickInfo::STRG );
}
updatePickInfoModifierKeys( &pickInfo );
// if we are in another viewer than the main view we just need the pixel position
if ( m_viewerName != "" && m_viewerName != "main" )
......
......@@ -128,7 +128,14 @@ protected:
private:
boost::signals2::signal1<void, WPickInfo > m_pickSignal; //!< One can register to this signal to receive pick events.
/**
* Sets the current modifiers to the provided pickInfo
*
* \param pickInfo This pickInfo will be updated.
*/
void updatePickInfoModifierKeys( WPickInfo* pickInfo );
boost::signals2::signal1< void, WPickInfo > m_pickSignal; //!< One can register to this signal to receive pick events.
};
#endif // WPICKHANDLER_H
......@@ -32,6 +32,7 @@
#include "algorithms/WMarchingLegoAlgorithm.h"
#include "callbacks/WGEFunctorCallback.h"
#include "WGraphicsEngine.h"
#include "WROIArbitrary.h"
......@@ -62,8 +63,7 @@ WROIArbitrary::WROIArbitrary( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoord
updateGFX();
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( this );
setUserData( this ); </