VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Core/vtkColorTransferFunction.h
Go to the documentation of this file.
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 =========================================================================*/
00041 #ifndef vtkColorTransferFunction_h
00042 #define vtkColorTransferFunction_h
00043 
00044 #include "vtkRenderingCoreModule.h" // For export macro
00045 #include "vtkScalarsToColors.h"
00046 
00047 class vtkColorTransferFunctionInternals;
00048 
00049 #define VTK_CTF_RGB           0
00050 #define VTK_CTF_HSV           1
00051 #define VTK_CTF_LAB           2
00052 #define VTK_CTF_DIVERGING     3
00053 
00054 #define VTK_CTF_LINEAR        0
00055 #define VTK_CTF_LOG10         1
00056 
00057 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
00058 {
00059 public:
00060   static vtkColorTransferFunction *New();
00061   vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors);
00062   void DeepCopy( vtkScalarsToColors *f );
00063   void ShallowCopy( vtkColorTransferFunction *f );
00064 
00066   void PrintSelf(ostream& os, vtkIndent indent);
00067 
00069   int GetSize();
00070 
00072 
00076   int AddRGBPoint( double x, double r, double g, double b );
00077   int AddRGBPoint( double x, double r, double g, double b,
00078                    double midpoint, double sharpness );
00079   int AddHSVPoint( double x, double h, double s, double v );
00080   int AddHSVPoint( double x, double h, double s, double v,
00081                    double midpoint, double sharpness );
00082   int RemovePoint( double x );
00084 
00086 
00087   void AddRGBSegment( double x1, double r1, double g1, double b1,
00088                       double x2, double r2, double g2, double b2 );
00089   void AddHSVSegment( double x1, double h1, double s1, double v1,
00090                       double x2, double h2, double s2, double v2 );
00092 
00094   void RemoveAllPoints();
00095 
00097 
00098   double *GetColor(double x) {
00099     return vtkScalarsToColors::GetColor(x); }
00100   void GetColor(double x, double rgb[3]);
00102 
00104 
00105   double GetRedValue( double x );
00106   double GetGreenValue( double x );
00107   double GetBlueValue( double x );
00109 
00111 
00113   int GetNodeValue( int index, double val[6] );
00114   int SetNodeValue( int index, double val[6] );
00116 
00118   virtual unsigned char *MapValue(double v);
00119 
00121 
00122   vtkGetVector2Macro( Range, double );
00124 
00127   int AdjustRange(double range[2]);
00128 
00130 
00133   void GetTable( double x1, double x2, int n, double* table );
00134   void GetTable( double x1, double x2, int n, float* table );
00135   const unsigned char *GetTable( double x1, double x2, int n );
00137 
00145   void BuildFunctionFromTable( double x1, double x2, int size, double *table );
00146 
00148 
00153   vtkSetClampMacro( Clamping, int, 0, 1 );
00154   vtkGetMacro( Clamping, int );
00155   vtkBooleanMacro( Clamping, int );
00157 
00159 
00166   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
00167   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00168   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00169   void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
00170   void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
00171   vtkGetMacro( ColorSpace, int );
00172   vtkSetMacro(HSVWrap, int);
00173   vtkGetMacro(HSVWrap, int);
00174   vtkBooleanMacro(HSVWrap, int);
00176 
00178 
00181   vtkSetMacro(Scale,int);
00182   void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
00183   void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
00184   vtkGetMacro(Scale,int);
00186 
00188 
00190   vtkSetVector3Macro(NanColor, double);
00191   vtkGetVector3Macro(NanColor, double);
00193 
00195 
00197   vtkSetVector3Macro(BelowRangeColor, double);
00198   vtkGetVector3Macro(BelowRangeColor, double);
00200 
00202 
00203   vtkSetMacro(UseBelowRangeColor, int);
00204   vtkGetMacro(UseBelowRangeColor, int);
00205   vtkBooleanMacro(UseBelowRangeColor, int);
00207 
00209 
00211   vtkSetVector3Macro(AboveRangeColor, double);
00212   vtkGetVector3Macro(AboveRangeColor, double);
00214 
00216 
00217   vtkSetMacro(UseAboveRangeColor, int);
00218   vtkGetMacro(UseAboveRangeColor, int);
00219   vtkBooleanMacro(UseAboveRangeColor, int);
00221 
00227   double* GetDataPointer();
00228 
00232   void FillFromDataPointer(int n, double* ptr);
00233 
00235 
00236   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00237                                        int inputDataType, int numberOfValues,
00238                                        int inputIncrement, int outputIncrement);
00240 
00242 
00244   vtkSetMacro(AllowDuplicateScalars, int);
00245   vtkGetMacro(AllowDuplicateScalars, int);
00246   vtkBooleanMacro(AllowDuplicateScalars, int);
00248 
00250   virtual vtkIdType GetNumberOfAvailableColors();
00251 
00255   virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
00256 
00257 protected:
00258   vtkColorTransferFunction();
00259   ~vtkColorTransferFunction();
00260 
00261   vtkColorTransferFunctionInternals *Internal;
00262 
00266   int Clamping;
00267 
00269   int ColorSpace;
00270 
00272   int HSVWrap;
00273 
00275   int Scale;
00276 
00278   double NanColor[3];
00279 
00281   double BelowRangeColor[3];
00282 
00284   int UseBelowRangeColor;
00285 
00287   double AboveRangeColor[3];
00288 
00290   int UseAboveRangeColor;
00291 
00293   double* Function;
00294 
00296   double Range[2];
00297 
00299   unsigned char UnsignedCharRGBAValue[4];
00300 
00303   int AllowDuplicateScalars;
00304 
00305   vtkTimeStamp BuildTime;
00306   unsigned char *Table;
00307 
00310   int TableSize;
00311 
00313 
00315   virtual void SetRange(double, double) {}
00316   void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00318 
00321   void SortAndUpdateRange();
00322 
00325   bool UpdateRange();
00326 
00329   void MovePoint(double oldX, double newX);
00330 
00331 private:
00332   vtkColorTransferFunction(const vtkColorTransferFunction&);  // Not implemented.
00333   void operator=(const vtkColorTransferFunction&);  // Not implemented.
00334 };
00335 
00336 #endif