VTK
vtkNamedColors.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkNamedColors.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
72 #ifndef vtkNamedColors_h
73 #define vtkNamedColors_h
74 
75 #include "vtkCommonColorModule.h" // For export macro
76 #include "vtkObject.h"
77 #include "vtkColor.h" // Needed for vtkColor[34]ub
78 #include "vtkStdString.h" // Needed for arguments
79 #include "vtkStringArray.h" // For returning color names
80 
81 class vtkNamedColorsDataStore;
82 class vtkColorStringParser;
83 
84 class VTKCOMMONCOLOR_EXPORT vtkNamedColors : public vtkObject
85 {
86 public:
87  vtkTypeMacro(vtkNamedColors, vtkObject);
88 
95  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
96 
100  static vtkNamedColors* New();
101 
106 
111  void ResetColors();
112 
117 
125 
133  void GetColor(const vtkStdString & name,
134  unsigned char & r, unsigned char & g,
135  unsigned char & b, unsigned char & a);
136 
144  void GetColor(const vtkStdString & name, unsigned char rgba[4]);
145 
152  void GetColor(const vtkStdString & name, vtkColor4ub & rgba);
153 
161 
169  void GetColor(const vtkStdString & name,
170  double & r, double & g, double & b, double & a);
171 
179  void GetColor(const vtkStdString & name, double rgba[4]);
180 
187  void GetColor(const vtkStdString & name, vtkColor4d & rgba);
188 
196 
204 
212  void GetColor(const vtkStdString & name,
213  double & r, double & g, double & b);
214 
222  void GetColorRGB(const vtkStdString & name, double rgb[3]);
223 
230  void GetColor(const vtkStdString & name, vtkColor3ub & rgb);
231 
238  void GetColor(const vtkStdString & name, vtkColor3d & rgb);
239 
246  virtual void SetColor(const vtkStdString & name,
247  const unsigned char & r, const unsigned char & g,
248  const unsigned char & b, const unsigned char & a = 255);
249 
256  virtual void SetColor(const vtkStdString & name,
257  const double & r, const double & g,
258  const double & b, const double & a = 1);
259 
268  virtual void SetColor(const vtkStdString & name, const unsigned char rgba[4]);
269 
276  virtual void SetColor(const vtkStdString & name, const vtkColor4ub & rgba);
277 
284  virtual void SetColor(const vtkStdString & name, const vtkColor3ub & rgb);
285 
293  virtual void SetColor(const vtkStdString & name, const double rgba[4]);
294 
301  virtual void SetColor(const vtkStdString & name, const vtkColor4d & rgba);
302 
309  virtual void SetColor(const vtkStdString & name, const vtkColor3d & rgb);
310 
318 
328 
332  void GetColorNames(vtkStringArray * colorNames);
333 
345 
359 
373 
379 
385 
393  void SetColor(const vtkStdString & name, const vtkStdString & htmlString);
394 
395 protected:
397  ~vtkNamedColors() VTK_OVERRIDE;
398 
399 private:
401 
404  vtkNamedColorsDataStore *Colors;
405  vtkColorStringParser* Parser;
407 
408  vtkNamedColors(const vtkNamedColors&) VTK_DELETE_FUNCTION;
409  void operator=(const vtkNamedColors&) VTK_DELETE_FUNCTION;
410 };
411 
412 #endif /* vtkNamedColors_h */
vtkNamedColors::ResetColors
void ResetColors()
Reset the colors in the color map to the original colors.
vtkStdString.h
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const double &r, const double &g, const double &b, const double &a=1)
Set the color by name.
vtkNamedColors::SetColor
void SetColor(const vtkStdString &name, const vtkStdString &htmlString)
Set the color by name.
vtkNamedColors::RGBToHTMLColor
vtkStdString RGBToHTMLColor(const vtkColor3ub &rgb)
Given a vtkColor3ub instance as input color return a valid HTML color string in the #RRGGBB format.
vtkNamedColors::GetColorNames
vtkStdString GetColorNames()
Return a string of color names with each name delimited by a line feed.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, double rgba[4])
Get the color by name.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const vtkColor4d &rgba)
Set the color by name.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const vtkColor3ub &rgb)
Set the color by name.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, double &r, double &g, double &b)
Get the color by name.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, vtkColor3ub &rgb)
Get the color by name.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, unsigned char rgba[4])
Get the color by name.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkNamedColors::vtkNamedColors
vtkNamedColors()
vtkNamedColors::~vtkNamedColors
~vtkNamedColors() override
vtkNamedColors::GetColor4d
vtkColor4d GetColor4d(const vtkStdString &name)
Get the color by name.
vtkNamedColors::GetNumberOfColors
int GetNumberOfColors()
Get the number of colors.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const double rgba[4])
Set the color by name.
vtkColor4d
Definition: vtkColor.h:285
vtkStringArray.h
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, vtkColor4d &rgba)
Get the color by name.
vtkColor.h
vtkNamedColors::GetSynonyms
vtkStdString GetSynonyms()
Return a string of synonyms such as cyan/aqua and magenta/fuchsia.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const vtkColor3d &rgb)
Set the color by name.
vtkNamedColors
A class holding colors and their names.
Definition: vtkNamedColors.h:85
vtkNamedColors::GetColor3d
vtkColor3d GetColor3d(const vtkStdString &name)
Get the color by name.
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkObject.h
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, double &r, double &g, double &b, double &a)
Get the color by name.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a)
Get the color by name.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const unsigned char &r, const unsigned char &g, const unsigned char &b, const unsigned char &a=255)
Set the color by name.
vtkColor3d
Definition: vtkColor.h:232
vtkNamedColors::ColorExists
bool ColorExists(const vtkStdString &name)
Return true if the color exists.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, vtkColor4ub &rgba)
Get the color by name.
vtkNamedColors::New
static vtkNamedColors * New()
Create a new vtkNamedColors object.
vtkColor3ub
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:195
vtkColor4ub
Definition: vtkColor.h:241
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:43
vtkNamedColors::RemoveColor
void RemoveColor(const vtkStdString &name)
Remove the color by name.
vtkNamedColors::GetColor4ub
vtkColor4ub GetColor4ub(const vtkStdString &name)
Get the color by name.
vtkNamedColors::GetColorNames
void GetColorNames(vtkStringArray *colorNames)
Return a string array of color names.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkNamedColors::HTMLColorToRGBA
vtkColor4ub HTMLColorToRGBA(const vtkStdString &colorString)
Return a vtkColor4ub instance from an HTML color string in any of the following formats:
vtkNamedColors::GetColorRGB
void GetColorRGB(const vtkStdString &name, double rgb[3])
Get the color by name.
vtkNamedColors::GetColor
void GetColor(const vtkStdString &name, vtkColor3d &rgb)
Get the color by name.
vtkNamedColors::GetColor3ub
vtkColor3ub GetColor3ub(const vtkStdString &name)
Get the color by name.
vtkNamedColors::HTMLColorToRGB
vtkColor3ub HTMLColorToRGB(const vtkStdString &colorString)
Return a vtkColor3ub instance from an HTML color string in any of the following formats:
vtkNamedColors::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const unsigned char rgba[4])
Set the color by name.
vtkNamedColors::SetColor
virtual void SetColor(const vtkStdString &name, const vtkColor4ub &rgba)
Set the color by name.
vtkNamedColors::RGBAToHTMLColor
vtkStdString RGBAToHTMLColor(const vtkColor4ub &rgba)
Given a vtkColor4ub instance as input color return a valid HTML color string in the rgba(r,...