VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
vtkNamedColors Class Reference

A class holding colors and their names. More...

#include <vtkNamedColors.h>

Inheritance diagram for vtkNamedColors:
[legend]
Collaboration diagram for vtkNamedColors:
[legend]

Public Types

typedef vtkObject Superclass
 
- Public Types inherited from vtkObject
typedef vtkObjectBase Superclass
 

Public Member Functions

virtual int IsA (const char *type)
 
vtkNamedColorsNewInstance () const
 
virtual void PrintSelf (ostream &os, vtkIndent indent)
 
int GetNumberOfColors ()
 
void ResetColors ()
 
bool ColorExists (const vtkStdString &name)
 
vtkColor4ub GetColor4ub (const vtkStdString &name)
 
void GetColor (const vtkStdString &name, unsigned char rgba[4])
 
void GetColor (const vtkStdString &name, vtkColor4ub &rgba)
 
vtkColor4d GetColor4d (const vtkStdString &name)
 
void GetColor (const vtkStdString &name, double rgba[4])
 
void GetColor (const vtkStdString &name, vtkColor4d &rgba)
 
vtkColor3ub GetColor3ub (const vtkStdString &name)
 
vtkColor3d GetColor3d (const vtkStdString &name)
 
void GetColorRGB (const vtkStdString &name, double rgb[3])
 
void GetColor (const vtkStdString &name, vtkColor3ub &rgb)
 
void GetColor (const vtkStdString &name, vtkColor3d &rgb)
 
virtual void SetColor (const vtkStdString &name, const unsigned char rgba[4])
 
virtual void SetColor (const vtkStdString &name, const vtkColor4ub &rgba)
 
virtual void SetColor (const vtkStdString &name, const vtkColor3ub &rgb)
 
virtual void SetColor (const vtkStdString &name, const double rgba[4])
 
virtual void SetColor (const vtkStdString &name, const vtkColor4d &rgba)
 
virtual void SetColor (const vtkStdString &name, const vtkColor3d &rgb)
 
void RemoveColor (const vtkStdString &name)
 
vtkStdString GetColorNames ()
 
void GetColorNames (vtkStringArray *colorNames)
 
vtkStdString GetSynonyms ()
 
vtkColor4ub HTMLColorToRGBA (const vtkStdString &colorString)
 
vtkColor3ub HTMLColorToRGB (const vtkStdString &colorString)
 
vtkStdString RGBToHTMLColor (const vtkColor3ub &rgb)
 
vtkStdString RGBAToHTMLColor (const vtkColor4ub &rgba)
 
void SetColor (const vtkStdString &name, const vtkStdString &htmlString)
 
void GetColor (const vtkStdString &name, unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a)
 
void GetColor (const vtkStdString &name, double &r, double &g, double &b, double &a)
 
void GetColor (const vtkStdString &name, double &r, double &g, double &b)
 
virtual void SetColor (const vtkStdString &name, const unsigned char &r, const unsigned char &g, const unsigned char &b, const unsigned char &a=255)
 
virtual void SetColor (const vtkStdString &name, const double &r, const double &g, const double &b, const double &a=1)
 
- Public Member Functions inherited from vtkObject
vtkObjectNewInstance () const
 
virtual void DebugOn ()
 
virtual void DebugOff ()
 
bool GetDebug ()
 
void SetDebug (bool debugFlag)
 
virtual void Modified ()
 
virtual unsigned long GetMTime ()
 
unsigned long AddObserver (unsigned long event, vtkCommand *, float priority=0.0f)
 
unsigned long AddObserver (const char *event, vtkCommand *, float priority=0.0f)
 
vtkCommandGetCommand (unsigned long tag)
 
void RemoveObserver (vtkCommand *)
 
void RemoveObservers (unsigned long event, vtkCommand *)
 
void RemoveObservers (const char *event, vtkCommand *)
 
int HasObserver (unsigned long event, vtkCommand *)
 
int HasObserver (const char *event, vtkCommand *)
 
void RemoveObserver (unsigned long tag)
 
void RemoveObservers (unsigned long event)
 
void RemoveObservers (const char *event)
 
void RemoveAllObservers ()
 
int HasObserver (unsigned long event)
 
int HasObserver (const char *event)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, void(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
template<class U , class T >
unsigned long AddObserver (unsigned long event, U observer, bool(T::*callback)(vtkObject *, unsigned long, void *), float priority=0.0f)
 
int InvokeEvent (unsigned long event, void *callData)
 
int InvokeEvent (const char *event, void *callData)
 
int InvokeEvent (unsigned long event)
 
int InvokeEvent (const char *event)
 
- Public Member Functions inherited from vtkObjectBase
const char * GetClassName () const
 
virtual void Delete ()
 
virtual void FastDelete ()
 
void Print (ostream &os)
 
virtual void Register (vtkObjectBase *o)
 
virtual void UnRegister (vtkObjectBase *o)
 
void SetReferenceCount (int)
 
void PrintRevisions (ostream &)
 
virtual void PrintHeader (ostream &os, vtkIndent indent)
 
virtual void PrintTrailer (ostream &os, vtkIndent indent)
 
int GetReferenceCount ()
 

Static Public Member Functions

static int IsTypeOf (const char *type)
 
static vtkNamedColorsSafeDownCast (vtkObjectBase *o)
 
static vtkNamedColorsNew ()
 
- Static Public Member Functions inherited from vtkObject
static int IsTypeOf (const char *type)
 
static vtkObjectSafeDownCast (vtkObjectBase *o)
 
static vtkObjectNew ()
 
static void BreakOnError ()
 
static void SetGlobalWarningDisplay (int val)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static int GetGlobalWarningDisplay ()
 
- Static Public Member Functions inherited from vtkObjectBase
static int IsTypeOf (const char *name)
 
static vtkObjectBaseNew ()
 

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 
 vtkNamedColors ()
 
virtual ~vtkNamedColors ()
 
- Protected Member Functions inherited from vtkObject
 vtkObject ()
 
virtual ~vtkObject ()
 
virtual void RegisterInternal (vtkObjectBase *, int check)
 
virtual void UnRegisterInternal (vtkObjectBase *, int check)
 
void InternalGrabFocus (vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
 
void InternalReleaseFocus ()
 
- Protected Member Functions inherited from vtkObjectBase
 vtkObjectBase ()
 
virtual ~vtkObjectBase ()
 
virtual void CollectRevisions (ostream &)
 
virtual void ReportReferences (vtkGarbageCollector *)
 
 vtkObjectBase (const vtkObjectBase &)
 
void operator= (const vtkObjectBase &)
 

Additional Inherited Members

- Protected Attributes inherited from vtkObject
bool Debug
 
vtkTimeStamp MTime
 
vtkSubjectHelper * SubjectHelper
 
- Protected Attributes inherited from vtkObjectBase
vtkAtomicInt32 ReferenceCount
 
vtkWeakPointerBase ** WeakPointers
 

Detailed Description

A class holding colors and their names.

vtkNamedColors is class that holds colors and their associated names.

Color names are case insensitive and are stored as lower-case names along with a 4-element array whose elements are red, green, blue and alpha, in that order, corresponding to the RGBA value of the color.

It is assumed that if the RGBA values are unsigned char then each element lies in the range 0...255 and if the RGBA values are double then each element lies in the range 0...1.

The colors and names are those in http://en.wikipedia.org/wiki/Web_colors that are derived from the CSS3 specification: http://www.w3.org/TR/css3-color/#svg-color In this table common synonyms such as cyan/aqua and magenta/fuchsia are also included.

Also included in this class are names and colors taken from Wrapping/Tcl/vtktesting/colors.tcl and Wrapping/Python/vtk/util/colors.py.

Web colors and names in http://en.wikipedia.org/wiki/Web_colors take precedence over those in colors.tcl and colors.py. One consequence of this is that while colors.py and colors.tcl specify green as equivalent to (0,255,0), the web color standard defines it as (0,128,0).

For a web page of VTK Named Colors and their RGB values, see: http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/VTKNamedColorPatches_html .

The code used to generate this table is available from: http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/NamedColorPatches , this is useful if you wish to generate your own table.

The SetColor methods will overwrite existing colors if the name of the color being set matches an existing color. Note that ColorExists() can be used to test for existence of the color being set.

In the case of the GetColor methods returning doubles, alternative versions, identified by the letters RGB in the names, are provided. These get functions return just the red, green and blue components of a color.

The class also provides methods for defining a color through an HTML color string. The following formats are supported:

Definition at line 83 of file vtkNamedColors.h.

Member Typedef Documentation

Definition at line 86 of file vtkNamedColors.h.

Constructor & Destructor Documentation

vtkNamedColors::vtkNamedColors ( )
protected
virtual vtkNamedColors::~vtkNamedColors ( )
protectedvirtual

Member Function Documentation

static int vtkNamedColors::IsTypeOf ( const char *  type)
static
virtual int vtkNamedColors::IsA ( const char *  name)
virtual

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

static vtkNamedColors* vtkNamedColors::SafeDownCast ( vtkObjectBase o)
static
virtual vtkObjectBase* vtkNamedColors::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkObject.

vtkNamedColors* vtkNamedColors::NewInstance ( ) const
virtual void vtkNamedColors::PrintSelf ( ostream &  os,
vtkIndent  indent 
)
virtual

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

static vtkNamedColors* vtkNamedColors::New ( )
static

Create a new vtkNamedColors object.

int vtkNamedColors::GetNumberOfColors ( )

Get the number of colors.

void vtkNamedColors::ResetColors ( )

Reset the colors in the color map to the original colors. Any colors inserted by the user will be lost.

bool vtkNamedColors::ColorExists ( const vtkStdString name)

Return true if the color exists.

vtkColor4ub vtkNamedColors::GetColor4ub ( const vtkStdString name)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor4ub class. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
unsigned char &  r,
unsigned char &  g,
unsigned char &  b,
unsigned char &  a 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as four unsigned char variables: red, green, blue, alpha. The range of each element is 0...255. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
unsigned char  rgba[4] 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as an unsigned char array: [red, green, blue, alpha]. The range of each element is 0...255. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
vtkColor4ub rgba 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor4ub class. The color black is returned if the color is not found.

vtkColor4d vtkNamedColors::GetColor4d ( const vtkStdString name)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor4d class. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
double r,
double g,
double b,
double a 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as four double variables: red, green, blue, alpha. The range of each element is 0...1. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
double  rgba[4] 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a double array: [red, green, blue, alpha]. The range of each element is 0...1. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
vtkColor4d rgba 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor4d class. The color black is returned if the color is not found.

vtkColor3ub vtkNamedColors::GetColor3ub ( const vtkStdString name)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor3ub class. The color black is returned if the color is not found.

vtkColor3d vtkNamedColors::GetColor3d ( const vtkStdString name)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor3d class. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
double r,
double g,
double b 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as three double variables: red, green, blue. The range of each element is 0...1. The color black is returned if the color is not found.

void vtkNamedColors::GetColorRGB ( const vtkStdString name,
double  rgb[3] 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a double array: [red, green, blue]. The range of each element is 0...1. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
vtkColor3ub rgb 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor3ub class. The color black is returned if the color is not found.

void vtkNamedColors::GetColor ( const vtkStdString name,
vtkColor3d rgb 
)

Get the color by name. The name is treated as being case-insensitive. The color is returned as a vtkColor3d class. The color black is returned if the color is not found.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const unsigned char &  r,
const unsigned char &  g,
const unsigned char &  b,
const unsigned char &  a = 255 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The range of each color is 0...255. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const double r,
const double g,
const double b,
const double a = 1 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The range of each color is 0...1. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const unsigned char  rgba[4] 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is an unsigned char array: [red, green, blue, alpha]. The range of each element is 0...255. The user must ensure that the color array size is 4. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const vtkColor4ub rgba 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is a vtkColor4ub class. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const vtkColor3ub rgb 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is a vtkColor3ub class. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const double  rgba[4] 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is a double array: [red, green, blue, alpha]. The range of each element is 0...1. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const vtkColor4d rgba 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is a vtkColor4d class. No color is set if the name is empty.

virtual void vtkNamedColors::SetColor ( const vtkStdString name,
const vtkColor3d rgb 
)
virtual

Set the color by name. The name is treated as being case-insensitive. The color is a vtkColor3d class. No color is set if the name is empty.

void vtkNamedColors::RemoveColor ( const vtkStdString name)

Remove the color by name. The name is treated as being case-insensitive. Examples for parsing are provided in: TestNamedColors.cxx and TestNamedColorsIntegration.py

vtkStdString vtkNamedColors::GetColorNames ( )

Return a string of color names with each name delimited by a line feed. This is easily parsed by the user into whatever data structure they require. Examples for parsing are provided in: TestNamedColors.cxx and TestNamedColorsIntegration.py

void vtkNamedColors::GetColorNames ( vtkStringArray colorNames)

Return a string array of color names.

vtkStdString vtkNamedColors::GetSynonyms ( )

Return a string of synonyms such as cyan/aqua and magenta/fuchsia. The string is formatted such that a single line feed delimits each color in the synonym and a double line feed delimits each synonym. Warning this could take a long time for very large color maps. This is easily parsed by the user into whatever data structure they require.

vtkColor4ub vtkNamedColors::HTMLColorToRGBA ( const vtkStdString colorString)

Return a vtkColor4ub instance from an HTML color string in any of the following formats: - #RGB - #RRGGBB - rgb(r, g, b) - rgba(r, g, b, a)

  • a CSS3 color name, e.g. "steelblue" If the string argument defines a color using one of the above formats the method returns the successfully parsed color else returns a color equal to rgba(0, 0, 0, 0).
vtkColor3ub vtkNamedColors::HTMLColorToRGB ( const vtkStdString colorString)

Return a vtkColor3ub instance from an HTML color string in any of the following formats: - #RGB - #RRGGBB - rgb(r, g, b) - rgba(r, g, b, a)

  • a CSS3 color name, e.g. "steelblue" If the string argument defines a color using one of the above formats the method returns the successfully parsed color else returns the color black.
vtkStdString vtkNamedColors::RGBToHTMLColor ( const vtkColor3ub rgb)

Given a vtkColor3ub instance as input color return a valid HTML color string in the #RRGGBB format.

vtkStdString vtkNamedColors::RGBAToHTMLColor ( const vtkColor4ub rgba)

Given a vtkColor4ub instance as input color return a valid HTML color string in the rgba(r, g, b, a) format.

void vtkNamedColors::SetColor ( const vtkStdString name,
const vtkStdString htmlString 
)

Set the color by name. The name is treated as being case-insensitive. The color must be a valid HTML color string. No color is set if the name is empty or if htmlString is not a valid HTML color string.


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