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 "vtkRenderingCoreModule.h" // For export macro
44 #include "vtkScalarsToColors.h"
45 
46 class vtkColorTransferFunctionInternals;
47 
48 #define VTK_CTF_RGB 0
49 #define VTK_CTF_HSV 1
50 #define VTK_CTF_LAB 2
51 #define VTK_CTF_DIVERGING 3
52 
53 #define VTK_CTF_LINEAR 0
54 #define VTK_CTF_LOG10 1
55 
56 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
57 {
58 public:
59  static vtkColorTransferFunction *New();
61  void DeepCopy( vtkScalarsToColors *f );
62  void ShallowCopy( vtkColorTransferFunction *f );
63 
65  void PrintSelf(ostream& os, vtkIndent indent);
66 
68  int GetSize();
69 
71 
75  int AddRGBPoint( double x, double r, double g, double b );
76  int AddRGBPoint( double x, double r, double g, double b,
77  double midpoint, double sharpness );
78  int AddHSVPoint( double x, double h, double s, double v );
79  int AddHSVPoint( double x, double h, double s, double v,
80  double midpoint, double sharpness );
81  int RemovePoint( double x );
83 
85 
86  void AddRGBSegment( double x1, double r1, double g1, double b1,
87  double x2, double r2, double g2, double b2 );
88  void AddHSVSegment( double x1, double h1, double s1, double v1,
89  double x2, double h2, double s2, double v2 );
91 
93  void RemoveAllPoints();
94 
96 
97  double *GetColor(double x) {
98  return vtkScalarsToColors::GetColor(x); }
99  void GetColor(double x, double rgb[3]);
101 
103 
104  double GetRedValue( double x );
105  double GetGreenValue( double x );
106  double GetBlueValue( double x );
108 
110 
112  int GetNodeValue( int index, double val[6] );
113  int SetNodeValue( int index, double val[6] );
115 
117  virtual unsigned char *MapValue(double v);
118 
120 
121  vtkGetVector2Macro( Range, double );
123 
126  int AdjustRange(double range[2]);
127 
129 
130  void GetTable( double x1, double x2, int n, double* table );
131  void GetTable( double x1, double x2, int n, float* table );
132  const unsigned char *GetTable( double x1, double x2, int n);
134 
139  void BuildFunctionFromTable( double x1, double x2, int size, double *table);
140 
142 
143  vtkSetClampMacro( Clamping, int, 0, 1 );
144  vtkGetMacro( Clamping, int );
145  vtkBooleanMacro( Clamping, int );
147 
149 
156  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
157  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
158  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
159  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
160  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
161  vtkGetMacro( ColorSpace, int );
162  vtkSetMacro(HSVWrap, int);
163  vtkGetMacro(HSVWrap, int);
164  vtkBooleanMacro(HSVWrap, int);
166 
168 
171  vtkSetMacro(Scale,int);
172  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
173  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
174  vtkGetMacro(Scale,int);
176 
178 
180  vtkSetVector3Macro(NanColor, double);
181  vtkGetVector3Macro(NanColor, double);
183 
185 
187  double *GetDataPointer();
188  void FillFromDataPointer(int, double*);
190 
192 
193  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
194  int inputDataType, int numberOfValues,
195  int inputIncrement, int outputIncrement);
197 
199 
201  vtkSetMacro(AllowDuplicateScalars, int);
202  vtkGetMacro(AllowDuplicateScalars, int);
203  vtkBooleanMacro(AllowDuplicateScalars, int);
205 
208 
209 protected:
212 
213  vtkColorTransferFunctionInternals *Internal;
214 
215  // Determines the function value outside of defined points
216  // Zero = always return 0.0 outside of defined points
217  // One = clamp to the lowest value below defined points and
218  // highest value above defined points
219  int Clamping;
220 
221  // The color space in which interpolation is performed
223 
224  // Specify if HSW is warp or not
225  int HSVWrap;
226 
227  // The color interpolation scale (linear or logarithmic).
228  int Scale;
229 
230  // The color to use for not-a-number.
231  double NanColor[3];
232 
233  double *Function;
234 
235  // The min and max node locations
236  double Range[2];
237 
238  // An evaluated color (0 to 255 RGBA A=255)
239  unsigned char UnsignedCharRGBAValue[4];
240 
242 
244  unsigned char *Table;
246 
248 
250  virtual void SetRange(double, double) {};
251  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
253 
254  // Internal method to sort the vector and update the
255  // Range whenever a node is added, edited or removed
256  // It always calls Modified().
257  void SortAndUpdateRange();
258  // Returns true if the range has been updated and Modified() has been called
259  bool UpdateRange();
260 
263  void MovePoint(double oldX, double newX);
264 
265 private:
266  vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented.
267  void operator=(const vtkColorTransferFunction&); // Not implemented.
268 };
269 
270 #endif
271