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 vtkTypeMacro(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
00144 vtkSetVector4Macro(NanColor, double);
00145 vtkGetVector4Macro(NanColor, double);
00147
00149 unsigned char *MapValue(double v);
00150
00153 void GetColor(double x, double rgb[3]);
00154
00157 double GetOpacity(double v);
00158
00160 virtual vtkIdType GetIndex(double v);
00161
00163
00164 void SetNumberOfTableValues(vtkIdType number);
00165 vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00167
00172 void SetTableValue(vtkIdType indx, double rgba[4]);
00173
00176 void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
00177
00180 double *GetTableValue(vtkIdType id);
00181
00184 void GetTableValue(vtkIdType id, double rgba[4]);
00185
00187
00189 unsigned char *GetPointer(const vtkIdType id) {
00190 return this->Table->GetPointer(4*id); };
00192
00197 unsigned char *WritePointer(const vtkIdType id, const int number);
00198
00200
00202 double *GetRange() { return this->GetTableRange(); };
00203 void SetRange(double min, double max) { this->SetTableRange(min, max); };
00204 void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
00206
00207
00212 static void GetLogRange(const double range[2], double log_range[2]);
00213
00215
00216 static double ApplyLogScale(double v, const double range[2],
00217 const double log_range[2]);
00218
00220
00222
00226 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00227 vtkGetMacro(NumberOfColors,vtkIdType);
00229
00231
00234 void SetTable(vtkUnsignedCharArray *);
00235 vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00237
00239
00240 void MapScalarsThroughTable2(void *input, unsigned char *output,
00241 int inputDataType, int numberOfValues,
00242 int inputIncrement, int outputIncrement);
00244
00246 void DeepCopy(vtkLookupTable *lut);
00247
00249
00251 virtual int UsingLogScale()
00252 {
00253 return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
00254 }
00256
00258 virtual vtkIdType GetNumberOfAvailableColors();
00259
00260 protected:
00261 vtkLookupTable(int sze=256, int ext=256);
00262 ~vtkLookupTable();
00263
00264 vtkIdType NumberOfColors;
00265 vtkUnsignedCharArray *Table;
00266 double TableRange[2];
00267 double HueRange[2];
00268 double SaturationRange[2];
00269 double ValueRange[2];
00270 double AlphaRange[2];
00271 double NanColor[4];
00272 int Scale;
00273 int Ramp;
00274 vtkTimeStamp InsertTime;
00275 vtkTimeStamp BuildTime;
00276 double RGBA[4];
00277
00278 int OpaqueFlag;
00279 vtkTimeStamp OpaqueFlagBuildTime;
00280
00281 private:
00282 vtkLookupTable(const vtkLookupTable&);
00283 void operator=(const vtkLookupTable&);
00284 };
00285
00286
00287 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00288 const int number)
00289 {
00290 this->InsertTime.Modified();
00291 return this->Table->WritePointer(4*id,4*number);
00292 }
00293
00294 #endif
00295
00296
00297