AGX Dynamics  2.37.3.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 
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 }
#define AGXOSG_EXPORT
ColorRangePreset
Enum representation of predefined color ranges than can be set in the class.
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
Vec4T< Real > Vec4
Definition: Vec4.h:25
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
osg::ref_ptr< osgSim::ColorRange > m_colorRange
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
double Real
Definition: Real.h:42
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...