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 #define VTK_CTF_LAB_CIEDE2000 4
49 
50 #define VTK_CTF_LINEAR 0
51 #define VTK_CTF_LOG10 1
52 
53 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
54 {
55 public:
56  static vtkColorTransferFunction *New();
58  void DeepCopy( vtkScalarsToColors *f ) override;
59  void ShallowCopy( vtkColorTransferFunction *f );
60 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  int GetSize();
70 
72 
78  int AddRGBPoint( double x, double r, double g, double b );
79  int AddRGBPoint( double x, double r, double g, double b,
80  double midpoint, double sharpness );
81  int AddHSVPoint( double x, double h, double s, double v );
82  int AddHSVPoint( double x, double h, double s, double v,
83  double midpoint, double sharpness );
84  int RemovePoint( double x );
86 
88 
92  void AddRGBSegment( double x1, double r1, double g1, double b1,
93  double x2, double r2, double g2, double b2 );
94  void AddHSVSegment( double x1, double h1, double s1, double v1,
95  double x2, double h2, double s2, double v2 );
97 
101  void RemoveAllPoints();
102 
106  double *GetColor(double x) VTK_SIZEHINT(3) {
107  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])
145  {
146  this->GetRange(_arg[0],_arg[1]);
147  }
149 
155  int AdjustRange(double range[2]);
156 
158 
164  void GetTable( double x1, double x2, int n, double* table );
165  void GetTable( double x1, double x2, int n, float* table );
166  const unsigned char *GetTable( double x1, double x2, int n );
168 
178  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
179 
181 
189  vtkSetClampMacro( Clamping, vtkTypeBool, 0, 1 );
190  vtkGetMacro( Clamping, vtkTypeBool );
191  vtkBooleanMacro( Clamping, vtkTypeBool );
193 
195 
206  vtkSetClampMacro(ColorSpace, int, VTK_CTF_RGB, VTK_CTF_LAB_CIEDE2000);
207  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);}
208  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);}
209  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);}
210  void SetColorSpaceToLabCIEDE2000() { this->SetColorSpace(VTK_CTF_LAB_CIEDE2000); }
211  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
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  this->SetNanColor(r, g, b);
257  this->SetNanOpacity(a);
258  }
259 
260  void SetNanColorRGBA(double rgba[4]) {
261  this->SetNanColorRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
262  }
264 
266 
270  vtkSetVector3Macro(BelowRangeColor, double);
271  vtkGetVector3Macro(BelowRangeColor, double);
273 
275 
278  vtkSetMacro(UseBelowRangeColor, vtkTypeBool);
279  vtkGetMacro(UseBelowRangeColor, vtkTypeBool);
280  vtkBooleanMacro(UseBelowRangeColor, vtkTypeBool);
282 
284 
288  vtkSetVector3Macro(AboveRangeColor, double);
289  vtkGetVector3Macro(AboveRangeColor, double);
291 
293 
296  vtkSetMacro(UseAboveRangeColor, vtkTypeBool);
297  vtkGetMacro(UseAboveRangeColor, vtkTypeBool);
298  vtkBooleanMacro(UseAboveRangeColor, vtkTypeBool);
300 
308  double* GetDataPointer();
309 
315  void FillFromDataPointer(int n, double* ptr);
316 
320  void MapScalarsThroughTable2(void *input, unsigned char *output,
321  int inputDataType, int numberOfValues,
322  int inputIncrement, int outputIncrement) override;
323 
325 
329  vtkSetMacro(AllowDuplicateScalars, vtkTypeBool);
330  vtkGetMacro(AllowDuplicateScalars, vtkTypeBool);
331  vtkBooleanMacro(AllowDuplicateScalars, vtkTypeBool);
333 
338 
345  void GetIndexedColor(vtkIdType idx, double rgba[4]) override;
346 
351  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
352 
353 protected:
355  ~vtkColorTransferFunction() override;
356 
357  vtkColorTransferFunctionInternals *Internal;
358 
366 
371 
376 
380  int Scale;
381 
385  double NanColor[3];
386 
390  double NanOpacity;
391 
395  double BelowRangeColor[3];
396 
401 
405  double AboveRangeColor[3];
406 
411 
415  double* Function;
416 
420  double Range[2];
421 
425  unsigned char UnsignedCharRGBAValue[4];
426 
431 
433  unsigned char *Table;
434 
440 
445  void SetRange(double, double) override {}
446  void SetRange(const double rng[2]) override {this->SetRange(rng[0],rng[1]);}
447 
453  void SortAndUpdateRange();
454 
459  bool UpdateRange();
460 
465  void MovePoint(double oldX, double newX);
466 
470  double FindMinimumXDistance();
471 
472 private:
474  void operator=(const vtkColorTransferFunction&) = delete;
475 };
476 
477 #endif
vtkColorTransferFunction::GetRange
virtual void GetRange(double _arg[2])
Definition: vtkColorTransferFunction.h:144
vtkColorTransferFunction::GetColor
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
Definition: vtkColorTransferFunction.h:106
vtkColorTransferFunction::BuildTime
vtkTimeStamp BuildTime
Definition: vtkColorTransferFunction.h:432
vtkColorTransferFunction::SetNanColorRGBA
void SetNanColorRGBA(double rgba[4])
Definition: vtkColorTransferFunction.h:260
vtkColorTransferFunction::UseBelowRangeColor
vtkTypeBool UseBelowRangeColor
Flag indicating whether below-range color should be used.
Definition: vtkColorTransferFunction.h:400
vtkColorTransferFunction::SetRange
void SetRange(double, double) override
Set the range of scalars being mapped.
Definition: vtkColorTransferFunction.h:445
vtkColorTransferFunction::AllowDuplicateScalars
vtkTypeBool AllowDuplicateScalars
If on, the same scalar value may have more than one node assigned to it.
Definition: vtkColorTransferFunction.h:430
vtkColorTransferFunction::SetRange
void SetRange(const double rng[2]) override
Definition: vtkColorTransferFunction.h:446
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkColorTransferFunction::SetNanColorRGBA
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.
Definition: vtkColorTransferFunction.h:255
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
VTK_CTF_LAB
#define VTK_CTF_LAB
Definition: vtkColorTransferFunction.h:46
vtkColorTransferFunction::SetColorSpaceToDiverging
void SetColorSpaceToDiverging()
Definition: vtkColorTransferFunction.h:211
vtkColorTransferFunction::Internal
vtkColorTransferFunctionInternals * Internal
Definition: vtkColorTransferFunction.h:357
vtkX3D::range
Definition: vtkX3D.h:238
vtkColorTransferFunction::Scale
int Scale
The color interpolation scale (linear or logarithmic).
Definition: vtkColorTransferFunction.h:380
vtkScalarsToColors::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkColorTransferFunction::NanOpacity
double NanOpacity
The opacity to use for not-a-number.
Definition: vtkColorTransferFunction.h:390
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:53
vtkScalarsToColors::GetIndexedColor
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
Get the "indexed color" assigned to an index.
vtkColorTransferFunction::SetColorSpaceToLab
void SetColorSpaceToLab()
Definition: vtkColorTransferFunction.h:209
VTK_CTF_LINEAR
#define VTK_CTF_LINEAR
Definition: vtkColorTransferFunction.h:50
VTK_CTF_LAB_CIEDE2000
#define VTK_CTF_LAB_CIEDE2000
Definition: vtkColorTransferFunction.h:48
vtkColorTransferFunction::SetScaleToLog10
void SetScaleToLog10()
Definition: vtkColorTransferFunction.h:226
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkScalarsToColors::DeepCopy
virtual void DeepCopy(vtkScalarsToColors *o)
Copy the contents from another object.
vtkColorTransferFunction::SetColorSpaceToRGB
void SetColorSpaceToRGB()
Definition: vtkColorTransferFunction.h:207
vtkColorTransferFunction::SetScaleToLinear
void SetScaleToLinear()
Definition: vtkColorTransferFunction.h:225
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkScalarsToColors.h
vtkColorTransferFunction::TableSize
int TableSize
Temporary storage for the size of the table.
Definition: vtkColorTransferFunction.h:439
vtkX3D::size
Definition: vtkX3D.h:253
VTK_CTF_RGB
#define VTK_CTF_RGB
Definition: vtkColorTransferFunction.h:44
vtkColorTransferFunction::UseAboveRangeColor
vtkTypeBool UseAboveRangeColor
Flag indicating whether below-range color should be used.
Definition: vtkColorTransferFunction.h:410
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:60
vtkColorTransferFunction::Table
unsigned char * Table
Definition: vtkColorTransferFunction.h:433
vtkScalarsToColors::MapValue
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...
vtkScalarsToColors::GetColor
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...
vtkScalarsToColors::GetNumberOfAvailableColors
virtual vtkIdType GetNumberOfAvailableColors()
Get the number of available colors for mapping to.
vtkColorTransferFunction::ColorSpace
int ColorSpace
The color space in which interpolation is performed.
Definition: vtkColorTransferFunction.h:370
vtkColorTransferFunction::GetRange
double * GetRange() override
Returns min and max position of all function points.
Definition: vtkColorTransferFunction.h:138
vtkColorTransferFunction::Clamping
vtkTypeBool Clamping
Determines the function value outside of defined points Zero = always return 0.0 outside of defined p...
Definition: vtkColorTransferFunction.h:365
vtkScalarsToColors::GetRange
virtual double * GetRange()
Sets/Gets the range of scalars that will be mapped.
vtkColorTransferFunction::SetColorSpaceToHSV
void SetColorSpaceToHSV()
Definition: vtkColorTransferFunction.h:208
vtkScalarsToColors::MapScalarsThroughTable2
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
An internal method typically not used in applications.
vtkColorTransferFunction::SetColorSpaceToLabCIEDE2000
void SetColorSpaceToLabCIEDE2000()
Definition: vtkColorTransferFunction.h:210
vtkColorTransferFunction::GetRange
virtual void GetRange(double &arg1, double &arg2)
Definition: vtkColorTransferFunction.h:139
vtkScalarsToColors::New
static vtkScalarsToColors * New()
VTK_CTF_LOG10
#define VTK_CTF_LOG10
Definition: vtkColorTransferFunction.h:51
vtkColorTransferFunction::Function
double * Function
Temporary array to store data from the nodes.
Definition: vtkColorTransferFunction.h:415
VTK_CTF_DIVERGING
#define VTK_CTF_DIVERGING
Definition: vtkColorTransferFunction.h:47
vtkX3D::index
Definition: vtkX3D.h:246
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
h
VTK_CTF_HSV
#define VTK_CTF_HSV
Definition: vtkColorTransferFunction.h:45
vtkColorTransferFunction::HSVWrap
vtkTypeBool HSVWrap
Specify if HSV is wrap or not.
Definition: vtkColorTransferFunction.h:375