WXP C++ Library Version 6.74.9
|
This class defines a specific color map. This is a mapping between color indices, color names and RGB values. More...
#include "../include/ColorMap.h"
Public Member Functions | |
ColorMap () | |
ColorMap (int size) | |
ColorMap (const ColorMap &color) | |
ColorMap & | operator= (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 |
This class defines a specific color map. This is a mapping between color indices, color names and RGB values.
ColorMap::ColorMap | ( | ) |
Constructor. Initializes and sets map size to 256 colors.
References init().
ColorMap::ColorMap | ( | int | size | ) |
Constructor. Initializes and sets map size.
size | Sets the size of color map. |
References init().
ColorMap::ColorMap | ( | const ColorMap & | color | ) |
ColorMap::~ColorMap | ( | ) |
Destructor. Deallocates the color map.
int ColorMap::add | ( | const char * | name, |
float | red, | ||
float | grn, | ||
float | blu | ||
) |
Adds a new color to the color map
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::outWarning(), and WXP::Color::red.
Referenced by add(), getInd(), WXP::ColorFile::readFile(), and WXP::Plot::setColorMap().
int ColorMap::add | ( | const char * | name, |
RGB & | rgb | ||
) |
Adds a new color to the color map
References add(), WXP::RGB::blu, WXP::RGB::grn, and WXP::RGB::red.
int ColorMap::get | ( | int | ind, |
RGB & | rgb | ||
) |
Gets the red, green, blue values for a particular color index
ind | The color map index |
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::ImageTool::addColor(), WXP::Plot::allocColor(), and WXP::ImageMath::toIndex().
int ColorMap::getInd | ( | const char * | name | ) |
Gets the index in the colormap of the specified color
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
ind | The color map index |
red | The red value (0-255) |
grn | The green value (0-255) |
blu | The blue value (0-255) |
References BACK.
|
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
ind | The color map index |
References WXP::Color::name.
Referenced by WXP::ColorFill::set(), and WXP::Plot::setColorMap().
|
inline |
Gets the number of allocated colors.
Referenced by WXP::Plot::allocColor(), WXP::ColorFile::read(), WXP::ColorFile::readFile(), WXP::Plot::setColorMap(), and WXP::ImageMath::toIndex().
|
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
ind | The color map index |
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
name | The color name |
References getInd(), and getValue().
int ColorMap::getValue | ( | int | ind | ) |
Gets the device specific color value
ind | The color map index |
References WXP::Color::value.
Referenced by getValue(), WXP::Plot::setFill(), WXP::Plot::setFill(), WXP::Plot::setFillColor(), WXP::Plot::setFillColor(), WXP::Plot::setLine(), WXP::Plot::setLine(), WXP::Plot::setLineColor(), WXP::Plot::setLineColor(), WXP::Plot::setMark(), WXP::Plot::setText(), WXP::Plot::setTextColor(), and WXP::Plot::setTextColor().
int ColorMap::init | ( | ) |
Initializes the color map
Referenced by ColorMap(), and ColorMap().
int ColorMap::init | ( | int | size | ) |
Initializes the color map and sets the map size.
size | The size of the color map. |
Referenced by WXP::ColorFile::readFile().
|
inlinestatic |
Is a valid color
Referenced by WXP::Plot::drawCircle(), WXP::Plot::drawCircle(), WXP::Plot::drawFill(), WXP::Plot::drawFill(), WXP::Plot::drawFormText(), WXP::Plot::drawLine(), WXP::Plot::drawLine(), WXP::Plot::drawLine(), WXP::Plot::drawLine(), WXP::Plot::drawMark(), WXP::Plot::drawMark(), WXP::Plot::drawRect(), WXP::Plot::drawRect(), WXP::Plot::drawSpline(), WXP::Plot::drawText(), WXP::Plot::setFill(), WXP::Plot::setFillColor(), WXP::Plot::setFillColor(), WXP::Plot::setLine(), WXP::Plot::setLineColor(), WXP::Plot::setLineColor(), WXP::Plot::setTextColor(), and WXP::Plot::setTextColor().
bool ColorMap::isColorNear | ( | int | ind, |
RGB & | rgb | ||
) |
Determines if a color is near a specific color in map
ind | Index of color to test |
rgb | Color to test |
References WXP::Color::blu, WXP::RGB::blu, WXP::Color::grn, WXP::RGB::grn, WXP::Color::red, and WXP::RGB::red.
int ColorMap::print | ( | ) |
Prints class data to standard output.
int ColorMap::set | ( | const ColorMap & | color | ) |
Sets the values of the colormap from another colormap
color | Class to copy from. |
Referenced by ColorMap(), and operator=().
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.
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)
ind | The color map index |
val | The device specific color value |
References WXP::Color::value.
Referenced by WXP::Plot::allocColor(), and WXP::Plot::setColorMap().
|
static |
|
static |
Special index for end of colors
Referenced by getInd().
|
static |
Special index for no color
Referenced by getInd().