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

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 =========================================================================*/
00051 #ifndef __vtkLookupTable_h
00052 #define __vtkLookupTable_h
00053 
00054 #include "vtkScalarsToColors.h"
00055 
00056 #include "vtkUnsignedCharArray.h" // Needed for inline method
00057 
00058 #define VTK_RAMP_LINEAR 0
00059 #define VTK_RAMP_SCURVE 1
00060 #define VTK_RAMP_SQRT 2
00061 #define VTK_SCALE_LINEAR 0
00062 #define VTK_SCALE_LOG10 1
00063 
00064 class VTK_COMMON_EXPORT vtkLookupTable : public vtkScalarsToColors
00065 {
00066 public:
00069   static vtkLookupTable *New();
00070   
00071   vtkTypeRevisionMacro(vtkLookupTable,vtkScalarsToColors);
00072   void PrintSelf(ostream& os, vtkIndent indent);
00073 
00075   int Allocate(int sz=256, int ext=256);
00076   
00079   virtual void Build();
00080 
00086   virtual void ForceBuild();
00087 
00089 
00096   vtkSetMacro(Ramp,int);
00097   void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00098   void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00099   void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
00100   vtkGetMacro(Ramp,int);
00102 
00104 
00107   void SetScale(int scale);
00108   void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00109   void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00110   vtkGetMacro(Scale,int);
00112 
00114 
00118   void SetTableRange(float r[2]); 
00119   virtual void SetTableRange(float min, float max);
00120   vtkGetVectorMacro(TableRange,float,2);
00122 
00124 
00126   vtkSetVector2Macro(HueRange,float);
00127   vtkGetVector2Macro(HueRange,float);
00129 
00131 
00133   vtkSetVector2Macro(SaturationRange,float);
00134   vtkGetVector2Macro(SaturationRange,float);
00136 
00138 
00140   vtkSetVector2Macro(ValueRange,float);
00141   vtkGetVector2Macro(ValueRange,float);
00143 
00145 
00147   vtkSetVector2Macro(AlphaRange,float);
00148   vtkGetVector2Macro(AlphaRange,float);
00150 
00152   unsigned char *MapValue(float v);
00153 
00155 
00157   float *GetColor(float x) { return vtkScalarsToColors::GetColor(x); }
00158   void GetColor(float x, float rgb[3]);
00160 
00163   float GetOpacity(float v);
00164 
00166   virtual vtkIdType GetIndex(float v);
00167 
00169 
00170   void SetNumberOfTableValues(vtkIdType number);
00171   vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00173 
00178   void SetTableValue(vtkIdType indx, float rgba[4]);
00179 
00182   void SetTableValue(vtkIdType indx, float r, float g, float b, float a=1.0);
00183 
00186   float *GetTableValue(vtkIdType id);
00187 
00190   void GetTableValue(vtkIdType id, float rgba[4]);
00191 
00193 
00195   unsigned char *GetPointer(const vtkIdType id) {
00196     return this->Table->GetPointer(4*id); };
00198 
00203   unsigned char *WritePointer(const vtkIdType id, const int number);
00204 
00206 
00208   float *GetRange() { return this->GetTableRange(); };
00209   void SetRange(float min, float max) { this->SetTableRange(min, max); };
00210   void SetRange(float rng[2]) { this->SetRange(rng[0], rng[1]); };
00212 
00214 
00218   vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
00219   vtkGetMacro(NumberOfColors,vtkIdType);
00221 
00223 
00224   void MapScalarsThroughTable2(void *input, unsigned char *output,
00225                                int inputDataType, int numberOfValues,
00226                                int inputIncrement, int outputIncrement);
00228 
00230   void DeepCopy(vtkLookupTable *lut);
00231 
00232 protected:
00233   vtkLookupTable(int sze=256, int ext=256);
00234   ~vtkLookupTable();
00235 
00236   vtkIdType NumberOfColors;
00237   vtkUnsignedCharArray *Table;
00238   float TableRange[2];
00239   float HueRange[2];
00240   float SaturationRange[2];
00241   float ValueRange[2];
00242   float AlphaRange[2];
00243   int Scale;
00244   int Ramp;
00245   vtkTimeStamp InsertTime;
00246   vtkTimeStamp BuildTime;
00247   float RGBA[4]; //used during conversion process
00248 
00249 private:
00250   vtkLookupTable(const vtkLookupTable&);  // Not implemented.
00251   void operator=(const vtkLookupTable&);  // Not implemented.
00252 };
00253 
00254 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id, 
00255                                                    const int number)
00256 {
00257  return this->Table->WritePointer(4*id,4*number);
00258 }
00259 
00260 #endif
00261 
00262 
00263