00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00048 #ifndef __vtkColorTransferFunction_h
00049 #define __vtkColorTransferFunction_h
00050
00051 #include "vtkScalarsToColors.h"
00052
00053 class vtkPiecewiseFunction;
00054
00055 #define VTK_CTF_RGB 0
00056 #define VTK_CTF_HSV 1
00057
00058 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00059 {
00060 public:
00061 static vtkColorTransferFunction *New();
00062 vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00063 void DeepCopy( vtkColorTransferFunction *f );
00064
00066 void PrintSelf(ostream& os, vtkIndent indent);
00067
00069 int GetSize() {return this->NumberOfPoints;};
00070
00072
00073 void AddRGBPoint( float x, float r, float g, float b );
00074 void AddHSVPoint( float x, float h, float s, float v );
00076
00078
00079 void AddRGBSegment( float x1, float r1, float g1, float b1,
00080 float x2, float r2, float g2, float b2 );
00081 void AddHSVSegment( float x1, float h1, float s1, float v1,
00082 float x2, float h2, float s2, float v2 );
00084
00086
00087 void RemovePoint( float x );
00088 void RemoveAllPoints();
00090
00092
00094 float *GetColor(float x) {
00095 return vtkScalarsToColors::GetColor(x); }
00096 void GetColor(float x, float rgb[3]);
00098
00100
00101 float GetRedValue( float x );
00102 float GetGreenValue( float x );
00103 float GetBlueValue( float x );
00105
00107 virtual unsigned char *MapValue(float v);
00108
00110
00111 vtkGetVector2Macro( Range, float );
00113
00115
00116 void GetTable( float x1, float x2, int n, float* table );
00117 const unsigned char *GetTable( float x1, float x2, int n);
00119
00124 void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00125
00127
00128 vtkSetClampMacro( Clamping, int, 0, 1 );
00129 vtkGetMacro( Clamping, int );
00130 vtkBooleanMacro( Clamping, int );
00132
00134
00135 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00136 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00137 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00138 vtkGetMacro( ColorSpace, int );
00140
00142
00144 float *GetDataPointer() {return this->Function;};
00145 void FillFromDataPointer(int, float*);
00147
00149
00150 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00151 int inputDataType, int numberOfValues,
00152 int inputIncrement, int outputIncrement);
00154
00155 protected:
00156 vtkColorTransferFunction();
00157 ~vtkColorTransferFunction();
00158
00159
00160
00161
00162
00163 int Clamping;
00164
00165
00166 int ColorSpace;
00167
00168
00169 float *Function;
00170 int FunctionSize;
00171 int NumberOfPoints;
00172
00173
00174 void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00175 void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00176
00177
00178 unsigned char UnsignedCharRGBAValue[4];
00179
00180
00181 float Range[2];
00182
00183
00184
00185 vtkPiecewiseFunction *Red;
00186 vtkPiecewiseFunction *Green;
00187 vtkPiecewiseFunction *Blue;
00188 vtkTimeStamp BuildTime;
00189 unsigned char *Table;
00190 int TableSize;
00191
00193
00195 virtual void SetRange(float, float) {};
00196 void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00198
00199
00200 private:
00201 vtkColorTransferFunction(const vtkColorTransferFunction&);
00202 void operator=(const vtkColorTransferFunction&);
00203 };
00204
00205 #endif
00206
00207