00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00038 #ifndef __vtkColorTransferFunction_h
00039 #define __vtkColorTransferFunction_h
00040
00041 #include "vtkScalarsToColors.h"
00042
00043 class vtkColorTransferFunctionInternals;
00044
00045 #define VTK_CTF_RGB 0
00046 #define VTK_CTF_HSV 1
00047 #define VTK_CTF_LAB 2
00048 #define VTK_CTF_DIVERGING 3
00049
00050 #define VTK_CTF_LINEAR 0
00051 #define VTK_CTF_LOG10 1
00052
00053 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00054 {
00055 public:
00056 static vtkColorTransferFunction *New();
00057 vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00058 void DeepCopy( vtkColorTransferFunction *f );
00059 void ShallowCopy( vtkColorTransferFunction *f );
00060
00062 void PrintSelf(ostream& os, vtkIndent indent);
00063
00065 int GetSize();
00066
00068
00070 int AddRGBPoint( double x, double r, double g, double b );
00071 int AddRGBPoint( double x, double r, double g, double b,
00072 double midpoint, double sharpness );
00073 int AddHSVPoint( double x, double h, double s, double v );
00074 int AddHSVPoint( double x, double h, double s, double v,
00075 double midpoint, double sharpness );
00076 int RemovePoint( double x );
00078
00080
00081 void AddRGBSegment( double x1, double r1, double g1, double b1,
00082 double x2, double r2, double g2, double b2 );
00083 void AddHSVSegment( double x1, double h1, double s1, double v1,
00084 double x2, double h2, double s2, double v2 );
00086
00088 void RemoveAllPoints();
00089
00091
00092 double *GetColor(double x) {
00093 return vtkScalarsToColors::GetColor(x); }
00094 void GetColor(double x, double rgb[3]);
00096
00098
00099 double GetRedValue( double x );
00100 double GetGreenValue( double x );
00101 double GetBlueValue( double x );
00103
00105
00107 int GetNodeValue( int index, double val[6] );
00108 int SetNodeValue( int index, double val[6] );
00110
00112 virtual unsigned char *MapValue(double v);
00113
00115
00116 vtkGetVector2Macro( Range, double );
00118
00121 int AdjustRange(double range[2]);
00122
00124
00125 void GetTable( double x1, double x2, int n, double* table );
00126 void GetTable( double x1, double x2, int n, float* table );
00127 const unsigned char *GetTable( double x1, double x2, int n);
00129
00134 void BuildFunctionFromTable( double x1, double x2, int size, double *table);
00135
00137
00138 vtkSetClampMacro( Clamping, int, 0, 1 );
00139 vtkGetMacro( Clamping, int );
00140 vtkBooleanMacro( Clamping, int );
00142
00144
00151 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
00152 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00153 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00154 void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
00155 void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
00156 vtkGetMacro( ColorSpace, int );
00157 vtkSetMacro(HSVWrap, int);
00158 vtkGetMacro(HSVWrap, int);
00159 vtkBooleanMacro(HSVWrap, int);
00161
00163
00166 vtkSetMacro(Scale,int);
00167 void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
00168 void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
00169 vtkGetMacro(Scale,int);
00171
00173
00175 double *GetDataPointer();
00176 void FillFromDataPointer(int, double*);
00178
00180
00181 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00182 int inputDataType, int numberOfValues,
00183 int inputIncrement, int outputIncrement);
00185
00187
00189 vtkSetMacro(AllowDuplicateScalars, int);
00190 vtkGetMacro(AllowDuplicateScalars, int);
00191 vtkBooleanMacro(AllowDuplicateScalars, int);
00193
00194 protected:
00195 vtkColorTransferFunction();
00196 ~vtkColorTransferFunction();
00197
00198 vtkColorTransferFunctionInternals *Internal;
00199
00200
00201
00202
00203
00204 int Clamping;
00205
00206
00207 int ColorSpace;
00208
00209
00210 int HSVWrap;
00211
00212
00213 int Scale;
00214
00215 double *Function;
00216
00217
00218 double Range[2];
00219
00220
00221 unsigned char UnsignedCharRGBAValue[4];
00222
00223 int AllowDuplicateScalars;
00224
00225 vtkTimeStamp BuildTime;
00226 unsigned char *Table;
00227 int TableSize;
00228
00230
00232 virtual void SetRange(double, double) {};
00233 void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00235
00236
00237
00238 void SortAndUpdateRange();
00239
00242 void MovePoint(double oldX, double newX);
00243
00244 private:
00245 vtkColorTransferFunction(const vtkColorTransferFunction&);
00246 void operator=(const vtkColorTransferFunction&);
00247 };
00248
00249 #endif
00250