VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
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 
131  void GetTable( double x1, double x2, int n, double* table );
132  void GetTable( double x1, double x2, int n, float* table );
133  const unsigned char *GetTable( double x1, double x2, int n);
135 
140  void BuildFunctionFromTable( double x1, double x2, int size, double *table);
141 
143 
144  vtkSetClampMacro( Clamping, int, 0, 1 );
145  vtkGetMacro( Clamping, int );
146  vtkBooleanMacro( Clamping, int );
148 
150 
157  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
158  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
159  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
160  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
161  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
162  vtkGetMacro( ColorSpace, int );
163  vtkSetMacro(HSVWrap, int);
164  vtkGetMacro(HSVWrap, int);
165  vtkBooleanMacro(HSVWrap, int);
167 
169 
172  vtkSetMacro(Scale,int);
173  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
174  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
175  vtkGetMacro(Scale,int);
177 
179 
181  vtkSetVector3Macro(NanColor, double);
182  vtkGetVector3Macro(NanColor, double);
184 
186 
188  double *GetDataPointer();
189  void FillFromDataPointer(int, double*);
191 
193 
194  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
195  int inputDataType, int numberOfValues,
196  int inputIncrement, int outputIncrement);
198 
200 
202  vtkSetMacro(AllowDuplicateScalars, int);
203  vtkGetMacro(AllowDuplicateScalars, int);
204  vtkBooleanMacro(AllowDuplicateScalars, int);
206 
209 
213  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
214 
215 protected:
218 
219  vtkColorTransferFunctionInternals *Internal;
220 
221  // Determines the function value outside of defined points
222  // Zero = always return 0.0 outside of defined points
223  // One = clamp to the lowest value below defined points and
224  // highest value above defined points
225  int Clamping;
226 
227  // The color space in which interpolation is performed
229 
230  // Specify if HSW is warp or not
231  int HSVWrap;
232 
233  // The color interpolation scale (linear or logarithmic).
234  int Scale;
235 
236  // The color to use for not-a-number.
237  double NanColor[3];
238 
239  double *Function;
240 
241  // The min and max node locations
242  double Range[2];
243 
244  // An evaluated color (0 to 255 RGBA A=255)
245  unsigned char UnsignedCharRGBAValue[4];
246 
248 
250  unsigned char *Table;
252 
254 
256  virtual void SetRange(double, double) {}
257  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
259 
260  // Internal method to sort the vector and update the
261  // Range whenever a node is added, edited or removed
262  // It always calls Modified().
263  void SortAndUpdateRange();
264  // Returns true if the range has been updated and Modified() has been called
265  bool UpdateRange();
266 
269  void MovePoint(double oldX, double newX);
270 
271 private:
272  vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented.
273  void operator=(const vtkColorTransferFunction&); // Not implemented.
274 };
275 
276 #endif
277 
GLsizeiptr size
Definition: vtkgl.h:11843
GLclampf f
Definition: vtkgl.h:14181
GLboolean GLboolean GLboolean b
Definition: vtkgl.h:12312
const GLdouble * v
Definition: vtkgl.h:11595
GLuint index
Definition: vtkgl.h:11983
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
#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:268
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: vtkgl.h:11332
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
#define VTK_CTF_LAB
vtkColorTransferFunctionInternals * Internal
virtual unsigned char * MapValue(double v)
Superclass for mapping scalar values to colors.
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
GLfloat GLfloat GLfloat v2
Definition: vtkgl.h:12015
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.
GLfloat GLfloat v1
Definition: vtkgl.h:12014
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
Get the "indexed color" assigned to an index.
GLboolean GLboolean g
Definition: vtkgl.h:12312
#define VTKRENDERINGCORE_EXPORT
GLdouble s
Definition: vtkgl.h:11594
GLclampd n
Definition: vtkgl.h:14370
virtual void DeepCopy(vtkScalarsToColors *o)
virtual void SetRange(double, double)
void PrintSelf(ostream &os, vtkIndent indent)
GLenum GLint * range
Definition: vtkgl.h:14180
#define VTK_CTF_DIVERGING
GLfloat GLfloat GLfloat GLfloat h
Definition: vtkgl.h:14364
virtual vtkIdType GetNumberOfAvailableColors()
#define VTK_CTF_RGB
GLuint GLfloat * val
Definition: vtkgl.h:13789