Commit 09f0b761 authored by mstuber's avatar mstuber
Browse files

[Merge]

parents 89cf2ecf 4f0dad66
......@@ -73,4 +73,4 @@ deleteROIKey = Del
# bgColor.g = .9 # background color (green part)
# bgColor.b = .9 # background color (blue part)
zoomTrackballManipulator.allowThrow = yes # allow the auto-rotation thing when "throwing" an object with the mouse
# multiThreadedViewers = no # Use multiple threads for the multiple viewers. Causes hanging on some machines when opening a new view.
multiThreadedViewers = no # Use multiple threads for the multiple viewers. Causes hanging on some machines when opening a new view.
......@@ -9,7 +9,7 @@
# default=HUD
## A list of modules that will be provided through the GUI.
## If the list is empty all available modules are provided.
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Read Mesh,Voxelizer,Superquadric Glyphs,Tensor Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI,Fiber Display,Read Spherical Harmonics,Navigation Slices,Deterministic Tract Clustering using Gaussian Processes,Deterministic Tract to Gaussian Process Converter,Cluster Param Display,Write Tracts,Fiber Resampling
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Read Mesh,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI,Fiber Display,Read Spherical Harmonics,Navigation Slices,Deterministic Tract Clustering using Gaussian Processes,Deterministic Tract to Gaussian Process Converter,Cluster Param Display,Write Tracts,Fiber Resampling,Teem Glyphs
## Specify a ";" separated list of additional paths for modules. The order of appearance is the order of loading. The following additional rules apply here:
## 1. if the directory contains one or more libOWmodule_XYZ it/they get loaded
......@@ -75,5 +75,5 @@ deleteROIKey = Del
# bgColor.r = .9 # background color (red part)
# bgColor.g = .9 # background color (green part)
# bgColor.b = .9 # background color (blue part)
# zoomTrackballManipulator.allowThrow = yes # allow the auto-rotation thing when "throwing" an object with the mouse
zoomTrackballManipulator.allowThrow = no # allow the auto-rotation thing when "throwing" an object with the mouse
multiThreadedViewers = no # Use multiple threads for the multiple viewers. Causes hanging on some machines when opening a new view.
......@@ -314,8 +314,8 @@ ENDIF()
#---------- walnut.cfg file -------------
IF( NOT EXISTS ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg )
CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg COPYONLY )
MESSAGE( STATUS "Copied ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi to ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg" )
CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.official ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg COPYONLY )
MESSAGE( STATUS "Copied ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.official to ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg" )
ENDIF()
# Special targets:
......
......@@ -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
......@@ -23,84 +23,15 @@
//---------------------------------------------------------------------------
#include <cmath>
#include <cassert>
#include <string>
#include <vector>
#include <boost/lexical_cast.hpp>
#include "../common/WStringUtils.h"
#include "../common/exceptions/WOutOfBounds.h"
#include "../common/WStringUtils.h"
#include "WColor.h"
WColor::WColor( float red, float green, float blue, float alpha )
: m_red( red ),
m_green( green ),
m_blue( blue ),
m_alpha( alpha )
{
// check if the given values are correct in range
// TODO(lmath): reenable asserts to WAsserts as soon as LIC module doesn't procude invalid colors
// assert( m_green <= 1.0 && m_green >= 0.0 && "WColor comopnent out of range" );
// assert( m_blue <= 1.0 && m_blue >= 0.0 && "WColor comopnent out of range" );
// assert( m_red <= 1.0 && m_red >= 0.0 && "WColor comopnent out of range" );
// assert( m_alpha <= 1.0 && m_alpha >= 0.0 && "WColor comopnent out of range" );
}
void WColor::setGreen( float green )
{
// TODO(lmath): reenable asserts to WAsserts as soon as LIC module doesn't procude invalid colors
// assert( green <= 1.0 && green >= 0.0 );
m_green = green;
}
void WColor::setBlue( float blue )
{
// TODO(lmath): reenable asserts to WAsserts as soon as LIC module doesn't procude invalid colors
// assert( blue <= 1.0 && blue >= 0.0 );
m_blue = blue;
}
void WColor::setRed( float red )
{
// TODO(lmath): reenable asserts to WAsserts as soon as LIC module doesn't procude invalid colors
// assert( red <= 1.0 && red >= 0.0 );
m_red = red;
}
void WColor::setAlpha( float alpha )
{
// TODO(lmath): reenable asserts to WAsserts as soon as LIC module doesn't procude invalid colors
// assert( alpha <= 1.0 && alpha >= 0.0 );
m_alpha = alpha;
}
float WColor::getRed() const
{
return m_red;
}
float WColor::getGreen() const
{
return m_green;
}
float WColor::getBlue() const
{
return m_blue;
}
float WColor::getAlpha() const
{
return m_alpha;
}
void WColor::setRGB( double r, double g, double b )
{
setRed( r );
setGreen( g );
setBlue( b );
}
// 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.
......@@ -129,7 +60,7 @@ void WColor::setRGB( double r, double g, double b )
// Contact: pppebay@sandia.gov,dcthomp@sandia.gov,
//
// =========================================================================*/
void WColor::setHSV( double h, double s, double v )
WColor convertHSVtoRGBA( double h, double s, double v )
{
const double onethird = 1.0 / 3.0;
const double onesixth = 1.0 / 6.0;
......@@ -182,63 +113,34 @@ void WColor::setHSV( double h, double s, double v )
g = ( s * g + ( 1.0 - s ) ) * v;
b = ( s * b + ( 1.0 - s ) ) * v;
setRGB( r, g, b );
return WColor( r, g, b, 1.0f );
}
std::ostream& operator<<( std::ostream& out, const WColor& c )
{
float r = c.getRed();
float g = c.getGreen();
float b = c.getBlue();
float a = c.getAlpha();
out << r << ";" << g << ";" << b << ";" << a;
return out;
return out << c[0] << ";" << c[1] << ";" << c[2] << ";" << c[3];
}
std::istream& operator>>( std::istream& in, WColor& c )
{
std::string str;
in >> str;
std::vector<std::string> tokens;
std::vector< std::string > tokens;
tokens = string_utils::tokenize( str, ";" );
assert( tokens.size() == 4 && "There weren't 4 color values for a WColor" );
if( tokens.size() != 4 )
{
throw WOutOfBounds( "Expected 4 color values for a WColor but got " + boost::lexical_cast< std::string >( tokens.size() ) );
}
c.setRed( boost::lexical_cast< float >( tokens[0] ) );
c.setGreen( boost::lexical_cast< float >( tokens[1] ) );
c.setBlue( boost::lexical_cast< float >( tokens[2] ) );
c.setAlpha( boost::lexical_cast< float >( tokens[3] ) );
c[0] = boost::lexical_cast< float >( tokens[0] );
c[1] = boost::lexical_cast< float >( tokens[1] );
c[2] = boost::lexical_cast< float >( tokens[2] );
c[3] = boost::lexical_cast< float >( tokens[3] );
return in;
}
bool WColor::operator==( const WColor &rhs ) const
{
return m_red == rhs.m_red &&
m_green == rhs.m_green &&
m_blue == rhs.m_blue &&
m_alpha == rhs.m_alpha;
}
bool WColor::operator!=( const WColor &rhs ) const
WColor inverseColor( const WColor& other )
{
return !( *this == rhs );
return WColor( std::abs( 1.0f - other[0] ), std::abs( 1.0f - other[1] ), std::abs( 1.0f - other[2] ), other[3] );
}
void WColor::inverse()
{
m_red = std::abs( 1. - m_red );
m_green = std::abs( 1. - m_green );
m_blue = std::abs( 1. - m_blue );
}
void WColor::average( const WColor& other )
{
m_red = ( m_red + other.getRed() ) / 2.0;
m_green = ( m_green + other.getGreen() ) / 2.0;
m_blue = ( m_blue + other.getBlue() ) / 2.0;
}
const WColor WColor::green( 0.0, 1.0, 0.0, 1.0 );
const WColor WColor::red( 1.0, 0.0, 0.0, 1.0 );
const WColor WColor::blue( 0.0, 0.0, 1.0, 1.0 );
......@@ -25,173 +25,48 @@
#ifndef WCOLOR_H
#define WCOLOR_H
#include <cassert>
#include <istream>
#include <ostream>
#include <string>
#include <vector>
#include <iostream>
#include <osg/Vec4>
#include "math/WVector3D.h"
#include "WExportCommon.h"
#include <osg/io_utils> // for the operator<< and operator>> for Vec4
/**
* Represents a RGBA Color
* Represents a RGBA Color.
*/
class OWCOMMON_EXPORT WColor
{
public:
/**
* Standard way of constructing colors, alpha is optional, and black is default
* \param red red value between [0,1]
* \param green green value between [0,1]
* \param blue blue value between [0,1]
* \param alpha opacity value between [0,1]
*/
WColor( float red = 0.0, float green = 0.0, float blue = 0.0, float alpha = 1.0 );
/**
* Casts a color to a vector comfortably.
*
* \return vector instance
*/
inline operator osg::Vec4f() const;
/**
* Casts a color to a vector comfortably. As the returned vector is three-dimensional, the alpha value is omitted.
*
* \return vector instance
*/
inline operator wmath::WVector3D() const;
/**
* Sets the green channel for this color
* \param green green value between [0,1]
*/
void setGreen( float green );
/**
* Sets the blue channel for this color
* \param blue blue value between [0,1]
*/
void setBlue( float blue );
/**
* Sets the red channel for this color
* \param red red value between [0,1]
*/
void setRed( float red );
/**
* Sets the alpha channel for this color
* \param alpha opacity value between [0,1]
*/
void setAlpha( float alpha );
/**
* \return red channel for this color
*/
float getRed() const;
/**
* \return green channel for this color
*/
float getGreen() const;
/**
* \return blue channel for this color
*/
float getBlue() const;
/**
* \return alpha channel for this color
*/
float getAlpha() const;
/**
* Reset this color via a given HSV color.
* \param h hue
* \param s saturation
* \param v value
*/
void setHSV( double h, double s, double v );
/**
* Reset all channels at once.
* \param r red value between [0,1]
* \param g green value between [0,1]
* \param b blue value between [0,1]
*/
void setRGB( double r, double g, double b );
/**
* Computes the inverse of this color in means of RGB space.
*/
void inverse();
/**
* Computes the arithmetic mean of this and the other color. This is done component wisely.
* For example red mixed with green will become yellow.
*
* \param other The other color to mix in here :D.
*/
void average( const WColor& other );
/**
* Compares two WColor instances on all four channels.
*
* \param rhs The other WColor instance
* \return True if they share the same values in all four channles:
* red, green, blue and alpha
*/
bool operator==( const WColor &rhs ) const;
/**
* Opposite of the operator==.
*
* \param rhs The other WColor instance
* \return True if they don't share the same values in all four channles:
* red, green, blue and alpha
*/
bool operator!=( const WColor &rhs ) const;
static const WColor green; //!< Default for green
static const WColor red; //!< Default for red
static const WColor blue; //!< Default for blue
protected:
private:
float m_red; //!< Red channel
float m_green; //!< Green channel
float m_blue; //!< Blue channel
float m_alpha; //!< Alpha channel
};
typedef osg::Vec4 WColor;
/**
* Write a color in string representation to the given output stream.
* Creates a color from a hue, saturation and value (HSV).
*
* \ingroup Color utils
*
* \param h hue
* \param s saturation
* \param v value
*
* \return The same color but in rgba format.
*/
std::ostream& operator<<( std::ostream& out, const WColor& c );
WColor convertHSVtoRGBA( double h, double s, double v );
/**
* Read a color in string representation from the given input stream.
* Computes the inverse of this color in means of RGB space. The alpha value is untouched.
*
* \ingroup Color utils
*
* \param other The color (RGBA) from which the inverse should be calculated.
*/
std::istream& operator>>( std::istream& in, WColor& c );
inline WColor::operator osg::Vec4f() const
{
return osg::Vec4f( static_cast< float >( m_red ),
static_cast< float >( m_green ),
static_cast< float >( m_blue ),
static_cast< float >( m_alpha ) );
}
WColor inverseColor( const WColor& other );
inline WColor::operator wmath::WVector3D() const
/**
* Some default colors.
*/
namespace defaultColor
{
return wmath::WVector3D( static_cast< float >( m_red ),
static_cast< float >( m_green ),
static_cast< float >( m_blue ) );
// \cond
static const WColor GREEN( 0.0, 1.0, 0.0, 1.0 ); //!< Default for green
static const WColor RED( 1.0, 0.0, 0.0, 1.0 ); //!< Default for red
static const WColor BLUE( 0.0, 0.0, 1.0, 1.0 ); //!< Default for blue
// \endcond
}
#endif // WCOLOR_H
......@@ -25,6 +25,7 @@
#ifndef WCONDITION_H
#define WCONDITION_H
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/signals2/signal.hpp>
#include <boost/thread.hpp>
......@@ -39,6 +40,15 @@ class OWCOMMON_EXPORT WCondition // NOLINT
{
friend class WCondition_test;
public:
/**
* Shared pointer type for WCondition.
*/
typedef boost::shared_ptr< WCondition > SPtr;
/**
* Const shared pointer type for WCondition.
*/
typedef boost::shared_ptr< const WCondition > ConstSPtr;
/**
* Default constructor.
......
......@@ -25,6 +25,8 @@
#ifndef WFLAG_H
#define WFLAG_H
#include <boost/shared_ptr.hpp>
#include "WCondition.h"
/**
......@@ -40,6 +42,16 @@ public:
*/
typedef T ValueType;
/**
* Convenience typedef for a boost::shared_ptr.
*/
typedef boost::shared_ptr< WFlag< T > > SPtr;
/**
* Convenience typedef for a boost::shared_ptr. Const.
*/
typedef boost::shared_ptr< const WFlag< T > > ConstSPtr;
/**
* Constructor. Uses a given condition to realize the wait/notify functionality. By using this constructor, the specified
* condition gets deleted whenever this WFlag is deleted.
......@@ -156,11 +168,14 @@ public:
virtual bool isValid();
/**
* True whenever the value inside this flag has changed since the last reset. It stays true until get( true ) is called.
* True whenever the value inside this flag has changed since the last reset. It stays true until get( true ) is called or the reset value is
* true.
*
* \param reset if true, the change flag gets reset.
*
* \return true when the value has changed and not yet been reseted.
*/
virtual bool changed();
virtual bool changed( bool reset = false );
protected:
......@@ -313,9 +328,14 @@ bool WFlag< T >::isValid()
}
template < typename T >
bool WFlag< T >::changed()
bool WFlag< T >::changed( bool reset )
{
return m_changed;
bool tmp = m_changed;
if ( reset )
{
m_changed = false;
}
return tmp;
}
#endif // WFLAG_H
......
......@@ -65,7 +65,8 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters( size_t cluster, s
worklist.push_back( current );
}
}
sortList( worklist );
worklist.sort( compSize( this ) );
bool newSplit = true;
......@@ -84,7 +85,7 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters( size_t cluster, s
{
worklist.pop_front();
worklist.push_back( left );
sortList( worklist );
worklist.sort( compSize( this ) );
newSplit = true;
}
......@@ -100,11 +101,10 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters( size_t cluster, s
worklist.pop_back();
}
worklist.push_back( right );
sortList( worklist );
worklist.sort( compSize( this ) );
newSplit = true;
}
}
sortList( worklist );
}
std::vector<size_t>returnVector;
......@@ -148,7 +148,8 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters2( size_t cluster,
worklist.push_back( current );
}
}
sortList( worklist );
worklist.sort( compSize( this ) );
bool newSplit = true;
......@@ -170,7 +171,8 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters2( size_t cluster,
{
worklist.pop_front();
worklist.push_back( left );
sortList( worklist );
worklist.sort( compSize( this ) );
newSplit = true;
}
......@@ -186,12 +188,12 @@ std::vector< size_t > WHierarchicalTree::findXBiggestClusters2( size_t cluster,
worklist.pop_back();
}
worklist.push_back( right );
sortList( worklist );
worklist.sort( compSize( this ) );
newSplit = true;
}
}
}
sortList( worklist );
}
std::vector<size_t>returnVector;
......@@ -252,7 +254,7 @@ std::vector< size_t > WHierarchicalTree::downXLevelsFromTop( size_t level, bool
worklist = newChildList;
}
sortList( worklist );
worklist.sort( compSize( this ) );
std::list<size_t>::iterator it;
for ( it = worklist.begin(); it != worklist.end(); ++it )
......@@ -264,60 +266,13 @@ std::vector< size_t > WHierarchicalTree::downXLevelsFromTop( size_t level, bool
return returnVector;
}
void WHierarchicalTree::sortList( std::list<size_t> &input ) //NOLINT
{
if ( input.size() == 0 )
{
return;
}
std::vector<size_t>vec;
std::list<size_t>::iterator it;
for ( it = input.begin(); it != input.end(); ++it )
{