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