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 =========================================================================*/
71 #ifndef vtkNamedColors_h
72 #define vtkNamedColors_h
73 
74 #include "vtkCommonColorModule.h" // For export macro
75 #include "vtkObject.h"
76 #include "vtkColor.h" // Needed for vtkColor[34]ub
77 #include "vtkStdString.h" // Needed for arguments
78 #include "vtkStringArray.h" // For returning color names
79 
80 class vtkNamedColorsDataStore;
81 class vtkColorStringParser;
82 
84 {
85 public:
86  vtkTypeMacro(vtkNamedColors, vtkObject);
87 
92  virtual void PrintSelf(ostream &os, vtkIndent indent);
93 
95  static vtkNamedColors* New();
96 
98  int GetNumberOfColors();
99 
102  void ResetColors();
103 
105  bool ColorExists(const vtkStdString & name);
106 
110  vtkColor4ub GetColor4ub(const vtkStdString & name);
111 
113 
117  void GetColor(const vtkStdString & name,
118  unsigned char & r, unsigned char & g,
119  unsigned char & b, unsigned char & a);
121 
126  void GetColor(const vtkStdString & name, unsigned char rgba[4]);
127 
131  void GetColor(const vtkStdString & name, vtkColor4ub & rgba);
132 
136  vtkColor4d GetColor4d(const vtkStdString & name);
137 
139 
143  void GetColor(const vtkStdString & name,
144  double & r, double & g, double & b, double & a);
146 
151  void GetColor(const vtkStdString & name, double rgba[4]);
152 
156  void GetColor(const vtkStdString & name, vtkColor4d & rgba);
157 
161  vtkColor3ub GetColor3ub(const vtkStdString & name);
162 
166  vtkColor3d GetColor3d(const vtkStdString & name);
167 
169 
173  void GetColor(const vtkStdString & name,
174  double & r, double & g, double & b);
176 
181  void GetColorRGB(const vtkStdString & name, double rgb[3]);
182 
186  void GetColor(const vtkStdString & name, vtkColor3ub & rgb);
187 
191  void GetColor(const vtkStdString & name, vtkColor3d & rgb);
192 
194 
197  virtual void SetColor(const vtkStdString & name,
198  const unsigned char & r, const unsigned char & g,
199  const unsigned char & b, const unsigned char & a = 255);
201 
203 
206  virtual void SetColor(const vtkStdString & name,
207  const double & r, const double & g,
208  const double & b, const double & a = 1);
210 
215  virtual void SetColor(const vtkStdString & name, const unsigned char rgba[4]);
216 
220  virtual void SetColor(const vtkStdString & name, const vtkColor4ub & rgba);
221 
225  virtual void SetColor(const vtkStdString & name, const vtkColor3ub & rgb);
226 
230  virtual void SetColor(const vtkStdString & name, const double rgba[4]);
231 
235  virtual void SetColor(const vtkStdString & name, const vtkColor4d & rgba);
236 
240  virtual void SetColor(const vtkStdString & name, const vtkColor3d & rgb);
241 
245  void RemoveColor(const vtkStdString & name);
246 
251  vtkStdString GetColorNames();
252 
254  void GetColorNames(vtkStringArray * colorNames);
255 
262  vtkStdString GetSynonyms();
263 
270  vtkColor4ub HTMLColorToRGBA(const vtkStdString& colorString);
271 
277  vtkColor3ub HTMLColorToRGB(const vtkStdString& colorString);
278 
281  vtkStdString RGBToHTMLColor(const vtkColor3ub & rgb);
282 
285  vtkStdString RGBAToHTMLColor(const vtkColor4ub & rgba);
286 
290  void SetColor(const vtkStdString & name, const vtkStdString & htmlString);
291 
292 protected:
293  vtkNamedColors();
294  virtual ~vtkNamedColors();
295 
296 private:
298 
299  vtkNamedColorsDataStore *Colors;
300  vtkColorStringParser* Parser;
302 
303  vtkNamedColors(const vtkNamedColors&); // Not implemented.
304  void operator=(const vtkNamedColors&); // Not implemented.
305 };
306 
307 #endif /* vtkNamedColors_h */
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
#define VTKCOMMONCOLOR_EXPORT
abstract base class for most VTK objects
Definition: vtkObject.h:61
A class holding colors and their names.
a vtkAbstractArray subclass for strings
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
static vtkObject * New()