00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00034 #ifndef __vtkLookupTable_h
00035 #define __vtkLookupTable_h
00036
00037 #include "vtkScalarsToColors.h"
00038
00039 #include "vtkUnsignedCharArray.h"
00040
00041 #define VTK_RAMP_LINEAR 0
00042 #define VTK_RAMP_SCURVE 1
00043 #define VTK_RAMP_SQRT 2
00044 #define VTK_SCALE_LINEAR 0
00045 #define VTK_SCALE_LOG10 1
00046
00047 class VTK_COMMON_EXPORT vtkLookupTable : public vtkScalarsToColors
00048 {
00049 public:
00052 static vtkLookupTable *New();
00053
00054 vtkTypeRevisionMacro(vtkLookupTable,vtkScalarsToColors);
00055 void PrintSelf(ostream& os, vtkIndent indent);
00056
00059 virtual int IsOpaque();
00060
00062 int Allocate(int sz=256, int ext=256);
00063
00066 virtual void Build();
00067
00073 virtual void ForceBuild();
00074
00076
00083 vtkSetMacro(Ramp,int);
00084 void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00085 void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00086 void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
00087 vtkGetMacro(Ramp,int);
00089
00091
00094 void SetScale(int scale);
00095 void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00096 void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00097 vtkGetMacro(Scale,int);
00099
00101
00105 void SetTableRange(double r[2]);
00106 virtual void SetTableRange(double min, double max);
00107 vtkGetVectorMacro(TableRange,double,2);
00109
00111
00113 vtkSetVector2Macro(HueRange,double);
00114 vtkGetVector2Macro(HueRange,double);
00116
00118
00120 vtkSetVector2Macro(SaturationRange,double);
00121 vtkGetVector2Macro(SaturationRange,double);
00123
00125
00127 vtkSetVector2Macro(ValueRange,double);
00128 vtkGetVector2Macro(ValueRange,double);
00130
00132
00134 vtkSetVector2Macro(AlphaRange,double);
00135 vtkGetVector2Macro(AlphaRange,double);
00137
00139 unsigned char *MapValue(double v);
00140
00143 void GetColor(double x, double rgb[3]);
00144
00147 double GetOpacity(double v);
00148
00150 virtual vtkIdType GetIndex(double v);
00151
00153
00154 void SetNumberOfTableValues(vtkIdType number);
00155 vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00157
00162 void SetTableValue(vtkIdType indx, double rgba[4]);
00163
00166 void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
00167
00170 double *GetTableValue(vtkIdType id);
00171
00174 void GetTableValue(vtkIdType id, double rgba[4]);
00175
00177
00179 unsigned char *GetPointer(const vtkIdType id) {
00180 return this->Table->GetPointer(4*id); };
00182
00187 unsigned char *WritePointer(const vtkIdType id, const int number);
00188
00190
00192 double *GetRange() { return this->GetTableRange(); };
00193 void SetRange(double min, double max) { this->SetTableRange(min, max); };
00194 void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
00196
00198
00202 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00203 vtkGetMacro(NumberOfColors,vtkIdType);
00205
00207
00210 void SetTable(vtkUnsignedCharArray *);
00211 vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00213
00215
00216 void MapScalarsThroughTable2(void *input, unsigned char *output,
00217 int inputDataType, int numberOfValues,
00218 int inputIncrement, int outputIncrement);
00220
00222 void DeepCopy(vtkLookupTable *lut);
00223
00225
00227 virtual int UsingLogScale()
00228 {
00229 return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
00230 }
00232
00233 protected:
00234 vtkLookupTable(int sze=256, int ext=256);
00235 ~vtkLookupTable();
00236
00237 vtkIdType NumberOfColors;
00238 vtkUnsignedCharArray *Table;
00239 double TableRange[2];
00240 double HueRange[2];
00241 double SaturationRange[2];
00242 double ValueRange[2];
00243 double AlphaRange[2];
00244 int Scale;
00245 int Ramp;
00246 vtkTimeStamp InsertTime;
00247 vtkTimeStamp BuildTime;
00248 double RGBA[4];
00249
00250 int OpaqueFlag;
00251 vtkTimeStamp OpaqueFlagBuildTime;
00252
00253 private:
00254 vtkLookupTable(const vtkLookupTable&);
00255 void operator=(const vtkLookupTable&);
00256 };
00257
00258
00259 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00260 const int number)
00261 {
00262 this->InsertTime.Modified();
00263 return this->Table->WritePointer(4*id,4*number);
00264 }
00265
00266 #endif
00267
00268
00269