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

vtkScalarsToColors.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkScalarsToColors.h,v $
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 =========================================================================*/
00044 #ifndef __vtkScalarsToColors_h
00045 #define __vtkScalarsToColors_h
00046 
00047 #include "vtkObject.h"
00048 
00049 class vtkDataArray;
00050 class vtkUnsignedCharArray;
00051 
00052 class VTK_COMMON_EXPORT vtkScalarsToColors : public vtkObject
00053 {
00054 public:
00055   vtkTypeRevisionMacro(vtkScalarsToColors,vtkObject);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057   
00059   virtual void Build() {};
00060   
00062 
00063   virtual double *GetRange() = 0;
00064   virtual void SetRange(double min, double max) = 0;
00065   void SetRange(double rng[2]) 
00066     {this->SetRange(rng[0],rng[1]);}
00068   
00071   virtual unsigned char *MapValue(double v) = 0;
00072 
00075   virtual void GetColor(double v, double rgb[3]) = 0;
00076 
00078 
00080   double *GetColor(double v) 
00081     {this->GetColor(v,this->RGB); return this->RGB;}
00083 
00085 
00087   virtual double GetOpacity(double vtkNotUsed(v)) 
00088     {return 1.0;}
00090 
00092 
00095   double GetLuminance(double x) 
00096     {double rgb[3]; this->GetColor(x,rgb);
00097     return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
00099 
00101 
00105   void SetAlpha(double alpha);
00106   vtkGetMacro(Alpha,double);
00108 
00110 
00119   vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
00120                                    int component);
00122 
00124 
00125   vtkSetMacro(VectorMode, int);
00126   vtkGetMacro(VectorMode, int);
00127   void SetVectorModeToMagnitude();
00128   void SetVectorModeToComponent();
00130 
00131 //BTX
00132   enum VectorModes {
00133     MAGNITUDE=0,
00134     COMPONENT=1
00135   };
00136 //ETX
00137 
00138 
00140 
00142   vtkSetMacro(VectorComponent, int);
00143   vtkGetMacro(VectorComponent, int);
00145   
00147 
00152   void MapScalarsThroughTable(vtkDataArray *scalars, 
00153                               unsigned char *output,
00154                               int outputFormat);
00155   void MapScalarsThroughTable(vtkDataArray *scalars, 
00156                               unsigned char *output) 
00157     {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
00159 
00160 
00162 
00163   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00164                                        int inputDataType, int numberOfValues,
00165                                        int inputIncrement, 
00166                                        int outputFormat) = 0;
00168 
00170 
00173   virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
00174     vtkUnsignedCharArray *colors, int numComp, int numTuples);
00176 
00177 protected:
00178   vtkScalarsToColors();
00179   ~vtkScalarsToColors() {}
00180 
00181   double Alpha;
00182 
00183   // How to map arrays with multiple components.
00184   int VectorMode;
00185   // Internal flag used to togle between vector and component mode.
00186   // We need this flag because the mapper can override our mode, and
00187   // I do not want to change the interface to the map scalars methods.
00188   int UseMagnitude;
00189   int VectorComponent;
00190 
00191 private:
00192   double RGB[3];
00193 private:
00194   vtkScalarsToColors(const vtkScalarsToColors&);  // Not implemented.
00195   void operator=(const vtkScalarsToColors&);  // Not implemented.
00196 };
00197 
00198 #endif
00199 
00200 
00201