VTK  9.2.6
vtkColorTransferFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkColorTransferFunction.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
42 #ifndef vtkColorTransferFunction_h
43 #define vtkColorTransferFunction_h
44 
45 #include "vtkRenderingCoreModule.h" // For export macro
46 #include "vtkScalarsToColors.h"
47 
48 class vtkColorTransferFunctionInternals;
49 class vtkDoubleArray;
50 
51 #define VTK_CTF_RGB 0
52 #define VTK_CTF_HSV 1
53 #define VTK_CTF_LAB 2
54 #define VTK_CTF_DIVERGING 3
55 #define VTK_CTF_LAB_CIEDE2000 4
56 #define VTK_CTF_STEP 5
57 
58 #define VTK_CTF_LINEAR 0
59 #define VTK_CTF_LOG10 1
60 
61 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
62 {
63 public:
64  static vtkColorTransferFunction* New();
66  void DeepCopy(vtkScalarsToColors* f) override;
67  void ShallowCopy(vtkColorTransferFunction* f);
68 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
77  int GetSize();
78 
80 
86  int AddRGBPoint(double x, double r, double g, double b);
87  int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness);
88  int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors);
89  int AddRGBPoints(vtkDoubleArray* x, vtkDoubleArray* rgbColors, double midpoint, double sharpness);
90  int AddHSVPoint(double x, double h, double s, double v);
91  int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness);
92  int RemovePoint(double x);
94 
96 
100  void AddRGBSegment(
101  double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2);
102  void AddHSVSegment(
103  double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2);
105 
109  void RemoveAllPoints();
110 
114  double* GetColor(double x) VTK_SIZEHINT(3) { return vtkScalarsToColors::GetColor(x); }
115  void GetColor(double x, double rgb[3]) override;
116 
118 
121  double GetRedValue(double x);
122  double GetGreenValue(double x);
123  double GetBlueValue(double x);
125 
127 
132  int GetNodeValue(int index, double val[6]);
133  int SetNodeValue(int index, double val[6]);
135 
139  const unsigned char* MapValue(double v) override;
140 
142 
145  double* GetRange() VTK_SIZEHINT(2) override { return this->Range; }
146  virtual void GetRange(double& arg1, double& arg2)
147  {
148  arg1 = this->Range[0];
149  arg2 = this->Range[1];
150  }
151  virtual void GetRange(double _arg[2]) { this->GetRange(_arg[0], _arg[1]); }
153 
159  int AdjustRange(double range[2]);
160 
162 
168  void GetTable(double x1, double x2, int n, double* table);
169  void GetTable(double x1, double x2, int n, float* table);
170  const unsigned char* GetTable(double x1, double x2, int n);
172 
182  void BuildFunctionFromTable(double x1, double x2, int size, double* table);
183 
185 
193  vtkSetClampMacro(Clamping, vtkTypeBool, 0, 1);
194  vtkGetMacro(Clamping, vtkTypeBool);
195  vtkBooleanMacro(Clamping, vtkTypeBool);
197 
199 
211  vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_STEP);
212  void SetColorSpaceToRGB() { this->SetColorSpace(VTK_CTF_RGB); }
213  void SetColorSpaceToHSV() { this->SetColorSpace(VTK_CTF_HSV); }
214  void SetColorSpaceToLab() { this->SetColorSpace(VTK_CTF_LAB); }
215  void SetColorSpaceToLabCIEDE2000() { this->SetColorSpace(VTK_CTF_LAB_CIEDE2000); }
216  void SetColorSpaceToDiverging() { this->SetColorSpace(VTK_CTF_DIVERGING); }
217  void SetColorSpaceToStep() { this->SetColorSpace(VTK_CTF_STEP); }
218  vtkGetMacro(ColorSpace, int);
219  vtkSetMacro(HSVWrap, vtkTypeBool);
220  vtkGetMacro(HSVWrap, vtkTypeBool);
221  vtkBooleanMacro(HSVWrap, vtkTypeBool);
223 
225 
230  vtkSetMacro(Scale, int);
231  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); }
232  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); }
233  vtkGetMacro(Scale, int);
235 
237 
242  vtkSetVector3Macro(NanColor, double);
243  vtkGetVector3Macro(NanColor, double);
245 
247 
251  vtkSetMacro(NanOpacity, double);
252  vtkGetMacro(NanOpacity, double);
254 
256 
261  virtual void SetNanColorRGBA(double r, double g, double b, double a)
262  {
263  this->SetNanColor(r, g, b);
264  this->SetNanOpacity(a);
265  }
266 
267  void SetNanColorRGBA(double rgba[4])
268  {
269  this->SetNanColorRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
270  }
272 
274 
278  vtkSetVector3Macro(BelowRangeColor, double);
279  vtkGetVector3Macro(BelowRangeColor, double);
281 
283 
286  vtkSetMacro(UseBelowRangeColor, vtkTypeBool);
287  vtkGetMacro(UseBelowRangeColor, vtkTypeBool);
288  vtkBooleanMacro(UseBelowRangeColor, vtkTypeBool);
290 
292 
296  vtkSetVector3Macro(AboveRangeColor, double);
297  vtkGetVector3Macro(AboveRangeColor, double);
299 
301 
304  vtkSetMacro(UseAboveRangeColor, vtkTypeBool);
305  vtkGetMacro(UseAboveRangeColor, vtkTypeBool);
306  vtkBooleanMacro(UseAboveRangeColor, vtkTypeBool);
308 
316  double* GetDataPointer();
317 
323  void FillFromDataPointer(int n, double* ptr);
324 
328  void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
329  int numberOfValues, int inputIncrement, int outputIncrement) override;
330 
332 
336  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
337  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
338  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
340 
345 
352  void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
353 
358  int EstimateMinNumberOfSamples(double const& x1, double const& x2);
359 
360 protected:
362  ~vtkColorTransferFunction() override;
363 
364  vtkColorTransferFunctionInternals* Internal;
365 
373 
378 
383 
387  int Scale;
388 
392  double NanColor[3];
393 
397  double NanOpacity;
398 
402  double BelowRangeColor[3];
403 
408 
412  double AboveRangeColor[3];
413 
418 
422  double* Function;
423 
427  double Range[2];
428 
432  unsigned char UnsignedCharRGBAValue[4];
433 
438 
440  unsigned char* Table;
441 
447 
452  void SetRange(double, double) override {}
453  void SetRange(const double rng[2]) override { this->SetRange(rng[0], rng[1]); }
454 
460  void SortAndUpdateRange();
461 
466  bool UpdateRange();
467 
472  void MovePoint(double oldX, double newX);
473 
477  double FindMinimumXDistance();
478 
479 private:
481  void operator=(const vtkColorTransferFunction&) = delete;
482 };
483 
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.
double NanOpacity
The opacity to use for not-a-number.
void UpdateRange(A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=0)
int Scale
The color interpolation scale (linear or logarithmic).
#define VTK_CTF_HSV
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void SetScaleToLinear()
Set the type of scale to use, linear or logarithmic.
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
An internal method typically not used in applications.
int vtkIdType
Definition: vtkType.h:332
#define VTK_CTF_LAB
void SetRange(double, double) override
Set the range of scalars being mapped.
vtkColorTransferFunctionInternals * Internal
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:69
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:85
static vtkScalarsToColors * New()
#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, Diverging or Step.
#define VTK_CTF_STEP
a simple class to control print indentation
Definition: vtkIndent.h:39
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 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, 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, Diverging or Step.
#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, 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, Diverging or Step.
void SetRange(const double rng[2]) override
Sets/Gets the range of scalars that will be 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, Diverging or Step.
void SetNanColorRGBA(double rgba[4])
Set the RGBA color to use when a NaN (not a number) is encountered.