Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkColorTransferFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkColorTransferFunction.h,v $
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 =========================================================================*/
00032 #ifndef __vtkColorTransferFunction_h
00033 #define __vtkColorTransferFunction_h
00034 
00035 #include "vtkScalarsToColors.h"
00036 
00037 class vtkPiecewiseFunction;
00038 
00039 #define VTK_CTF_RGB           0
00040 #define VTK_CTF_HSV           1
00041 
00042 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00043 {
00044 public:
00045   static vtkColorTransferFunction *New();
00046   vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00047   void DeepCopy( vtkColorTransferFunction *f );
00048 
00050   void PrintSelf(ostream& os, vtkIndent indent);
00051 
00053   int GetSize() {return this->NumberOfPoints;};
00054   
00056 
00058   int AddRGBPoint( double x, double r, double g, double b );
00059   int AddHSVPoint( double x, double h, double s, double v );
00060   int RemovePoint( double x );
00062 
00064 
00065   void AddRGBSegment( double x1, double r1, double g1, double b1, 
00066                       double x2, double r2, double g2, double b2 );
00067   void AddHSVSegment( double x1, double h1, double s1, double v1, 
00068                       double x2, double h2, double s2, double v2 );
00070   
00072   void RemoveAllPoints();
00073 
00075 
00076   double *GetColor(double x) {
00077     return vtkScalarsToColors::GetColor(x); }
00078   void GetColor(double x, double rgb[3]);
00080 
00082 
00083   double GetRedValue( double x );
00084   double GetGreenValue( double x );
00085   double GetBlueValue( double x );
00087 
00089   virtual unsigned char *MapValue(double v);
00090 
00092 
00093   vtkGetVector2Macro( Range, double );
00095 
00098   int AdjustRange(double range[2]);
00099 
00101 
00102   void GetTable( double x1, double x2, int n, double* table );
00103   void GetTable( double x1, double x2, int n, float* table );
00104   const unsigned char *GetTable( double x1, double x2, int n);
00106 
00111   void BuildFunctionFromTable( double x1, double x2, int size, double *table);
00112 
00114 
00115   vtkSetClampMacro( Clamping, int, 0, 1 );
00116   vtkGetMacro( Clamping, int );
00117   vtkBooleanMacro( Clamping, int );
00119   
00121 
00126   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00127   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00128   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00129   vtkGetMacro( ColorSpace, int );
00130   vtkSetMacro(HSVWrap, int);
00131   vtkGetMacro(HSVWrap, int);
00132   vtkBooleanMacro(HSVWrap, int);
00133   VTK_LEGACY(void SetColorSpaceToHSVNoWrap());
00135     
00137 
00139   double *GetDataPointer() {return this->Function;};
00140   void FillFromDataPointer(int, double*);
00142 
00144 
00145   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00146                                      int inputDataType, int numberOfValues,
00147                                      int inputIncrement, int outputIncrement);
00149   
00150 protected:
00151   vtkColorTransferFunction();
00152   ~vtkColorTransferFunction();
00153 
00154   // Determines the function value outside of defined points
00155   // Zero = always return 0.0 outside of defined points
00156   // One  = clamp to the lowest value below defined points and
00157   //        highest value above defined points
00158   int Clamping;
00159 
00160   // The color space in which interpolation is performed
00161   int ColorSpace;
00162 
00163   // Specify if HSW is warp or not
00164   int HSVWrap;
00165   
00166   // The color function
00167   double     *Function;
00168   int         FunctionSize;
00169   int         NumberOfPoints;
00170 
00171   // An evaluated color (0 to 255 RGBA A=255)
00172   unsigned char UnsignedCharRGBAValue[4];
00173 
00174   // The min and max point locations for all three transfer functions
00175   double Range[2]; 
00176 
00177   // Transfer functions for each color component
00178   // Remove after corresponding depricated methods are removed
00179   vtkPiecewiseFunction  *Red;
00180   vtkPiecewiseFunction  *Green;
00181   vtkPiecewiseFunction  *Blue;
00182   vtkTimeStamp BuildTime;
00183   unsigned char *Table;
00184   int TableSize;
00185   
00187 
00189   virtual void SetRange(double, double) {};
00190   void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00192 
00193 
00194 private:
00195   vtkColorTransferFunction(const vtkColorTransferFunction&);  // Not implemented.
00196   void operator=(const vtkColorTransferFunction&);  // Not implemented.
00197 };
00198 
00199 #endif
00200 

Generated on Mon Jan 21 23:07:18 2008 for VTK by  doxygen 1.4.3-20050530