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

Filtering/vtkColorTransferFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkColorTransferFunction.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00036 #ifndef __vtkColorTransferFunction_h
00037 #define __vtkColorTransferFunction_h
00038 
00039 #include "vtkScalarsToColors.h"
00040 
00041 class vtkPiecewiseFunction;
00042 
00043 #define VTK_CTF_RGB   0
00044 #define VTK_CTF_HSV   1
00045 
00046 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00047 {
00048 public:
00049   static vtkColorTransferFunction *New();
00050   vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00051   void DeepCopy( vtkColorTransferFunction *f );
00052 
00054   void PrintSelf(ostream& os, vtkIndent indent);
00055 
00057   int GetSize() {return this->NumberOfPoints;};
00058   
00060 
00061   void AddRGBPoint( float x, float r, float g, float b );
00062   void AddHSVPoint( float x, float h, float s, float v );
00064 
00066 
00067   void AddRGBSegment( float x1, float r1, float g1, float b1, 
00068                       float x2, float r2, float g2, float b2 );
00069   void AddHSVSegment( float x1, float h1, float s1, float v1, 
00070                       float x2, float h2, float s2, float v2 );
00072   
00074 
00075   void RemovePoint( float x );
00076   void RemoveAllPoints();
00078 
00080 
00082   float *GetColor(float x) { 
00083     return vtkScalarsToColors::GetColor(x); }
00084   void GetColor(float x, float rgb[3]);
00086 
00088 
00089   float GetRedValue( float x );
00090   float GetGreenValue( float x );
00091   float GetBlueValue( float x );
00093 
00095   virtual unsigned char *MapValue(float v);
00096 
00098 
00099   vtkGetVector2Macro( Range, float );
00101 
00103 
00104   void GetTable( float x1, float x2, int n, float* table );
00105   const unsigned char *GetTable( float x1, float x2, int n);
00107 
00112   void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00113 
00115 
00116   vtkSetClampMacro( Clamping, int, 0, 1 );
00117   vtkGetMacro( Clamping, int );
00118   vtkBooleanMacro( Clamping, int );
00120   
00122 
00123   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00124   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00125   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00126   vtkGetMacro( ColorSpace, int );
00128     
00130 
00132   float *GetDataPointer() {return this->Function;};
00133   void FillFromDataPointer(int, float*);
00135 
00137 
00138   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00139                                      int inputDataType, int numberOfValues,
00140                                      int inputIncrement, int outputIncrement);
00142   
00143 protected:
00144   vtkColorTransferFunction();
00145   ~vtkColorTransferFunction();
00146 
00147   // Determines the function value outside of defined points
00148   // Zero = always return 0.0 outside of defined points
00149   // One  = clamp to the lowest value below defined points and
00150   //        highest value above defined points
00151   int Clamping;
00152 
00153   // The color space in which interpolation is performed
00154   int ColorSpace;
00155   
00156   // The color function
00157   float       *Function;
00158   int         FunctionSize;
00159   int         NumberOfPoints;
00160 
00161   // conversion methods
00162   void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00163   void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00164   
00165   // An evaluated color (0 to 255 RGBA A=255)
00166   unsigned char UnsignedCharRGBAValue[4];
00167 
00168   // The min and max point locations for all three transfer functions
00169   float Range[2]; 
00170 
00171   // Transfer functions for each color component
00172   // Remove after corresponding depricated methods are removed
00173   vtkPiecewiseFunction  *Red;
00174   vtkPiecewiseFunction  *Green;
00175   vtkPiecewiseFunction  *Blue;
00176   vtkTimeStamp BuildTime;
00177   unsigned char *Table;
00178   int TableSize;
00179   
00181 
00183   virtual void SetRange(float, float) {};
00184   void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00186 
00187 
00188 private:
00189   vtkColorTransferFunction(const vtkColorTransferFunction&);  // Not implemented.
00190   void operator=(const vtkColorTransferFunction&);  // Not implemented.
00191 };
00192 
00193 #endif
00194 
00195