VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkLookupTable.h
Go to the documentation of this file.
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 =========================================================================*/
00059 #ifndef vtkLookupTable_h
00060 #define vtkLookupTable_h
00061 
00062 #include "vtkCommonCoreModule.h" // For export macro
00063 #include "vtkScalarsToColors.h"
00064 
00065 #include "vtkUnsignedCharArray.h" // Needed for inline method
00066 
00067 #define VTK_RAMP_LINEAR 0
00068 #define VTK_RAMP_SCURVE 1
00069 #define VTK_RAMP_SQRT 2
00070 #define VTK_SCALE_LINEAR 0
00071 #define VTK_SCALE_LOG10 1
00072 
00073 class VTKCOMMONCORE_EXPORT vtkLookupTable : public vtkScalarsToColors
00074 {
00075 public:
00077 
00080   const static vtkIdType BELOW_RANGE_COLOR_INDEX;
00081   const static vtkIdType ABOVE_RANGE_COLOR_INDEX;
00082   const static vtkIdType NAN_COLOR_INDEX;
00083   const static vtkIdType NUMBER_OF_SPECIAL_COLORS;
00085 
00088   static vtkLookupTable *New();
00089 
00090   vtkTypeMacro(vtkLookupTable,vtkScalarsToColors);
00091   void PrintSelf(ostream& os, vtkIndent indent);
00092 
00095   virtual int IsOpaque();
00096 
00098   int Allocate(int sz=256, int ext=256);
00099 
00102   virtual void Build();
00103 
00109   virtual void ForceBuild();
00110 
00112 
00119   vtkSetMacro(Ramp,int);
00120   void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00121   void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00122   void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
00123   vtkGetMacro(Ramp,int);
00125 
00127 
00130   void SetScale(int scale);
00131   void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00132   void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00133   vtkGetMacro(Scale,int);
00135 
00137 
00142   void SetTableRange(double r[2]);
00143   virtual void SetTableRange(double min, double max);
00144   vtkGetVectorMacro(TableRange,double,2);
00146 
00148 
00150   vtkSetVector2Macro(HueRange,double);
00151   vtkGetVector2Macro(HueRange,double);
00153 
00155 
00157   vtkSetVector2Macro(SaturationRange,double);
00158   vtkGetVector2Macro(SaturationRange,double);
00160 
00162 
00164   vtkSetVector2Macro(ValueRange,double);
00165   vtkGetVector2Macro(ValueRange,double);
00167 
00169 
00171   vtkSetVector2Macro(AlphaRange,double);
00172   vtkGetVector2Macro(AlphaRange,double);
00174 
00176 
00178   vtkSetVector4Macro(NanColor, double);
00179   vtkGetVector4Macro(NanColor, double);
00181 
00184   unsigned char* GetNanColorAsUnsignedChars();
00185 
00187 
00189   static void GetColorAsUnsignedChars(const double colorIn[4],
00190                                       unsigned char colorOut[4]);
00192 
00194 
00196   vtkSetVector4Macro(BelowRangeColor, double);
00197   vtkGetVector4Macro(BelowRangeColor, double);
00199 
00201 
00202   vtkSetMacro(UseBelowRangeColor, int);
00203   vtkGetMacro(UseBelowRangeColor, int);
00204   vtkBooleanMacro(UseBelowRangeColor, int);
00206 
00208 
00210   vtkSetVector4Macro(AboveRangeColor, double);
00211   vtkGetVector4Macro(AboveRangeColor, double);
00213 
00215 
00216   vtkSetMacro(UseAboveRangeColor, int);
00217   vtkGetMacro(UseAboveRangeColor, int);
00218   vtkBooleanMacro(UseAboveRangeColor, int);
00220 
00222   unsigned char* MapValue(double v);
00223 
00226   void GetColor(double x, double rgb[3]);
00227 
00230   double GetOpacity(double v);
00231 
00237   virtual vtkIdType GetIndex(double v);
00238 
00240 
00241   void SetNumberOfTableValues(vtkIdType number);
00242   vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
00244 
00249   virtual void SetTableValue(vtkIdType indx, double rgba[4]);
00250 
00252 
00254   virtual void SetTableValue(vtkIdType indx,
00255                               double r, double g, double b, double a=1.0);
00257 
00260   double *GetTableValue(vtkIdType id);
00261 
00264   void GetTableValue(vtkIdType id, double rgba[4]);
00265 
00267 
00269   unsigned char *GetPointer(const vtkIdType id) {
00270     return this->Table->GetPointer(4*id); };
00272 
00277   unsigned char *WritePointer(const vtkIdType id, const int number);
00278 
00280 
00282   double *GetRange() { return this->GetTableRange(); };
00283   void SetRange(double min, double max) { this->SetTableRange(min, max); };
00284   void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
00286 
00287   //BTX
00292   static void GetLogRange(const double range[2], double log_range[2]);
00293 
00295 
00296   static double ApplyLogScale(double v, const double range[2],
00297     const double log_range[2]);
00298   //ETX
00300 
00302 
00306   vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_ID_MAX);
00307   vtkGetMacro(NumberOfColors,vtkIdType);
00309 
00311 
00314   void SetTable(vtkUnsignedCharArray *);
00315   vtkGetObjectMacro(Table,vtkUnsignedCharArray);
00317 
00319 
00320   void MapScalarsThroughTable2(void *input, unsigned char *output,
00321                                int inputDataType, int numberOfValues,
00322                                int inputIncrement, int outputIncrement);
00324 
00326   void DeepCopy(vtkScalarsToColors *lut);
00327 
00329 
00331   virtual int UsingLogScale()
00332     {
00333     return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
00334     }
00336 
00338   virtual vtkIdType GetNumberOfAvailableColors();
00339 
00343   virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
00344 
00345 protected:
00346   vtkLookupTable(int sze=256, int ext=256);
00347   ~vtkLookupTable();
00348 
00349   vtkIdType NumberOfColors;
00350   vtkUnsignedCharArray *Table;
00351   double TableRange[2];
00352   double HueRange[2];
00353   double SaturationRange[2];
00354   double ValueRange[2];
00355   double AlphaRange[2];
00356   double NanColor[4];
00357   double BelowRangeColor[4];
00358   int    UseBelowRangeColor;
00359   double AboveRangeColor[4];
00360   int    UseAboveRangeColor;
00361 
00362   int Scale;
00363   int Ramp;
00364   vtkTimeStamp InsertTime;
00365   vtkTimeStamp BuildTime;
00366   double RGBA[4]; //used during conversion process
00367   unsigned char NanColorChar[4];
00368 
00369   int OpaqueFlag;
00370   vtkTimeStamp OpaqueFlagBuildTime;
00371 
00372 private:
00373   vtkLookupTable(const vtkLookupTable&);  // Not implemented.
00374   void operator=(const vtkLookupTable&);  // Not implemented.
00375 };
00376 
00377 //----------------------------------------------------------------------------
00378 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
00379                                                    const int number)
00380 {
00381   this->InsertTime.Modified();
00382   return this->Table->WritePointer(4*id,4*number);
00383 }
00384 
00385 #endif
00386 
00387 
00388