VTK  9.3.1
vtkNamedColors.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
62 #ifndef vtkNamedColors_h
63 #define vtkNamedColors_h
64 
65 #include "vtkColor.h" // Needed for vtkColor[34]ub
66 #include "vtkCommonColorModule.h" // For export macro
67 #include "vtkObject.h"
68 #include "vtkStdString.h" // Needed for arguments
69 #include "vtkStringArray.h" // For returning color names
70 
71 VTK_ABI_NAMESPACE_BEGIN
72 class vtkNamedColorsDataStore;
73 class vtkColorStringParser;
74 
75 class VTKCOMMONCOLOR_EXPORT vtkNamedColors : public vtkObject
76 {
77 public:
78  vtkTypeMacro(vtkNamedColors, vtkObject);
79 
86  void PrintSelf(ostream& os, vtkIndent indent) override;
87 
91  static vtkNamedColors* New();
92 
96  int GetNumberOfColors();
97 
102  void ResetColors();
103 
107  bool ColorExists(const vtkStdString& name);
108 
115  vtkColor4ub GetColor4ub(const vtkStdString& name);
116 
124  void GetColor(const vtkStdString& name, unsigned char& r, unsigned char& g, unsigned char& b,
125  unsigned char& a);
126 
134  void GetColor(const vtkStdString& name, unsigned char rgba[4]);
135 
142  void GetColor(const vtkStdString& name, vtkColor4ub& rgba);
143 
150  vtkColor4d GetColor4d(const vtkStdString& name);
151 
159  void GetColor(const vtkStdString& name, double& r, double& g, double& b, double& a);
160 
168  void GetColor(const vtkStdString& name, double rgba[4]);
169 
176  void GetColor(const vtkStdString& name, vtkColor4d& rgba);
177 
184  vtkColor3ub GetColor3ub(const vtkStdString& name);
185 
192  vtkColor3d GetColor3d(const vtkStdString& name);
193 
201  void GetColor(const vtkStdString& name, double& r, double& g, double& b);
202 
210  void GetColorRGB(const vtkStdString& name, double rgb[3]);
211 
218  void GetColor(const vtkStdString& name, vtkColor3ub& rgb);
219 
226  void GetColor(const vtkStdString& name, vtkColor3d& rgb);
227 
234  virtual void SetColor(const vtkStdString& name, const unsigned char& r, const unsigned char& g,
235  const unsigned char& b, const unsigned char& a = 255);
236 
243  virtual void SetColor(const vtkStdString& name, const double& r, const double& g, const double& b,
244  const double& a = 1);
245 
254  virtual void SetColor(const vtkStdString& name, const unsigned char rgba[4]);
255 
262  virtual void SetColor(const vtkStdString& name, const vtkColor4ub& rgba);
263 
270  virtual void SetColor(const vtkStdString& name, const vtkColor3ub& rgb);
271 
279  virtual void SetColor(const vtkStdString& name, const double rgba[4]);
280 
287  virtual void SetColor(const vtkStdString& name, const vtkColor4d& rgba);
288 
295  virtual void SetColor(const vtkStdString& name, const vtkColor3d& rgb);
296 
303  void RemoveColor(const vtkStdString& name);
304 
313  vtkStdString GetColorNames();
314 
318  void GetColorNames(vtkStringArray* colorNames);
319 
330  vtkStdString GetSynonyms();
331 
344  vtkColor4ub HTMLColorToRGBA(const vtkStdString& colorString);
345 
358  vtkColor3ub HTMLColorToRGB(const vtkStdString& colorString);
359 
364  vtkStdString RGBToHTMLColor(const vtkColor3ub& rgb);
365 
370  vtkStdString RGBAToHTMLColor(const vtkColor4ub& rgba);
371 
379  void SetColor(const vtkStdString& name, const vtkStdString& htmlString);
380 
381 protected:
382  vtkNamedColors();
383  ~vtkNamedColors() override;
384 
385 private:
387 
390  vtkNamedColorsDataStore* Colors;
391  vtkColorStringParser* Parser;
393 
394  vtkNamedColors(const vtkNamedColors&) = delete;
395  void operator=(const vtkNamedColors&) = delete;
396 };
397 
398 VTK_ABI_NAMESPACE_END
399 #endif /* vtkNamedColors_h */
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
abstract base class for most VTK objects
Definition: vtkObject.h:51
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:183
a simple class to control print indentation
Definition: vtkIndent.h:28
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...