Filtering/vtkColorTransferFunction.h Source File

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