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

dox/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 =========================================================================*/ 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 vtkTypeRevisionMacro(vtkScalarsToColors,vtkObject); 00046 void PrintSelf(ostream& os, vtkIndent indent); 00047 00049 virtual void Build() {}; 00050 00052 00053 virtual float *GetRange() = 0; 00054 virtual void SetRange(float min, float max) = 0; 00055 void SetRange(float rng[2]) 00056 {this->SetRange(rng[0],rng[1]);} 00058 00061 virtual unsigned char *MapValue(float v) = 0; 00062 00065 virtual void GetColor(float v, float rgb[3]) = 0; 00066 00068 00070 float *GetColor(float v) 00071 {this->GetColor(v,this->RGB); return this->RGB;} 00073 00075 00077 virtual float GetOpacity(float vtkNotUsed(v)) 00078 {return 1.0;} 00080 00082 00085 float GetLuminance(float x) 00086 {float rgb[3]; this->GetColor(x,rgb); 00087 return static_cast<float>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);} 00089 00091 00095 void SetAlpha(float alpha); 00096 vtkGetMacro(Alpha,float); 00098 00100 00109 vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode, 00110 int component); 00112 00114 00115 vtkSetMacro(VectorMode, int); 00116 vtkGetMacro(VectorMode, int); 00117 void SetVectorModeToMagnitude(); 00118 void SetVectorModeToComponent(); 00120 00122 00124 vtkSetMacro(VectorComponent, int); 00125 vtkGetMacro(VectorComponent, int); 00127 00129 00134 void MapScalarsThroughTable(vtkDataArray *scalars, 00135 unsigned char *output, 00136 int outputFormat); 00137 void MapScalarsThroughTable(vtkDataArray *scalars, 00138 unsigned char *output) 00139 {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);} 00141 00142 00144 00145 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00146 int inputDataType, int numberOfValues, 00147 int inputIncrement, 00148 int outputFormat) = 0; 00150 00152 00155 virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA( 00156 vtkUnsignedCharArray *colors, int numComp, int numTuples); 00158 00159 protected: 00160 vtkScalarsToColors(); 00161 ~vtkScalarsToColors() {} 00162 00163 float Alpha; 00164 00165 // How to map arrays with multiple components. 00166 int VectorMode; 00167 // Internal flag used to togle between vector and component mode. 00168 // We need this flag because the mapper can override our mode, and 00169 // I do not want to change the interface to the map scalars methods. 00170 int UseMagnitude; 00171 int VectorComponent; 00172 00173 //BTX 00174 enum VectorModes { 00175 MAGNITUDE=0, 00176 COMPONENT=1 00177 }; 00178 //ETX 00179 00180 private: 00181 float RGB[3]; 00182 private: 00183 vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented. 00184 void operator=(const vtkScalarsToColors&); // Not implemented. 00185 }; 00186 00187 #endif 00188 00189 00190