VTK
dox/Common/vtkScalarsToColors.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkScalarsToColors.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 =========================================================================*/
00034 #ifndef __vtkScalarsToColors_h
00035 #define __vtkScalarsToColors_h
00036 
00037 #include "vtkObject.h"
00038 
00039 class vtkDataArray;
00040 class vtkUnsignedCharArray;
00041 
00042 class VTK_COMMON_EXPORT vtkScalarsToColors : public vtkObject
00043 {
00044 public:
00045   vtkTypeMacro(vtkScalarsToColors,vtkObject);
00046   void PrintSelf(ostream& os, vtkIndent indent);
00047   static vtkScalarsToColors *New();
00048 
00051   virtual int IsOpaque();
00052   
00054   virtual void Build() {};
00055   
00057 
00058   virtual double *GetRange();
00059   virtual void SetRange(double min, double max);
00060   void SetRange(double rng[2])
00061     {this->SetRange(rng[0],rng[1]);}
00063   
00066   virtual unsigned char *MapValue(double v);
00067 
00070   virtual void GetColor(double v, double rgb[3]);
00071 
00073 
00075   double *GetColor(double v)
00076     {this->GetColor(v,this->RGB); return this->RGB;}
00078  
00081   virtual double GetOpacity(double v);
00082 
00084 
00087   double GetLuminance(double x) 
00088     {double rgb[3]; this->GetColor(x,rgb);
00089     return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
00091 
00093 
00097   virtual void SetAlpha(double alpha);
00098   vtkGetMacro(Alpha,double);
00100 
00102 
00111   virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
00112                                    int component);
00114 
00116 
00119   vtkSetMacro(VectorMode, int);
00120   vtkGetMacro(VectorMode, int);
00121   void SetVectorModeToMagnitude();
00122   void SetVectorModeToComponent();
00123   void SetVectorModeToRGBColors();
00125 
00126 //BTX
00127   enum VectorModes {
00128     MAGNITUDE=0,
00129     COMPONENT=1,
00130     RGBCOLORS=2
00131   };
00132 //ETX
00133 
00134 
00136 
00138   vtkSetMacro(VectorComponent, int);
00139   vtkGetMacro(VectorComponent, int);
00141 
00143 
00148   vtkSetMacro(VectorSize, int);
00149   vtkGetMacro(VectorSize, int);
00151 
00153 
00158   void MapVectorsThroughTable(void *input, unsigned char *output,
00159                               int inputDataType, int numberOfValues,
00160                               int inputIncrement, int outputFormat,
00161                               int vectorComponent, int vectorSize);
00162   void MapVectorsThroughTable(void *input, unsigned char *output,
00163                               int inputDataType, int numberOfValues,
00164                               int inputIncrement, int outputFormat)
00165     { this->MapVectorsThroughTable(input, output, inputDataType, numberOfValues,
00166                                    inputIncrement, outputFormat, -1, -1); }
00168 
00170 
00176   void MapScalarsThroughTable(vtkDataArray *scalars, 
00177                               unsigned char *output,
00178                               int outputFormat);
00179   void MapScalarsThroughTable(vtkDataArray *scalars, 
00180                               unsigned char *output) 
00181     {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
00182   void MapScalarsThroughTable(void *input, unsigned char *output,
00183                               int inputDataType, int numberOfValues,
00184                               int inputIncrement,
00185                               int outputFormat)
00186     {this->MapScalarsThroughTable2(input, output, inputDataType,
00187        numberOfValues, inputIncrement, outputFormat);}
00189 
00191 
00194   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00195                                        int inputDataType, int numberOfValues,
00196                                        int inputIncrement, 
00197                                        int outputFormat);
00199 
00201 
00204   virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
00205     vtkUnsignedCharArray *colors, int numComp, int numTuples);
00207 
00209   virtual void DeepCopy(vtkScalarsToColors *o);
00210 
00212 
00214   virtual int UsingLogScale()
00215     { return 0; }
00217 
00219   virtual vtkIdType GetNumberOfAvailableColors();
00220 
00221 protected:
00222   vtkScalarsToColors();
00223   ~vtkScalarsToColors() {}
00224 
00226 
00235   void MapColorsToColors(void *input, unsigned char *output,
00236                          int inputDataType, int numberOfValues,
00237                          int numberOfComponents, int vectorSize,
00238                          int outputFormat);
00240 
00242 
00244   void MapVectorsToMagnitude(void *input, double *output,
00245                              int inputDataType, int numberOfValues,
00246                              int numberOfComponents, int vectorSize);
00248 
00249   double Alpha;
00250 
00251   // How to map arrays with multiple components.
00252   int VectorMode;
00253   int VectorComponent;
00254   int VectorSize;
00255 
00256   // Obsolete, kept so subclasses will still compile
00257   int UseMagnitude;
00258 
00259 private:
00260   double RGB[3];
00261   unsigned char RGBABytes[4];
00262   double InputRange[2];
00263 
00264   vtkScalarsToColors(const vtkScalarsToColors&);  // Not implemented.
00265   void operator=(const vtkScalarsToColors&);  // Not implemented.
00266 };
00267 
00268 #endif
00269 
00270 
00271