AGX Dynamics  2.35.0.1
ScalarColorMap.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 
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 
148 
153 
158 
162  osg::ref_ptr < osgSim::ColorRange > getOsgColorRange() const;
163 
164  protected:
165  virtual ~ScalarColorMap();
166  void initColorRange( const std::vector<osg::Vec4>& osgColors );
170 
171  protected:
174  float m_rScaling;
175  osg::ref_ptr< osgSim::ColorRange > m_colorRange;
176  };
177 }
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXOSG_EXPORT
Class that represents a linear scalar color map that converts a scalar interval to a specified color ...
ColorRangePreset
Enum representation of predefined color ranges than can be set in the class.
void setColors(const agxRender::ColorVector &colorVector)
agxRender::ColorVector getColors() const
osg::ref_ptr< osgSim::ColorRange > getOsgColorRange() const
void setMaxScalar(agx::Real maxScalar)
Set the maximum scalar of the interval.
void setScalarInterval(agx::Real minScalar, agx::Real maxScalar)
Set the scalars of the interval used in the color interpolation.
void initColorRange(const std::vector< osg::Vec4 > &osgColors)
ScalarColorMap()
Default constructor.
agx::Real getMaxScalar() const
ScalarColorMap(ColorRangePreset preset, 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.
agx::Real getMinScalar() const
void setMinScalar(agx::Real minScalar)
Set the min scalar of the interval.
osg::ref_ptr< osgSim::ColorRange > m_colorRange
ScalarColorMap(const agxRender::ColorVector &colorVector, agx::Real minScalar, agx::Real maxScalar)
Constructor.
agxRender::ColorVector getColorsFromPreset(ColorRangePreset preset)
void setColorsFromPreset(ColorRangePreset colorRangePreset)
Set a range of colors from an available color range preset in the class.
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.
Base class providing referencing counted objects.
Definition: Referenced.h:114
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
Templated vector class.
Definition: agx/Vector.h:53
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
double Real
Definition: Real.h:42
Vec4T< Real > Vec4
Definition: Vec4.h:25