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 =========================================================================*/
36 #ifndef vtkColorTransferFunction_h
37 #define vtkColorTransferFunction_h
38 
39 #include "vtkRenderingCoreModule.h" // For export macro
40 #include "vtkScalarsToColors.h"
41 
42 class vtkColorTransferFunctionInternals;
43 
44 #define VTK_CTF_RGB 0
45 #define VTK_CTF_HSV 1
46 #define VTK_CTF_LAB 2
47 #define VTK_CTF_DIVERGING 3
48 
49 #define VTK_CTF_LINEAR 0
50 #define VTK_CTF_LOG10 1
51 
52 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
53 {
54 public:
55  static vtkColorTransferFunction *New();
57  void DeepCopy( vtkScalarsToColors *f ) VTK_OVERRIDE;
58  void ShallowCopy( vtkColorTransferFunction *f );
59 
63  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
64 
68  int GetSize();
69 
71 
77  int AddRGBPoint( double x, double r, double g, double b );
78  int AddRGBPoint( double x, double r, double g, double b,
79  double midpoint, double sharpness );
80  int AddHSVPoint( double x, double h, double s, double v );
81  int AddHSVPoint( double x, double h, double s, double v,
82  double midpoint, double sharpness );
83  int RemovePoint( double x );
85 
87 
91  void AddRGBSegment( double x1, double r1, double g1, double b1,
92  double x2, double r2, double g2, double b2 );
93  void AddHSVSegment( double x1, double h1, double s1, double v1,
94  double x2, double h2, double s2, double v2 );
96 
100  void RemoveAllPoints();
101 
105  double *GetColor(double x) {
106  return vtkScalarsToColors::GetColor(x); }
107  void GetColor(double x, double rgb[3]) VTK_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  unsigned char *MapValue(double v) VTK_OVERRIDE;
132 
134 
137  double* GetRange() VTK_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])
144  {
145  this->GetRange(_arg[0],_arg[1]);
146  }
148 
154  int AdjustRange(double range[2]);
155 
157 
163  void GetTable( double x1, double x2, int n, double* table );
164  void GetTable( double x1, double x2, int n, float* table );
165  const unsigned char *GetTable( double x1, double x2, int n );
167 
177  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
178 
180 
188  vtkSetClampMacro( Clamping, int, 0, 1 );
189  vtkGetMacro( Clamping, int );
190  vtkBooleanMacro( Clamping, int );
192 
194 
203  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
204  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
205  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
206  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
207  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
208  vtkGetMacro( ColorSpace, int );
209  vtkSetMacro(HSVWrap, int);
210  vtkGetMacro(HSVWrap, int);
211  vtkBooleanMacro(HSVWrap, int);
213 
215 
220  vtkSetMacro(Scale,int);
221  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
222  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
223  vtkGetMacro(Scale,int);
225 
227 
232  vtkSetVector3Macro(NanColor, double);
233  vtkGetVector3Macro(NanColor, double);
235 
237 
241  vtkSetVector3Macro(BelowRangeColor, double);
242  vtkGetVector3Macro(BelowRangeColor, double);
244 
246 
249  vtkSetMacro(UseBelowRangeColor, int);
250  vtkGetMacro(UseBelowRangeColor, int);
251  vtkBooleanMacro(UseBelowRangeColor, int);
253 
255 
259  vtkSetVector3Macro(AboveRangeColor, double);
260  vtkGetVector3Macro(AboveRangeColor, double);
262 
264 
267  vtkSetMacro(UseAboveRangeColor, int);
268  vtkGetMacro(UseAboveRangeColor, int);
269  vtkBooleanMacro(UseAboveRangeColor, int);
271 
279  double* GetDataPointer();
280 
286  void FillFromDataPointer(int n, double* ptr);
287 
291  void MapScalarsThroughTable2(void *input, unsigned char *output,
292  int inputDataType, int numberOfValues,
293  int inputIncrement, int outputIncrement) VTK_OVERRIDE;
294 
296 
300  vtkSetMacro(AllowDuplicateScalars, int);
301  vtkGetMacro(AllowDuplicateScalars, int);
302  vtkBooleanMacro(AllowDuplicateScalars, int);
304 
308  vtkIdType GetNumberOfAvailableColors() VTK_OVERRIDE;
309 
316  void GetIndexedColor(vtkIdType idx, double rgba[4]) VTK_OVERRIDE;
317 
322  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
323 
324 protected:
326  ~vtkColorTransferFunction() VTK_OVERRIDE;
327 
328  vtkColorTransferFunctionInternals *Internal;
329 
336  int Clamping;
337 
342 
346  int HSVWrap;
347 
351  int Scale;
352 
356  double NanColor[3];
357 
361  double BelowRangeColor[3];
362 
367 
371  double AboveRangeColor[3];
372 
377 
381  double* Function;
382 
386  double Range[2];
387 
391  unsigned char UnsignedCharRGBAValue[4];
392 
397 
399  unsigned char *Table;
400 
406 
411  void SetRange(double, double) VTK_OVERRIDE {}
412  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
413 
419  void SortAndUpdateRange();
420 
425  bool UpdateRange();
426 
431  void MovePoint(double oldX, double newX);
432 
436  double FindMinimumXDistance();
437 
438 private:
439  vtkColorTransferFunction(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
440  void operator=(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
441 };
442 
443 #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:32
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 a RGBA unsigned char tuple (4 by...
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:33
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.
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.
#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