VTK  9.6.20260226
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
105
106#ifndef vtkDiscretizableColorTransferFunction_h
107#define vtkDiscretizableColorTransferFunction_h
108
110#include "vtkRenderingCoreModule.h" // For export macro
111#include "vtkSmartPointer.h" // for vtkSmartPointer
112#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
113
114VTK_ABI_NAMESPACE_BEGIN
116class vtkLookupTable;
119
122{
123public:
126 void PrintSelf(ostream& os, vtkIndent indent) override;
127
129
133 vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
134 vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component,
135 vtkUnsignedCharArray* ghosts, unsigned char ghostsToSkip = 0xff) override;
137
145 void SetIndexedColorRGB(unsigned int index, const double rgb[3])
146 {
147 this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
148 }
149 void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
150 {
151 this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
152 }
153 void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
154
167 void GetIndexedColor(vtkIdType i, double rgba[4]) override;
168
170
175 void SetNumberOfIndexedColors(unsigned int count);
178
185 void Build() override;
186
188
194 vtkSetMacro(Discretize, vtkTypeBool);
195 vtkGetMacro(Discretize, vtkTypeBool);
196 vtkBooleanMacro(Discretize, vtkTypeBool);
198
200
204 virtual void SetUseLogScale(vtkTypeBool useLogScale);
207
209
217
222 const unsigned char* MapValue(double v) override;
223
228 void GetColor(double v, double rgb[3]) override;
229
233 double GetOpacity(double v) override;
234
236
241 void MapScalarsThroughTable(vtkAbstractArray* input, unsigned char* output, int numberOfTuples,
242 int numberOfComponents, int vectorComponent, int outputFormat) override;
245
253 void SetAlpha(double alpha) override;
254
256
261 void SetNanColor(double r, double g, double b) override;
262 void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
264
270 void SetNanOpacity(double a) override;
271
276 vtkTypeBool UsingLogScale() override { return this->UseLogScale; }
277
282
284
290
292
295 vtkSetMacro(EnableOpacityMapping, bool);
296 vtkGetMacro(EnableOpacityMapping, bool);
297 vtkBooleanMacro(EnableOpacityMapping, bool);
299
304
305protected:
308
313
318
323
328
330
333
334 void MapDataArrayToOpacity(vtkDataArray* scalars, int component, vtkUnsignedCharArray* colors);
335
336private:
338 void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
339
340 template <typename T, typename VectorGetter>
341 void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
342 vtkIdType numberOfTuples, unsigned char* colors);
343
344 template <template <class> class VectorGetter>
345 void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
346 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
347
348 class vtkInternals;
349 vtkInternals* Internals;
350};
351
352VTK_ABI_NAMESPACE_END
353#endif
Abstract superclass for all arrays.
Defines a transfer function for mapping a property to an RGB color value.
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 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.
void MapScalarsThroughTable(vtkAbstractArray *input, unsigned char *output, int numberOfTuples, int numberOfComponents, int vectorComponent, int outputFormat) override
Map a set of scalars through the lookup table.
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:108
map scalar values into colors via a lookup table
Defines a 1D piecewise function.
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output, int outputFormat)
Map a set of scalars through the lookup table in a single operation.
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
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_MARSHALMANUAL