A Color class for creating the color object following the standard RGB color space. More...
#include <Color.h>
Public Types | |
enum | Value { red, green, blue, yellow, orange, cyan, magenta, black, darkgray, lightgray, white } |
A few common colors. More... |
Public Member Functions | |
Color (int red=0, int green=0, int blue=0) | |
The following constructor takes red, green, and blue components as | |
Color (Color::Value value) | |
A constructor using Color::Value to set the color. | |
Color (const std::string &name) | |
A constructor using a name to set the color. | |
int | getBlue () const |
int | getGreen () const |
int | getRed () const |
bool | operator== (Color c) |
void | setColor (const std::string &) |
Sets the color. | |
void | setColor (int red=0, int green=0, int blue=0) |
Sets the color. | |
void | setColor (Color::Value value) |
Sets the color. |
Static Public Member Functions | |
static void | addColor (const char *name, const Color &color) |
Adds a named color to the color by name map. | |
static const std::vector < std::string > & | colorNames () |
Returns the list of color names. | |
static Color::Value | getColor () |
Instead of getting a random color, this static method loop over the 5 common colors: red, green, blue, magenta and orange. | |
static bool | isValid (const std::string &name) |
Returns true if name is a valid color. |
Static Public Attributes | |
static int | colorIndex = 0 |
Color index for composite plotter. |
Private Types | |
typedef std::map< std::string, Color > | ColorMapByName_t |
The type of container mapping string to Color object. |
Static Private Member Functions | |
static void | initColorByNameMap () |
Initializes the mapping of a name to Color object. |
Private Attributes | |
int | m_blue |
The blue component of the color. | |
int | m_green |
The green component of the color. | |
int | m_red |
The red component of the color. |
Static Private Attributes | |
static ColorMapByName_t | s_color_by_name |
The color by name map. | |
static std::vector< std::string > | s_color_names |
The list of available color names. |
A Color class for creating the color object following the standard RGB color space.
This class represents color in a way similar to color classes of GUI tool kits such as Java and Qt. It should, thus, be straight-forward to convert from one to the other.
The compiler-generated copy constructor, destructor, and assignment operator are all valid and, thus, not explicitly implemented.
|
private |
enum Value |
A few common colors.
A few common colors for use by clients.
|
explicit |
|
explicit |
A constructor using Color::Value to set the color.
Definition at line 30 of file Color.cxx.
References Color::setColor().
|
explicit |
A constructor using a name to set the color.
A constructor using a name to set the color. The name must match one of the values of the Color::Value enumeration, otherwise the color is set to Color::black.
Definition at line 105 of file Color.cxx.
References Color::setColor().
|
static |
Adds a named color to the color by name map.
Definition at line 37 of file Color.cxx.
References Color::s_color_by_name.
Referenced by Color::initColorByNameMap().
|
static |
Returns the list of color names.
Definition at line 144 of file Color.cxx.
References Color::s_color_by_name, and Color::s_color_names.
int getBlue | ( | ) | const |
Definition at line 174 of file Color.cxx.
References Color::m_blue.
Referenced by Inspector::colorSelect_clicked(), ColorXML::createElement(), QtViewImp::createPen(), BinToGreyScale::doubleToColor(), BinToBlack::doubleToColor(), BinToLineStyle::doubleToColor(), BinToGamma::doubleToColor(), OpenGLView::drawColorLines(), QtViewImp::drawColorLines(), AxisRepColor::drawColorScale(), CutRangeRep::drawInvertedRange1D(), CutRangeRep::drawInvertedRange2D(), OpenGLView::drawLines(), CutRangeRep::drawNormalRange(), OpenGLView::drawPoints(), QtViewImp::drawPoints(), QtViewImp::drawPolygon(), OpenGLView::drawPolyLine(), ColorBoxPointRep::drawProjectedValues(), QtViewImp::drawText(), FilledColumnPointRep::drawValues(), OpenGLView::drawViewLines(), Color::operator==(), EpsView::setRgbColor(), and Inspector::updatePlotTab().
|
static |
Instead of getting a random color, this static method loop over the 5 common colors: red, green, blue, magenta and orange.
Definition at line 181 of file Color.cxx.
References Color::blue, Color::colorIndex, Color::green, Color::magenta, Color::orange, and Color::red.
Referenced by Inspector::addDataRepButton_clicked().
int getGreen | ( | ) | const |
Definition at line 169 of file Color.cxx.
References Color::m_green.
Referenced by Inspector::colorSelect_clicked(), ColorXML::createElement(), QtViewImp::createPen(), BinToGreyScale::doubleToColor(), BinToBlack::doubleToColor(), BinToLineStyle::doubleToColor(), BinToGamma::doubleToColor(), OpenGLView::drawColorLines(), QtViewImp::drawColorLines(), AxisRepColor::drawColorScale(), CutRangeRep::drawInvertedRange1D(), CutRangeRep::drawInvertedRange2D(), OpenGLView::drawLines(), CutRangeRep::drawNormalRange(), OpenGLView::drawPoints(), QtViewImp::drawPoints(), QtViewImp::drawPolygon(), OpenGLView::drawPolyLine(), ColorBoxPointRep::drawProjectedValues(), QtViewImp::drawText(), FilledColumnPointRep::drawValues(), OpenGLView::drawViewLines(), Color::operator==(), EpsView::setRgbColor(), and Inspector::updatePlotTab().
int getRed | ( | ) | const |
Definition at line 164 of file Color.cxx.
References Color::m_red.
Referenced by Inspector::colorSelect_clicked(), ColorXML::createElement(), QtViewImp::createPen(), BinToGreyScale::doubleToColor(), BinToBlack::doubleToColor(), BinToLineStyle::doubleToColor(), BinToGamma::doubleToColor(), OpenGLView::drawColorLines(), QtViewImp::drawColorLines(), AxisRepColor::drawColorScale(), CutRangeRep::drawInvertedRange1D(), CutRangeRep::drawInvertedRange2D(), OpenGLView::drawLines(), CutRangeRep::drawNormalRange(), OpenGLView::drawPoints(), QtViewImp::drawPoints(), QtViewImp::drawPolygon(), OpenGLView::drawPolyLine(), ColorBoxPointRep::drawProjectedValues(), QtViewImp::drawText(), FilledColumnPointRep::drawValues(), OpenGLView::drawViewLines(), Color::operator==(), EpsView::setRgbColor(), and Inspector::updatePlotTab().
|
staticprivate |
Initializes the mapping of a name to Color object.
Definition at line 89 of file Color.cxx.
References Color::addColor().
Referenced by Color::isValid().
|
static |
Returns true
if name is a valid color.
Definition at line 131 of file Color.cxx.
References Color::initColorByNameMap(), and Color::s_color_by_name.
Referenced by Color::setColor().
bool operator== | ( | Color | c | ) |
Definition at line 202 of file Color.cxx.
References Color::getBlue(), Color::getGreen(), Color::getRed(), Color::m_blue, Color::m_green, and Color::m_red.
void setColor | ( | const std::string & | name | ) |
Sets the color.
Sets the color by one of the known color names. If the name is not found in the color map, then sets the color to black.
Definition at line 112 of file Color.cxx.
References Color::isValid(), Color::m_blue, Color::m_green, Color::m_red, and Color::s_color_by_name.
Referenced by Color::Color(), ColorXML::createObject(), BinToKamaeScale::doubleToColor(), BinToGreyScale::doubleToColor(), BinToBlack::doubleToColor(), BinTo3ColorScale::doubleToColor(), BinToLineStyle::doubleToColor(), BinToGamma::doubleToColor(), BinToMovingBrkPt::doubleToColor(), BinToFullColorScale::doubleToColor(), BinToUsrDefinedScale::doubleToColor(), BinToColorScaleMovingBrkPt::doubleToColor(), BinToColorMap::doubleToColor(), and Color::setColor().
void setColor | ( | int | red = 0 , |
int | green = 0 , |
||
int | blue = 0 |
||
) |
Sets the color.
Definition at line 157 of file Color.cxx.
References Color::blue, Color::green, Color::m_blue, Color::m_green, Color::m_red, and Color::red.
void setColor | ( | Color::Value | value | ) |
Sets the color.
Definition at line 45 of file Color.cxx.
References Color::black, Color::blue, Color::cyan, Color::darkgray, Color::green, Color::lightgray, Color::magenta, Color::orange, Color::red, Color::setColor(), Color::white, and Color::yellow.
|
static |
Color index for composite plotter.
Definition at line 137 of file Color.h.
Referenced by Color::getColor().
|
private |
The blue component of the color.
Definition at line 75 of file Color.h.
Referenced by Color::getBlue(), Color::operator==(), and Color::setColor().
|
private |
The green component of the color.
Definition at line 72 of file Color.h.
Referenced by Color::getGreen(), Color::operator==(), and Color::setColor().
|
private |
The red component of the color.
Definition at line 69 of file Color.h.
Referenced by Color::getRed(), Color::operator==(), and Color::setColor().
|
staticprivate |
The color by name map.
Definition at line 62 of file Color.h.
Referenced by Color::addColor(), Color::colorNames(), Color::isValid(), and Color::setColor().
|
staticprivate |
The list of available color names.
Definition at line 66 of file Color.h.
Referenced by Color::colorNames().