AGX Dynamics  2.38.0.2
ScalarColorMap.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
20 #include <osgSim/ColorRange>
21 #include <osgSim/ScalarsToColors>
22 #include <osg/ref_ptr>
23 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
24 
25 #include <agxOSG/export.h>
26 #include <agxRender/Color.h>
27 #include <agx/Referenced.h>
28 
29 namespace agxOSG
30 {
38  {
39  public:
40 
45  {
56  AFMHOT
57  };
58 
63 
73  ScalarColorMap( const agxRender::ColorVector& colorVector,
74  agx::Real minScalar,
75  agx::Real maxScalar );
76 
86  ScalarColorMap( ColorRangePreset preset,
87  agx::Real minScalar,
88  agx::Real maxScalar );
89 
95  void setColorsFromPreset( ColorRangePreset colorRangePreset );
96 
103  osg::Vec4 getColorOSG( agx::Real scalar, bool modifyAlpha = false ) const;
104 
111  agx::Vec4f getColor( agx::Real scalar, bool modifyAlpha = false ) const;
112 
119  void setMinScalar( agx::Real minScalar );
120 
127  void setMaxScalar( agx::Real maxScalar );
128 
136  void setScalarInterval( agx::Real minScalar, agx::Real maxScalar );
137 
138  /*
139  Manually set the colors used in the interpolation range.
140  \param colorVector - a vector containing the specified colors of the interval.
141  */
142  void setColors( const agxRender::ColorVector& colorVector );
143 
147  agx::Real getMinScalar() const;
148 
152  agx::Real getMaxScalar() const;
153 
157  agxRender::ColorVector getColors() const;
158 
162  osg::ref_ptr < osgSim::ColorRange > getOsgColorRange() const;
163 
164  protected:
165  virtual ~ScalarColorMap();
166  void initColorRange( const std::vector<osg::Vec4>& osgColors );
167  void updateColorRange();
168  void correctScalarInterval();
169  agxRender::ColorVector getColorsFromPreset( ColorRangePreset preset );
170 
171  protected:
174  float m_rScaling;
175  osg::ref_ptr< osgSim::ColorRange > m_colorRange;
176  };
177 }
agxOSG::ScalarColorMap::CIVIDIS
@ CIVIDIS
Definition: ScalarColorMap.h:53
Referenced.h
agx::Real
double Real
Definition: Real.h:42
agxOSG::ScalarColorMap::INFERNO
@ INFERNO
Definition: ScalarColorMap.h:49
agx::Vector
Templated vector class.
Definition: Vector.h:52
agxOSG::ScalarColorMap::PLASMA
@ PLASMA
Definition: ScalarColorMap.h:50
agxOSG::ScalarColorMap
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
Definition: ScalarColorMap.h:37
agxOSG::ScalarColorMap::GRAYSCALE
@ GRAYSCALE
Definition: ScalarColorMap.h:51
agx::Vec4
Vec4T< Real > Vec4
Definition: Vec4.h:25
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxOSG::ScalarColorMap::m_minScalar
agx::Real m_minScalar
Definition: ScalarColorMap.h:172
agxOSG::ScalarColorMap::m_rScaling
float m_rScaling
Definition: ScalarColorMap.h:174
agxOSG::ScalarColorMap::m_colorRange
osg::ref_ptr< osgSim::ColorRange > m_colorRange
Definition: ScalarColorMap.h:175
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxOSG::ScalarColorMap::BLUE_WHITE_RED
@ BLUE_WHITE_RED
Definition: ScalarColorMap.h:52
agxOSG::ScalarColorMap::BONE
@ BONE
Definition: ScalarColorMap.h:54
agxOSG::ScalarColorMap::COOLWARM
@ COOLWARM
Definition: ScalarColorMap.h:47
agxOSG::ScalarColorMap::m_maxScalar
agx::Real m_maxScalar
Definition: ScalarColorMap.h:173
agxOSG::ScalarColorMap::ColorRangePreset
ColorRangePreset
Enum representation of predefined color ranges than can be set in the class.
Definition: ScalarColorMap.h:44
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agxOSG::ScalarColorMap::VIRIDIS
@ VIRIDIS
Definition: ScalarColorMap.h:48
export.h
Color.h
agxOSG::ScalarColorMap::COPPER
@ COPPER
Definition: ScalarColorMap.h:55
agxOSG::ScalarColorMap::RAINBOW
@ RAINBOW
Definition: ScalarColorMap.h:46
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h