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 vtkLookupTable; 00052 class vtkColorTransferFunction; 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 00062 int IsOpaque(); 00063 00065 00070 void SetIndexedColor(unsigned int index, const double rgb[3]) 00071 { this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]); } 00072 void SetIndexedColor(unsigned int index, double r, double g, double b); 00074 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); 00153 00155 double* GetRGBPoints(); 00156 00161 virtual void SetAlpha(double alpha); 00162 00163 00165 00168 virtual void SetNanColor(double r, double g, double b); 00169 virtual void SetNanColor(double rgb[3]) { 00170 this->SetNanColor(rgb[0], rgb[1], rgb[2]); 00171 } 00173 00174 00176 00178 virtual int UsingLogScale() 00179 { return this->UseLogScale; } 00181 00183 virtual vtkIdType GetNumberOfAvailableColors(); 00184 00186 00187 virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function); 00188 virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const; 00190 00192 00193 vtkSetMacro(EnableOpacityMapping, bool) 00194 vtkGetMacro(EnableOpacityMapping, bool) 00195 vtkBooleanMacro(EnableOpacityMapping, bool) 00197 00199 virtual unsigned long GetMTime(); 00200 00201 protected: 00202 vtkDiscretizableColorTransferFunction(); 00203 ~vtkDiscretizableColorTransferFunction(); 00204 00205 int Discretize; 00206 int UseLogScale; 00207 00208 vtkIdType NumberOfValues; 00209 vtkLookupTable* LookupTable; 00210 00211 vtkTimeStamp BuildTime; 00212 00213 bool EnableOpacityMapping; 00214 vtkSmartPointer<vtkPiecewiseFunction> ScalarOpacityFunction; 00215 unsigned long ScalarOpacityFunctionObserverId; 00216 00217 void MapDataArrayToOpacity( 00218 vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors); 00219 00220 private: 00221 vtkDiscretizableColorTransferFunction(const vtkDiscretizableColorTransferFunction&); // Not implemented. 00222 void operator=(const vtkDiscretizableColorTransferFunction&); // Not implemented. 00223 template<typename T, typename VectorGetter> 00224 void MapVectorToOpacity ( 00225 VectorGetter getter, T* scalars, int component, 00226 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors); 00227 template<template<class> class VectorGetter> 00228 void AllTypesMapVectorToOpacity ( 00229 int scalarType, 00230 void* scalarsPtr, int component, 00231 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors); 00232 00233 00234 // Pointer used by GetRGBPoints(). 00235 double* Data; 00236 00237 class vtkInternals; 00238 vtkInternals* Internals; 00239 }; 00240 00241 #endif