00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00049 #ifndef __vtkColorTransferFunction_h
00050 #define __vtkColorTransferFunction_h
00051
00052 #include "vtkScalarsToColors.h"
00053
00054 class vtkPiecewiseFunction;
00055
00056 #define VTK_CTF_RGB 0
00057 #define VTK_CTF_HSV 1
00058
00059 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00060 {
00061 public:
00062 static vtkColorTransferFunction *New();
00063 vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00064 void DeepCopy( vtkColorTransferFunction *f );
00065
00067 void PrintSelf(ostream& os, vtkIndent indent);
00068
00070 int GetSize() {return this->NumberOfPoints;};
00071
00073
00074 void AddRGBPoint( float x, float r, float g, float b );
00075 void AddHSVPoint( float x, float h, float s, float v );
00077
00079
00080 void AddRGBSegment( float x1, float r1, float g1, float b1,
00081 float x2, float r2, float g2, float b2 );
00082 void AddHSVSegment( float x1, float h1, float s1, float v1,
00083 float x2, float h2, float s2, float v2 );
00085
00087
00088 void RemovePoint( float x );
00089 void RemoveAllPoints();
00091
00093
00095 float *GetColor(float x) {
00096 return vtkScalarsToColors::GetColor(x); }
00097 void GetColor(float x, float rgb[3]);
00099
00101
00102 float GetRedValue( float x );
00103 float GetGreenValue( float x );
00104 float GetBlueValue( float x );
00106
00108 virtual unsigned char *MapValue(float v);
00109
00111
00112 vtkGetVector2Macro( Range, float );
00114
00116
00117 void GetTable( float x1, float x2, int n, float* table );
00118 const unsigned char *GetTable( float x1, float x2, int n);
00120
00125 void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00126
00128
00129 vtkSetClampMacro( Clamping, int, 0, 1 );
00130 vtkGetMacro( Clamping, int );
00131 vtkBooleanMacro( Clamping, int );
00133
00135
00136 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00137 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00138 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00139 vtkGetMacro( ColorSpace, int );
00141
00143
00145 float *GetDataPointer() {return this->Function;};
00146 void FillFromDataPointer(int, float*);
00148
00150
00151 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00152 int inputDataType, int numberOfValues,
00153 int inputIncrement, int outputIncrement);
00155
00156 protected:
00157 vtkColorTransferFunction();
00158 ~vtkColorTransferFunction();
00159
00160
00161
00162
00163
00164 int Clamping;
00165
00166
00167 int ColorSpace;
00168
00169
00170 float *Function;
00171 int FunctionSize;
00172 int NumberOfPoints;
00173
00174
00175 void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00176 void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00177
00178
00179 unsigned char UnsignedCharRGBAValue[4];
00180
00181
00182 float Range[2];
00183
00184
00185
00186 vtkPiecewiseFunction *Red;
00187 vtkPiecewiseFunction *Green;
00188 vtkPiecewiseFunction *Blue;
00189 vtkTimeStamp BuildTime;
00190 unsigned char *Table;
00191 int TableSize;
00192
00194
00196 virtual void SetRange(float, float) {};
00197 void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00199
00200
00201 private:
00202 vtkColorTransferFunction(const vtkColorTransferFunction&);
00203 void operator=(const vtkColorTransferFunction&);
00204 };
00205
00206 #endif
00207
00208