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 =========================================================================*/
40 #ifndef __vtkColorTransferFunction_h
41 #define __vtkColorTransferFunction_h
42 
43 #include "vtkScalarsToColors.h"
44 
45 class vtkColorTransferFunctionInternals;
46 
47 #define VTK_CTF_RGB 0
48 #define VTK_CTF_HSV 1
49 #define VTK_CTF_LAB 2
50 #define VTK_CTF_DIVERGING 3
51 
52 #define VTK_CTF_LINEAR 0
53 #define VTK_CTF_LOG10 1
54 
56 {
57 public:
58  static vtkColorTransferFunction *New();
60  void DeepCopy( vtkColorTransferFunction *f );
61  void ShallowCopy( vtkColorTransferFunction *f );
62 
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
67  int GetSize();
68 
70 
74  int AddRGBPoint( double x, double r, double g, double b );
75  int AddRGBPoint( double x, double r, double g, double b,
76  double midpoint, double sharpness );
77  int AddHSVPoint( double x, double h, double s, double v );
78  int AddHSVPoint( double x, double h, double s, double v,
79  double midpoint, double sharpness );
80  int RemovePoint( double x );
82 
84 
85  void AddRGBSegment( double x1, double r1, double g1, double b1,
86  double x2, double r2, double g2, double b2 );
87  void AddHSVSegment( double x1, double h1, double s1, double v1,
88  double x2, double h2, double s2, double v2 );
90 
92  void RemoveAllPoints();
93 
95 
96  double *GetColor(double x) {
97  return vtkScalarsToColors::GetColor(x); }
98  void GetColor(double x, double rgb[3]);
100 
102 
103  double GetRedValue( double x );
104  double GetGreenValue( double x );
105  double GetBlueValue( double x );
107 
109 
111  int GetNodeValue( int index, double val[6] );
112  int SetNodeValue( int index, double val[6] );
114 
116  virtual unsigned char *MapValue(double v);
117 
119 
120  vtkGetVector2Macro( Range, double );
122 
125  int AdjustRange(double range[2]);
126 
128 
129  void GetTable( double x1, double x2, int n, double* table );
130  void GetTable( double x1, double x2, int n, float* table );
131  const unsigned char *GetTable( double x1, double x2, int n);
133 
138  void BuildFunctionFromTable( double x1, double x2, int size, double *table);
139 
141 
142  vtkSetClampMacro( Clamping, int, 0, 1 );
143  vtkGetMacro( Clamping, int );
144  vtkBooleanMacro( Clamping, int );
146 
148 
155  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
156  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
157  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
158  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
159  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
160  vtkGetMacro( ColorSpace, int );
161  vtkSetMacro(HSVWrap, int);
162  vtkGetMacro(HSVWrap, int);
163  vtkBooleanMacro(HSVWrap, int);
165 
167 
170  vtkSetMacro(Scale,int);
171  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
172  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
173  vtkGetMacro(Scale,int);
175 
177 
179  vtkSetVector3Macro(NanColor, double);
180  vtkGetVector3Macro(NanColor, double);
182 
184 
186  double *GetDataPointer();
187  void FillFromDataPointer(int, double*);
189 
191 
192  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
193  int inputDataType, int numberOfValues,
194  int inputIncrement, int outputIncrement);
196 
198 
200  vtkSetMacro(AllowDuplicateScalars, int);
201  vtkGetMacro(AllowDuplicateScalars, int);
202  vtkBooleanMacro(AllowDuplicateScalars, int);
204 
207 
208 protected:
211 
212  vtkColorTransferFunctionInternals *Internal;
213 
214  // Determines the function value outside of defined points
215  // Zero = always return 0.0 outside of defined points
216  // One = clamp to the lowest value below defined points and
217  // highest value above defined points
218  int Clamping;
219 
220  // The color space in which interpolation is performed
222 
223  // Specify if HSW is warp or not
224  int HSVWrap;
225 
226  // The color interpolation scale (linear or logarithmic).
227  int Scale;
228 
229  // The color to use for not-a-number.
230  double NanColor[3];
231 
232  double *Function;
233 
234  // The min and max node locations
235  double Range[2];
236 
237  // An evaluated color (0 to 255 RGBA A=255)
238  unsigned char UnsignedCharRGBAValue[4];
239 
241 
243  unsigned char *Table;
245 
247 
249  virtual void SetRange(double, double) {};
250  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
252 
253  // Internal method to sort the vector and update the
254  // Range whenever a node is added or removed
255  void SortAndUpdateRange();
256 
259  void MovePoint(double oldX, double newX);
260 
261 private:
262  vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented.
263  void operator=(const vtkColorTransferFunction&); // Not implemented.
264 };
265 
266 #endif
267