VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkLookupTable.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00037 #ifndef __vtkLookupTable_h 00038 #define __vtkLookupTable_h 00039 00040 #include "vtkScalarsToColors.h" 00041 00042 #include "vtkUnsignedCharArray.h" // Needed for inline method 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 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 00200 //BTX 00205 static void GetLogRange(const double range[2], double log_range[2]); 00206 00208 00209 static double ApplyLogScale(double v, const double range[2], 00210 const double log_range[2]); 00211 //ETX 00213 00215 00219 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID); 00220 vtkGetMacro(NumberOfColors,vtkIdType); 00222 00224 00227 void SetTable(vtkUnsignedCharArray *); 00228 vtkGetObjectMacro(Table,vtkUnsignedCharArray); 00230 00232 00233 void MapScalarsThroughTable2(void *input, unsigned char *output, 00234 int inputDataType, int numberOfValues, 00235 int inputIncrement, int outputIncrement); 00237 00239 void DeepCopy(vtkLookupTable *lut); 00240 00242 00244 virtual int UsingLogScale() 00245 { 00246 return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0; 00247 } 00249 00250 protected: 00251 vtkLookupTable(int sze=256, int ext=256); 00252 ~vtkLookupTable(); 00253 00254 vtkIdType NumberOfColors; 00255 vtkUnsignedCharArray *Table; 00256 double TableRange[2]; 00257 double HueRange[2]; 00258 double SaturationRange[2]; 00259 double ValueRange[2]; 00260 double AlphaRange[2]; 00261 int Scale; 00262 int Ramp; 00263 vtkTimeStamp InsertTime; 00264 vtkTimeStamp BuildTime; 00265 double RGBA[4]; //used during conversion process 00266 00267 int OpaqueFlag; 00268 vtkTimeStamp OpaqueFlagBuildTime; 00269 00270 private: 00271 vtkLookupTable(const vtkLookupTable&); // Not implemented. 00272 void operator=(const vtkLookupTable&); // Not implemented. 00273 }; 00274 00275 //---------------------------------------------------------------------------- 00276 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id, 00277 const int number) 00278 { 00279 this->InsertTime.Modified(); 00280 return this->Table->WritePointer(4*id,4*number); 00281 } 00282 00283 #endif 00284 00285 00286