VTK  9.0.1
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 =========================================================================*/
67 #ifndef vtkNamedColors_h
68 #define vtkNamedColors_h
69 
70 #include "vtkColor.h" // Needed for vtkColor[34]ub
71 #include "vtkCommonColorModule.h" // For export macro
72 #include "vtkObject.h"
73 #include "vtkStdString.h" // Needed for arguments
74 #include "vtkStringArray.h" // For returning color names
75 
76 class vtkNamedColorsDataStore;
77 class vtkColorStringParser;
78 
79 class VTKCOMMONCOLOR_EXPORT vtkNamedColors : public vtkObject
80 {
81 public:
82  vtkTypeMacro(vtkNamedColors, vtkObject);
83 
90  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
95  static vtkNamedColors* New();
96 
101 
106  void ResetColors();
107 
112 
120 
128  void GetColor(const vtkStdString& name, unsigned char& r, unsigned char& g, unsigned char& b,
129  unsigned char& a);
130 
138  void GetColor(const vtkStdString& name, unsigned char rgba[4]);
139 
146  void GetColor(const vtkStdString& name, vtkColor4ub& rgba);
147 
155 
163  void GetColor(const vtkStdString& name, double& r, double& g, double& b, double& a);
164 
172  void GetColor(const vtkStdString& name, double rgba[4]);
173 
180  void GetColor(const vtkStdString& name, vtkColor4d& rgba);
181 
189 
197 
205  void GetColor(const vtkStdString& name, double& r, double& g, double& b);
206 
214  void GetColorRGB(const vtkStdString& name, double rgb[3]);
215 
222  void GetColor(const vtkStdString& name, vtkColor3ub& rgb);
223 
230  void GetColor(const vtkStdString& name, vtkColor3d& rgb);
231 
238  virtual void SetColor(const vtkStdString& name, const unsigned char& r, const unsigned char& g,
239  const unsigned char& b, const unsigned char& a = 255);
240 
247  virtual void SetColor(const vtkStdString& name, const double& r, const double& g, const double& b,
248  const double& a = 1);
249 
258  virtual void SetColor(const vtkStdString& name, const unsigned char rgba[4]);
259 
266  virtual void SetColor(const vtkStdString& name, const vtkColor4ub& rgba);
267 
274  virtual void SetColor(const vtkStdString& name, const vtkColor3ub& rgb);
275 
283  virtual void SetColor(const vtkStdString& name, const double rgba[4]);
284 
291  virtual void SetColor(const vtkStdString& name, const vtkColor4d& rgba);
292 
299  virtual void SetColor(const vtkStdString& name, const vtkColor3d& rgb);
300 
308 
318 
322  void GetColorNames(vtkStringArray* colorNames);
323 
335 
349 
363 
369 
375 
383  void SetColor(const vtkStdString& name, const vtkStdString& htmlString);
384 
385 protected:
387  ~vtkNamedColors() override;
388 
389 private:
391 
394  vtkNamedColorsDataStore* Colors;
395  vtkColorStringParser* Parser;
397 
398  vtkNamedColors(const vtkNamedColors&) = delete;
399  void operator=(const vtkNamedColors&) = delete;
400 };
401 
402 #endif /* vtkNamedColors_h */
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:195
a simple class to control print indentation
Definition: vtkIndent.h:34
A class holding colors and their names.
virtual void SetColor(const vtkStdString &name, const vtkColor4ub &rgba)
Set the color by name.
virtual void SetColor(const vtkStdString &name, const double &r, const double &g, const double &b, const double &a=1)
Set the color by name.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkColor4d GetColor4d(const vtkStdString &name)
Get the color by name.
void GetColor(const vtkStdString &name, vtkColor4d &rgba)
Get the color by name.
~vtkNamedColors() override
void GetColorRGB(const vtkStdString &name, double rgb[3])
Get the color by name.
void GetColor(const vtkStdString &name, vtkColor3ub &rgb)
Get the color by name.
void GetColor(const vtkStdString &name, vtkColor3d &rgb)
Get the color by name.
vtkStdString GetSynonyms()
Return a string of synonyms such as cyan/aqua and magenta/fuchsia.
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.
virtual void SetColor(const vtkStdString &name, const vtkColor3ub &rgb)
Set the color by name.
vtkColor3ub HTMLColorToRGB(const vtkStdString &colorString)
Return a vtkColor3ub instance from an HTML color string in any of the following formats:
virtual void SetColor(const vtkStdString &name, const unsigned char rgba[4])
Set the color by name.
virtual void SetColor(const vtkStdString &name, const vtkColor4d &rgba)
Set the color by name.
void GetColor(const vtkStdString &name, unsigned char rgba[4])
Get the color by name.
vtkColor3d GetColor3d(const vtkStdString &name)
Get the color by name.
vtkStdString RGBAToHTMLColor(const vtkColor4ub &rgba)
Given a vtkColor4ub instance as input color return a valid HTML color string in the rgba(r,...
void ResetColors()
Reset the colors in the color map to the original colors.
virtual void SetColor(const vtkStdString &name, const double rgba[4])
Set the color by name.
vtkStdString RGBToHTMLColor(const vtkColor3ub &rgb)
Given a vtkColor3ub instance as input color return a valid HTML color string in the #RRGGBB format.
vtkColor3ub GetColor3ub(const vtkStdString &name)
Get the color by name.
virtual void SetColor(const vtkStdString &name, const vtkColor3d &rgb)
Set the color by name.
void GetColor(const vtkStdString &name, unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a)
Get the color by name.
static vtkNamedColors * New()
Create a new vtkNamedColors object.
vtkColor4ub GetColor4ub(const vtkStdString &name)
Get the color by name.
void SetColor(const vtkStdString &name, const vtkStdString &htmlString)
Set the color by name.
void GetColor(const vtkStdString &name, double &r, double &g, double &b)
Get the color by name.
void RemoveColor(const vtkStdString &name)
Remove the color by name.
int GetNumberOfColors()
Get the number of colors.
void GetColor(const vtkStdString &name, double rgba[4])
Get the color by name.
void GetColor(const vtkStdString &name, double &r, double &g, double &b, double &a)
Get the color by name.
vtkStdString GetColorNames()
Return a string of color names with each name delimited by a line feed.
bool ColorExists(const vtkStdString &name)
Return true if the color exists.
void GetColorNames(vtkStringArray *colorNames)
Return a string array of color names.
void GetColor(const vtkStdString &name, vtkColor4ub &rgba)
Get the color by name.
vtkColor4ub HTMLColorToRGBA(const vtkStdString &colorString)
Return a vtkColor4ub instance from an HTML color string in any of the following formats:
abstract base class for most VTK objects
Definition: vtkObject.h:63
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:35
a vtkAbstractArray subclass for strings
@ name
Definition: vtkX3D.h:225