00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00037 #ifndef __vtkColorTransferFunction_h
00038 #define __vtkColorTransferFunction_h
00039
00040 #include "vtkScalarsToColors.h"
00041
00042 class vtkColorTransferFunctionInternals;
00043
00044 #define VTK_CTF_RGB 0
00045 #define VTK_CTF_HSV 1
00046 #define VTK_CTF_LAB 2
00047 #define VTK_CTF_DIVERGING 3
00048
00049 #define VTK_CTF_LINEAR 0
00050 #define VTK_CTF_LOG10 1
00051
00052 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00053 {
00054 public:
00055 static vtkColorTransferFunction *New();
00056 vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00057 void DeepCopy( vtkColorTransferFunction *f );
00058 void ShallowCopy( vtkColorTransferFunction *f );
00059
00061 void PrintSelf(ostream& os, vtkIndent indent);
00062
00064 int GetSize();
00065
00067
00071 int AddRGBPoint( double x, double r, double g, double b );
00072 int AddRGBPoint( double x, double r, double g, double b,
00073 double midpoint, double sharpness );
00074 int AddHSVPoint( double x, double h, double s, double v );
00075 int AddHSVPoint( double x, double h, double s, double v,
00076 double midpoint, double sharpness );
00077 int RemovePoint( double x );
00079
00081
00082 void AddRGBSegment( double x1, double r1, double g1, double b1,
00083 double x2, double r2, double g2, double b2 );
00084 void AddHSVSegment( double x1, double h1, double s1, double v1,
00085 double x2, double h2, double s2, double v2 );
00087
00089 void RemoveAllPoints();
00090
00092
00093 double *GetColor(double x) {
00094 return vtkScalarsToColors::GetColor(x); }
00095 void GetColor(double x, double rgb[3]);
00097
00099
00100 double GetRedValue( double x );
00101 double GetGreenValue( double x );
00102 double GetBlueValue( double x );
00104
00106
00108 int GetNodeValue( int index, double val[6] );
00109 int SetNodeValue( int index, double val[6] );
00111
00113 virtual unsigned char *MapValue(double v);
00114
00116
00117 vtkGetVector2Macro( Range, double );
00119
00122 int AdjustRange(double range[2]);
00123
00125
00126 void GetTable( double x1, double x2, int n, double* table );
00127 void GetTable( double x1, double x2, int n, float* table );
00128 const unsigned char *GetTable( double x1, double x2, int n);
00130
00135 void BuildFunctionFromTable( double x1, double x2, int size, double *table);
00136
00138
00139 vtkSetClampMacro( Clamping, int, 0, 1 );
00140 vtkGetMacro( Clamping, int );
00141 vtkBooleanMacro( Clamping, int );
00143
00145
00152 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
00153 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00154 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00155 void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
00156 void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
00157 vtkGetMacro( ColorSpace, int );
00158 vtkSetMacro(HSVWrap, int);
00159 vtkGetMacro(HSVWrap, int);
00160 vtkBooleanMacro(HSVWrap, int);
00162
00164
00167 vtkSetMacro(Scale,int);
00168 void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
00169 void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
00170 vtkGetMacro(Scale,int);
00172
00174
00176 double *GetDataPointer();
00177 void FillFromDataPointer(int, double*);
00179
00181
00182 virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00183 int inputDataType, int numberOfValues,
00184 int inputIncrement, int outputIncrement);
00186
00188
00190 vtkSetMacro(AllowDuplicateScalars, int);
00191 vtkGetMacro(AllowDuplicateScalars, int);
00192 vtkBooleanMacro(AllowDuplicateScalars, int);
00194
00195 protected:
00196 vtkColorTransferFunction();
00197 ~vtkColorTransferFunction();
00198
00199 vtkColorTransferFunctionInternals *Internal;
00200
00201
00202
00203
00204
00205 int Clamping;
00206
00207
00208 int ColorSpace;
00209
00210
00211 int HSVWrap;
00212
00213
00214 int Scale;
00215
00216 double *Function;
00217
00218
00219 double Range[2];
00220
00221
00222 unsigned char UnsignedCharRGBAValue[4];
00223
00224 int AllowDuplicateScalars;
00225
00226 vtkTimeStamp BuildTime;
00227 unsigned char *Table;
00228 int TableSize;
00229
00231
00233 virtual void SetRange(double, double) {};
00234 void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00236
00237
00238
00239 void SortAndUpdateRange();
00240
00243 void MovePoint(double oldX, double newX);
00244
00245 private:
00246 vtkColorTransferFunction(const vtkColorTransferFunction&);
00247 void operator=(const vtkColorTransferFunction&);
00248 };
00249
00250 #endif
00251