00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00037 #ifndef __vtkLookupTable_h
00038 #define __vtkLookupTable_h
00039
00040 #include "vtkScalarsToColors.h"
00041
00042 #include "vtkUnsignedCharArray.h"
00043
00044 #define VTK_RAMP_LINEAR 0
00045 #define VTK_RAMP_SCURVE 1
00046 #define VTK_RAMP_SQRT 2
00047 #define VTK_SCALE_LINEAR 0
00048 #define VTK_SCALE_LOG10 1
00049
00050 class VTK_COMMON_EXPORT vtkLookupTable : public vtkScalarsToColors
00051 {
00052 public:
00055 static vtkLookupTable *New();
00056
00057 vtkTypeRevisionMacro(vtkLookupTable,vtkScalarsToColors);
00058 void PrintSelf(ostream& os, vtkIndent indent);
00059
00061 int Allocate(int sz=256, int ext=256);
00062
00065 virtual void Build();
00066
00072 virtual void ForceBuild();
00073
00075
00082 vtkSetMacro(Ramp,int);
00083 void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00084 void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00085 void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
00086 vtkGetMacro(Ramp,int);
00088
00090
00093 void SetScale(int scale);
00094 void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00095 void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00096 vtkGetMacro(Scale,int);
00098
00100
00104 void SetTableRange(double r[2]);
00105 virtual void SetTableRange(double min, double max);
00106 vtkGetVectorMacro(TableRange,double,2);
00108
00110
00112 vtkSetVector2Macro(HueRange,double);
00113 vtkGetVector2Macro(HueRange,double);
00115
00117
00119 vtkSetVector2Macro(SaturationRange,double);
00120 vtkGetVector2Macro(SaturationRange,double);
00122
00124
00126 vtkSetVector2Macro(ValueRange,double);
00127 vtkGetVector2Macro(ValueRange,double);
00129
00131
00133 vtkSetVector2Macro(AlphaRange,double);
00134 vtkGetVector2Macro(AlphaRange,double);
00136
00138 unsigned char *MapValue(double v);
00139
00142 void GetColor(double x, double rgb[3]);
00143
00146 double GetOpacity(double v);
00147
00149 virtual vtkIdType GetIndex(double v);
00150
00152
00153 void SetNumberOfTableValues(vtkIdType number);
00154 vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00156
00161 void SetTableValue(vtkIdType indx, double rgba[4]);
00162
00165 void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
00166
00169 double *GetTableValue(vtkIdType id);
00170
00173 void GetTableValue(vtkIdType id, double rgba[4]);
00174
00176
00178 unsigned char *GetPointer(const vtkIdType id) {
00179 return this->Table->GetPointer(4*id); };
00181
00186 unsigned char *WritePointer(const vtkIdType id, const int number);
00187
00189
00191 double *GetRange() { return this->GetTableRange(); };
00192 void SetRange(double min, double max) { this->SetTableRange(min, max); };
00193 void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
00195
00197
00201 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00202 vtkGetMacro(NumberOfColors,vtkIdType);
00204
00206
00209 void SetTable(vtkUnsignedCharArray *);
00210 vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00212
00214
00215 void MapScalarsThroughTable2(void *input, unsigned char *output,
00216 int inputDataType, int numberOfValues,
00217 int inputIncrement, int outputIncrement);
00219
00221 void DeepCopy(vtkLookupTable *lut);
00222
00223 protected:
00224 vtkLookupTable(int sze=256, int ext=256);
00225 ~vtkLookupTable();
00226
00227 vtkIdType NumberOfColors;
00228 vtkUnsignedCharArray *Table;
00229 double TableRange[2];
00230 double HueRange[2];
00231 double SaturationRange[2];
00232 double ValueRange[2];
00233 double AlphaRange[2];
00234 int Scale;
00235 int Ramp;
00236 vtkTimeStamp InsertTime;
00237 vtkTimeStamp BuildTime;
00238 double RGBA[4];
00239
00240 private:
00241 vtkLookupTable(const vtkLookupTable&);
00242 void operator=(const vtkLookupTable&);
00243 };
00244
00245
00246 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00247 const int number)
00248 {
00249 this->InsertTime.Modified();
00250 return this->Table->WritePointer(4*id,4*number);
00251 }
00252
00253 #endif
00254
00255
00256