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
00062 virtual int IsOpaque();
00063
00065 int Allocate(int sz=256, int ext=256);
00066
00069 virtual void Build();
00070
00076 virtual void ForceBuild();
00077
00079
00086 vtkSetMacro(Ramp,int);
00087 void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00088 void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00089 void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
00090 vtkGetMacro(Ramp,int);
00092
00094
00097 void SetScale(int scale);
00098 void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00099 void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00100 vtkGetMacro(Scale,int);
00102
00104
00108 void SetTableRange(double r[2]);
00109 virtual void SetTableRange(double min, double max);
00110 vtkGetVectorMacro(TableRange,double,2);
00112
00114
00116 vtkSetVector2Macro(HueRange,double);
00117 vtkGetVector2Macro(HueRange,double);
00119
00121
00123 vtkSetVector2Macro(SaturationRange,double);
00124 vtkGetVector2Macro(SaturationRange,double);
00126
00128
00130 vtkSetVector2Macro(ValueRange,double);
00131 vtkGetVector2Macro(ValueRange,double);
00133
00135
00137 vtkSetVector2Macro(AlphaRange,double);
00138 vtkGetVector2Macro(AlphaRange,double);
00140
00142 unsigned char *MapValue(double v);
00143
00146 void GetColor(double x, double rgb[3]);
00147
00150 double GetOpacity(double v);
00151
00153 virtual vtkIdType GetIndex(double v);
00154
00156
00157 void SetNumberOfTableValues(vtkIdType number);
00158 vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00160
00165 void SetTableValue(vtkIdType indx, double rgba[4]);
00166
00169 void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
00170
00173 double *GetTableValue(vtkIdType id);
00174
00177 void GetTableValue(vtkIdType id, double rgba[4]);
00178
00180
00182 unsigned char *GetPointer(const vtkIdType id) {
00183 return this->Table->GetPointer(4*id); };
00185
00190 unsigned char *WritePointer(const vtkIdType id, const int number);
00191
00193
00195 double *GetRange() { return this->GetTableRange(); };
00196 void SetRange(double min, double max) { this->SetTableRange(min, max); };
00197 void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
00199
00201
00205 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00206 vtkGetMacro(NumberOfColors,vtkIdType);
00208
00210
00213 void SetTable(vtkUnsignedCharArray *);
00214 vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00216
00218
00219 void MapScalarsThroughTable2(void *input, unsigned char *output,
00220 int inputDataType, int numberOfValues,
00221 int inputIncrement, int outputIncrement);
00223
00225 void DeepCopy(vtkLookupTable *lut);
00226
00228
00230 virtual int UsingLogScale()
00231 {
00232 return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
00233 }
00235
00236 protected:
00237 vtkLookupTable(int sze=256, int ext=256);
00238 ~vtkLookupTable();
00239
00240 vtkIdType NumberOfColors;
00241 vtkUnsignedCharArray *Table;
00242 double TableRange[2];
00243 double HueRange[2];
00244 double SaturationRange[2];
00245 double ValueRange[2];
00246 double AlphaRange[2];
00247 int Scale;
00248 int Ramp;
00249 vtkTimeStamp InsertTime;
00250 vtkTimeStamp BuildTime;
00251 double RGBA[4];
00252
00253 int OpaqueFlag;
00254 vtkTimeStamp OpaqueFlagBuildTime;
00255
00256 private:
00257 vtkLookupTable(const vtkLookupTable&);
00258 void operator=(const vtkLookupTable&);
00259 };
00260
00261
00262 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00263 const int number)
00264 {
00265 this->InsertTime.Modified();
00266 return this->Table->WritePointer(4*id,4*number);
00267 }
00268
00269 #endif
00270
00271
00272