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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00062 #ifndef __vtkLookupTable_h
00063 #define __vtkLookupTable_h
00064 
00065 #include "vtkScalarsToColors.h"
00066 
00067 #define VTK_RAMP_LINEAR 0
00068 #define VTK_RAMP_SCURVE 1
00069 #define VTK_SCALE_LINEAR 0
00070 #define VTK_SCALE_LOG10 1
00071 
00072 class VTK_COMMON_EXPORT vtkLookupTable : public vtkScalarsToColors
00073 {
00074 public:
00077   static vtkLookupTable *New();
00078   
00079   vtkTypeMacro(vtkLookupTable,vtkScalarsToColors);
00080   void PrintSelf(ostream& os, vtkIndent indent);
00081 
00083   int Allocate(int sz=256, int ext=256);
00084   
00087   virtual void Build();
00088 
00090 
00096   vtkSetMacro(Ramp,int);
00097   void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
00098   void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
00099   vtkGetMacro(Ramp,int);
00101 
00103 
00106   void SetScale(int scale);
00107   void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
00108   void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
00109   vtkGetMacro(Scale,int);
00111 
00113 
00117   void SetTableRange(float r[2]); 
00118   virtual void SetTableRange(float min, float max);
00119   vtkGetVectorMacro(TableRange,float,2);
00121 
00123 
00125   vtkSetVector2Macro(HueRange,float);
00126   vtkGetVector2Macro(HueRange,float);
00128 
00130 
00132   vtkSetVector2Macro(SaturationRange,float);
00133   vtkGetVector2Macro(SaturationRange,float);
00135 
00137 
00139   vtkSetVector2Macro(ValueRange,float);
00140   vtkGetVector2Macro(ValueRange,float);
00142 
00144 
00146   vtkSetVector2Macro(AlphaRange,float);
00147   vtkGetVector2Macro(AlphaRange,float);
00149 
00151   unsigned char *MapValue(float v);
00152 
00154 
00156   float *GetColor(float x) { return vtkScalarsToColors::GetColor(x); }
00157   void GetColor(float x, float rgb[3]);
00159 
00162   float GetOpacity(float v);  
00163 
00165 
00166   void SetNumberOfTableValues(int number);
00167   int GetNumberOfTableValues() { return this->NumberOfColors; };
00169 
00174   void SetTableValue(int indx, float rgba[4]);
00175 
00178   void SetTableValue(int indx, float r, float g, float b, float a=1.0);
00179 
00182   float *GetTableValue(int id);
00183 
00186   void GetTableValue(int id, float rgba[4]);
00187 
00189 
00191   unsigned char *GetPointer(const int id) {
00192     return this->Table->GetPointer(4*id); };
00194 
00199   unsigned char *WritePointer(const int id, const int number);
00200 
00202 
00204   float *GetRange() { return this->GetTableRange(); };
00205   void SetRange(float min, float max) { this->SetTableRange(min, max); };
00206   void SetRange(float rng[2]) { this->SetRange(rng[0], rng[1]); };
00208 
00210 
00214   vtkSetClampMacro(NumberOfColors,int,2,65535);
00215   vtkGetMacro(NumberOfColors,int);
00217 
00219 
00220   void MapScalarsThroughTable2(void *input, unsigned char *output,
00221                                int inputDataType, int numberOfValues,
00222                                int inputIncrement, int outputIncrement);
00224 
00225 protected:
00226   vtkLookupTable(int sze=256, int ext=256);
00227   ~vtkLookupTable();
00228 
00229   int NumberOfColors;
00230   vtkUnsignedCharArray *Table;
00231   float TableRange[2];
00232   float HueRange[2];
00233   float SaturationRange[2];
00234   float ValueRange[2];
00235   float AlphaRange[2];
00236   int Scale;
00237   int Ramp;
00238   vtkTimeStamp InsertTime;
00239   vtkTimeStamp BuildTime;
00240   float RGBA[4]; //used during conversion process
00241 private:
00242   vtkLookupTable(const vtkLookupTable&);  // Not implemented.
00243   void operator=(const vtkLookupTable&);  // Not implemented.
00244 };
00245 
00246 inline unsigned char *vtkLookupTable::WritePointer(const int id, 
00247                                                    const int number)
00248 {
00249  return this->Table->WritePointer(4*id,4*number);
00250 }
00251 
00252 #endif
00253 
00254 
00255 

Generated on Thu Mar 28 14:19:16 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001