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 =========================================================================*/ 00048 #ifndef __vtkScalarsToColors_h 00049 #define __vtkScalarsToColors_h 00050 00051 #include "vtkCommonCoreModule.h" // For export macro 00052 #include "vtkVariant.h" // Set/get annotation methods require variants. 00053 #include "vtkObject.h" 00054 00055 class vtkDataArray; 00056 class vtkUnsignedCharArray; 00057 class vtkAbstractArray; 00058 class vtkStringArray; 00059 00060 00061 class VTKCOMMONCORE_EXPORT vtkScalarsToColors : public vtkObject 00062 { 00063 public: 00064 vtkTypeMacro(vtkScalarsToColors,vtkObject); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00066 static vtkScalarsToColors *New(); 00067 00070 virtual int IsOpaque(); 00071 00073 virtual void Build() {}; 00074 00076 00077 virtual double *GetRange(); 00078 virtual void SetRange(double min, double max); 00079 void SetRange(double rng[2]) 00080 {this->SetRange(rng[0],rng[1]);} 00082 00085 virtual unsigned char *MapValue(double v); 00086 00089 virtual void GetColor(double v, double rgb[3]); 00090 00092 00094 double *GetColor(double v) 00095 {this->GetColor(v,this->RGB); return this->RGB;} 00097 00100 virtual double GetOpacity(double v); 00101 00103 00106 double GetLuminance(double x) 00107 {double rgb[3]; this->GetColor(x,rgb); 00108 return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);} 00110 00112 00116 virtual void SetAlpha(double alpha); 00117 vtkGetMacro(Alpha,double); 00119 00121 00130 virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode, 00131 int component); 00133 00135 00138 vtkSetMacro(VectorMode, int); 00139 vtkGetMacro(VectorMode, int); 00140 void SetVectorModeToMagnitude(); 00141 void SetVectorModeToComponent(); 00142 void SetVectorModeToRGBColors(); 00144 00145 //BTX 00146 enum VectorModes { 00147 MAGNITUDE=0, 00148 COMPONENT=1, 00149 RGBCOLORS=2 00150 }; 00151 //ETX 00152 00153 00155 00157 vtkSetMacro(VectorComponent, int); 00158 vtkGetMacro(VectorComponent, int); 00160 00162 00167 vtkSetMacro(VectorSize, int); 00168 vtkGetMacro(VectorSize, int); 00170 00172 00177 void MapVectorsThroughTable(void *input, unsigned char *output, 00178 int inputDataType, int numberOfValues, 00179 int inputIncrement, int outputFormat, 00180 int vectorComponent, int vectorSize); 00181 void MapVectorsThroughTable(void *input, unsigned char *output, 00182 int inputDataType, int numberOfValues, 00183 int inputIncrement, int outputFormat) 00184 { this->MapVectorsThroughTable(input, output, inputDataType, numberOfValues, 00185 inputIncrement, outputFormat, -1, -1); } 00187 00189 00195 void MapScalarsThroughTable(vtkDataArray *scalars, 00196 unsigned char *output, 00197 int outputFormat); 00198 void MapScalarsThroughTable(vtkDataArray *scalars, 00199 unsigned char *output) 00200 {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);} 00201 void MapScalarsThroughTable(void *input, unsigned char *output, 00202 int inputDataType, int numberOfValues, 00203 int inputIncrement, 00204 int outputFormat) 00205 {this->MapScalarsThroughTable2(input, output, inputDataType, 00206 numberOfValues, inputIncrement, outputFormat);} 00208 00210 00213 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00214 int inputDataType, int numberOfValues, 00215 int inputIncrement, 00216 int outputFormat); 00218 00220 00223 virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA( 00224 vtkUnsignedCharArray *colors, int numComp, int numTuples); 00226 00228 virtual void DeepCopy(vtkScalarsToColors *o); 00229 00231 00233 virtual int UsingLogScale() 00234 { return 0; } 00236 00238 virtual vtkIdType GetNumberOfAvailableColors(); 00239 00241 00245 virtual void SetAnnotations( vtkAbstractArray* values, vtkStringArray* annotations ); 00246 vtkGetObjectMacro(AnnotatedValues,vtkAbstractArray); 00247 vtkGetObjectMacro(Annotations,vtkStringArray); 00249 00254 virtual vtkIdType SetAnnotation(vtkVariant value, vtkStdString annotation); 00255 00257 virtual vtkIdType SetAnnotation(vtkStdString value, vtkStdString annotation); 00258 00260 vtkIdType GetNumberOfAnnotatedValues(); 00261 00263 vtkVariant GetAnnotatedValue(vtkIdType idx); 00264 00266 vtkStdString GetAnnotation(vtkIdType idx); 00267 00269 virtual void GetAnnotationColor(const vtkVariant& val, double rgba[4]); 00270 00272 vtkIdType GetAnnotatedValueIndex( vtkVariant val ); 00273 00275 vtkIdType GetAnnotatedValueIndexInternal(vtkVariant& val); 00276 00288 virtual void GetIndexedColor(vtkIdType i, double rgba[4]); 00289 00295 virtual bool RemoveAnnotation(vtkVariant value); 00296 00298 virtual void ResetAnnotations(); 00299 00301 00306 vtkSetMacro(IndexedLookup,int); 00307 vtkGetMacro(IndexedLookup,int); 00308 vtkBooleanMacro(IndexedLookup,int); 00310 00311 protected: 00312 vtkScalarsToColors(); 00313 ~vtkScalarsToColors(); 00314 00316 00325 void MapColorsToColors(void *input, unsigned char *output, 00326 int inputDataType, int numberOfValues, 00327 int numberOfComponents, int vectorSize, 00328 int outputFormat); 00330 00332 00334 void MapVectorsToMagnitude(void *input, double *output, 00335 int inputDataType, int numberOfValues, 00336 int numberOfComponents, int vectorSize); 00338 00340 virtual vtkIdType CheckForAnnotatedValue( vtkVariant value ); 00342 virtual void UpdateAnnotatedValueMap(); 00343 00344 // Annotations of specific values. 00345 class vtkInternalAnnotatedValueMap; 00346 vtkAbstractArray* AnnotatedValues; 00347 vtkStringArray* Annotations; 00348 vtkInternalAnnotatedValueMap* AnnotatedValueMap; 00349 int IndexedLookup; 00350 00351 double Alpha; 00352 00353 // How to map arrays with multiple components. 00354 int VectorMode; 00355 int VectorComponent; 00356 int VectorSize; 00357 00358 // Obsolete, kept so subclasses will still compile 00359 int UseMagnitude; 00360 00361 private: 00362 double RGB[3]; 00363 unsigned char RGBABytes[4]; 00364 double InputRange[2]; 00365 00366 vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented. 00367 void operator=(const vtkScalarsToColors&); // Not implemented. 00368 }; 00369 00370 #endif 00371 00372 00373