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 
55 #define VTK_CTF_LINEAR 0
56 #define VTK_CTF_LOG10 1
57 
58 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
59 {
60 public:
61  static vtkColorTransferFunction *New();
63  void DeepCopy( vtkScalarsToColors *f ) VTK_OVERRIDE;
64  void ShallowCopy( vtkColorTransferFunction *f );
65 
69  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
70 
74  int GetSize();
75 
77 
83  int AddRGBPoint( double x, double r, double g, double b );
84  int AddRGBPoint( double x, double r, double g, double b,
85  double midpoint, double sharpness );
86  int AddHSVPoint( double x, double h, double s, double v );
87  int AddHSVPoint( double x, double h, double s, double v,
88  double midpoint, double sharpness );
89  int RemovePoint( double x );
91 
93 
97  void AddRGBSegment( double x1, double r1, double g1, double b1,
98  double x2, double r2, double g2, double b2 );
99  void AddHSVSegment( double x1, double h1, double s1, double v1,
100  double x2, double h2, double s2, double v2 );
102 
106  void RemoveAllPoints();
107 
111  double *GetColor(double x) {
112  return vtkScalarsToColors::GetColor(x); }
113  void GetColor(double x, double rgb[3]) VTK_OVERRIDE;
114 
116 
119  double GetRedValue( double x );
120  double GetGreenValue( double x );
121  double GetBlueValue( double x );
123 
125 
130  int GetNodeValue( int index, double val[6] );
131  int SetNodeValue( int index, double val[6] );
133 
137  unsigned char *MapValue(double v) VTK_OVERRIDE;
138 
140 
143  double* GetRange() VTK_OVERRIDE { return this->Range; }
144  virtual void GetRange(double& arg1, double& arg2)
145  {
146  arg1 = this->Range[0];
147  arg2 = this->Range[1];
148  }
149  virtual void GetRange(double _arg[2])
150  {
151  this->GetRange(_arg[0],_arg[1]);
152  }
154 
160  int AdjustRange(double range[2]);
161 
163 
169  void GetTable( double x1, double x2, int n, double* table );
170  void GetTable( double x1, double x2, int n, float* table );
171  const unsigned char *GetTable( double x1, double x2, int n );
173 
183  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
184 
186 
194  vtkSetClampMacro( Clamping, int, 0, 1 );
195  vtkGetMacro( Clamping, int );
196  vtkBooleanMacro( Clamping, int );
198 
200 
209  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
210  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
211  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
212  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
213  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
214  vtkGetMacro( ColorSpace, int );
215  vtkSetMacro(HSVWrap, int);
216  vtkGetMacro(HSVWrap, int);
217  vtkBooleanMacro(HSVWrap, int);
219 
221 
226  vtkSetMacro(Scale,int);
227  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
228  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
229  vtkGetMacro(Scale,int);
231 
233 
238  vtkSetVector3Macro(NanColor, double);
239  vtkGetVector3Macro(NanColor, double);
241 
243 
247  vtkSetVector3Macro(BelowRangeColor, double);
248  vtkGetVector3Macro(BelowRangeColor, double);
250 
252 
255  vtkSetMacro(UseBelowRangeColor, int);
256  vtkGetMacro(UseBelowRangeColor, int);
257  vtkBooleanMacro(UseBelowRangeColor, int);
259 
261 
265  vtkSetVector3Macro(AboveRangeColor, double);
266  vtkGetVector3Macro(AboveRangeColor, double);
268 
270 
273  vtkSetMacro(UseAboveRangeColor, int);
274  vtkGetMacro(UseAboveRangeColor, int);
275  vtkBooleanMacro(UseAboveRangeColor, int);
277 
285  double* GetDataPointer();
286 
292  void FillFromDataPointer(int n, double* ptr);
293 
297  void MapScalarsThroughTable2(void *input, unsigned char *output,
298  int inputDataType, int numberOfValues,
299  int inputIncrement, int outputIncrement) VTK_OVERRIDE;
300 
302 
306  vtkSetMacro(AllowDuplicateScalars, int);
307  vtkGetMacro(AllowDuplicateScalars, int);
308  vtkBooleanMacro(AllowDuplicateScalars, int);
310 
314  vtkIdType GetNumberOfAvailableColors() VTK_OVERRIDE;
315 
322  void GetIndexedColor(vtkIdType idx, double rgba[4]) VTK_OVERRIDE;
323 
328  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
329 
330 protected:
332  ~vtkColorTransferFunction() VTK_OVERRIDE;
333 
334  vtkColorTransferFunctionInternals *Internal;
335 
342  int Clamping;
343 
348 
352  int HSVWrap;
353 
357  int Scale;
358 
362  double NanColor[3];
363 
367  double BelowRangeColor[3];
368 
373 
377  double AboveRangeColor[3];
378 
383 
387  double* Function;
388 
392  double Range[2];
393 
397  unsigned char UnsignedCharRGBAValue[4];
398 
403 
405  unsigned char *Table;
406 
412 
417  void SetRange(double, double) VTK_OVERRIDE {}
418  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
419 
425  void SortAndUpdateRange();
426 
431  bool UpdateRange();
432 
437  void MovePoint(double oldX, double newX);
438 
442  double FindMinimumXDistance();
443 
444 private:
445  vtkColorTransferFunction(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
446  void operator=(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
447 };
448 
449 #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 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: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.
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