Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 =========================================================================*/
00045 #ifndef __vtkColorTransferFunction_h
00046 #define __vtkColorTransferFunction_h
00047 
00048 #include "vtkScalarsToColors.h"
00049 
00050 class vtkPiecewiseFunction;
00051 
00052 #define VTK_CTF_RGB           0
00053 #define VTK_CTF_HSV           1
00054 #define VTK_CTF_HSV_NO_WRAP   2
00055 
00056 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00057 {
00058 public:
00059   static vtkColorTransferFunction *New();
00060   vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00061   void DeepCopy( vtkColorTransferFunction *f );
00062 
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00067   int GetSize() {return this->NumberOfPoints;};
00068   
00070 
00072   int AddRGBPoint( double x, double r, double g, double b );
00073   int AddHSVPoint( double x, double h, double s, double v );
00074   int RemovePoint( double x );
00076 
00078 
00079   void AddRGBSegment( double x1, double r1, double g1, double b1, 
00080                       double x2, double r2, double g2, double b2 );
00081   void AddHSVSegment( double x1, double h1, double s1, double v1, 
00082                       double x2, double h2, double s2, double v2 );
00084   
00086   void RemoveAllPoints();
00087 
00089 
00091   double *GetColor(double x) { 
00092     return vtkScalarsToColors::GetColor(x); }
00093   void GetColor(double x, double rgb[3]);
00095 
00097 
00098   double GetRedValue( double x );
00099   double GetGreenValue( double x );
00100   double GetBlueValue( double x );
00102 
00104   virtual unsigned char *MapValue(double v);
00105 
00107 
00108   vtkGetVector2Macro( Range, double );
00110 
00112 
00113   void GetTable( double x1, double x2, int n, double* table );
00114   void GetTable( double x1, double x2, int n, float* table );
00115   const unsigned char *GetTable( double x1, double x2, int n);
00117 
00122   void BuildFunctionFromTable( double x1, double x2, int size, double *table);
00123 
00125 
00126   vtkSetClampMacro( Clamping, int, 0, 1 );
00127   vtkGetMacro( Clamping, int );
00128   vtkBooleanMacro( Clamping, int );
00130   
00132 
00137   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV_NO_WRAP );
00138   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00139   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00140   void SetColorSpaceToHSVNoWrap(){this->SetColorSpace(VTK_CTF_HSV_NO_WRAP);};
00141   vtkGetMacro( ColorSpace, int );
00143     
00145 
00147   double *GetDataPointer() {return this->Function;};
00148   void FillFromDataPointer(int, double*);
00150 
00152 
00153   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00154                                      int inputDataType, int numberOfValues,
00155                                      int inputIncrement, int outputIncrement);
00157   
00158 protected:
00159   vtkColorTransferFunction();
00160   ~vtkColorTransferFunction();
00161 
00162   // Determines the function value outside of defined points
00163   // Zero = always return 0.0 outside of defined points
00164   // One  = clamp to the lowest value below defined points and
00165   //        highest value above defined points
00166   int Clamping;
00167 
00168   // The color space in which interpolation is performed
00169   int ColorSpace;
00170   
00171   // The color function
00172   double     *Function;
00173   int         FunctionSize;
00174   int         NumberOfPoints;
00175 
00176   // An evaluated color (0 to 255 RGBA A=255)
00177   unsigned char UnsignedCharRGBAValue[4];
00178 
00179   // The min and max point locations for all three transfer functions
00180   double Range[2]; 
00181 
00182   // Transfer functions for each color component
00183   // Remove after corresponding depricated methods are removed
00184   vtkPiecewiseFunction  *Red;
00185   vtkPiecewiseFunction  *Green;
00186   vtkPiecewiseFunction  *Blue;
00187   vtkTimeStamp BuildTime;
00188   unsigned char *Table;
00189   int TableSize;
00190   
00192 
00194   virtual void SetRange(double, double) {};
00195   void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00197 
00198 
00199 private:
00200   vtkColorTransferFunction(const vtkColorTransferFunction&);  // Not implemented.
00201   void operator=(const vtkColorTransferFunction&);  // Not implemented.
00202 };
00203 
00204 #endif
00205 
00206