TGLParametric.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLParametric.h 28464 2009-05-06 12:37:21Z brun $
00002 // Author:  Timur Pocheptsov  26/01/2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGLParametric
00013 #define ROOT_TGLParametric
00014 
00015 #include <memory>
00016 
00017 #ifndef ROOT_TGLHistPainter
00018 #include "TGLHistPainter.h"
00019 #endif
00020 #ifndef ROOT_TGLUtil
00021 #include "TGLUtil.h"
00022 #endif
00023 #ifndef ROOT_TF2
00024 #include "TF2.h"
00025 #endif
00026 
00027 class TString;
00028 
00029 //////////////////////////////////////////////////////////////////////////
00030 //                                                                      //
00031 // TGLParametricEquation                                                //
00032 //                                                                      //
00033 // Parametric equations drawing with GL.                                //
00034 //                                                                      //
00035 //////////////////////////////////////////////////////////////////////////
00036 
00037 
00038 typedef void (*ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v);
00039 
00040 class TGLParametricEquation : public TNamed {
00041 private:
00042    typedef std::auto_ptr<TF2> Ptr_t;
00043 
00044    Ptr_t                fXEquation;
00045    Ptr_t                fYEquation;
00046    Ptr_t                fZEquation;
00047 
00048    ParametricEquation_t fEquation;
00049 
00050    Rgl::Range_t         fURange;
00051    Rgl::Range_t         fVRange;
00052 
00053    Bool_t               fConstrained;
00054    Bool_t               fModified;
00055 
00056    typedef std::auto_ptr<TGLHistPainter> Painter_t;
00057    //C++ compiler do not need TGLhistPainter definition here, but I'm not sure about CINT,
00058    //so I've included TGLHistPainter definition.
00059    Painter_t            fPainter;
00060 
00061 public:
00062    TGLParametricEquation(const TString &name, const TString &xEquation,
00063                  const TString &yEquation, const TString &zEquation,
00064                  Double_t uMin, Double_t uMax,
00065                  Double_t vMin, Double_t vMax);
00066    TGLParametricEquation(const TString &name, ParametricEquation_t equation,
00067                  Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax);
00068 
00069    Rgl::Range_t GetURange()const;
00070    Rgl::Range_t GetVRange()const;
00071 
00072    Bool_t       IsConstrained()const;
00073    void         SetConstrained(Bool_t c);
00074 
00075    Bool_t       IsModified()const;
00076    void         SetModified(Bool_t m);
00077 
00078    void         EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v)const;
00079 
00080    Int_t        DistancetoPrimitive(Int_t px, Int_t py);
00081    void         ExecuteEvent(Int_t event, Int_t px, Int_t py);
00082    char        *GetObjectInfo(Int_t px, Int_t py) const;
00083    void         Paint(Option_t *option);
00084 
00085 private:
00086 
00087    TGLParametricEquation(const TGLParametricEquation &);
00088    TGLParametricEquation &operator = (const TGLParametricEquation &);
00089 
00090    ClassDef(TGLParametricEquation, 0)//Equation of parametric surface.
00091 };
00092 
00093 class TGLParametricPlot : public TGLPlotPainter {
00094 private:
00095    struct Vertex_t {
00096       TGLVertex3 fPos;
00097       TGLVector3 fNormal;
00098       Float_t    fRGBA[4];
00099    };
00100 
00101    enum EMeshSize {kLow = 30, kHigh = 150};
00102 
00103    Int_t                  fMeshSize;
00104    TGL2DArray<Vertex_t>   fMesh;
00105 
00106    Bool_t                 fShowMesh;
00107    Int_t                  fColorScheme;
00108 
00109    TGLParametricEquation *fEquation;
00110 
00111 public:
00112    TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
00113 
00114    Bool_t   InitGeometry();
00115    void     StartPan(Int_t px, Int_t py);
00116    void     Pan(Int_t px, Int_t py);
00117    char    *GetPlotInfo(Int_t px, Int_t py);
00118    void     AddOption(const TString &option);
00119    void     ProcessEvent(Int_t event, Int_t px, Int_t py);
00120 
00121 private:
00122    void     InitGL()const;
00123    void     DeInitGL()const;
00124    
00125    void     DrawPlot()const;
00126 
00127    void     InitColors();
00128 
00129    void     DrawSectionXOZ()const;
00130    void     DrawSectionYOZ()const;
00131    void     DrawSectionXOY()const;
00132 
00133    void     SetSurfaceColor()const;
00134 
00135    TGLParametricPlot(const TGLParametricPlot &);
00136    TGLParametricPlot &operator = (const TGLParametricPlot &);
00137 
00138    ClassDef(TGLParametricPlot, 0)//Parametric plot's painter.
00139 };
00140 
00141 #endif

Generated on Tue Jul 5 14:16:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1