00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00060 #ifndef __vtkColorTransferFunction_h
00061 #define __vtkColorTransferFunction_h
00062
00063 #include "vtkScalarsToColors.h"
00064 #include "vtkPiecewiseFunction.h"
00065
00066 #define VTK_CTF_RGB 0
00067 #define VTK_CTF_HSV 1
00068
00069 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00070 {
00071 public:
00072 static vtkColorTransferFunction *New();
00073 vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors);
00074 void DeepCopy( vtkColorTransferFunction *f );
00075
00077 void PrintSelf(ostream& os, vtkIndent indent);
00078
00080 int GetSize() {return this->NumberOfPoints;};
00081
00083
00084 void AddRGBPoint( float x, float r, float g, float b );
00085 void AddHSVPoint( float x, float h, float s, float v );
00087
00089
00090 void AddRGBSegment( float x1, float r1, float g1, float b1,
00091 float x2, float r2, float g2, float b2 );
00092 void AddHSVSegment( float x1, float h1, float s1, float v1,
00093 float x2, float h2, float s2, float v2 );
00095
00097
00098 void RemovePoint( float x );
00099 void RemoveAllPoints();
00101
00103
00105 float *GetColor(float x) {
00106 return vtkScalarsToColors::GetColor(x); }
00107 void GetColor(float x, float rgb[3]);
00109
00111
00112 float GetRedValue( float x );
00113 float GetGreenValue( float x );
00114 float GetBlueValue( float x );
00116
00118 virtual unsigned char *MapValue(float v);
00119
00121
00122 vtkGetVector2Macro( Range, float );
00124
00126
00127 void GetTable( float x1, float x2, int n, float* table );
00128 const unsigned char *GetTable( float x1, float x2, int n);
00130
00135 void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00136
00138
00139 vtkSetClampMacro( Clamping, int, 0, 1 );
00140 vtkGetMacro( Clamping, int );
00141 vtkBooleanMacro( Clamping, int );
00143
00145
00146 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00147 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00148 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00149 vtkGetMacro( ColorSpace, int );
00151
00153 float *GetDataPointer() {return this->Function;};
00154
00156
00157 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00158 int inputDataType, int numberOfValues,
00159 int inputIncrement, int outputIncrement);
00161
00162 protected:
00163 vtkColorTransferFunction();
00164 ~vtkColorTransferFunction();
00165
00166
00167
00168
00169
00170 int Clamping;
00171
00172
00173 int ColorSpace;
00174
00175
00176 float *Function;
00177 int FunctionSize;
00178 int NumberOfPoints;
00179
00180
00181 void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00182 void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00183
00184
00185 unsigned char UnsignedCharRGBAValue[4];
00186
00187
00188 float Range[2];
00189
00190
00191
00192 vtkPiecewiseFunction *Red;
00193 vtkPiecewiseFunction *Green;
00194 vtkPiecewiseFunction *Blue;
00195 vtkTimeStamp BuildTime;
00196 unsigned char *Table;
00197 int TableSize;
00198
00200
00202 virtual void SetRange(float, float) {};
00203 void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00205
00206
00207 private:
00208 vtkColorTransferFunction(const vtkColorTransferFunction&);
00209 void operator=(const vtkColorTransferFunction&);
00210 };
00211
00212 #endif
00213
00214