WXP::ColorMap Class Reference

This class defines a specific color map. This is a mapping between color indices, color names and RGB values. More...

#include "../include/ColorMap.h"

List of all members.

Public Member Functions

 ColorMap ()
 ColorMap (int size)
 ColorMap (const ColorMap &color)
ColorMapoperator= (const ColorMap &color)
 ~ColorMap ()
int init (int size)
int init ()
int set (const ColorMap &color)
int add (const char *name, float red, float grn, float blu)
int add (const char *name, RGB &rgb)
int getMax ()
int getNum ()
int getInd (const char *name)
const char * getName (int ind)
int get (int ind, RGB &rgb)
int getRGB (int ind, float &red, float &grn, float &blu)
int getIRGB (int ind, int &red, int &grn, int &blu)
int setValue (int ind, int val)
int getValue (int ind)
int getValue (const char *name)
int getNumFill ()
bool isColorNear (int ind, RGB &rgb)
int setNumFill (int nfill)
int print ()

Static Public Member Functions

static bool isColor (int a)

Static Public Attributes

static const int BACK = -1
static const int OFF = -1
static const int END = -2

Detailed Description

This class defines a specific color map. This is a mapping between color indices, color names and RGB values.

Author:
Dan Vietor

Constructor & Destructor Documentation

ColorMap::ColorMap (  ) 

Constructor. Initializes and sets map size to 256 colors.

References init().

ColorMap::ColorMap ( int  size  ) 

Constructor. Initializes and sets map size.

Parameters:
size Sets the size of color map.

References init().

ColorMap::ColorMap ( const ColorMap color  ) 

Copy contructor.

Parameters:
color Class to copy from.
ColorMap::~ColorMap (  ) 

Destructor. Deallocates the color map.


Member Function Documentation

int ColorMap::add ( const char *  name,
float  red,
float  grn,
float  blu 
)

Adds a new color to the color map

Parameters:
name String describing the color
red Number from 0 to 1 representing red intensity
grn Number from 0 to 1 representing green intensity
blu Number from 0 to 1 representing blue intensity

References WXP::Color::blu, WXP::StrLib::equal(), WXP::Color::grn, WXP::Wxp::outDebug(), WXP::Wxp::outWarning(), and WXP::Color::red.

Referenced by WXP::Plot::allocColor(), getInd(), WXP::ColorFile::readFile(), and WXP::Plot::setColorMap().

int ColorMap::get ( int  ind,
RGB rgb 
)

Gets the red, green, blue values for a particular color index

Parameters:
ind The color map index
Return values:
rgb The RGB values (0-1)

References BACK, WXP::Color::blu, WXP::RGB::blu, WXP::Color::grn, WXP::RGB::grn, WXP::Color::red, and WXP::RGB::red.

Referenced by WXP::Plot::allocColor().

int ColorMap::getInd ( const char *  name  ) 

Gets the index in the colormap of the specified color

Parameters:
name The name of the color (ie red)

References add(), BACK, END, WXP::StrLib::iequal(), and OFF.

Referenced by getValue(), WXP::Plot::setFill(), WXP::Plot::setFillColor(), WXP::Plot::setLine(), WXP::Plot::setLineColor(), and WXP::Plot::setTextColor().

int ColorMap::getIRGB ( int  ind,
int &  red,
int &  grn,
int &  blu 
)

Gets the integral red, green, blue values for a particular color index

Parameters:
ind The color map index
Return values:
red The red value (0-255)
grn The green value (0-255)
blu The blue value (0-255)

References BACK.

int WXP::ColorMap::getMax (  )  [inline]

Gets the maximum number of colors allowed in colormap.

Referenced by WXP::ColorFile::readFile().

const char * ColorMap::getName ( int  ind  ) 

Gets the color name given the index

Parameters:
ind The color map index
Returns:
The color name string

References WXP::Color::name.

Referenced by WXP::Plot::allocColor(), WXP::ColorFill::set(), and WXP::Plot::setColorMap().

int WXP::ColorMap::getNum (  )  [inline]

Gets the number of allocated colors.

Referenced by WXP::Plot::allocColor(), WXP::ColorFile::read(), WXP::ColorFile::readFile(), and WXP::Plot::setColorMap().

int WXP::ColorMap::getNumFill (  )  [inline]

Gets the number of colors used in color fill.

Referenced by WXP::ColorFile::read(), WXP::ColorFile::readFile(), and WXP::ColorFill::set().

int ColorMap::getRGB ( int  ind,
float &  red,
float &  grn,
float &  blu 
)

Gets the red, green, blue values for a particular color index

Parameters:
ind The color map index
Return values:
red The red value (0-1)
grn The green value (0-1)
blu The blue value (0-1)

References BACK, WXP::Color::blu, WXP::Color::grn, and WXP::Color::red.

Referenced by WXP::Plot::setColorMap().

int ColorMap::getValue ( const char *  name  ) 

gets the device specific color value given a name

Parameters:
name The color name
Returns:
The device specific color value

References getInd(), and getValue().

int ColorMap::getValue ( int  ind  ) 

Gets the device specific color value

Parameters:
ind The color map index
Returns:
The device specific color value

References WXP::Color::value.

Referenced by getValue(), WXP::Plot::setFill(), WXP::Plot::setFillColor(), WXP::Plot::setLine(), WXP::Plot::setLineColor(), WXP::Plot::setMark(), WXP::Plot::setText(), and WXP::Plot::setTextColor().

int ColorMap::init ( int  size  ) 

Initializes the color map and sets the map size.

Parameters:
size The size of the color map.

Referenced by ColorMap(), and WXP::ColorFile::readFile().

static bool WXP::ColorMap::isColor ( int  a  )  [inline, static]
ColorMap & ColorMap::operator= ( const ColorMap color  ) 

Assignment operator.

Parameters:
color Class to copy from.
int ColorMap::print (  ) 

Prints class data to standard output.

int ColorMap::set ( const ColorMap color  ) 

Sets the values of the colormap from another colormap

Parameters:
color Class to copy from.

Referenced by WXP::Plot::setColorMap().

int ColorMap::setNumFill ( int  nfill  ) 

Sets the number of values to use in color fill. The first nfill colors will be used as a default color fill palette.

Parameters:
nfill The number of color values to use.

Referenced by WXP::ColorFile::read(), and WXP::ColorFile::readFile().

int ColorMap::setValue ( int  ind,
int  val 
)

Sets the color index value (device specific)

Parameters:
ind The color map index
val The device specific color value

References WXP::Color::value.

Referenced by WXP::Plot::allocColor(), and WXP::Plot::setColorMap().


Member Data Documentation

const int WXP::ColorMap::BACK = -1 [static]

Special index for background color

Referenced by get(), getInd(), getIRGB(), and getRGB().

const int WXP::ColorMap::END = -2 [static]

Special index for end of colors

Referenced by getInd().

const int WXP::ColorMap::OFF = -1 [static]

Special index for no color

Referenced by getInd().


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

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1