VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkColorTransferFunction.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 =========================================================================*/ 00040 #ifndef __vtkColorTransferFunction_h 00041 #define __vtkColorTransferFunction_h 00042 00043 #include "vtkScalarsToColors.h" 00044 00045 class vtkColorTransferFunctionInternals; 00046 00047 #define VTK_CTF_RGB 0 00048 #define VTK_CTF_HSV 1 00049 #define VTK_CTF_LAB 2 00050 #define VTK_CTF_DIVERGING 3 00051 00052 #define VTK_CTF_LINEAR 0 00053 #define VTK_CTF_LOG10 1 00054 00055 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 00056 { 00057 public: 00058 static vtkColorTransferFunction *New(); 00059 vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors); 00060 void DeepCopy( vtkColorTransferFunction *f ); 00061 void ShallowCopy( vtkColorTransferFunction *f ); 00062 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00067 int GetSize(); 00068 00070 00074 int AddRGBPoint( double x, double r, double g, double b ); 00075 int AddRGBPoint( double x, double r, double g, double b, 00076 double midpoint, double sharpness ); 00077 int AddHSVPoint( double x, double h, double s, double v ); 00078 int AddHSVPoint( double x, double h, double s, double v, 00079 double midpoint, double sharpness ); 00080 int RemovePoint( double x ); 00082 00084 00085 void AddRGBSegment( double x1, double r1, double g1, double b1, 00086 double x2, double r2, double g2, double b2 ); 00087 void AddHSVSegment( double x1, double h1, double s1, double v1, 00088 double x2, double h2, double s2, double v2 ); 00090 00092 void RemoveAllPoints(); 00093 00095 00096 double *GetColor(double x) { 00097 return vtkScalarsToColors::GetColor(x); } 00098 void GetColor(double x, double rgb[3]); 00100 00102 00103 double GetRedValue( double x ); 00104 double GetGreenValue( double x ); 00105 double GetBlueValue( double x ); 00107 00109 00111 int GetNodeValue( int index, double val[6] ); 00112 int SetNodeValue( int index, double val[6] ); 00114 00116 virtual unsigned char *MapValue(double v); 00117 00119 00120 vtkGetVector2Macro( Range, double ); 00122 00125 int AdjustRange(double range[2]); 00126 00128 00129 void GetTable( double x1, double x2, int n, double* table ); 00130 void GetTable( double x1, double x2, int n, float* table ); 00131 const unsigned char *GetTable( double x1, double x2, int n); 00133 00138 void BuildFunctionFromTable( double x1, double x2, int size, double *table); 00139 00141 00142 vtkSetClampMacro( Clamping, int, 0, 1 ); 00143 vtkGetMacro( Clamping, int ); 00144 vtkBooleanMacro( Clamping, int ); 00146 00148 00155 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING ); 00156 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);}; 00157 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);}; 00158 void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);}; 00159 void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);} 00160 vtkGetMacro( ColorSpace, int ); 00161 vtkSetMacro(HSVWrap, int); 00162 vtkGetMacro(HSVWrap, int); 00163 vtkBooleanMacro(HSVWrap, int); 00165 00167 00170 vtkSetMacro(Scale,int); 00171 void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); }; 00172 void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); }; 00173 vtkGetMacro(Scale,int); 00175 00177 00179 double *GetDataPointer(); 00180 void FillFromDataPointer(int, double*); 00182 00184 00185 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00186 int inputDataType, int numberOfValues, 00187 int inputIncrement, int outputIncrement); 00189 00191 00193 vtkSetMacro(AllowDuplicateScalars, int); 00194 vtkGetMacro(AllowDuplicateScalars, int); 00195 vtkBooleanMacro(AllowDuplicateScalars, int); 00197 00198 protected: 00199 vtkColorTransferFunction(); 00200 ~vtkColorTransferFunction(); 00201 00202 vtkColorTransferFunctionInternals *Internal; 00203 00204 // Determines the function value outside of defined points 00205 // Zero = always return 0.0 outside of defined points 00206 // One = clamp to the lowest value below defined points and 00207 // highest value above defined points 00208 int Clamping; 00209 00210 // The color space in which interpolation is performed 00211 int ColorSpace; 00212 00213 // Specify if HSW is warp or not 00214 int HSVWrap; 00215 00216 // The color interpolation scale (linear or logarithmic). 00217 int Scale; 00218 00219 double *Function; 00220 00221 // The min and max node locations 00222 double Range[2]; 00223 00224 // An evaluated color (0 to 255 RGBA A=255) 00225 unsigned char UnsignedCharRGBAValue[4]; 00226 00227 int AllowDuplicateScalars; 00228 00229 vtkTimeStamp BuildTime; 00230 unsigned char *Table; 00231 int TableSize; 00232 00234 00236 virtual void SetRange(double, double) {}; 00237 void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);}; 00239 00240 // Internal method to sort the vector and update the 00241 // Range whenever a node is added or removed 00242 void SortAndUpdateRange(); 00243 00246 void MovePoint(double oldX, double newX); 00247 00248 private: 00249 vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented. 00250 void operator=(const vtkColorTransferFunction&); // Not implemented. 00251 }; 00252 00253 #endif 00254