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

graphics/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 
00008 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00009 All rights reserved.
00010 
00011 Redistribution and use in source and binary forms, with or without
00012 modification, are permitted provided that the following conditions are met:
00013 
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016 
00017  * Redistributions in binary form must reproduce the above copyright notice,
00018    this list of conditions and the following disclaimer in the documentation
00019    and/or other materials provided with the distribution.
00020 
00021  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00022    of any contributors may be used to endorse or promote products derived
00023    from this software without specific prior written permission.
00024 
00025  * Modified source versions must be plainly marked as such, and must not be
00026    misrepresented as being the original software.
00027 
00028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00032 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038 
00039 =========================================================================*/
00056 #ifndef __vtkColorTransferFunction_h
00057 #define __vtkColorTransferFunction_h
00058 
00059 #include "vtkScalarsToColors.h"
00060 #include "vtkPiecewiseFunction.h"
00061 
00062 #define VTK_CTF_RGB   0
00063 #define VTK_CTF_HSV   1
00064 
00065 class VTK_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00066 {
00067 public:
00068   static vtkColorTransferFunction *New();
00069   vtkTypeMacro(vtkColorTransferFunction,vtkScalarsToColors);
00070   void DeepCopy( vtkColorTransferFunction *f );
00071 
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00076   int GetSize() {return this->NumberOfPoints;};
00077   
00079   void AddRGBPoint( float x, float r, float g, float b );
00080   void AddHSVPoint( float x, float h, float s, float v );
00081 
00083   void AddRGBSegment( float x1, float r1, float g1, float b1, 
00084                       float x2, float r2, float g2, float b2 );
00085   void AddHSVSegment( float x1, float h1, float s1, float v1, 
00086                       float x2, float h2, float s2, float v2 );
00087   
00089   void RemovePoint( float x );
00090   void RemoveAllPoints();
00091 
00094   float *GetColor(float x) { 
00095     return vtkScalarsToColors::GetColor(x); }
00096   void GetColor(float x, float rgb[3]);
00097 
00099   float GetRedValue( float x );
00100   float GetGreenValue( float x );
00101   float GetBlueValue( float x );
00102 
00104   virtual unsigned char *MapValue(float v);
00105 
00107   vtkGetVector2Macro( Range, float );
00108 
00110   void GetTable( float x1, float x2, int n, float* table );
00111   const unsigned char *GetTable( float x1, float x2, int n);
00112 
00117   void BuildFunctionFromTable( float x1, float x2, int size, float *table);
00118 
00120   vtkSetClampMacro( Clamping, int, 0, 1 );
00121   vtkGetMacro( Clamping, int );
00122   vtkBooleanMacro( Clamping, int );
00123   
00125   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_HSV );
00126   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00127   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00128   vtkGetMacro( ColorSpace, int );
00129     
00131   float *GetDataPointer() {return this->Function;};
00132   
00134   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00135                                      int inputDataType, int numberOfValues,
00136                                      int inputIncrement, int outputIncrement);
00137 
00138 
00139   
00140 
00141   // **********************************************************
00142   // **********************************************************
00143   // These are all deprecated functions - do not use!
00144   // **********************************************************
00145   // **********************************************************
00146   
00148   float *GetValue( float x )
00149     {VTK_LEGACY_METHOD(GetValue,"3.2"); return this->GetColor(x); }
00150 
00153   int  GetTotalSize();
00154   int  GetRedSize(); 
00155   int  GetGreenSize();
00156   int  GetBlueSize();
00157 
00160   void AddRedPoint( float x, float r );
00161   void AddGreenPoint( float x, float g );
00162   void AddBluePoint( float x, float b );
00163 
00166   void RemoveRedPoint( float x );
00167   void RemoveGreenPoint( float x );
00168   void RemoveBluePoint( float x );
00169   void RemoveRGBPoint( float x );
00170 
00173   void AddRedSegment( float x1, float r1, float x2, float r2 );
00174   void AddGreenSegment( float x1, float g1, float x2, float g2 );
00175   void AddBlueSegment( float x1, float b1, float x2, float b2 );
00176 
00179   virtual void SetRange(float, float) {};
00180   void SetRange(float rng[2]) {this->SetRange(rng[0],rng[1]);};
00181 
00185   vtkPiecewiseFunction *GetRedFunction(){return this->Red;};
00186   vtkPiecewiseFunction *GetGreenFunction(){return this->Green;};
00187   vtkPiecewiseFunction *GetBlueFunction(){return this->Blue;};
00188 
00189 
00190 protected:
00191   vtkColorTransferFunction();
00192   ~vtkColorTransferFunction();
00193   vtkColorTransferFunction(const vtkColorTransferFunction&) {};
00194   void operator=(const vtkColorTransferFunction&) {};
00195 
00196   // Determines the function value outside of defined points
00197   // Zero = always return 0.0 outside of defined points
00198   // One  = clamp to the lowest value below defined points and
00199   //        highest value above defined points
00200   int Clamping;
00201 
00202   // The color space in which interpolation is performed
00203   int ColorSpace;
00204   
00205   // The color function
00206   float       *Function;
00207   int         FunctionSize;
00208   int         NumberOfPoints;
00209 
00210   // conversion methods
00211   void RGBToHSV( float r, float g, float b, float &h, float &s, float &v );
00212   void HSVToRGB( float h, float s, float v, float &r, float &g, float &b );
00213   
00214   // An evaluated color (0 to 255 RGBA A=255)
00215   unsigned char UnsignedCharRGBAValue[4];
00216 
00217   // The min and max point locations for all three transfer functions
00218   float Range[2]; 
00219 
00220   // Transfer functions for each color component
00221   // Remove after corresponding depricated methods are removed
00222   vtkPiecewiseFunction  *Red;
00223   vtkPiecewiseFunction  *Green;
00224   vtkPiecewiseFunction  *Blue;
00225   vtkTimeStamp BuildTime;
00226   unsigned char *Table;
00227   int TableSize;
00228 };
00229 
00230 #endif
00231 
00232 

Generated on Wed Nov 21 12:26:57 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001