VTK  9.3.0
vtkDiscretizableColorTransferFunction.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
46#ifndef vtkDiscretizableColorTransferFunction_h
47#define vtkDiscretizableColorTransferFunction_h
48
50#include "vtkRenderingCoreModule.h" // For export macro
51#include "vtkSmartPointer.h" // for vtkSmartPointer
52
53VTK_ABI_NAMESPACE_BEGIN
55class vtkLookupTable;
58
59class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
61{
62public:
65 void PrintSelf(ostream& os, vtkIndent indent) override;
66
68
72 vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
73 vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component,
74 vtkUnsignedCharArray* ghosts, unsigned char ghostsToSkip = 0xff) override;
76
84 void SetIndexedColorRGB(unsigned int index, const double rgb[3])
85 {
86 this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
87 }
88 void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
89 {
90 this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
91 }
92 void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
93
106 void GetIndexedColor(vtkIdType i, double rgba[4]) override;
107
109
114 void SetNumberOfIndexedColors(unsigned int count);
117
124 void Build() override;
125
127
133 vtkSetMacro(Discretize, vtkTypeBool);
134 vtkGetMacro(Discretize, vtkTypeBool);
135 vtkBooleanMacro(Discretize, vtkTypeBool);
137
139
143 virtual void SetUseLogScale(vtkTypeBool useLogScale);
144 vtkGetMacro(UseLogScale, vtkTypeBool);
146
148
153 vtkSetMacro(NumberOfValues, vtkIdType);
154 vtkGetMacro(NumberOfValues, vtkIdType);
156
161 const unsigned char* MapValue(double v) override;
162
167 void GetColor(double v, double rgb[3]) override;
168
172 double GetOpacity(double v) override;
173
179 void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
180 int numberOfValues, int inputIncrement, int outputFormat) override;
181
189 void SetAlpha(double alpha) override;
190
192
197 void SetNanColor(double r, double g, double b) override;
198 void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
200
206 void SetNanOpacity(double a) override;
207
212 vtkTypeBool UsingLogScale() override { return this->UseLogScale; }
213
218
220
226
228
231 vtkSetMacro(EnableOpacityMapping, bool);
232 vtkGetMacro(EnableOpacityMapping, bool);
233 vtkBooleanMacro(EnableOpacityMapping, bool);
235
240
241protected:
244
249
254
259
264
266
269
270 void MapDataArrayToOpacity(vtkDataArray* scalars, int component, vtkUnsignedCharArray* colors);
271
272private:
274 void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
275
276 template <typename T, typename VectorGetter>
277 void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
278 vtkIdType numberOfTuples, unsigned char* colors);
279
280 template <template <class> class VectorGetter>
281 void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
282 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
283
284 class vtkInternals;
285 vtkInternals* Internals;
286};
287
288VTK_ABI_NAMESPACE_END
289#endif
Abstract superclass for all arrays.
Defines a transfer function for mapping a property to an RGB color value.
abstract superclass for arrays of numeric data
a combination of vtkColorTransferFunction and vtkLookupTable.
void SetNanColor(const double rgb[3]) override
Set the color to use when a NaN (not a number) is encountered.
unsigned int GetNumberOfIndexedColors()
Set the number of indexed colors.
vtkMTimeType GetMTime() override
Overridden to include the ScalarOpacityFunction's MTime.
vtkIdType NumberOfValues
Number of values to use in discretized color map.
vtkTypeBool IsOpaque(vtkAbstractArray *scalars, int colorMode, int component) override
Returns the negation of EnableOpacityMapping.
void MapDataArrayToOpacity(vtkDataArray *scalars, int component, vtkUnsignedCharArray *colors)
vtkTypeBool UseLogScale
Flag indicating whether log scaling is to be used.
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat) override
Map a set of scalars through the lookup table.
void GetColor(double v, double rgb[3]) override
Map one value through the lookup table and return the color as an RGB array of doubles between 0 and ...
void SetNumberOfIndexedColors(unsigned int count)
Set the number of indexed colors.
void GetIndexedColor(vtkIdType i, double rgba[4]) override
Get the "indexed color" assigned to an index.
const unsigned char * MapValue(double v) override
Map one value through the lookup table and return a color defined as a RGBA unsigned char tuple (4 by...
virtual void SetUseLogScale(vtkTypeBool useLogScale)
Get/Set if log scale must be used while mapping scalars to colors.
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
void SetAlpha(double alpha) override
Specify an additional opacity (alpha) value to blend with.
virtual vtkPiecewiseFunction * GetScalarOpacityFunction() const
Set/get the opacity function to use.
vtkTypeBool IsOpaque() override
Returns the negation of EnableOpacityMapping.
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function)
Set/get the opacity function to use.
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
vtkTypeBool IsOpaque(vtkAbstractArray *scalars, int colorMode, int component, vtkUnsignedCharArray *ghosts, unsigned char ghostsToSkip=0xff) override
Returns the negation of EnableOpacityMapping.
double GetOpacity(double v) override
Return the opacity of a given scalar.
void SetIndexedColor(unsigned int index, double r, double g, double b, double a=1.0)
void SetNanColor(double r, double g, double b) override
Set the color to use when a NaN (not a number) is encountered.
static vtkDiscretizableColorTransferFunction * New()
void SetNanOpacity(double a) override
Set the opacity to use when a NaN (not a number) is encountered.
vtkTypeBool UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
void Build() override
Generate discretized lookup table, if applicable.
a simple class to control print indentation
Definition vtkIndent.h:38
map scalar values into colors via a lookup table
Defines a 1D piecewise function.
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270