VTK  9.7.1
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
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 
39 VTK_ABI_NAMESPACE_BEGIN
40 class vtkColorTransferFunctionInternals;
41 class 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 #define VTK_CTF_PROLAB 6
50 
51 #define VTK_CTF_LINEAR 0
52 #define VTK_CTF_LOG10 1
53 
54 class VTKRENDERINGCORE_EXPORT VTK_MARSHALMANUAL vtkColorTransferFunction : public vtkScalarsToColors
55 {
56 public:
57  static vtkColorTransferFunction* New();
59  void DeepCopy(vtkScalarsToColors* f) override;
60  void ShallowCopy(vtkColorTransferFunction* f);
61 
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
70  int GetSize();
71 
73 
79  int AddRGBPoint(double x, double r, double g, double b);
80  int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness);
81  int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors);
82  int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors, double midpoint, double sharpness);
83  int AddHSVPoint(double x, double h, double s, double v);
84  int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness);
85  int RemovePoint(double x);
87 
89 
93  void AddRGBSegment(
94  double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2);
95  void AddHSVSegment(
96  double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2);
98 
102  void RemoveAllPoints();
103 
107  double* GetColor(double x) VTK_SIZEHINT(3) { return vtkScalarsToColors::GetColor(x); }
108  void GetColor(double x, double rgb[3]) override;
109 
111 
114  double GetRedValue(double x);
115  double GetGreenValue(double x);
116  double GetBlueValue(double x);
118 
120 
125  int GetNodeValue(int index, double val[6]);
126  int SetNodeValue(int index, double val[6]);
128 
132  const unsigned char* MapValue(double v) override;
133 
135 
138  double* GetRange() VTK_SIZEHINT(2) override { return this->Range; }
139  virtual void GetRange(double& arg1, double& arg2)
140  {
141  arg1 = this->Range[0];
142  arg2 = this->Range[1];
143  }
144  virtual void GetRange(double _arg[2]) { this->GetRange(_arg[0], _arg[1]); }
146 
152  int AdjustRange(double range[2]);
153 
155 
161  void GetTable(double x1, double x2, int n, double* table);
162  void GetTable(double x1, double x2, int n, float* table);
163  const unsigned char* GetTable(double x1, double x2, int n);
165 
175  void BuildFunctionFromTable(double x1, double x2, int size, double* table);
176 
178 
186  vtkSetClampMacro(Clamping, vtkTypeBool, 0, 1);
187  vtkGetMacro(Clamping, vtkTypeBool);
188  vtkBooleanMacro(Clamping, vtkTypeBool);
190 
192 
204  vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_PROLAB);
205  void SetColorSpaceToRGB() { this->SetColorSpace(VTK_CTF_RGB); }
206  void SetColorSpaceToHSV() { this->SetColorSpace(VTK_CTF_HSV); }
207  void SetColorSpaceToLab() { this->SetColorSpace(VTK_CTF_LAB); }
208  void SetColorSpaceToLabCIEDE2000() { this->SetColorSpace(VTK_CTF_LAB_CIEDE2000); }
209  void SetColorSpaceToDiverging() { this->SetColorSpace(VTK_CTF_DIVERGING); }
210  void SetColorSpaceToStep() { this->SetColorSpace(VTK_CTF_STEP); }
211  void SetColorSpaceToProlab() { this->SetColorSpace(VTK_CTF_PROLAB); };
212  vtkGetMacro(ColorSpace, int);
213  vtkSetMacro(HSVWrap, vtkTypeBool);
214  vtkGetMacro(HSVWrap, vtkTypeBool);
215  vtkBooleanMacro(HSVWrap, vtkTypeBool);
217 
219 
224  vtkSetMacro(Scale, int);
225  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); }
226  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); }
227  vtkGetMacro(Scale, int);
229 
231 
236  vtkSetVector3Macro(NanColor, double);
237  vtkGetVector3Macro(NanColor, double);
239 
241 
245  vtkSetMacro(NanOpacity, double);
246  vtkGetMacro(NanOpacity, double);
248 
250 
255  virtual void SetNanColorRGBA(double r, double g, double b, double a)
256  {
257  this->SetNanColor(r, g, b);
258  this->SetNanOpacity(a);
259  }
260 
261  void SetNanColorRGBA(double rgba[4])
262  {
263  this->SetNanColorRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
264  }
266 
268 
272  vtkSetVector3Macro(BelowRangeColor, double);
273  vtkGetVector3Macro(BelowRangeColor, double);
275 
277 
280  vtkSetMacro(UseBelowRangeColor, vtkTypeBool);
281  vtkGetMacro(UseBelowRangeColor, vtkTypeBool);
282  vtkBooleanMacro(UseBelowRangeColor, vtkTypeBool);
284 
286 
290  vtkSetVector3Macro(AboveRangeColor, double);
291  vtkGetVector3Macro(AboveRangeColor, double);
293 
295 
298  vtkSetMacro(UseAboveRangeColor, vtkTypeBool);
299  vtkGetMacro(UseAboveRangeColor, vtkTypeBool);
300  vtkBooleanMacro(UseAboveRangeColor, vtkTypeBool);
302 
310  double* GetDataPointer();
311 
317  void FillFromDataPointer(int n, double* ptr);
318 
320 
323  void MapScalarsThroughTable(vtkAbstractArray* input, unsigned char* output, int numberOfTuples,
324  int numberOfComponents, int vectorComponent, int outputFormat) override;
327 
329 
333  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
334  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
335  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
337 
342 
349  void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
350 
355  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
356 
357 protected:
359  ~vtkColorTransferFunction() override;
360 
361  vtkColorTransferFunctionInternals* Internal;
362 
370 
375 
380 
384  int Scale;
385 
389  double NanColor[3];
390 
394  double NanOpacity;
395 
399  double BelowRangeColor[3];
400 
405 
409  double AboveRangeColor[3];
410 
415 
419  double* Function;
420 
424  double Range[2];
425 
429  unsigned char UnsignedCharRGBAValue[4];
430 
435 
437  unsigned char* Table;
438 
444 
446 
450  void SetRange(double, double) override {}
451  void SetRange(const double rng[2]) override { this->SetRange(rng[0], rng[1]); }
453 
459  void SortAndUpdateRange();
460 
465  bool UpdateRange();
466 
471  void MovePoint(double oldX, double newX);
472 
476  double FindMinimumXDistance();
477 
478 private:
480  void operator=(const vtkColorTransferFunction&) = delete;
481 };
482 
483 VTK_ABI_NAMESPACE_END
484 #endif
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.
RealT r2
Definition: PyrC2Basis.h:20
void SetColorSpaceToProlab()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
double NanOpacity
The opacity to use for not-a-number.
int Scale
The color interpolation scale (linear or logarithmic).
Abstract superclass for all arrays.
#define VTK_CTF_HSV
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetScaleToLinear()
Set the type of scale to use, linear or logarithmic.
int vtkIdType
Definition: vtkType.h:363
#define VTK_CTF_LAB
void SetRange(double, double) override
Set the range of scalars being mapped.
vtkColorTransferFunctionInternals * Internal
RealT s2
Definition: PyrC2Basis.h:21
dynamic, self-adjusting array of double
virtual const unsigned char * MapValue(double v)
Map one value through the lookup table and return a color defined as an RGBA unsigned char tuple (4 b...
int vtkTypeBool
Definition: vtkABI.h:64
Superclass for mapping scalar values to colors.
auto Range(IterablePtr iterable, Options &&...opts) -> typename detail::IterableTraits< typename detail::StripPointers< IterablePtr >::type >::RangeType
Generate an iterable STL proxy object for a VTK container.
Definition: vtkRange.h:74
static vtkScalarsToColors * New()
#define VTK_MARSHALMANUAL
#define VTK_CTF_LINEAR
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
void SetColorSpaceToLab()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
#define VTK_CTF_STEP
a simple class to control print indentation
Definition: vtkIndent.h:28
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...
#define VTK_CTF_LOG10
void UpdateRange(A &min, A &max, const A &value)
Update an existing min - max range with a new prospective value.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool HSVWrap
Specify if HSV is wrap or not.
void SetColorSpaceToRGB()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
virtual void GetRange(double _arg[2])
Returns min and max position of all function points.
vtkTypeBool AllowDuplicateScalars
If on, the same scalar value may have more than one node assigned to it.
vtkTypeBool UseBelowRangeColor
Flag indicating whether below-range color should be used.
#define VTK_SIZEHINT(...)
double * GetRange() override
Returns min and max position of all function points.
vtkTypeBool UseAboveRangeColor
Flag indicating whether below-range color should be used.
virtual void GetRange(double &arg1, double &arg2)
Returns min and max position of all function points.
void SetColorSpaceToDiverging()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
#define VTK_CTF_PROLAB
#define VTK_CTF_LAB_CIEDE2000
Defines a transfer function for mapping a property to an RGB color value.
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
Get the "indexed color" assigned to an index.
int TableSize
Temporary storage for the size of the table.
void SetColorSpaceToStep()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
vtkTypeBool Clamping
Determines the function value outside of defined points Zero = always return 0.0 outside of defined p...
double * Function
Temporary array to store data from the nodes.
void SetScaleToLog10()
Set the type of scale to use, linear or logarithmic.
virtual void DeepCopy(vtkScalarsToColors *o)
Copy the contents from another object.
void SetColorSpaceToHSV()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
void SetRange(const double rng[2]) override
Set the range of scalars being mapped.
#define VTK_CTF_DIVERGING
int ColorSpace
The color space in which interpolation is performed.
virtual vtkIdType GetNumberOfAvailableColors()
Get the number of available colors for mapping to.
#define VTK_CTF_RGB
void SetColorSpaceToLabCIEDE2000()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, PROLAB, Diverging or Step...
void SetNanColorRGBA(double rgba[4])
Set the RGBA color to use when a NaN (not a number) is encountered.
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output, int outputFormat)
Map a set of scalars through the lookup table in a single operation.