AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
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.
 
 ScalarColorMap (ColorRangePreset preset, agx::Real minScalar, agx::Real maxScalar)
 Constructor.
 
 ScalarColorMap (const agxRender::ColorVector &colorVector, agx::Real minScalar, agx::Real maxScalar)
 Constructor.
 
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.
 
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.
 
agxRender::ColorVector getColors () const
 
agx::Real getMaxScalar () const
 
agx::Real getMinScalar () const
 
osg::ref_ptr< osgSim::ColorRange > getOsgColorRange () const
 
void setColors (const agxRender::ColorVector &colorVector)
 
void setColorsFromPreset (ColorRangePreset colorRangePreset)
 Set a range of colors from an available color range preset in the class.
 
void setMaxScalar (agx::Real maxScalar)
 Set the maximum scalar of the interval.
 
void setMinScalar (agx::Real minScalar)
 Set the min scalar of the interval.
 
void setScalarInterval (agx::Real minScalar, agx::Real maxScalar)
 Set the scalars of the interval used in the color interpolation.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Protected Member Functions

virtual ~ScalarColorMap ()
 
void correctScalarInterval ()
 
agxRender::ColorVector getColorsFromPreset (ColorRangePreset preset)
 
void initColorRange (const std::vector< osg::Vec4 > &osgColors)
 
void updateColorRange ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

osg::ref_ptr< osgSim::ColorRange > m_colorRange
 
agx::Real m_maxScalar
 
agx::Real m_minScalar
 
float m_rScaling
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

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

◆ ColorRangePreset

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

◆ ScalarColorMap() [1/3]

agxOSG::ScalarColorMap::ScalarColorMap ( )

Default constructor.

◆ ScalarColorMap() [2/3]

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.

◆ ScalarColorMap() [3/3]

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.

◆ ~ScalarColorMap()

virtual agxOSG::ScalarColorMap::~ScalarColorMap ( )
protectedvirtual

Member Function Documentation

◆ correctScalarInterval()

void agxOSG::ScalarColorMap::correctScalarInterval ( )
protected

◆ getColor()

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.

◆ getColorOSG()

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.

◆ getColors()

agxRender::ColorVector agxOSG::ScalarColorMap::getColors ( ) const
Returns
vector containing colors used the current interval.

◆ getColorsFromPreset()

agxRender::ColorVector agxOSG::ScalarColorMap::getColorsFromPreset ( ColorRangePreset  preset)
protected

◆ getMaxScalar()

agx::Real agxOSG::ScalarColorMap::getMaxScalar ( ) const
Returns
the maximum scalar value of the interval.

◆ getMinScalar()

agx::Real agxOSG::ScalarColorMap::getMinScalar ( ) const
Returns
the minimum scalar value of the interval.

◆ getOsgColorRange()

osg::ref_ptr< osgSim::ColorRange > agxOSG::ScalarColorMap::getOsgColorRange ( ) const
Returns
a pointer to the internal osgSim::ColorRange object.

◆ initColorRange()

void agxOSG::ScalarColorMap::initColorRange ( const std::vector< osg::Vec4 > &  osgColors)
protected

◆ setColors()

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

◆ setColorsFromPreset()

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.

◆ setMaxScalar()

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.

◆ setMinScalar()

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.

◆ setScalarInterval()

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.

◆ updateColorRange()

void agxOSG::ScalarColorMap::updateColorRange ( )
protected

Member Data Documentation

◆ m_colorRange

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

Definition at line 175 of file ScalarColorMap.h.

◆ m_maxScalar

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

Definition at line 173 of file ScalarColorMap.h.

◆ m_minScalar

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

Definition at line 172 of file ScalarColorMap.h.

◆ m_rScaling

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: