VTK
|
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 00050 virtual int IsOpaque(); 00051 00053 virtual void Build() {}; 00054 00056 00057 virtual double *GetRange() = 0; 00058 virtual void SetRange(double min, double max) = 0; 00059 void SetRange(double rng[2]) 00060 {this->SetRange(rng[0],rng[1]);} 00062 00065 virtual unsigned char *MapValue(double v) = 0; 00066 00069 virtual void GetColor(double v, double rgb[3]) = 0; 00070 00072 00074 double *GetColor(double v) 00075 {this->GetColor(v,this->RGB); return this->RGB;} 00077 00079 00081 virtual double GetOpacity(double vtkNotUsed(v)) 00082 {return 1.0;} 00084 00086 00089 double GetLuminance(double x) 00090 {double rgb[3]; this->GetColor(x,rgb); 00091 return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);} 00093 00095 00099 virtual void SetAlpha(double alpha); 00100 vtkGetMacro(Alpha,double); 00102 00104 00113 virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode, 00114 int component); 00116 00118 00119 vtkSetMacro(VectorMode, int); 00120 vtkGetMacro(VectorMode, int); 00121 void SetVectorModeToMagnitude(); 00122 void SetVectorModeToComponent(); 00124 00125 //BTX 00126 enum VectorModes { 00127 MAGNITUDE=0, 00128 COMPONENT=1 00129 }; 00130 //ETX 00131 00132 00134 00136 vtkSetMacro(VectorComponent, int); 00137 vtkGetMacro(VectorComponent, int); 00139 00141 00146 void MapScalarsThroughTable(vtkDataArray *scalars, 00147 unsigned char *output, 00148 int outputFormat); 00149 void MapScalarsThroughTable(vtkDataArray *scalars, 00150 unsigned char *output) 00151 {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);} 00153 00154 00156 00157 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00158 int inputDataType, int numberOfValues, 00159 int inputIncrement, 00160 int outputFormat) = 0; 00162 00164 00167 virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA( 00168 vtkUnsignedCharArray *colors, int numComp, int numTuples); 00170 00172 00174 virtual int UsingLogScale() 00175 { return 0; } 00177 00179 virtual vtkIdType GetNumberOfAvailableColors() = 0; 00180 00181 protected: 00182 vtkScalarsToColors(); 00183 ~vtkScalarsToColors() {} 00184 00185 double Alpha; 00186 00187 // How to map arrays with multiple components. 00188 int VectorMode; 00189 // Internal flag used to togle between vector and component mode. 00190 // We need this flag because the mapper can override our mode, and 00191 // I do not want to change the interface to the map scalars methods. 00192 int UseMagnitude; 00193 int VectorComponent; 00194 00195 private: 00196 double RGB[3]; 00197 00198 vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented. 00199 void operator=(const vtkScalarsToColors&); // Not implemented. 00200 }; 00201 00202 #endif 00203 00204 00205