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 =========================================================================*/
41 #ifndef vtkColorTransferFunction_h
42 #define vtkColorTransferFunction_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkScalarsToColors.h"
46 
47 class vtkColorTransferFunctionInternals;
48 
49 #define VTK_CTF_RGB 0
50 #define VTK_CTF_HSV 1
51 #define VTK_CTF_LAB 2
52 #define VTK_CTF_DIVERGING 3
53 
54 #define VTK_CTF_LINEAR 0
55 #define VTK_CTF_LOG10 1
56 
58 {
59 public:
60  static vtkColorTransferFunction *New();
62  void DeepCopy( vtkScalarsToColors *f );
63  void ShallowCopy( vtkColorTransferFunction *f );
64 
66  void PrintSelf(ostream& os, vtkIndent indent);
67 
69  int GetSize();
70 
72 
76  int AddRGBPoint( double x, double r, double g, double b );
77  int AddRGBPoint( double x, double r, double g, double b,
78  double midpoint, double sharpness );
79  int AddHSVPoint( double x, double h, double s, double v );
80  int AddHSVPoint( double x, double h, double s, double v,
81  double midpoint, double sharpness );
82  int RemovePoint( double x );
84 
86 
87  void AddRGBSegment( double x1, double r1, double g1, double b1,
88  double x2, double r2, double g2, double b2 );
89  void AddHSVSegment( double x1, double h1, double s1, double v1,
90  double x2, double h2, double s2, double v2 );
92 
94  void RemoveAllPoints();
95 
97 
98  double *GetColor(double x) {
99  return vtkScalarsToColors::GetColor(x); }
100  void GetColor(double x, double rgb[3]);
102 
104 
105  double GetRedValue( double x );
106  double GetGreenValue( double x );
107  double GetBlueValue( double x );
109 
111 
113  int GetNodeValue( int index, double val[6] );
114  int SetNodeValue( int index, double val[6] );
116 
118  virtual unsigned char *MapValue(double v);
119 
121 
122  vtkGetVector2Macro( Range, double );
124 
127  int AdjustRange(double range[2]);
128 
130 
133  void GetTable( double x1, double x2, int n, double* table );
134  void GetTable( double x1, double x2, int n, float* table );
135  const unsigned char *GetTable( double x1, double x2, int n );
137 
145  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
146 
148 
153  vtkSetClampMacro( Clamping, int, 0, 1 );
154  vtkGetMacro( Clamping, int );
155  vtkBooleanMacro( Clamping, int );
157 
159 
166  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
167  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
168  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
169  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
170  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
171  vtkGetMacro( ColorSpace, int );
172  vtkSetMacro(HSVWrap, int);
173  vtkGetMacro(HSVWrap, int);
174  vtkBooleanMacro(HSVWrap, int);
176 
178 
181  vtkSetMacro(Scale,int);
182  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
183  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
184  vtkGetMacro(Scale,int);
186 
188 
190  vtkSetVector3Macro(NanColor, double);
191  vtkGetVector3Macro(NanColor, double);
193 
195 
197  vtkSetVector3Macro(BelowRangeColor, double);
198  vtkGetVector3Macro(BelowRangeColor, double);
200 
202 
203  vtkSetMacro(UseBelowRangeColor, int);
204  vtkGetMacro(UseBelowRangeColor, int);
205  vtkBooleanMacro(UseBelowRangeColor, int);
207 
209 
211  vtkSetVector3Macro(AboveRangeColor, double);
212  vtkGetVector3Macro(AboveRangeColor, double);
214 
216 
217  vtkSetMacro(UseAboveRangeColor, int);
218  vtkGetMacro(UseAboveRangeColor, int);
219  vtkBooleanMacro(UseAboveRangeColor, int);
221 
227  double* GetDataPointer();
228 
232  void FillFromDataPointer(int n, double* ptr);
233 
235 
236  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
237  int inputDataType, int numberOfValues,
238  int inputIncrement, int outputIncrement);
240 
242 
244  vtkSetMacro(AllowDuplicateScalars, int);
245  vtkGetMacro(AllowDuplicateScalars, int);
246  vtkBooleanMacro(AllowDuplicateScalars, int);
248 
251 
255  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
256 
257 protected:
260 
261  vtkColorTransferFunctionInternals *Internal;
262 
266  int Clamping;
267 
270 
272  int HSVWrap;
273 
275  int Scale;
276 
278  double NanColor[3];
279 
281  double BelowRangeColor[3];
282 
285 
287  double AboveRangeColor[3];
288 
291 
293  double* Function;
294 
296  double Range[2];
297 
299  unsigned char UnsignedCharRGBAValue[4];
300 
304 
306  unsigned char *Table;
307 
311 
313 
315  virtual void SetRange(double, double) {}
316  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
318 
321  void SortAndUpdateRange();
322 
325  bool UpdateRange();
326 
329  void MovePoint(double oldX, double newX);
330 
331 private:
332  vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented.
333  void operator=(const vtkColorTransferFunction&); // Not implemented.
334 };
335 
336 #endif
#define VTK_CTF_HSV
record modification and/or execution time
Definition: vtkTimeStamp.h:34
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
int vtkIdType
Definition: vtkType.h:275
#define VTK_CTF_LAB
vtkColorTransferFunctionInternals * Internal
virtual unsigned char * MapValue(double v)
Superclass for mapping scalar values to colors.
static vtkScalarsToColors * New()
#define VTK_CTF_LINEAR
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void GetColor(double v, double rgb[3])
#define VTK_CTF_LOG10
Defines a transfer function for mapping a property to an RGB color value.
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
#define VTKRENDERINGCORE_EXPORT
virtual void DeepCopy(vtkScalarsToColors *o)
virtual void SetRange(double, double)
void PrintSelf(ostream &os, vtkIndent indent)
#define VTK_CTF_DIVERGING
virtual vtkIdType GetNumberOfAvailableColors()
#define VTK_CTF_RGB