LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
LibCarna::base::ColorMap Class Reference

Represents a mapping of intensity values to RGBA colors, that can be queried in a shader. More...

#include <ColorMap.hpp>

Public Member Functions

 ColorMap (unsigned int resolution=DEFAULT_RESOLUTION)
 Instantiates.
 
 ~ColorMap ()
 Deletes the maintained OpenGL texture and sampler objects.
 
void clear ()
 Clears the color map. All intensity values are mapped to base::Color::BLACK_NO_ALPHA after calling this method.
 
ColorMapwriteLinearSegment (const base::math::Span< float > &intensityRange, const base::math::Span< base::Color > colorRange)
 Linearly maps all intensity values from intensityRange to colorRange.
 
ColorMapwriteLinearSegment (float intensityFirst, float intensityLast, const base::Color &colorFirst, const base::Color &colorLast)
 
ColorMapwriteLinearSpline (const std::vector< base::Color > &colors)
 Writes a linear segment with writeLinearSegment for each subsequent pair of colors. The colors are spaced equidistantly to cover the whole range of values in \([0, 1]\).
 
const std::vector< base::Color > & getColorList () const
 Returns the list of colors stored in the color map.
 
void bind (int unit) const
 Binds this texture and the corresponding sampler to unit.
 
ColorMapoperator= (const ColorMap &other)
 Writes the content the other color map into this.
 
void setMinimumIntensity (float minimumIntensity)
 Sets the minimum intensity value. Intensity values below this value are treated as 0.
 
float minimumIntensity () const
 Returns the minimum intensity value. Intensity values below this value are treated as 0.
 
void setMaximumIntensity (float maximumIntensity)
 Sets the maximum intensity value. Intensity values above this value are treated as 1.
 
float maximumIntensity () const
 Returns the maximum intensity value. Intensity values above this value are treated as 1.
 

Static Public Attributes

static const unsigned int DEFAULT_RESOLUTION = ( 1 << 16 )
 Holds the default resolution of the color map (16bit).
 
static const float DEFAULT_MINIMUM_INTENSITY
 Holds the default value for minimumIntensity.
 
static const float DEFAULT_MAXIMUM_INTENSITY
 Holds the default value for maximumIntensity.
 

Detailed Description

Represents a mapping of intensity values to RGBA colors, that can be queried in a shader.

Author
Leonid Kostrykin

Definition at line 44 of file ColorMap.hpp.

Constructor & Destructor Documentation

◆ ColorMap()

LibCarna::base::ColorMap::ColorMap ( unsigned int  resolution = DEFAULT_RESOLUTION)
explicit

Instantiates.

The parameter resolution determines the resolution of the color map. If your data is 8bit, using a 8bit color map is sufficient. If your data is 32bit, you probably also want to use a 32bit color map.

Member Function Documentation

◆ setMaximumIntensity()

void LibCarna::base::ColorMap::setMaximumIntensity ( float  maximumIntensity)

Sets the maximum intensity value. Intensity values above this value are treated as 1.

Precondition
0 <= maximumIntensity <= 1
Postcondition
maximumIntensity() == maximumIntensity
minimumIntensity() <= maximumIntensity()

◆ setMinimumIntensity()

void LibCarna::base::ColorMap::setMinimumIntensity ( float  minimumIntensity)

Sets the minimum intensity value. Intensity values below this value are treated as 0.

Precondition
0 <= minimumIntensity <= 1
Postcondition
minimumIntensity() == minimumIntensity
minimumIntensity() <= maximumIntensity()

◆ writeLinearSegment() [1/2]

ColorMap & LibCarna::base::ColorMap::writeLinearSegment ( const base::math::Span< float > &  intensityRange,
const base::math::Span< base::Color colorRange 
)

Linearly maps all intensity values from intensityRange to colorRange.

The first/last intensity values from intensityRange are mapped to the first/last values of colorRange, respectively. The values are interpolated linearly in between.

Nothing happens if the last intensity value of intensityRange is smaller than the first. If the first and the last intensity values of intensityRange correspond to the same entry of the color map, the mean of the first and the last values from colorRange is written.

◆ writeLinearSegment() [2/2]

ColorMap & LibCarna::base::ColorMap::writeLinearSegment ( float  intensityFirst,
float  intensityLast,
const base::Color colorFirst,
const base::Color colorLast 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Data Documentation

◆ DEFAULT_MAXIMUM_INTENSITY

const float LibCarna::base::ColorMap::DEFAULT_MAXIMUM_INTENSITY
static

Holds the default value for maximumIntensity.

Definition at line 61 of file ColorMap.hpp.

◆ DEFAULT_MINIMUM_INTENSITY

const float LibCarna::base::ColorMap::DEFAULT_MINIMUM_INTENSITY
static

Holds the default value for minimumIntensity.

Definition at line 59 of file ColorMap.hpp.

◆ DEFAULT_RESOLUTION

const unsigned int LibCarna::base::ColorMap::DEFAULT_RESOLUTION = ( 1 << 16 )
static

Holds the default resolution of the color map (16bit).

Definition at line 57 of file ColorMap.hpp.


The documentation for this class was generated from the following file: