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 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 =========================================================================*/ 00030 #ifndef __vtkScalarsToColors_h 00031 #define __vtkScalarsToColors_h 00032 00033 #include "vtkObject.h" 00034 00035 class vtkDataArray; 00036 class vtkUnsignedCharArray; 00037 00038 class VTK_COMMON_EXPORT vtkScalarsToColors : public vtkObject 00039 { 00040 public: 00041 vtkTypeRevisionMacro(vtkScalarsToColors,vtkObject); 00042 void PrintSelf(ostream& os, vtkIndent indent); 00043 00045 virtual void Build() {}; 00046 00048 00049 virtual double *GetRange() = 0; 00050 virtual void SetRange(double min, double max) = 0; 00051 void SetRange(double rng[2]) 00052 {this->SetRange(rng[0],rng[1]);} 00054 00057 virtual unsigned char *MapValue(double v) = 0; 00058 00061 virtual void GetColor(double v, double rgb[3]) = 0; 00062 00064 00066 double *GetColor(double v) 00067 {this->GetColor(v,this->RGB); return this->RGB;} 00069 00071 00073 virtual double GetOpacity(double vtkNotUsed(v)) 00074 {return 1.0;} 00076 00078 00081 double GetLuminance(double x) 00082 {double rgb[3]; this->GetColor(x,rgb); 00083 return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);} 00085 00087 00091 void SetAlpha(double alpha); 00092 vtkGetMacro(Alpha,double); 00094 00096 00105 vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode, 00106 int component); 00108 00110 00111 vtkSetMacro(VectorMode, int); 00112 vtkGetMacro(VectorMode, int); 00113 void SetVectorModeToMagnitude(); 00114 void SetVectorModeToComponent(); 00116 00118 00120 vtkSetMacro(VectorComponent, int); 00121 vtkGetMacro(VectorComponent, int); 00123 00125 00130 void MapScalarsThroughTable(vtkDataArray *scalars, 00131 unsigned char *output, 00132 int outputFormat); 00133 void MapScalarsThroughTable(vtkDataArray *scalars, 00134 unsigned char *output) 00135 {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);} 00137 00138 00140 00141 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00142 int inputDataType, int numberOfValues, 00143 int inputIncrement, 00144 int outputFormat) = 0; 00146 00148 00151 virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA( 00152 vtkUnsignedCharArray *colors, int numComp, int numTuples); 00154 00155 protected: 00156 vtkScalarsToColors(); 00157 ~vtkScalarsToColors() {} 00158 00159 double Alpha; 00160 00161 // How to map arrays with multiple components. 00162 int VectorMode; 00163 // Internal flag used to togle between vector and component mode. 00164 // We need this flag because the mapper can override our mode, and 00165 // I do not want to change the interface to the map scalars methods. 00166 int UseMagnitude; 00167 int VectorComponent; 00168 00169 //BTX 00170 enum VectorModes { 00171 MAGNITUDE=0, 00172 COMPONENT=1 00173 }; 00174 //ETX 00175 00176 private: 00177 double RGB[3]; 00178 private: 00179 vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented. 00180 void operator=(const vtkScalarsToColors&); // Not implemented. 00181 }; 00182 00183 #endif 00184 00185 00186