VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDiscretizableColorTransferFunction.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 =========================================================================*/ 00044 #ifndef vtkDiscretizableColorTransferFunction_h 00045 #define vtkDiscretizableColorTransferFunction_h 00046 00047 #include "vtkRenderingCoreModule.h" // For export macro 00048 #include "vtkColorTransferFunction.h" 00049 #include "vtkSmartPointer.h" // for vtkSmartPointer 00050 00051 class vtkColorTransferFunction; 00052 class vtkLookupTable; 00053 class vtkPiecewiseFunction; 00054 00055 class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction : public vtkColorTransferFunction 00056 { 00057 public: 00058 static vtkDiscretizableColorTransferFunction* New(); 00059 vtkTypeMacro(vtkDiscretizableColorTransferFunction, vtkColorTransferFunction); 00060 void PrintSelf(ostream& os, vtkIndent indent); 00061 00063 int IsOpaque(); 00064 00066 00071 void SetIndexedColor(unsigned int index, const double rgb[3]) 00072 { this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]); } 00073 void SetIndexedColor(unsigned int index, double r, double g, double b); 00075 00086 virtual void GetIndexedColor(vtkIdType i, double rgba[4]); 00087 00089 00092 void SetNumberOfIndexedColors(unsigned int count); 00093 unsigned int GetNumberOfIndexedColors(); 00095 00100 virtual void Build(); 00101 00103 00107 vtkSetMacro(Discretize, int); 00108 vtkGetMacro(Discretize, int); 00109 vtkBooleanMacro(Discretize, int); 00111 00113 00115 virtual void SetUseLogScale(int useLogScale); 00116 vtkGetMacro(UseLogScale, int); 00118 00120 00123 vtkSetMacro(NumberOfValues, vtkIdType); 00124 vtkGetMacro(NumberOfValues, vtkIdType); 00126 00129 virtual unsigned char *MapValue(double v); 00130 00133 virtual void GetColor(double v, double rgb[3]); 00134 00136 virtual double GetOpacity(double v); 00137 00139 00150 virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode, 00151 int component); 00152 virtual vtkUnsignedCharArray *MapScalars(vtkAbstractArray *scalars, int colorMode, 00153 int component); 00155 00159 VTK_LEGACY(double* GetRGBPoints()); 00160 00165 virtual void SetAlpha(double alpha); 00166 00168 00171 virtual void SetNanColor(double r, double g, double b); 00172 virtual void SetNanColor(double rgb[3]) { 00173 this->SetNanColor(rgb[0], rgb[1], rgb[2]); 00174 } 00176 00178 00180 virtual int UsingLogScale() 00181 { return this->UseLogScale; } 00183 00185 virtual vtkIdType GetNumberOfAvailableColors(); 00186 00188 00189 virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function); 00190 virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const; 00192 00194 00195 vtkSetMacro(EnableOpacityMapping, bool) 00196 vtkGetMacro(EnableOpacityMapping, bool) 00197 vtkBooleanMacro(EnableOpacityMapping, bool) 00199 00201 virtual unsigned long GetMTime(); 00202 00203 protected: 00204 vtkDiscretizableColorTransferFunction(); 00205 ~vtkDiscretizableColorTransferFunction(); 00206 00208 int Discretize; 00209 00211 int UseLogScale; 00212 00214 vtkIdType NumberOfValues; 00215 00217 vtkLookupTable* LookupTable; 00218 00219 vtkTimeStamp BuildTime; 00220 00221 bool EnableOpacityMapping; 00222 vtkSmartPointer<vtkPiecewiseFunction> ScalarOpacityFunction; 00223 00224 void MapDataArrayToOpacity( 00225 vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors); 00226 00227 private: 00228 vtkDiscretizableColorTransferFunction(const vtkDiscretizableColorTransferFunction&); // Not implemented. 00229 void operator=(const vtkDiscretizableColorTransferFunction&); // Not implemented. 00230 00231 template<typename T, typename VectorGetter> 00232 void MapVectorToOpacity ( 00233 VectorGetter getter, T* scalars, int component, 00234 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors); 00235 00236 template<template<class> class VectorGetter> 00237 void AllTypesMapVectorToOpacity ( 00238 int scalarType, 00239 void* scalarsPtr, int component, 00240 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors); 00241 00242 class vtkInternals; 00243 vtkInternals* Internals; 00244 }; 00245 00246 #endif