00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00036 #ifndef __vtkColorTransferFunction_h
00037 #define __vtkColorTransferFunction_h
00038
00039 #include "vtkScalarsToColors.h"
00040
00041 class vtkPiecewiseFunction;
00042
00043 #define VTK_CTF_RGB 0
00044 #define VTK_CTF_HSV 1
00045
00046 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00047 {
00048 public:
00049 static vtkColorTransferFunction *New();
00050 vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00051 void DeepCopy( vtkColorTransferFunction *f );
00052
00054 void PrintSelf(ostream& os, vtkIndent indent);
00055
00057 int GetSize() {return this->NumberOfPoints;};
00058
00060
00061 void AddRGBPoint( float x, float r, float g, float b );
00062 void AddHSVPoint( float x, float h, float s, float v );
00064
00066
00067 void AddRGBSegment( float x1, float r1, float g1, float b1,
00068 float x2, float r2, float g2, float b2 );
00069 void AddHSVSegment( float x1, float h1, float s1, float v1,
00070 float x2, float h2, float s2, float v2 );
00072
00074
00075 void RemovePoint( float x );
00076 void RemoveAllPoints();
00078
00080
00082 float *GetColor(float x) {
00083 return vtkScalarsToColors::GetColor(x); }
00084 void GetColor(float x, float rgb[3]);
00086
00088
00089 float GetRedValue( float x );
00090 float GetGreenValue( float x );
00091 float GetBlueValue( float x );
00093
00095 virtual unsigned char *MapValue(float v);
00096
00098
00099 vtkGetVector2Macro( Range, float );
00101
00103
00104 void GetTable( float x1, float x2, int n, float* table );
00105 const unsigned char *GetTable( float x1, float x2, int n);
00107
00112 void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00113
00115
00116 vtkSetClampMacro( Clamping, int, 0, 1 );
00117 vtkGetMacro( Clamping, int );
00118 vtkBooleanMacro( Clamping, int );
00120
00122
00123 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00124 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00125 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00126 vtkGetMacro( ColorSpace, int );
00128
00130
00132 float *GetDataPointer() {return this->Function;};
00133 void FillFromDataPointer(int, float*);
00135
00137
00138 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00139 int inputDataType, int numberOfValues,
00140 int inputIncrement, int outputIncrement);
00142
00143 protected:
00144 vtkColorTransferFunction();
00145 ~vtkColorTransferFunction();
00146
00147
00148
00149
00150
00151 int Clamping;
00152
00153
00154 int ColorSpace;
00155
00156
00157 float *Function;
00158 int FunctionSize;
00159 int NumberOfPoints;
00160
00161
00162 void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00163 void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00164
00165
00166 unsigned char UnsignedCharRGBAValue[4];
00167
00168
00169 float Range[2];
00170
00171
00172
00173 vtkPiecewiseFunction *Red;
00174 vtkPiecewiseFunction *Green;
00175 vtkPiecewiseFunction *Blue;
00176 vtkTimeStamp BuildTime;
00177 unsigned char *Table;
00178 int TableSize;
00179
00181
00183 virtual void SetRange(float, float) {};
00184 void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00186
00187
00188 private:
00189 vtkColorTransferFunction(const vtkColorTransferFunction&);
00190 void operator=(const vtkColorTransferFunction&);
00191 };
00192
00193 #endif
00194
00195