VTK  9.3.20240424
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
171#ifndef vtkNamedColors_h
172#define vtkNamedColors_h
173
174#include "vtkColor.h" // Needed for vtkColor[34]ub
175#include "vtkCommonColorModule.h" // For export macro
176#include "vtkObject.h"
177#include "vtkStdString.h" // Needed for arguments
178#include "vtkStringArray.h" // For returning color names
179#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
180
181VTK_ABI_NAMESPACE_BEGIN
182class vtkNamedColorsDataStore;
183class vtkColorStringParser;
184
185class VTKCOMMONCOLOR_EXPORT VTK_MARSHALAUTO vtkNamedColors : public vtkObject
186{
187public:
188 vtkTypeMacro(vtkNamedColors, vtkObject);
189
196 void PrintSelf(ostream& os, vtkIndent indent) override;
197
202
207
213
217 bool ColorExists(const vtkStdString& name);
218
226
234 void GetColor(const vtkStdString& name, unsigned char& r, unsigned char& g, unsigned char& b,
235 unsigned char& a);
236
244 void GetColor(const vtkStdString& name, unsigned char rgba[4]);
245
252 void GetColor(const vtkStdString& name, vtkColor4ub& rgba);
253
261
269 void GetColor(const vtkStdString& name, double& r, double& g, double& b, double& a);
270
278 void GetColor(const vtkStdString& name, double rgba[4]);
279
286 void GetColor(const vtkStdString& name, vtkColor4d& rgba);
287
295
303
311 void GetColor(const vtkStdString& name, double& r, double& g, double& b);
312
320 void GetColorRGB(const vtkStdString& name, double rgb[3]);
321
328 void GetColor(const vtkStdString& name, vtkColor3ub& rgb);
329
336 void GetColor(const vtkStdString& name, vtkColor3d& rgb);
337
344 virtual void SetColor(const vtkStdString& name, const unsigned char& r, const unsigned char& g,
345 const unsigned char& b, const unsigned char& a = 255);
346
353 virtual void SetColor(const vtkStdString& name, const double& r, const double& g, const double& b,
354 const double& a = 1);
355
364 virtual void SetColor(const vtkStdString& name, const unsigned char rgba[4]);
365
372 virtual void SetColor(const vtkStdString& name, const vtkColor4ub& rgba);
373
380 virtual void SetColor(const vtkStdString& name, const vtkColor3ub& rgb);
381
389 virtual void SetColor(const vtkStdString& name, const double rgba[4]);
390
397 virtual void SetColor(const vtkStdString& name, const vtkColor4d& rgba);
398
405 virtual void SetColor(const vtkStdString& name, const vtkColor3d& rgb);
406
413 void RemoveColor(const vtkStdString& name);
414
424
428 void GetColorNames(vtkStringArray* colorNames);
429
441
455
469
475
481
489 void SetColor(const vtkStdString& name, const vtkStdString& htmlString);
490
491protected:
493 ~vtkNamedColors() override;
494
495private:
497
500 vtkNamedColorsDataStore* Colors;
501 vtkColorStringParser* Parser;
503
504 vtkNamedColors(const vtkNamedColors&) = delete;
505 void operator=(const vtkNamedColors&) = delete;
506};
507
508VTK_ABI_NAMESPACE_END
509#endif /* vtkNamedColors_h */
Some derived classes for the different colors commonly used.
Definition vtkColor.h:203
a simple class to control print indentation
Definition vtkIndent.h:108
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.
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.
static vtkNamedColors * New()
Create a new vtkNamedColors object.
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:162
Wrapper around std::string to keep symbols short.
a vtkAbstractArray subclass for strings
#define VTK_MARSHALAUTO