AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxOSG::ScalarColorMap Class Reference

Class that represents a linear scalar color map that converts a scalar interval to a specified color range. More...

#include <ScalarColorMap.h>

+ Inheritance diagram for agxOSG::ScalarColorMap:

Public Types

enum  ColorRangePreset {
  RAINBOW, COOLWARM, VIRIDIS, INFERNO,
  PLASMA, GRAYSCALE, BLUE_WHITE_RED, CIVIDIS,
  BONE, COPPER, AFMHOT
}
 Enum representation of predefined color ranges than can be set in the class. More...
 

Public Member Functions

 ScalarColorMap ()
 Default constructor. More...
 
 ScalarColorMap (const agxRender::ColorVector &colorVector, agx::Real minScalar, agx::Real maxScalar)
 Constructor. More...
 
 ScalarColorMap (ColorRangePreset preset, agx::Real minScalar, agx::Real maxScalar)
 Constructor. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
agx::Vec4f getColor (agx::Real scalar, bool modifyAlpha=false) const
 Get an agx representation of a color value in the map given a scalar inside the interval. More...
 
osg::Vec4 getColorOSG (agx::Real scalar, bool modifyAlpha=false) const
 Get an osg representation of a color value in the map given a scalar inside the interval. More...
 
agxRender::ColorVector getColors () const
 
agx::Real getMaxScalar () const
 
agx::Real getMinScalar () const
 
osg::ref_ptr< osgSim::ColorRange > getOsgColorRange () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void setColors (const agxRender::ColorVector &colorVector)
 
void setColorsFromPreset (ColorRangePreset colorRangePreset)
 Set a range of colors from an available color range preset in the class. More...
 
void setMaxScalar (agx::Real maxScalar)
 Set the maximum scalar of the interval. More...
 
void setMinScalar (agx::Real minScalar)
 Set the min scalar of the interval. More...
 
void setScalarInterval (agx::Real minScalar, agx::Real maxScalar)
 Set the scalars of the interval used in the color interpolation. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~ScalarColorMap ()
 
void allocateObserverVector () const
 
void correctScalarInterval ()
 
void deleteUsingDeleteHandler () const
 
agxRender::ColorVector getColorsFromPreset (ColorRangePreset preset)
 
void initColorRange (const std::vector< osg::Vec4 > &osgColors)
 
void updateColorRange ()
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

osg::ref_ptr< osgSim::ColorRange > m_colorRange
 
agx::Real m_maxScalar
 
agx::Real m_minScalar
 
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
float m_rScaling
 

Detailed Description

Class that represents a linear scalar color map that converts a scalar interval to a specified color range.

This wraps the osgSim::ColorRange object with a layer of convenience functionality.

Definition at line 37 of file ScalarColorMap.h.

Member Enumeration Documentation

Enum representation of predefined color ranges than can be set in the class.

Enumerator
RAINBOW 
COOLWARM 
VIRIDIS 
INFERNO 
PLASMA 
GRAYSCALE 
BLUE_WHITE_RED 
CIVIDIS 
BONE 
COPPER 
AFMHOT 

Definition at line 44 of file ScalarColorMap.h.

Constructor & Destructor Documentation

agxOSG::ScalarColorMap::ScalarColorMap ( )

Default constructor.

agxOSG::ScalarColorMap::ScalarColorMap ( const agxRender::ColorVector &  colorVector,
agx::Real  minScalar,
agx::Real  maxScalar 
)

Constructor.

Parameters
colorVector- the specific color range to be used in scalar map, which is mapped to the scalar interval.
minScalar- The minimum value of the scalar interval that is mapped to the color range.
maxScalar- The maximum value of the scalar interval that is mapped to the color range.
Note
- if the specified minimum scalar larger than the current maximum value or vice versa, the values will be switched.
agxOSG::ScalarColorMap::ScalarColorMap ( ColorRangePreset  preset,
agx::Real  minScalar,
agx::Real  maxScalar 
)

Constructor.

Parameters
preset- preset enum for one of the predefined color ranges that exist in the class that can be chosen to initialize the colors in the map.
minScalar- The minimum value of the scalar interval that is mapped to the color range.
maxScalar- The maximum value of the scalar interval that is mapped to the color range.
Note
- if the specified minimum scalar larger than the current maximum value or vice versa, the values will be switched.
virtual agxOSG::ScalarColorMap::~ScalarColorMap ( )
protectedvirtual

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agxOSG::ScalarColorMap::correctScalarInterval ( )
protected
void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
agx::Vec4f agxOSG::ScalarColorMap::getColor ( agx::Real  scalar,
bool  modifyAlpha = false 
) const

Get an agx representation of a color value in the map given a scalar inside the interval.

Parameters
scalar- a specified scalar that is used to interpolate a color in the given range.
modifyAlpha- true if the alpha value of the color should be modified, false otherwise.
Returns
an agx::Vec4f color representation given the specified scalar value.
osg::Vec4 agxOSG::ScalarColorMap::getColorOSG ( agx::Real  scalar,
bool  modifyAlpha = false 
) const

Get an osg representation of a color value in the map given a scalar inside the interval.

Parameters
scalar- a specified scalar that is used to interpolate a color in the given range.
modifyAlpha- true if the alpha value of the color should be modified, false otherwise.
Returns
an osg::Vec4 color representation given the specified scalar value.
agxRender::ColorVector agxOSG::ScalarColorMap::getColors ( ) const
Returns
vector containing colors used the current interval.
agxRender::ColorVector agxOSG::ScalarColorMap::getColorsFromPreset ( ColorRangePreset  preset)
protected
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
agx::Real agxOSG::ScalarColorMap::getMaxScalar ( ) const
Returns
the maximum scalar value of the interval.
agx::Real agxOSG::ScalarColorMap::getMinScalar ( ) const
Returns
the minimum scalar value of the interval.
osg::ref_ptr< osgSim::ColorRange > agxOSG::ScalarColorMap::getOsgColorRange ( ) const
Returns
a pointer to the internal osgSim::ColorRange object.
int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
void agxOSG::ScalarColorMap::initColorRange ( const std::vector< osg::Vec4 > &  osgColors)
protected
template<typename T >
bool agx::Referenced::is ( ) const
inherited
void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

void agxOSG::ScalarColorMap::setColors ( const agxRender::ColorVector &  colorVector)
void agxOSG::ScalarColorMap::setColorsFromPreset ( ColorRangePreset  colorRangePreset)

Set a range of colors from an available color range preset in the class.

Parameters
colorRangePreset- the specified preset enum that is used to construct the color range.
static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agxOSG::ScalarColorMap::setMaxScalar ( agx::Real  maxScalar)

Set the maximum scalar of the interval.

Parameters
maxScalar- the maximum scalar value in the interval.
Note
- the specified maximum scalar will be rejected if the value is less than the current minimum value.
void agxOSG::ScalarColorMap::setMinScalar ( agx::Real  minScalar)

Set the min scalar of the interval.

Parameters
minScalar- the minimum scalar value in the interval.
Note
- the specified minimum scalar will be rejected if the value is larger than the current maximum value.
void agxOSG::ScalarColorMap::setScalarInterval ( agx::Real  minScalar,
agx::Real  maxScalar 
)

Set the scalars of the interval used in the color interpolation.

Parameters
minScalar- the minimum scalar value in the interval.
maxScalar- the maximum scalar value in the interval.
Note
- if the specified minimum scalar larger than the current maximum value or vice versa, the values will be switched.
void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

void agxOSG::ScalarColorMap::updateColorRange ( )
protected
template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

osg::ref_ptr< osgSim::ColorRange > agxOSG::ScalarColorMap::m_colorRange
protected

Definition at line 175 of file ScalarColorMap.h.

agx::Real agxOSG::ScalarColorMap::m_maxScalar
protected

Definition at line 173 of file ScalarColorMap.h.

agx::Real agxOSG::ScalarColorMap::m_minScalar
protected

Definition at line 172 of file ScalarColorMap.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

float agxOSG::ScalarColorMap::m_rScaling
protected

Definition at line 174 of file ScalarColorMap.h.


The documentation for this class was generated from the following file: