VTK  9.4.20251007
vtkColorTransferFunction.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
31
32#ifndef vtkColorTransferFunction_h
33#define vtkColorTransferFunction_h
34
35#include "vtkRenderingCoreModule.h" // For export macro
36#include "vtkScalarsToColors.h"
37#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
38
39VTK_ABI_NAMESPACE_BEGIN
40class vtkColorTransferFunctionInternals;
41class vtkDoubleArray;
42
43#define VTK_CTF_RGB 0
44#define VTK_CTF_HSV 1
45#define VTK_CTF_LAB 2
46#define VTK_CTF_DIVERGING 3
47#define VTK_CTF_LAB_CIEDE2000 4
48#define VTK_CTF_STEP 5
49
50#define VTK_CTF_LINEAR 0
51#define VTK_CTF_LOG10 1
52
54{
55public:
58 void DeepCopy(vtkScalarsToColors* f) override;
60
64 void PrintSelf(ostream& os, vtkIndent indent) override;
65
69 int GetSize();
70
72
78 int AddRGBPoint(double x, double r, double g, double b);
79 int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness);
81 int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors, double midpoint, double sharpness);
82 int AddHSVPoint(double x, double h, double s, double v);
83 int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness);
84 int RemovePoint(double x);
86
88
93 double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2);
95 double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2);
97
102
106 double* GetColor(double x) VTK_SIZEHINT(3) { return vtkScalarsToColors::GetColor(x); }
107 void GetColor(double x, double rgb[3]) override;
108
110
113 double GetRedValue(double x);
114 double GetGreenValue(double x);
115 double GetBlueValue(double x);
117
119
124 int GetNodeValue(int index, double val[6]);
125 int SetNodeValue(int index, double val[6]);
127
131 const unsigned char* MapValue(double v) override;
132
134
137 double* GetRange() VTK_SIZEHINT(2) override { return this->Range; }
138 virtual void GetRange(double& arg1, double& arg2)
139 {
140 arg1 = this->Range[0];
141 arg2 = this->Range[1];
142 }
143 virtual void GetRange(double _arg[2]) { this->GetRange(_arg[0], _arg[1]); }
145
151 int AdjustRange(double range[2]);
152
154
160 void GetTable(double x1, double x2, int n, double* table);
161 void GetTable(double x1, double x2, int n, float* table);
162 const unsigned char* GetTable(double x1, double x2, int n);
164
174 void BuildFunctionFromTable(double x1, double x2, int size, double* table);
175
177
185 vtkSetClampMacro(Clamping, vtkTypeBool, 0, 1);
186 vtkGetMacro(Clamping, vtkTypeBool);
187 vtkBooleanMacro(Clamping, vtkTypeBool);
189
191
203 vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_STEP);
210 vtkGetMacro(ColorSpace, int);
211 vtkSetMacro(HSVWrap, vtkTypeBool);
212 vtkGetMacro(HSVWrap, vtkTypeBool);
213 vtkBooleanMacro(HSVWrap, vtkTypeBool);
215
217
222 vtkSetMacro(Scale, int);
225 vtkGetMacro(Scale, int);
227
229
234 vtkSetVector3Macro(NanColor, double);
235 vtkGetVector3Macro(NanColor, double);
237
239
243 vtkSetMacro(NanOpacity, double);
244 vtkGetMacro(NanOpacity, double);
246
248
253 virtual void SetNanColorRGBA(double r, double g, double b, double a)
254 {
255 this->SetNanColor(r, g, b);
256 this->SetNanOpacity(a);
257 }
258
259 void SetNanColorRGBA(double rgba[4])
260 {
261 this->SetNanColorRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
262 }
263
264
266
270 vtkSetVector3Macro(BelowRangeColor, double);
271 vtkGetVector3Macro(BelowRangeColor, double);
273
275
282
284
288 vtkSetVector3Macro(AboveRangeColor, double);
289 vtkGetVector3Macro(AboveRangeColor, double);
291
293
300
308 double* GetDataPointer();
309
315 void FillFromDataPointer(int n, double* ptr);
316
320 void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
321 int numberOfValues, int inputIncrement, int outputIncrement) override;
322
324
332
337
344 void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
345
350 int EstimateMinNumberOfSamples(double const& x1, double const& x2);
351
352protected:
355
356 vtkColorTransferFunctionInternals* Internal;
357
365
370
375
379 int Scale;
380
384 double NanColor[3];
385
390
395
400
405
410
414 double* Function;
415
419 double Range[2];
420
424 unsigned char UnsignedCharRGBAValue[4];
425
430
432 unsigned char* Table;
433
439
441
445 void SetRange(double, double) override {}
446 void SetRange(const double rng[2]) override { this->SetRange(rng[0], rng[1]); }
448
455
461
466 void MovePoint(double oldX, double newX);
467
472
473private:
475 void operator=(const vtkColorTransferFunction&) = delete;
476};
477
478VTK_ABI_NAMESPACE_END
479#endif
RealT r2
Definition PyrC2Basis.h:20
RealT s2
Definition PyrC2Basis.h:21
virtual void SetNanColorRGBA(double r, double g, double b, double a)
Set the RGBA color to use when a NaN (not a number) is encountered.
void GetTable(double x1, double x2, int n, double *table)
Fills in a table of n colors mapped from values mapped with even spacing between x1 and x2,...
int Scale
The color interpolation scale (linear or logarithmic).
void BuildFunctionFromTable(double x1, double x2, int size, double *table)
Construct a color transfer function from a table.
void DeepCopy(vtkScalarsToColors *f) override
Copy the contents from another object.
void RemoveAllPoints()
Remove all points.
virtual void SetColorSpace(int)
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
void AddHSVSegment(double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2)
Add two points to the function and remove all the points between them.
void SetNanColorRGBA(double rgba[4])
Set the RGBA color to use when a NaN (not a number) is encountered.
int AdjustRange(double range[2])
Remove all points out of the new range, and make sure there is a point at each end of that range.
int AddHSVPoint(double x, double h, double s, double v)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
void GetTable(double x1, double x2, int n, float *table)
Fills in a table of n colors mapped from values mapped with even spacing between x1 and x2,...
int RemovePoint(double x)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
double NanColor[3]
The color to use for not-a-number.
int TableSize
Temporary storage for the size of the table.
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
~vtkColorTransferFunction() override
int AddRGBPoints(vtkDoubleArray *x, vtkDoubleArray *rgbColors, double midpoint, double sharpness)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
void SetScaleToLog10()
Set the type of scale to use, linear or logarithmic.
double NanOpacity
The opacity to use for not-a-number.
double GetRedValue(double x)
Get the color components individually.
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
unsigned char UnsignedCharRGBAValue[4]
Temporary storage for an evaluated color (0 to 255 RGBA A=255)
int ColorSpace
The color space in which interpolation is performed.
void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputIncrement) override
Map a set of scalars through the lookup table.
void SetColorSpaceToHSV()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
const unsigned char * MapValue(double v) override
Map one value through the lookup table.
double * GetDataPointer()
Returns a pointer to an array of all node values in an interleaved array with the layout [X1,...
int AddRGBPoints(vtkDoubleArray *x, vtkDoubleArray *rgbColors)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
double BelowRangeColor[3]
The below-range color.
int GetSize()
How many nodes define this function?
void SetColorSpaceToDiverging()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
vtkColorTransferFunctionInternals * Internal
int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
void MovePoint(double oldX, double newX)
Moves point from oldX to newX.
static vtkColorTransferFunction * New()
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
int GetNodeValue(int index, double val[6])
For the node specified by index, set/get the location (X), R, G, and B values, midpoint,...
double Range[2]
The min and max node locations.
double FindMinimumXDistance()
Traverses the nodes to find the minimum distance.
void SetRange(const double rng[2]) override
Set the range of scalars being mapped.
virtual void GetRange(double &arg1, double &arg2)
Returns min and max position of all function points.
void SetScaleToLinear()
Set the type of scale to use, linear or logarithmic.
double AboveRangeColor[3]
The above-range color.
int AddRGBPoint(double x, double r, double g, double b)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
virtual void SetNanColor(double, double, double)
Set the RGB color to use when a NaN (not a number) is encountered.
void SetColorSpaceToLab()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
vtkTypeBool HSVWrap
Specify if HSV is wrap or not.
double * Function
Temporary array to store data from the nodes.
void SetColorSpaceToStep()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
const unsigned char * GetTable(double x1, double x2, int n)
Fills in a table of n colors mapped from values mapped with even spacing between x1 and x2,...
void AddRGBSegment(double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2)
Add two points to the function and remove all the points between them.
int SetNodeValue(int index, double val[6])
For the node specified by index, set/get the location (X), R, G, and B values, midpoint,...
double GetBlueValue(double x)
Get the color components individually.
double * GetRange() override
Returns min and max position of all function points.
void ShallowCopy(vtkColorTransferFunction *f)
void SetColorSpaceToLabCIEDE2000()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
void FillFromDataPointer(int n, double *ptr)
Defines the nodes from an array ptr with the layout [X1, R1, G1, B1, X2, R2, G2, B2,...
vtkTypeBool UseAboveRangeColor
Flag indicating whether below-range color should be used.
vtkTypeBool UseBelowRangeColor
Flag indicating whether below-range color should be used.
vtkTypeBool Clamping
Determines the function value outside of defined points Zero = always return 0.0 outside of defined p...
void GetColor(double x, double rgb[3]) override
Map one value through the lookup table and store the color as an RGB array of doubles between 0 and 1...
vtkTypeBool AllowDuplicateScalars
If on, the same scalar value may have more than one node assigned to it.
void SetColorSpaceToRGB()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, Diverging or Step.
void SetRange(double, double) override
Set the range of scalars being mapped.
void SortAndUpdateRange()
Internal method to sort the vector and update the Range whenever a node is added, edited or removed I...
virtual void SetNanOpacity(double)
Get/Set the opacity to use when a NaN (not a number) is encountered.
void GetIndexedColor(vtkIdType idx, double rgba[4]) override
Return a color given an integer index.
virtual void GetRange(double _arg[2])
Returns min and max position of all function points.
bool UpdateRange()
Returns true if the range has been changed.
virtual void SetScale(int)
Set the type of scale to use, linear or logarithmic.
double GetGreenValue(double x)
Get the color components individually.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:29
virtual void GetColor(double v, double rgb[3])
Map one value through the lookup table and store the color as an RGB array of doubles between 0 and 1...
Computes the portion of a dataset which is inside a selection.
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_CTF_DIVERGING
#define VTK_CTF_LAB_CIEDE2000
#define VTK_CTF_RGB
#define VTK_CTF_LAB
#define VTK_CTF_LINEAR
#define VTK_CTF_HSV
#define VTK_CTF_STEP
#define VTK_CTF_LOG10
int vtkIdType
Definition vtkType.h:315
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL