Commit 9a5a7a6b authored by Mario Hlawitschka's avatar Mario Hlawitschka
Browse files

[MERGE]

parents d148cfc0 dc15d392
......@@ -240,6 +240,10 @@ IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
ENDIF()
ENDIF()
FIND_PACKAGE( OpenSceneGraph ${MIN_OSG_VERSION} REQUIRED osgDB osgUtil osgGA osgViewer osgSim osgWidget osgText )
IF( OPENSCENEGRAPH_FOUND )
INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} )
ENDIF()
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Eigen3, at least 3.0.0
......@@ -358,7 +362,7 @@ ADD_CUSTOM_TARGET( doc
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# SETUP_STYLECHECKER adds targets for each lib which then add theirself to this target
ADD_CUSTOM_TARGET( stylecheck DEPENDS numCores )
ADD_CUSTOM_TARGET( stylecheck )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
......
......@@ -32,6 +32,22 @@
#include "../common/WStringUtils.h"
#include "WColor.h"
// initialize static palette
namespace defaultColor
{
/** the default palette colors */
const WColor DefaultPalette[ 22 ]= {
// The standard colors
RED, GREEN, BLUE, YELLOW, ORANGE, PINK, CYAN,
// the slightly lighter standard colors
LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTYELLOW,
// the slighly darker standard colors
DARKRED, DARKGREEN, DARKBLUE, DARKYELLOW, VIOLET, TEAL,
// black-white
BLACK, GRAY25, GRAY50, GRAY75, WHITE
};
}
// This function is taken from VTK 5.4.2. Since its BSD licensed the license
// notice follows below. It is not taken from FAnToM since it seems more self
// documenting.
......
......@@ -25,8 +25,6 @@
#ifndef WCOLOR_H
#define WCOLOR_H
#include <iostream>
#include <osg/Vec4>
#include <osg/io_utils> // for the operator<< and operator>> for Vec4
......@@ -105,16 +103,7 @@ namespace defaultColor
* This array is a simple palette definition containing the above colors. This palette is probably not very usable for all your special
* needs. DO NOT add thousand other palettes here. Define them for yourself, in your module.
*/
static const WColor DefaultPalette[22] = {
// The standard colors
RED, GREEN, BLUE, YELLOW, ORANGE, PINK, CYAN,
// the slightly lighter standard colors
LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTYELLOW,
// the slighly darker standard colors
DARKRED, DARKGREEN, DARKBLUE, DARKYELLOW, VIOLET, TEAL,
// black-white
BLACK, GRAY25, GRAY50, GRAY75, WHITE
};
extern const WColor DefaultPalette[22];
}
#endif // WCOLOR_H
......@@ -44,6 +44,16 @@ class OWCOMMON_EXPORT WConditionSet: public WCondition
friend class WConditionSetTest;
public:
/**
* Shared pointer to instance of this class.
*/
typedef boost::shared_ptr< WConditionSet > SPtr;
/**
* Shared pointer to const instance of this class.
*/
typedef boost::shared_ptr< const WConditionSet > ConstSPtr;
/**
* Default constructor.
*/
......
......@@ -60,7 +60,7 @@ public:
* \note condition can also be a WConditionOneShot.
* \param initial the initial value of this flag.
*/
WFlag( WCondition* condition, T initial );
WFlag( WCondition* condition, const T& initial );
/**
* Constructor. Uses a given condition to realize the wait/notify functionality. By using this constructor, the specified
......@@ -70,7 +70,7 @@ public:
* \note condition can also be a WConditionOneShot.
* \param initial the initial value of this flag.
*/
WFlag( boost::shared_ptr< WCondition > condition, T initial );
WFlag( boost::shared_ptr< WCondition > condition, const T& initial );
/**
* Copy constructor. Creates a deep copy of this property. As boost::signals2 and condition variables are non-copyable, new instances get
......@@ -95,21 +95,21 @@ public:
*
* \return the value.
*/
virtual const T get( bool resetChangeState = false );
virtual const T& get( bool resetChangeState = false );
/**
* Operator returns value of the flag.
*
* \return the value.
*/
virtual const T get() const;
virtual const T& get() const;
/**
* Operator returns value of the flag.
*
* \return the value.
*/
virtual const T operator()() const;
virtual const T& operator()() const;
/**
* Operator returns value of the flag. It does not reset the change flag.
......@@ -133,14 +133,14 @@ public:
*
* \note set( get() ) == true
*/
virtual bool set( T value, bool suppressNotification = false );
virtual bool set( const T& value, bool suppressNotification = false );
/**
* Sets the new value for this flag. Also notifies waiting threads.
*
* \param value the new value
*/
virtual void operator()( T value );
virtual void operator()( const T& value );
/**
* Returns the condition that is used by this flag.
......@@ -165,7 +165,7 @@ public:
*
* \return true if it is a valid/acceptable value.
*/
virtual bool accept( T newValue );
virtual bool accept( const T& newValue );
/**
* Tests whether a flag is currently valid. It is equal to accept( get() );
......@@ -216,7 +216,7 @@ private:
typedef WFlag< bool > WBoolFlag;
template < typename T >
WFlag< T >::WFlag( WCondition* condition, T initial ):
WFlag< T >::WFlag( WCondition* condition, const T& initial ):
m_condition( boost::shared_ptr< WCondition >( condition ) ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
......@@ -225,7 +225,7 @@ WFlag< T >::WFlag( WCondition* condition, T initial ):
}
template < typename T >
WFlag< T >::WFlag( boost::shared_ptr< WCondition > condition, T initial ):
WFlag< T >::WFlag( boost::shared_ptr< WCondition > condition, const T& initial ):
m_condition( condition ),
m_valueChangeCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
m_flag( initial ),
......@@ -248,13 +248,13 @@ WFlag< T >::~WFlag()
}
template < typename T >
const T WFlag< T >::operator()() const
const T& WFlag< T >::operator()() const
{
return get();
}
template < typename T >
const T WFlag< T >::get( bool resetChangeState )
const T& WFlag< T >::get( bool resetChangeState )
{
if( resetChangeState )
{
......@@ -264,7 +264,7 @@ const T WFlag< T >::get( bool resetChangeState )
}
template < typename T >
const T WFlag< T >::get() const
const T& WFlag< T >::get() const
{
return m_flag;
}
......@@ -282,13 +282,13 @@ void WFlag< T >::wait() const
}
template < typename T >
void WFlag< T >::operator()( T value )
void WFlag< T >::operator()( const T& value )
{
set( value );
}
template < typename T >
bool WFlag< T >::set( T value, bool suppressNotification )
bool WFlag< T >::set( const T& value, bool suppressNotification )
{
// if the value is the same as the current one -> do not notify but let the caller know "all ok"
if( m_flag == value )
......@@ -328,7 +328,7 @@ boost::shared_ptr< WCondition > WFlag< T >::getValueChangeCondition()
}
template < typename T >
bool WFlag< T >::accept( T /* newValue */ )
bool WFlag< T >::accept( const T& /* newValue */ )
{
// please implement this method in your class to modify the behaviour.
return true;
......
......@@ -22,4 +22,18 @@
//
//---------------------------------------------------------------------------
#include <limits>
#include "WLimits.h"
namespace wlimits
{
const double MAX_DOUBLE = std::numeric_limits< double >::max();
const float MAX_FLOAT = std::numeric_limits< float >::max();
const size_t MAX_SIZE_T = std::numeric_limits< size_t >::max();
const int32_t MAX_INT32_T = std::numeric_limits< int32_t >::max();
const double MIN_DOUBLE = std::numeric_limits< double >::min();
const double DBL_EPS = std::numeric_limits< double >::epsilon();
const float FLT_EPS = std::numeric_limits< float >::epsilon();
}
......@@ -28,34 +28,33 @@
#include <stdint.h> // since <cstdint> is part of c++0x upcoming standard
#include <cstddef>
#include <limits>
#include <boost/math/special_functions/fpclassify.hpp> // isnan, isinf
/**
* Project wide limits for different quantitities.
* Project wide limits for different quantities.
*/
namespace wlimits
{
static const double MAX_DOUBLE = std::numeric_limits< double >::max(); //!< Maximum double value
extern const double MAX_DOUBLE; //!< Maximum double value
static const float MAX_FLOAT = std::numeric_limits< float >::max(); //!< Maximum float value
extern const float MAX_FLOAT; //!< Maximum float value
static const size_t MAX_SIZE_T = std::numeric_limits< size_t >::max(); //!< Maximum size value
extern const size_t MAX_SIZE_T; //!< Maximum size value
static const int32_t MAX_INT32_T = std::numeric_limits< int32_t >::max(); //!< Maximum int32_t value
extern const int32_t MAX_INT32_T; //!< Maximum int32_t value
static const double MIN_DOUBLE = std::numeric_limits< double >::min(); //!< Positive minimum double value
extern const double MIN_DOUBLE; //!< Positive minimum double value
/**
* Smallest double such: 1.0 + DBL_EPS == 1.0 is still true.
*/
static const double DBL_EPS = std::numeric_limits< double >::epsilon();
extern const double DBL_EPS;
/**
* Smallest float such: 1.0 + FLT_EPS == 1.0 is still true.
*/
static const float FLT_EPS = std::numeric_limits< float >::epsilon();
extern const float FLT_EPS;
/**
* Determines if a number is considered as NaN (aka Not a Number) or not.
......
......@@ -640,7 +640,7 @@ namespace PROPERTY_TYPE_HELPER
/**
* Creates a string from the specified value.
*
* \param v the value to convert
* \param tf the value to convert
*
* \return the string representation
*/
......
......@@ -33,13 +33,8 @@
#include <string>
#include <vector>
// Use filesystem version 2 for compatibility with newer boost versions.
#ifndef BOOST_FILESYSTEM_VERSION
#define BOOST_FILESYSTEM_VERSION 2
#endif
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include "constraints/WPropertyConstraintIsDirectory.h"
#include "constraints/WPropertyConstraintMax.h"
......@@ -50,7 +45,6 @@
#include "constraints/WPropertyConstraintTypes.h"
#include "WCondition.h"
#include "WFlag.h"
#include "WLogger.h"
#include "WPropertyBase.h"
#include "WSharedAssociativeContainer.h"
#include "WSharedObjectTicketRead.h"
......@@ -161,7 +155,7 @@ public:
*
* \return true if it is a valid/acceptable value.
*/
virtual bool accept( T newValue );
virtual bool accept( const T& newValue );
/**
* This method is useful to ensure, that there is a valid value in the property. Assume the following situation. The property p got a min
......@@ -174,7 +168,7 @@ public:
*
* \return true if the new value has been accepted ( if it was valid ) - for short true if the property NOW is valid
*/
virtual bool ensureValidity( T newValidValue, bool suppressNotification = false );
virtual bool ensureValidity( const T& newValidValue, bool suppressNotification = false );
/**
* Class building the base for user defined constraints on a property instance.
......@@ -201,7 +195,7 @@ public:
*
* \return true whenever the new value is acceptable for the property.
*/
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, T value ) = 0;
virtual bool accept( boost::shared_ptr< WPropertyVariable< T > > property, const T& value ) = 0;
/**
* Allows simple identification of the real constraint type.
......@@ -273,7 +267,7 @@ public:
*
* \return the new constraint.
*/
static PropertyConstraintMin minConstraint( T min );
static PropertyConstraintMin minConstraint( const T& min );
/**
* Creates a new WPropertyConstraintMax for this WPropertyVariable.
......@@ -282,7 +276,7 @@ public:
*
* \return the new constraint.
*/
static PropertyConstraintMax maxConstraint( T max );
static PropertyConstraintMax maxConstraint( const T& max );
/**
* Set a minimum constraint.
......@@ -291,7 +285,7 @@ public:
*
* \return the newly created constraint.
*/
PropertyConstraintMin setMin( T min );
PropertyConstraintMin setMin( const T& min );
/**
* Set a maximum constraint.
......@@ -300,7 +294,7 @@ public:
*
* \return the newly created constraint.
*/
PropertyConstraintMax setMax( T max );
PropertyConstraintMax setMax( const T& max );
/**
* Gets the current minimum constraint value.
......@@ -404,7 +398,7 @@ public:
* \note set( get() ) == true
* \note this is defined here to help the compiler to disambiguate between WFlag::set and the WPropertyBase::set.
*/
virtual bool set( T value, bool suppressNotification = false );
virtual bool set( const T& value, bool suppressNotification = false );
/**
* Sets the specified value as recommended value. The difference to \ref set is simple. If some value was set using the method \ref set
......@@ -415,7 +409,7 @@ public:
*
* \return true if value has been set successfully.
*/
virtual bool setRecommendedValue( T value );
virtual bool setRecommendedValue( const T& value );
protected:
......@@ -583,7 +577,7 @@ void WPropertyVariable< T >::propertyChangeNotifier()
}
template < typename T >
bool WPropertyVariable< T >::accept( T newValue )
bool WPropertyVariable< T >::accept( const T& newValue )
{
// lock, lock vanishes if l looses focus
typename WPropertyVariable< T >::ConstraintContainerType::ReadTicket l = m_constraints->getReadTicket();
......@@ -640,14 +634,14 @@ bool WPropertyVariable< T >::set( boost::shared_ptr< WPropertyBase > value )
}
template < typename T >
bool WPropertyVariable< T >::set( T value, bool suppressNotification )
bool WPropertyVariable< T >::set( const T& value, bool suppressNotification )
{
m_notYetSet = false;
return WFlag< T >::set( value, suppressNotification );
}
template < typename T >
bool WPropertyVariable< T >::setRecommendedValue( T value )
bool WPropertyVariable< T >::setRecommendedValue( const T& value )
{
// NOTE: well this is quite problematic when used multi-threaded ...
if( m_notYetSet )
......@@ -663,7 +657,7 @@ bool WPropertyVariable< T >::setRecommendedValue( T value )
}
template < typename T >
bool WPropertyVariable< T >::ensureValidity( T newValidValue, bool suppressNotification )
bool WPropertyVariable< T >::ensureValidity( const T& newValidValue, bool suppressNotification )
{
if( !accept( WFlag< T >::get() ) )
{
......@@ -700,19 +694,19 @@ void WPropertyVariable< T >::updateType()
}
template < typename T >
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::minConstraint( T min )
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::minConstraint( const T& min )
{
return boost::shared_ptr< WPropertyConstraintMin< T > >( new WPropertyConstraintMin< T >( min ) );
}
template < typename T >
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::maxConstraint( T max )
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::maxConstraint( const T& max )
{
return boost::shared_ptr< WPropertyConstraintMax< T > >( new WPropertyConstraintMax< T >( max ) );
}
template < typename T >
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin( T min )
boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin( const T& min )
{
boost::shared_ptr< WPropertyConstraintMin< T > > c = minConstraint( min );
replaceConstraint( c, PC_MIN );
......@@ -720,7 +714,7 @@ boost::shared_ptr< WPropertyConstraintMin< T > > WPropertyVariable< T >::setMin(
}
template < typename T >
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::setMax( T max )
boost::shared_ptr< WPropertyConstraintMax< T > > WPropertyVariable< T >::setMax( const T& max )
{
boost::shared_ptr< WPropertyConstraintMax< T > > c = maxConstraint( max );
replaceConstraint( c, PC_MAX );
......
......@@ -52,6 +52,11 @@ public:
*/
virtual ~WSharedObject();
/**
* The type protected by this shared object class
*/
typedef T ValueT;
/**
* Type for read tickets.
*/
......@@ -62,6 +67,16 @@ public:
*/
typedef boost::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket;
/**
* Shared pointer abbreviation.
*/
typedef boost::shared_ptr< WSharedObject< T > > SPtr;
/**
* Const shared ptr abbreviation.
*/
typedef boost::shared_ptr< WSharedObject< T > > ConstSPtr;
/**
* Returns a ticket to get read access to the contained data. After the ticket is freed, the read lock vanishes.
*
......
......@@ -24,6 +24,10 @@
#include <cassert>
#include <iostream>
#include <algorithm>
#include "WTransferFunction.h"
bool WTransferFunction::operator==( const WTransferFunction &rhs ) const
......
......@@ -25,13 +25,9 @@
#ifndef WTRANSFERFUNCTION_H
#define WTRANSFERFUNCTION_H
#include <iostream>
#include <vector>
#include <algorithm>
#include "WColor.h"
#include <osg/Vec4>
#include <osg/io_utils> // for the operator<< and operator>> for Vec4
#include "WExportCommon.h"
......@@ -41,176 +37,228 @@
*/
class WTransferFunction
{
private:
private:
struct Entry
/**
* Prototype for a storage element
*/
struct Entry
{
/**
* Default constructor
* \param iso the iso value
*/
explicit Entry( double iso ) : iso( iso )
{
explicit Entry( double iso ) : iso( iso )
{
}
}
bool operator <= ( const Entry &rhs ) const
{
return iso <= rhs.iso;
}
/**
* comparison by isovalue
* \param rhs entry to compare t
*/
bool operator <= ( const Entry &rhs ) const
{
return iso <= rhs.iso;
}
double iso;
};
double iso; //< the isovalue
};
//typedef Entry LessPred;
struct ColorEntry : public Entry
/**
* Color entries are linearly interpolated colors along isovalues
*/
struct ColorEntry : public Entry
{
/** default constructor
* \param iso the isovalue
* \param color the color at the isovalue
*/
ColorEntry( double iso, WColor color ) : Entry( iso ), color( color )
{
}
/**
* comparison operator to check for changes
* \param rhs ColorEntry to compare to
*/
bool operator==( const ColorEntry& rhs ) const
{
return iso == rhs.iso && color == rhs.color;
}
WColor color;
WColor color; //< holds the current color at isovalue Entry::iso
};
struct AlphaEntry : public Entry
/**
* Alpha entries represent linearly interpolated transparency values
* along the isovalue scale. Alpha is in the range [ 0...1 ] where
* 1 signifies entirely opaque ( which makes it more an opacity value instead
* of alpha, but I use the commonly used language here )
*/
struct AlphaEntry : public Entry
{
AlphaEntry( double iso, double alpha ) : Entry( iso ), alpha( alpha )
/** default constructor
* \param iso the isovalue
* \param alpha the alpha at the isovalue in the range from 0 = transparent to 1 = opaque
*/
AlphaEntry( double iso, double alpha ) : Entry( iso ), alpha( alpha )
{
}
/**
* comparison operator to check for changes
* \param rhs AlphaEntry to compare to
*/
bool operator==( const AlphaEntry& rhs ) const
{
return iso == rhs.iso && alpha == rhs.alpha;
}
double alpha;
double alpha; //< holds the current alpha at isovalue Entry::iso
};
template<typename T>
struct LessPred
/**
* Templatized comparison predicate for internal searching
*/
template<typename T