00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00035 #ifndef __vtkColorTransferFunction_h
00036 #define __vtkColorTransferFunction_h
00037 
00038 #include "vtkScalarsToColors.h"
00039 
00040 class vtkColorTransferFunctionInternals;
00041 
00042 #define VTK_CTF_RGB           0
00043 #define VTK_CTF_HSV           1
00044 #define VTK_CTF_LAB           2
00045 #define VTK_CTF_DIVERGING     3
00046 
00047 #define VTK_CTF_LINEAR        0
00048 #define VTK_CTF_LOG10         1
00049 
00050 class VTK_FILTERING_EXPORT vtkColorTransferFunction : public vtkScalarsToColors 
00051 {
00052 public:
00053   static vtkColorTransferFunction *New();
00054   vtkTypeRevisionMacro(vtkColorTransferFunction,vtkScalarsToColors);
00055   void DeepCopy( vtkColorTransferFunction *f );
00056   void ShallowCopy( vtkColorTransferFunction *f );
00057 
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00062   int GetSize();
00063   
00065 
00067   int AddRGBPoint( double x, double r, double g, double b );
00068   int AddRGBPoint( double x, double r, double g, double b, 
00069                    double midpoint, double sharpness );
00070   int AddHSVPoint( double x, double h, double s, double v );
00071   int AddHSVPoint( double x, double h, double s, double v,
00072                    double midpoint, double sharpness );
00073   int RemovePoint( double x );
00075 
00077 
00078   void AddRGBSegment( double x1, double r1, double g1, double b1, 
00079                       double x2, double r2, double g2, double b2 );
00080   void AddHSVSegment( double x1, double h1, double s1, double v1, 
00081                       double x2, double h2, double s2, double v2 );
00083   
00085   void RemoveAllPoints();
00086 
00088 
00089   double *GetColor(double x) {
00090     return vtkScalarsToColors::GetColor(x); }
00091   void GetColor(double x, double rgb[3]);
00093 
00095 
00096   double GetRedValue( double x );
00097   double GetGreenValue( double x );
00098   double GetBlueValue( double x );
00100 
00102 
00104   int GetNodeValue( int index, double val[6] );
00105   int SetNodeValue( int index, double val[6] );
00107   
00109   virtual unsigned char *MapValue(double v);
00110 
00112 
00113   vtkGetVector2Macro( Range, double );
00115 
00118   int AdjustRange(double range[2]);
00119 
00121 
00122   void GetTable( double x1, double x2, int n, double* table );
00123   void GetTable( double x1, double x2, int n, float* table );
00124   const unsigned char *GetTable( double x1, double x2, int n);
00126 
00131   void BuildFunctionFromTable( double x1, double x2, int size, double *table);
00132 
00134 
00135   vtkSetClampMacro( Clamping, int, 0, 1 );
00136   vtkGetMacro( Clamping, int );
00137   vtkBooleanMacro( Clamping, int );
00139   
00141 
00148   vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
00149   void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
00150   void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
00151   void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
00152   void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
00153   vtkGetMacro( ColorSpace, int );
00154   vtkSetMacro(HSVWrap, int);
00155   vtkGetMacro(HSVWrap, int);
00156   vtkBooleanMacro(HSVWrap, int);
00158 
00160 
00163   vtkSetMacro(Scale,int);
00164   void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
00165   void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
00166   vtkGetMacro(Scale,int);
00168     
00170 
00172   double *GetDataPointer();
00173   void FillFromDataPointer(int, double*);
00175 
00177 
00178   virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
00179                                      int inputDataType, int numberOfValues,
00180                                      int inputIncrement, int outputIncrement);
00182   
00184 
00186   vtkSetMacro(AllowDuplicateScalars, int);
00187   vtkGetMacro(AllowDuplicateScalars, int);
00188   vtkBooleanMacro(AllowDuplicateScalars, int);
00190 
00191 protected:
00192   vtkColorTransferFunction();
00193   ~vtkColorTransferFunction();
00194 
00195   vtkColorTransferFunctionInternals *Internal;
00196   
00197   
00198   
00199   
00200   
00201   int Clamping;
00202 
00203   
00204   int ColorSpace;
00205 
00206   
00207   int HSVWrap;
00208 
00209   
00210   int Scale;
00211   
00212   double     *Function;
00213   
00214   
00215   double Range[2];
00216   
00217   
00218   unsigned char UnsignedCharRGBAValue[4];
00219 
00220   int AllowDuplicateScalars;
00221 
00222   vtkTimeStamp BuildTime;
00223   unsigned char *Table;
00224   int TableSize;
00225   
00227 
00229   virtual void SetRange(double, double) {};
00230   void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
00232 
00233   
00234   
00235   void SortAndUpdateRange();
00236  
00239   void MovePoint(double oldX, double newX);
00240 
00241 private:
00242   vtkColorTransferFunction(const vtkColorTransferFunction&);  
00243   void operator=(const vtkColorTransferFunction&);  
00244 };
00245 
00246 #endif
00247