VTK
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 
50 #define VTK_CTF_RGB 0
51 #define VTK_CTF_HSV 1
52 #define VTK_CTF_LAB 2
53 #define VTK_CTF_DIVERGING 3
54 #define VTK_CTF_LAB_CIEDE2000 4
55 
56 #define VTK_CTF_LINEAR 0
57 #define VTK_CTF_LOG10 1
58 
59 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
60 {
61 public:
62  static vtkColorTransferFunction *New();
64  void DeepCopy( vtkScalarsToColors *f ) override;
65  void ShallowCopy( vtkColorTransferFunction *f );
66 
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
75  int GetSize();
76 
78 
84  int AddRGBPoint( double x, double r, double g, double b );
85  int AddRGBPoint( double x, double r, double g, double b,
86  double midpoint, double sharpness );
87  int AddHSVPoint( double x, double h, double s, double v );
88  int AddHSVPoint( double x, double h, double s, double v,
89  double midpoint, double sharpness );
90  int RemovePoint( double x );
92 
94 
98  void AddRGBSegment( double x1, double r1, double g1, double b1,
99  double x2, double r2, double g2, double b2 );
100  void AddHSVSegment( double x1, double h1, double s1, double v1,
101  double x2, double h2, double s2, double v2 );
103 
107  void RemoveAllPoints();
108 
112  double *GetColor(double x) {
113  return vtkScalarsToColors::GetColor(x); }
114  void GetColor(double x, double rgb[3]) override;
115 
117 
120  double GetRedValue( double x );
121  double GetGreenValue( double x );
122  double GetBlueValue( double x );
124 
126 
131  int GetNodeValue( int index, double val[6] );
132  int SetNodeValue( int index, double val[6] );
134 
138  unsigned char *MapValue(double v) override;
139 
141 
144  double* GetRange() override { return this->Range; }
145  virtual void GetRange(double& arg1, double& arg2)
146  {
147  arg1 = this->Range[0];
148  arg2 = this->Range[1];
149  }
150  virtual void GetRange(double _arg[2])
151  {
152  this->GetRange(_arg[0],_arg[1]);
153  }
155 
161  int AdjustRange(double range[2]);
162 
164 
170  void GetTable( double x1, double x2, int n, double* table );
171  void GetTable( double x1, double x2, int n, float* table );
172  const unsigned char *GetTable( double x1, double x2, int n );
174 
184  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
185 
187 
195  vtkSetClampMacro( Clamping, int, 0, 1 );
196  vtkGetMacro( Clamping, int );
197  vtkBooleanMacro( Clamping, int );
199 
201 
212  vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_LAB_CIEDE2000);
213  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);}
214  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);}
215  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);}
216  void SetColorSpaceToLabCIEDE2000() { this->SetColorSpace(VTK_CTF_LAB_CIEDE2000); }
217  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
218  vtkGetMacro( ColorSpace, int );
219  vtkSetMacro(HSVWrap, int);
220  vtkGetMacro(HSVWrap, int);
221  vtkBooleanMacro(HSVWrap, int);
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  vtkSetVector3Macro(BelowRangeColor, double);
252  vtkGetVector3Macro(BelowRangeColor, double);
254 
256 
259  vtkSetMacro(UseBelowRangeColor, int);
260  vtkGetMacro(UseBelowRangeColor, int);
261  vtkBooleanMacro(UseBelowRangeColor, int);
263 
265 
269  vtkSetVector3Macro(AboveRangeColor, double);
270  vtkGetVector3Macro(AboveRangeColor, double);
272 
274 
277  vtkSetMacro(UseAboveRangeColor, int);
278  vtkGetMacro(UseAboveRangeColor, int);
279  vtkBooleanMacro(UseAboveRangeColor, int);
281 
289  double* GetDataPointer();
290 
296  void FillFromDataPointer(int n, double* ptr);
297 
301  void MapScalarsThroughTable2(void *input, unsigned char *output,
302  int inputDataType, int numberOfValues,
303  int inputIncrement, int outputIncrement) override;
304 
306 
310  vtkSetMacro(AllowDuplicateScalars, int);
311  vtkGetMacro(AllowDuplicateScalars, int);
312  vtkBooleanMacro(AllowDuplicateScalars, int);
314 
319 
326  void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
327 
332  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
333 
334 protected:
336  ~vtkColorTransferFunction() override;
337 
338  vtkColorTransferFunctionInternals *Internal;
339 
346  int Clamping;
347 
352 
356  int HSVWrap;
357 
361  int Scale;
362 
366  double NanColor[3];
367 
371  double BelowRangeColor[3];
372 
377 
381  double AboveRangeColor[3];
382 
387 
391  double* Function;
392 
396  double Range[2];
397 
401  unsigned char UnsignedCharRGBAValue[4];
402 
407 
409  unsigned char *Table;
410 
416 
421  void SetRange(double, double) override {}
422  void SetRange(const double rng[2]) override {this->SetRange(rng[0],rng[1]);}
423 
429  void SortAndUpdateRange();
430 
435  bool UpdateRange();
436 
441  void MovePoint(double oldX, double newX);
442 
446  double FindMinimumXDistance();
447 
448 private:
450  void operator=(const vtkColorTransferFunction&) = delete;
451 };
452 
453 #endif
int Clamping
Determines the function value outside of defined points Zero = always return 0.0 outside of defined p...
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 double * GetRange()
Sets/Gets the range of scalars that will be mapped.
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:345
#define VTK_CTF_LAB
void SetRange(double, double) override
Set the range of scalars being mapped.
vtkColorTransferFunctionInternals * Internal
virtual 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...
Superclass for mapping scalar values to colors.
int HSVWrap
Specify if HSV is wrap or not.
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, or Diverging.
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.
void SetColorSpaceToRGB()
Set/Get the color space used for interpolation: RGB, HSV, CIELAB, or Diverging.
virtual void GetRange(double _arg[2])
Returns min and max position of all function points.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
double * GetRange() override
Returns min and max position of all function points.
int AllowDuplicateScalars
If on, the same scalar value may have more than one node assigned to it.
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, or Diverging.
#define VTK_CTF_LAB_CIEDE2000
Defines a transfer function for mapping a property to an RGB color value.
int UseAboveRangeColor
Flag indicating whether below-range color should be used.
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.
double * Function
Temporary array to store data from the nodes.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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, or Diverging.
int UseBelowRangeColor
Flag indicating whether below-range color should be used.
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, or Diverging.