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
00056 #ifndef __vtkColorTransferFunction_h
00057 #define __vtkColorTransferFunction_h
00058
00059 #include "vtkScalarsToColors.h"
00060 #include "vtkPiecewiseFunction.h"
00061
00062 #define VTK_CTF_RGB 0
00063 #define VTK_CTF_HSV 1
00064
00065 class VTK_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00066 {
00067 public:
00068 static vtkColorTransferFunction *New();
00069 vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors);
00070 void DeepCopy( vtkColorTransferFunction *f );
00071
00073 void PrintSelf(ostream& os, vtkIndent indent);
00074
00076 int GetSize() {return this->NumberOfPoints;};
00077
00079 void AddRGBPoint( float x, float r, float g, float b );
00080 void AddHSVPoint( float x, float h, float s, float v );
00081
00083 void AddRGBSegment( float x1, float r1, float g1, float b1,
00084 float x2, float r2, float g2, float b2 );
00085 void AddHSVSegment( float x1, float h1, float s1, float v1,
00086 float x2, float h2, float s2, float v2 );
00087
00089 void RemovePoint( float x );
00090 void RemoveAllPoints();
00091
00094 float *GetColor(float x) {
00095 return vtkScalarsToColors::GetColor(x); }
00096 void GetColor(float x, float rgb[3]);
00097
00099 float GetRedValue( float x );
00100 float GetGreenValue( float x );
00101 float GetBlueValue( float x );
00102
00104 virtual unsigned char *MapValue(float v);
00105
00107 vtkGetVector2Macro( Range, float );
00108
00110 void GetTable( float x1, float x2, int n, float* table );
00111 const unsigned char *GetTable( float x1, float x2, int n);
00112
00117 void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00118
00120 vtkSetClampMacro( Clamping, int, 0, 1 );
00121 vtkGetMacro( Clamping, int );
00122 vtkBooleanMacro( Clamping, int );
00123
00125 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00126 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00127 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00128 vtkGetMacro( ColorSpace, int );
00129
00131 float *GetDataPointer() {return this->Function;};
00132
00134 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00135 int inputDataType, int numberOfValues,
00136 int inputIncrement, int outputIncrement);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00148 float *GetValue( float x )
00149 {VTK_LEGACY_METHOD(GetValue,"3.2"); return this->GetColor(x); }
00150
00153 int GetTotalSize();
00154 int GetRedSize();
00155 int GetGreenSize();
00156 int GetBlueSize();
00157
00160 void AddRedPoint( float x, float r );
00161 void AddGreenPoint( float x, float g );
00162 void AddBluePoint( float x, float b );
00163
00166 void RemoveRedPoint( float x );
00167 void RemoveGreenPoint( float x );
00168 void RemoveBluePoint( float x );
00169 void RemoveRGBPoint( float x );
00170
00173 void AddRedSegment( float x1, float r1, float x2, float r2 );
00174 void AddGreenSegment( float x1, float g1, float x2, float g2 );
00175 void AddBlueSegment( float x1, float b1, float x2, float b2 );
00176
00179 virtual void SetRange(float, float) {};
00180 void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00181
00185 vtkPiecewiseFunction *GetRedFunction(){return this->Red;};
00186 vtkPiecewiseFunction *GetGreenFunction(){return this->Green;};
00187 vtkPiecewiseFunction *GetBlueFunction(){return this->Blue;};
00188
00189
00190 protected:
00191 vtkColorTransferFunction();
00192 ~vtkColorTransferFunction();
00193 vtkColorTransferFunction(const vtkColorTransferFunction&) {};
00194 void operator=(const vtkColorTransferFunction&) {};
00195
00196
00197
00198
00199
00200 int Clamping;
00201
00202
00203 int ColorSpace;
00204
00205
00206 float *Function;
00207 int FunctionSize;
00208 int NumberOfPoints;
00209
00210
00211 void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00212 void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00213
00214
00215 unsigned char UnsignedCharRGBAValue[4];
00216
00217
00218 float Range[2];
00219
00220
00221
00222 vtkPiecewiseFunction *Red;
00223 vtkPiecewiseFunction *Green;
00224 vtkPiecewiseFunction *Blue;
00225 vtkTimeStamp BuildTime;
00226 unsigned char *Table;
00227 int TableSize;
00228 };
00229
00230 #endif
00231
00232