VTK  9.4.20250509
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
141#ifndef vtkColorTransferFunction_h
142#define vtkColorTransferFunction_h
143
144#include "vtkRenderingCoreModule.h" // For export macro
145#include "vtkScalarsToColors.h"
146#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
147
148VTK_ABI_NAMESPACE_BEGIN
149class vtkColorTransferFunctionInternals;
150class vtkDoubleArray;
151
152#define VTK_CTF_RGB 0
153#define VTK_CTF_HSV 1
154#define VTK_CTF_LAB 2
155#define VTK_CTF_DIVERGING 3
156#define VTK_CTF_LAB_CIEDE2000 4
157#define VTK_CTF_STEP 5
158#define VTK_CTF_PROLAB 6
159
160#define VTK_CTF_LINEAR 0
161#define VTK_CTF_LOG10 1
162
164{
165public:
168 void DeepCopy(vtkScalarsToColors* f) override;
170
174 void PrintSelf(ostream& os, vtkIndent indent) override;
175
179 int GetSize();
180
182
188 int AddRGBPoint(double x, double r, double g, double b);
189 int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness);
191 int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors, double midpoint, double sharpness);
192 int AddHSVPoint(double x, double h, double s, double v);
193 int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness);
194 int RemovePoint(double x);
196
198
203 double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2);
205 double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2);
207
212
216 double* GetColor(double x) VTK_SIZEHINT(3) { return vtkScalarsToColors::GetColor(x); }
217 void GetColor(double x, double rgb[3]) override;
218
220
223 double GetRedValue(double x);
224 double GetGreenValue(double x);
225 double GetBlueValue(double x);
227
229
234 int GetNodeValue(int index, double val[6]);
235 int SetNodeValue(int index, double val[6]);
237
241 const unsigned char* MapValue(double v) override;
242
244
247 double* GetRange() VTK_SIZEHINT(2) override { return this->Range; }
248 virtual void GetRange(double& arg1, double& arg2)
249 {
250 arg1 = this->Range[0];
251 arg2 = this->Range[1];
252 }
253 virtual void GetRange(double _arg[2]) { this->GetRange(_arg[0], _arg[1]); }
255
261 int AdjustRange(double range[2]);
262
264
270 void GetTable(double x1, double x2, int n, double* table);
271 void GetTable(double x1, double x2, int n, float* table);
272 const unsigned char* GetTable(double x1, double x2, int n);
274
284 void BuildFunctionFromTable(double x1, double x2, int size, double* table);
285
287
295 vtkSetClampMacro(Clamping, vtkTypeBool, 0, 1);
296 vtkGetMacro(Clamping, vtkTypeBool);
297 vtkBooleanMacro(Clamping, vtkTypeBool);
299
301
313 vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_PROLAB);
314 void SetColorSpaceToRGB() { this->SetColorSpace(VTK_CTF_RGB); }
315 void SetColorSpaceToHSV() { this->SetColorSpace(VTK_CTF_HSV); }
316 void SetColorSpaceToLab() { this->SetColorSpace(VTK_CTF_LAB); }
317 void SetColorSpaceToLabCIEDE2000() { this->SetColorSpace(VTK_CTF_LAB_CIEDE2000); }
318 void SetColorSpaceToDiverging() { this->SetColorSpace(VTK_CTF_DIVERGING); }
319 void SetColorSpaceToStep() { this->SetColorSpace(VTK_CTF_STEP); }
320 void SetColorSpaceToProlab() { this->SetColorSpace(VTK_CTF_PROLAB); };
321 vtkGetMacro(ColorSpace, int);
322 vtkSetMacro(HSVWrap, vtkTypeBool);
323 vtkGetMacro(HSVWrap, vtkTypeBool);
324 vtkBooleanMacro(HSVWrap, vtkTypeBool);
326
328
333 vtkSetMacro(Scale, int);
334 void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); }
335 void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); }
336 vtkGetMacro(Scale, int);
338
340
345 vtkSetVector3Macro(NanColor, double);
346 vtkGetVector3Macro(NanColor, double);
348
350
354 vtkSetMacro(NanOpacity, double);
355 vtkGetMacro(NanOpacity, double);
357
359
364 virtual void SetNanColorRGBA(double r, double g, double b, double a)
365 {
366 this->SetNanColor(r, g, b);
367 this->SetNanOpacity(a);
368 }
369
370 void SetNanColorRGBA(double rgba[4])
371 {
372 this->SetNanColorRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
373 }
375
377
381 vtkSetVector3Macro(BelowRangeColor, double);
382 vtkGetVector3Macro(BelowRangeColor, double);
384
386
389 vtkSetMacro(UseBelowRangeColor, vtkTypeBool);
390 vtkGetMacro(UseBelowRangeColor, vtkTypeBool);
391 vtkBooleanMacro(UseBelowRangeColor, vtkTypeBool);
393
395
399 vtkSetVector3Macro(AboveRangeColor, double);
400 vtkGetVector3Macro(AboveRangeColor, double);
402
404
407 vtkSetMacro(UseAboveRangeColor, vtkTypeBool);
408 vtkGetMacro(UseAboveRangeColor, vtkTypeBool);
409 vtkBooleanMacro(UseAboveRangeColor, vtkTypeBool);
411
419 double* GetDataPointer();
420
426 void FillFromDataPointer(int n, double* ptr);
427
431 void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
432 int numberOfValues, int inputIncrement, int outputIncrement) override;
433
435
439 vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
440 vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
441 vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
443
448
455 void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
456
461 int EstimateMinNumberOfSamples(double const& x1, double const& x2);
462
463protected:
466
467 vtkColorTransferFunctionInternals* Internal;
468
476
481
486
490 int Scale;
491
495 double NanColor[3];
496
501
505 double BelowRangeColor[3];
506
511
515 double AboveRangeColor[3];
516
521
525 double* Function;
526
530 double Range[2];
531
535 unsigned char UnsignedCharRGBAValue[4];
536
541
543 unsigned char* Table;
544
550
552
556 void SetRange(double, double) override {}
557 void SetRange(const double rng[2]) override { this->SetRange(rng[0], rng[1]); }
559
566
572
577 void MovePoint(double oldX, double newX);
578
583
584private:
586 void operator=(const vtkColorTransferFunction&) = delete;
587};
588
589VTK_ABI_NAMESPACE_END
590#endif
RealT r2
Definition PyrC2Basis.h:20
RealT s2
Definition PyrC2Basis.h:21
Defines a transfer function for mapping a property to an RGB color value.
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.
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)...
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.
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, PROLAB, 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.
void SetColorSpaceToProlab()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step.
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)...
int GetSize()
How many nodes define this function?
void SetColorSpaceToDiverging()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, 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 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.
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)...
void SetColorSpaceToLab()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, 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, PROLAB, 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, PROLAB, 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, PROLAB, 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...
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.
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:108
Superclass for mapping scalar values to colors.
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_PROLAB
#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:332
#define VTK_SIZEHINT(...)
#define VTK_MARSHALMANUAL