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
00197
00202 static void GetLogRange(const double range[2], double log_range[2]);
00203
00205
00206 static double ApplyLogScale(double v, const double range[2],
00207 const double log_range[2]);
00208
00210
00212
00216 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00217 vtkGetMacro(NumberOfColors,vtkIdType);
00219
00221
00224 void SetTable(vtkUnsignedCharArray *);
00225 vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00227
00229
00230 void MapScalarsThroughTable2(void *input, unsigned char *output,
00231 int inputDataType, int numberOfValues,
00232 int inputIncrement, int outputIncrement);
00234
00236 void DeepCopy(vtkLookupTable *lut);
00237
00239
00241 virtual int UsingLogScale()
00242 {
00243 return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
00244 }
00246
00247 protected:
00248 vtkLookupTable(int sze=256, int ext=256);
00249 ~vtkLookupTable();
00250
00251 vtkIdType NumberOfColors;
00252 vtkUnsignedCharArray *Table;
00253 double TableRange[2];
00254 double HueRange[2];
00255 double SaturationRange[2];
00256 double ValueRange[2];
00257 double AlphaRange[2];
00258 int Scale;
00259 int Ramp;
00260 vtkTimeStamp InsertTime;
00261 vtkTimeStamp BuildTime;
00262 double RGBA[4];
00263
00264 int OpaqueFlag;
00265 vtkTimeStamp OpaqueFlagBuildTime;
00266
00267 private:
00268 vtkLookupTable(const vtkLookupTable&);
00269 void operator=(const vtkLookupTable&);
00270 };
00271
00272
00273 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00274 const int number)
00275 {
00276 this->InsertTime.Modified();
00277 return this->Table->WritePointer(4*id,4*number);
00278 }
00279
00280 #endif
00281
00282
00283