1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSGSIM_COLORRANGE
15#define OSGSIM_COLORRANGE 1
17#include <osgSim/Export>
19#include <osgSim/ScalarsToColors>
25ColorRange is a ScalarsToColors object to define a color spectrum
26for a scalar range. An optional vector of colors may be passed in at
27construction time. The range of colors will be mapped to the scalar range,
28and interpolation between the colors will be performed as necessary.
29By default, the color range will run Red-Yellow-Green-Cyan-Blue.
31class OSGSIM_EXPORT ColorRange: public ScalarsToColors
35 /** Constructor for a ColorRange with a default list of colors set to Red-Yellow-Green-Blue-Cyan
36 @param min minimum scalar value
37 @param max maximum scalar value
39 ColorRange(float min, float max);
41 /** Constructor for a ColorRange
42 @param min minimum scalar value
43 @param max maximum scalar value
44 @param colors optional range of colors,
46 ColorRange(float min, float max, const std::vector<osg::Vec4>& colors);
48 /** Set the range of colors. */
49 void setColors(const std::vector<osg::Vec4>& colors);
51 /** Get the range of colors */
52 const std::vector<osg::Vec4>& getColors() const { return _colors; }
54 /** Get the color for a given scalar value. */
55 osg::Vec4 getColor(float scalar) const;
59 // Default assignment and copy construction are OK.
61 std::vector<osg::Vec4> _colors;