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 =========================================================================*/
66 #ifndef vtkNamedColors_h
67 #define vtkNamedColors_h
68 
69 #include "vtkCommonColorModule.h" // For export macro
70 #include "vtkObject.h"
71 #include "vtkColor.h" // Needed for vtkColor[34]ub
72 #include "vtkStdString.h" // Needed for arguments
73 #include "vtkStringArray.h" // For returning color names
74 
75 class vtkNamedColorsDataStore;
76 class vtkColorStringParser;
77 
78 class VTKCOMMONCOLOR_EXPORT vtkNamedColors : public vtkObject
79 {
80 public:
81  vtkTypeMacro(vtkNamedColors, vtkObject);
82 
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
94  static vtkNamedColors* New();
95 
99  int GetNumberOfColors();
100 
105  void ResetColors();
106 
110  bool ColorExists(const vtkStdString & name);
111 
118  vtkColor4ub GetColor4ub(const vtkStdString & name);
119 
127  void GetColor(const vtkStdString & name,
128  unsigned char & r, unsigned char & g,
129  unsigned char & b, unsigned char & a);
130 
138  void GetColor(const vtkStdString & name, unsigned char rgba[4]);
139 
146  void GetColor(const vtkStdString & name, vtkColor4ub & rgba);
147 
154  vtkColor4d GetColor4d(const vtkStdString & name);
155 
163  void GetColor(const vtkStdString & name,
164  double & r, double & g, double & b, double & a);
165 
173  void GetColor(const vtkStdString & name, double rgba[4]);
174 
181  void GetColor(const vtkStdString & name, vtkColor4d & rgba);
182 
189  vtkColor3ub GetColor3ub(const vtkStdString & name);
190 
197  vtkColor3d GetColor3d(const vtkStdString & name);
198 
206  void GetColor(const vtkStdString & name,
207  double & r, double & g, double & b);
208 
216  void GetColorRGB(const vtkStdString & name, double rgb[3]);
217 
224  void GetColor(const vtkStdString & name, vtkColor3ub & rgb);
225 
232  void GetColor(const vtkStdString & name, vtkColor3d & rgb);
233 
240  virtual void SetColor(const vtkStdString & name,
241  const unsigned char & r, const unsigned char & g,
242  const unsigned char & b, const unsigned char & a = 255);
243 
250  virtual void SetColor(const vtkStdString & name,
251  const double & r, const double & g,
252  const double & b, const double & a = 1);
253 
262  virtual void SetColor(const vtkStdString & name, const unsigned char rgba[4]);
263 
270  virtual void SetColor(const vtkStdString & name, const vtkColor4ub & rgba);
271 
278  virtual void SetColor(const vtkStdString & name, const vtkColor3ub & rgb);
279 
287  virtual void SetColor(const vtkStdString & name, const double rgba[4]);
288 
295  virtual void SetColor(const vtkStdString & name, const vtkColor4d & rgba);
296 
303  virtual void SetColor(const vtkStdString & name, const vtkColor3d & rgb);
304 
311  void RemoveColor(const vtkStdString & name);
312 
321  vtkStdString GetColorNames();
322 
326  void GetColorNames(vtkStringArray * colorNames);
327 
338  vtkStdString GetSynonyms();
339 
352  vtkColor4ub HTMLColorToRGBA(const vtkStdString& colorString);
353 
366  vtkColor3ub HTMLColorToRGB(const vtkStdString& colorString);
367 
372  vtkStdString RGBToHTMLColor(const vtkColor3ub & rgb);
373 
378  vtkStdString RGBAToHTMLColor(const vtkColor4ub & rgba);
379 
387  void SetColor(const vtkStdString & name, const vtkStdString & htmlString);
388 
389 protected:
390  vtkNamedColors();
391  ~vtkNamedColors() override;
392 
393 private:
395 
398  vtkNamedColorsDataStore *Colors;
399  vtkColorStringParser* Parser;
401 
402  vtkNamedColors(const vtkNamedColors&) = delete;
403  void operator=(const vtkNamedColors&) = delete;
404 };
405 
406 #endif /* vtkNamedColors_h */
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A class holding colors and their names.
a vtkAbstractArray subclass for strings
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:194
a simple class to control print indentation
Definition: vtkIndent.h:33
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.