Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Common/vtkLookupTable.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkLookupTable.h,v $ 00005 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00038 #ifndef __vtkLookupTable_h 00039 #define __vtkLookupTable_h 00040 00041 #include "vtkScalarsToColors.h" 00042 00043 #include "vtkUnsignedCharArray.h" // Needed for inline method 00044 00045 #define VTK_RAMP_LINEAR 0 00046 #define VTK_RAMP_SCURVE 1 00047 #define VTK_RAMP_SQRT 2 00048 #define VTK_SCALE_LINEAR 0 00049 #define VTK_SCALE_LOG10 1 00050 00051 class VTK_COMMON_EXPORT vtkLookupTable : public vtkScalarsToColors 00052 { 00053 public: 00056 static vtkLookupTable *New(); 00057 00058 vtkTypeRevisionMacro(vtkLookupTable,vtkScalarsToColors); 00059 void PrintSelf(ostream& os, vtkIndent indent); 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(float r[2]); 00106 virtual void SetTableRange(float min, float max); 00107 vtkGetVectorMacro(TableRange,float,2); 00109 00111 00113 vtkSetVector2Macro(HueRange,float); 00114 vtkGetVector2Macro(HueRange,float); 00116 00118 00120 vtkSetVector2Macro(SaturationRange,float); 00121 vtkGetVector2Macro(SaturationRange,float); 00123 00125 00127 vtkSetVector2Macro(ValueRange,float); 00128 vtkGetVector2Macro(ValueRange,float); 00130 00132 00134 vtkSetVector2Macro(AlphaRange,float); 00135 vtkGetVector2Macro(AlphaRange,float); 00137 00139 unsigned char *MapValue(float v); 00140 00142 00144 float *GetColor(float x) { return vtkScalarsToColors::GetColor(x); } 00145 void GetColor(float x, float rgb[3]); 00147 00150 float GetOpacity(float v); 00151 00153 virtual vtkIdType GetIndex(float v); 00154 00156 00157 void SetNumberOfTableValues(vtkIdType number); 00158 vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; }; 00160 00165 void SetTableValue(vtkIdType indx, float rgba[4]); 00166 00169 void SetTableValue(vtkIdType indx, float r, float g, float b, float a=1.0); 00170 00173 float *GetTableValue(vtkIdType id); 00174 00177 void GetTableValue(vtkIdType id, float 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 float *GetRange() { return this->GetTableRange(); }; 00196 void SetRange(float min, float max) { this->SetTableRange(min, max); }; 00197 void SetRange(float rng[2]) { this->SetRange(rng[0], rng[1]); }; 00199 00201 00205 vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID); 00206 vtkGetMacro(NumberOfColors,vtkIdType); 00208 00210 00211 void MapScalarsThroughTable2(void *input, unsigned char *output, 00212 int inputDataType, int numberOfValues, 00213 int inputIncrement, int outputIncrement); 00215 00217 void DeepCopy(vtkLookupTable *lut); 00218 00219 protected: 00220 vtkLookupTable(int sze=256, int ext=256); 00221 ~vtkLookupTable(); 00222 00223 vtkIdType NumberOfColors; 00224 vtkUnsignedCharArray *Table; 00225 float TableRange[2]; 00226 float HueRange[2]; 00227 float SaturationRange[2]; 00228 float ValueRange[2]; 00229 float AlphaRange[2]; 00230 int Scale; 00231 int Ramp; 00232 vtkTimeStamp InsertTime; 00233 vtkTimeStamp BuildTime; 00234 float RGBA[4]; //used during conversion process 00235 00236 private: 00237 vtkLookupTable(const vtkLookupTable&); // Not implemented. 00238 void operator=(const vtkLookupTable&); // Not implemented. 00239 }; 00240 00241 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id, 00242 const int number) 00243 { 00244 return this->Table->WritePointer(4*id,4*number); 00245 } 00246 00247 #endif 00248 00249 00250