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 "vtkRenderingCoreModule.h" // For export macro 00044 #include "vtkScalarsToColors.h" 00045 00046 class vtkColorTransferFunctionInternals; 00047 00048 #define VTK_CTF_RGB 0 00049 #define VTK_CTF_HSV 1 00050 #define VTK_CTF_LAB 2 00051 #define VTK_CTF_DIVERGING 3 00052 00053 #define VTK_CTF_LINEAR 0 00054 #define VTK_CTF_LOG10 1 00055 00056 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 00057 { 00058 public: 00059 static vtkColorTransferFunction *New(); 00060 vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors); 00061 void DeepCopy( vtkScalarsToColors *f ); 00062 void ShallowCopy( vtkColorTransferFunction *f ); 00063 00065 void PrintSelf(ostream& os, vtkIndent indent); 00066 00068 int GetSize(); 00069 00071 00075 int AddRGBPoint( double x, double r, double g, double b ); 00076 int AddRGBPoint( double x, double r, double g, double b, 00077 double midpoint, double sharpness ); 00078 int AddHSVPoint( double x, double h, double s, double v ); 00079 int AddHSVPoint( double x, double h, double s, double v, 00080 double midpoint, double sharpness ); 00081 int RemovePoint( double x ); 00083 00085 00086 void AddRGBSegment( double x1, double r1, double g1, double b1, 00087 double x2, double r2, double g2, double b2 ); 00088 void AddHSVSegment( double x1, double h1, double s1, double v1, 00089 double x2, double h2, double s2, double v2 ); 00091 00093 void RemoveAllPoints(); 00094 00096 00097 double *GetColor(double x) { 00098 return vtkScalarsToColors::GetColor(x); } 00099 void GetColor(double x, double rgb[3]); 00101 00103 00104 double GetRedValue( double x ); 00105 double GetGreenValue( double x ); 00106 double GetBlueValue( double x ); 00108 00110 00112 int GetNodeValue( int index, double val[6] ); 00113 int SetNodeValue( int index, double val[6] ); 00115 00117 virtual unsigned char *MapValue(double v); 00118 00120 00121 vtkGetVector2Macro( Range, double ); 00123 00126 int AdjustRange(double range[2]); 00127 00129 00131 void GetTable( double x1, double x2, int n, double* table ); 00132 void GetTable( double x1, double x2, int n, float* table ); 00133 const unsigned char *GetTable( double x1, double x2, int n); 00135 00140 void BuildFunctionFromTable( double x1, double x2, int size, double *table); 00141 00143 00144 vtkSetClampMacro( Clamping, int, 0, 1 ); 00145 vtkGetMacro( Clamping, int ); 00146 vtkBooleanMacro( Clamping, int ); 00148 00150 00157 vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING ); 00158 void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);}; 00159 void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);}; 00160 void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);}; 00161 void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);} 00162 vtkGetMacro( ColorSpace, int ); 00163 vtkSetMacro(HSVWrap, int); 00164 vtkGetMacro(HSVWrap, int); 00165 vtkBooleanMacro(HSVWrap, int); 00167 00169 00172 vtkSetMacro(Scale,int); 00173 void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); }; 00174 void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); }; 00175 vtkGetMacro(Scale,int); 00177 00179 00181 vtkSetVector3Macro(NanColor, double); 00182 vtkGetVector3Macro(NanColor, double); 00184 00186 00188 double *GetDataPointer(); 00189 void FillFromDataPointer(int, double*); 00191 00193 00194 virtual void MapScalarsThroughTable2(void *input, unsigned char *output, 00195 int inputDataType, int numberOfValues, 00196 int inputIncrement, int outputIncrement); 00198 00200 00202 vtkSetMacro(AllowDuplicateScalars, int); 00203 vtkGetMacro(AllowDuplicateScalars, int); 00204 vtkBooleanMacro(AllowDuplicateScalars, int); 00206 00208 virtual vtkIdType GetNumberOfAvailableColors(); 00209 00213 virtual void GetIndexedColor(vtkIdType idx, double rgba[4]); 00214 00215 protected: 00216 vtkColorTransferFunction(); 00217 ~vtkColorTransferFunction(); 00218 00219 vtkColorTransferFunctionInternals *Internal; 00220 00221 // Determines the function value outside of defined points 00222 // Zero = always return 0.0 outside of defined points 00223 // One = clamp to the lowest value below defined points and 00224 // highest value above defined points 00225 int Clamping; 00226 00227 // The color space in which interpolation is performed 00228 int ColorSpace; 00229 00230 // Specify if HSW is warp or not 00231 int HSVWrap; 00232 00233 // The color interpolation scale (linear or logarithmic). 00234 int Scale; 00235 00236 // The color to use for not-a-number. 00237 double NanColor[3]; 00238 00239 double *Function; 00240 00241 // The min and max node locations 00242 double Range[2]; 00243 00244 // An evaluated color (0 to 255 RGBA A=255) 00245 unsigned char UnsignedCharRGBAValue[4]; 00246 00247 int AllowDuplicateScalars; 00248 00249 vtkTimeStamp BuildTime; 00250 unsigned char *Table; 00251 int TableSize; 00252 00254 00256 virtual void SetRange(double, double) {} 00257 void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);}; 00259 00260 // Internal method to sort the vector and update the 00261 // Range whenever a node is added, edited or removed 00262 // It always calls Modified(). 00263 void SortAndUpdateRange(); 00264 // Returns true if the range has been updated and Modified() has been called 00265 bool UpdateRange(); 00266 00269 void MovePoint(double oldX, double newX); 00270 00271 private: 00272 vtkColorTransferFunction(const vtkColorTransferFunction&); // Not implemented. 00273 void operator=(const vtkColorTransferFunction&); // Not implemented. 00274 }; 00275 00276 #endif 00277