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( vtkScalarsToColors *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 vtkSetVector3Macro(NanColor, double); 00180 vtkGetVector3Macro(NanColor, double); 00182 00184 00186 double *GetDataPointer(); 00187 void FillFromDataPointer(int, double*); 00189 00191 00192 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00193 int inputDataType, int numberOfValues, 00194 int inputIncrement, int outputIncrement); 00196 00198 00200 vtkSetMacro(AllowDuplicateScalars, int); 00201 vtkGetMacro(AllowDuplicateScalars, int); 00202 vtkBooleanMacro(AllowDuplicateScalars, int); 00204 00206 virtual vtkIdType GetNumberOfAvailableColors(); 00207 00208 protected: 00209 vtkColorTransferFunction(); 00210 ~vtkColorTransferFunction(); 00211 00212 vtkColorTransferFunctionInternals *Internal; 00213 00214 // Determines the function value outside of defined points 00215 // Zero = always return 0.0 outside of defined points 00216 // One = clamp to the lowest value below defined points and 00217 // highest value above defined points 00218 int Clamping; 00219 00220 // The color space in which interpolation is performed 00221 int ColorSpace; 00222 00223 // Specify if HSW is warp or not 00224 int HSVWrap; 00225 00226 // The color interpolation scale (linear or logarithmic). 00227 int Scale; 00228 00229 // The color to use for not-a-number. 00230 double NanColor[3]; 00231 00232 double *Function; 00233 00234 // The min and max node locations 00235 double Range[2]; 00236 00237 // An evaluated color (0 to 255 RGBA A=255) 00238 unsigned char UnsignedCharRGBAValue[4]; 00239 00240 int AllowDuplicateScalars; 00241 00242 vtkTimeStamp BuildTime; 00243 unsigned char *Table; 00244 int TableSize; 00245 00247 00249 virtual void SetRange(double, double) {}; 00250 void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);}; 00252 00253 // Internal method to sort the vector and update the 00254 // Range whenever a node is added, edited or removed 00255 // It always calls Modified(). 00256 void SortAndUpdateRange(); 00257 // Returns true if the range has been updated and Modified() has been called 00258 bool UpdateRange(); 00259 00262 void MovePoint(double oldX, double newX); 00263 00264 private: 00265 vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented. 00266 void operator=(const vtkColorTransferFunction&); // Not implemented. 00267 }; 00268 00269 #endif 00270