WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
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"

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() [1/3]

ColorMap::ColorMap ( )

Constructor. Initializes and sets map size to 256 colors.

References init().

Referenced by ColorMap(), operator=(), and set().

◆ ColorMap() [2/3]

ColorMap::ColorMap ( int size)

Constructor. Initializes and sets map size.

Parameters
sizeSets the size of color map.

References init().

◆ ColorMap() [3/3]

ColorMap::ColorMap ( const ColorMap & color)

Copy contructor.

Parameters
colorClass to copy from.

References ColorMap(), and set().

◆ ~ColorMap()

ColorMap::~ColorMap ( )

Destructor. Deallocates the color map.

Member Function Documentation

◆ add() [1/2]

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

Adds a new color to the color map

Parameters
nameString describing the color
redNumber from 0 to 1 representing red intensity
grnNumber from 0 to 1 representing green intensity
bluNumber from 0 to 1 representing blue intensity

References WXP::StrLib::equal(), and WXP::Wxp::outWarning().

Referenced by add(), getInd(), and WXP::ColorFile::readFile().

◆ add() [2/2]

int ColorMap::add ( const char * name,
RGB & rgb )

Adds a new color to the color map

Parameters
nameString describing the color
rgbRGB structure holding color info

References add(), WXP::RGB::blu, WXP::RGB::grn, and WXP::RGB::red.

◆ get()

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

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

Parameters
indThe color map index
Return values
rgbThe RGB values (0-1)

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

Referenced by WXP::ImageTool::addColor(), WXP::DatumPlot::draw(), WXP::Lev2Plot::draw(), WXP::LightPlot::draw(), WXP::VectPlot::draw(), WXP::ContPlot::drawFill(), WXP::ImagePlot::drawImage(), WXP::ContPlot::drawLine(), WXP::ContPlot::drawValues(), and WXP::ImageMath::toIndex().

◆ getInd()

int ColorMap::getInd ( const char * name)

Gets the index in the colormap of the specified color

Parameters
nameThe name of the color (ie red)

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

Referenced by getValue().

◆ getIRGB()

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

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

Parameters
indThe color map index
Return values
redThe red value (0-255)
grnThe green value (0-255)
bluThe blue value (0-255)

References BACK.

◆ getMax()

int WXP::ColorMap::getMax ( )
inline

Gets the maximum number of colors allowed in colormap.

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

◆ getName()

const char * ColorMap::getName ( int ind)

Gets the color name given the index

Parameters
indThe color map index
Returns
The color name string

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

◆ getNum()

int WXP::ColorMap::getNum ( )
inline

◆ getNumFill()

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().

◆ getRGB()

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

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

Parameters
indThe color map index
Return values
redThe red value (0-1)
grnThe green value (0-1)
bluThe blue value (0-1)

References BACK.

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

◆ getValue() [1/2]

int ColorMap::getValue ( const char * name)

gets the device specific color value given a name

Parameters
nameThe color name
Returns
The device specific color value

References getInd(), and getValue().

◆ getValue() [2/2]

int ColorMap::getValue ( int ind)

Gets the device specific color value

Parameters
indThe color map index
Returns
The device specific color value

Referenced by getValue().

◆ init() [1/2]

int ColorMap::init ( )

Initializes the color map

Referenced by ColorMap(), and ColorMap().

◆ init() [2/2]

int ColorMap::init ( int size)

Initializes the color map and sets the map size.

Parameters
sizeThe size of the color map.

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

◆ isColor()

◆ isColorNear()

bool ColorMap::isColorNear ( int ind,
RGB & rgb )

Determines if a color is near a specific color in map

Parameters
indIndex of color to test
rgbColor to test

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

◆ operator=()

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

Assignment operator.

Parameters
colorClass to copy from.

References ColorMap(), and set().

◆ print()

int ColorMap::print ( )

Prints class data to standard output.

◆ set()

int ColorMap::set ( const ColorMap & color)

Sets the values of the colormap from another colormap

Parameters
colorClass to copy from.

References ColorMap().

Referenced by ColorMap(), WXP::DatumPlot::draw(), WXP::ContPlot::drawFill(), WXP::ImagePlot::drawImage(), WXP::ContPlot::drawLine(), WXP::ContPlot::drawValues(), and operator=().

◆ setNumFill()

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
nfillThe number of color values to use.

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

◆ setValue()

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

Sets the color index value (device specific)

Parameters
indThe color map index
valThe device specific color value

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

Member Data Documentation

◆ BACK

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

Special index for background color

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

◆ END

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

Special index for end of colors

Referenced by getInd().

◆ OFF

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: