ColorMap Class Reference

This class manages a color map. More...

#include <ColorMap.h>

List of all members.

Public Member Functions

 ColorMap ()
 ColorMap (const std::string &filename)
 ColorMap (const std::string &name, const std::vector< ColorType > &table)
 ColorMap (const std::string &name, const Gradient &gradient)
 ColorMap (const ColorMap &colorMap)
 ~ColorMap ()
ColorMapoperator= (const ColorMap &colorMap)
bool operator== (const ColorMap &colorMap) const
const std::string & getName () const
bool saveToFile (const std::string &filename) const
bool saveToBuffer (std::string &buffer) const
const std::vector< ColorType > & getTable () const
const ColorTypeoperator[] (int index) const
ColorTypeoperator[] (int index)
void resetToDefault ()
bool isDefault () const
bool isFullyOpaque () const
const GradientgetGradientDefinition () const
bool loadFromFile (const std::string &filename)
bool loadFromBuffer (const std::string &buffer)

Classes

struct  Gradient
 This struct defines a color table. More...


Detailed Description

This class manages a color map.

A colormap can be a hold any number of colors, and may contain RGB or RGBA color. Each channel must have a value of between 0 and 256.

Definition at line 27 of file ColorMap.h.


Constructor & Destructor Documentation

ColorMap::ColorMap (  ) 

Construct a default ColorMap.

ColorMap::ColorMap ( const std::string &  filename  )  [explicit]

Construct a ColorMap by loading it from the file specified.

The object's name is specified within the file.

Parameters:
filename The file to load the ColorMap from.
Exceptions:
std::runtime_error This exception is thrown if the file load fails.

ColorMap::ColorMap ( const std::string &  name,
const std::vector< ColorType > &  table 
)

Construct a new ColorMap from a vector of ColorType.

Parameters:
name The name of the new ColorMap.
table The colors to place in the ColorMap.
Exceptions:
std::runtime_error This exception is thrown if there is an invalid color specified.

ColorMap::ColorMap ( const std::string &  name,
const Gradient gradient 
)

Construct a new ColorMap from a Gradient definition.

Parameters:
name The name of the new ColorMap.
gradient The gradient object defining the colormap
Exceptions:
std::runtime_error This exception is thrown if there is an invalid color specified.

ColorMap::ColorMap ( const ColorMap colorMap  ) 

Copy an existing ColorMap.

The new ColorMap will have the same name as the existing one.

Parameters:
colorMap The ColorMap to copy.

ColorMap::~ColorMap (  ) 

Frees all resources associated with a ColorMap.


Member Function Documentation

ColorMap& ColorMap::operator= ( const ColorMap colorMap  ) 

Assign from an existing ColorMap.

The assigned ColorMap will have the same name as the existing one.

Parameters:
colorMap The ColorMap to assign from.

bool ColorMap::operator== ( const ColorMap colorMap  )  const

Determine if ColorMaps are equal.

Parameters:
colorMap The map to compare against
Returns:
true if the maps are equal, false otherwise.

const std::string& ColorMap::getName (  )  const

Get the name of the ColorMap.

Returns:
The name of the object.

bool ColorMap::saveToFile ( const std::string &  filename  )  const

Save the ColorMap to a file.

Parameters:
filename The name of the file to save to.
Returns:
true if the operation was a success, false otherwise.

bool ColorMap::saveToBuffer ( std::string &  buffer  )  const

Save the ColorMap to a string buffer.

Parameters:
buffer The ColorMap data will be written to this string. The string will be resized to accomidate the data.
Returns:
true if the operation was a success, false otherwise.

const std::vector<ColorType>& ColorMap::getTable (  )  const

Get the ColorMap's color table.

Returns:
The vector of ColorTypes for the ColorMap.

const ColorType& ColorMap::operator[] ( int  index  )  const

Get a specific color from the map.

Parameters:
index The index to retrieve. This must be within the bounds of the map.
Returns:
The associated ColorType.

ColorType& ColorMap::operator[] ( int  index  ) 

Get a specific color from the map as a non-const reference.

This allows for code like map[i] = ColorType(255, 255, 255)

Parameters:
index The index to retrieve. This must be within the bounds of the map.
Returns:
The associated ColorType.

void ColorMap::resetToDefault (  ) 

Clear the table and name, replacing it with a default grayscale.

bool ColorMap::isDefault (  )  const

Determine if the ColorMap has not been changed from the default.

Returns:
true if the object is still default, false otherwise.

bool ColorMap::isFullyOpaque (  )  const

Determine if the ColorMap contains only fully opaque colors.

Returns:
true if the object is fully opaque, false otherwise.

const Gradient* ColorMap::getGradientDefinition (  )  const

Returns a pointer to the Gradient object that was used to define the ColorMap, if any.

Returns:
A pointer to the Gradient object that was used to define the ColorMap, or NULL if none was used.

bool ColorMap::loadFromFile ( const std::string &  filename  ) 

Load ColorMap data from a file.

Parameters:
filename The file containing the ColorMap data.
Returns:
true if successful, false otherwise.

bool ColorMap::loadFromBuffer ( const std::string &  buffer  ) 

Load ColorMap data from a string buffer.

Parameters:
buffer The string containing the ColorMap data.
Returns:
true if successful, false otherwise.


Software Development Kit - Opticks 4.9.0 Build 16218