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

# Common/vtkScalarsToColors.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkScalarsToColors.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 =========================================================================*/
    00048 #ifndef __vtkScalarsToColors_h
    00049 #define __vtkScalarsToColors_h
    00050
    00051 #include "vtkObject.h"
    00052
    00053 class vtkDataArray;
    00054 class vtkUnsignedCharArray;
    00055
    00056 class VTK_COMMON_EXPORT vtkScalarsToColors : public vtkObject
    00057 {
    00058 public:
    00059   vtkTypeRevisionMacro(vtkScalarsToColors,vtkObject);
    00060   void PrintSelf(ostream& os, vtkIndent indent);
    00061
    00063   virtual void Build() {};
    00064
    00066
    00067   virtual float *GetRange() = 0;
    00068   virtual void SetRange(float min, float max) = 0;
    00069   void SetRange(float rng[2])
    00070     {this->SetRange(rng[0],rng[1]);}
    00072
    00075   virtual unsigned char *MapValue(float v) = 0;
    00076
    00079   virtual void GetColor(float v, float rgb[3]) = 0;
    00080
    00082
    00084   float *GetColor(float v)
    00085     {this->GetColor(v,this->RGB); return this->RGB;}
    00087
    00089
    00091   virtual float GetOpacity(float vtkNotUsed(v))
    00092     {return 1.0;}
    00094
    00096
    00099   float GetLuminance(float x)
    00100     {float rgb[3]; this->GetColor(x,rgb);
    00101     return static_cast<float>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
    00103
    00105
    00109   void SetAlpha(float alpha);
    00110   vtkGetMacro(Alpha,float);
    00112
    00114
    00123   vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
    00124                                    int component);
    00126
    00128
    00129   vtkSetMacro(VectorMode, int);
    00130   vtkGetMacro(VectorMode, int);
    00131   void SetVectorModeToMagnitude();
    00132   void SetVectorModeToComponent();
    00134
    00136
    00138   vtkSetMacro(VectorComponent, int);
    00139   vtkGetMacro(VectorComponent, int);
    00141
    00143
    00148   void MapScalarsThroughTable(vtkDataArray *scalars,
    00149                               unsigned char *output,
    00150                               int outputFormat);
    00151   void MapScalarsThroughTable(vtkDataArray *scalars,
    00152                               unsigned char *output)
    00153     {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
    00155
    00156
    00158
    00159   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
    00160                                        int inputDataType, int numberOfValues,
    00161                                        int inputIncrement,
    00162                                        int outputFormat) = 0;
    00164
    00166
    00169   virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
    00170     vtkUnsignedCharArray *colors, int numComp, int numTuples);
    00172
    00173 protected:
    00174   vtkScalarsToColors();
    00175   ~vtkScalarsToColors() {}
    00176
    00177   float Alpha;
    00178
    00179   // How to map arrays with multiple components.
    00180   int VectorMode;
    00181   // Internal flag used to togle between vector and component mode.
    00182   // We need this flag because the mapper can override our mode, and
    00183   // I do not want to change the interface to the map scalars methods.
    00184   int UseMagnitude;
    00185   int VectorComponent;
    00186
    00187 //BTX
    00188   enum VectorModes {
    00189     MAGNITUDE=0,
    00190     COMPONENT=1
    00191   };
    00192 //ETX
    00193
    00194 private:
    00195   float RGB[3];
    00196 private:
    00197   vtkScalarsToColors(const vtkScalarsToColors&);  // Not implemented.
    00198   void operator=(const vtkScalarsToColors&);  // Not implemented.
    00199 };
    00200
    00201 #endif
    00202
    00203
    00204