Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:00

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov  26/01/2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGLParametric
0013 #define ROOT_TGLParametric
0014 
0015 #include "TGLHistPainter.h"
0016 #include "TGLUtil.h"
0017 #include "TAxis.h"
0018 #include "TF2.h"
0019 
0020 #include <memory>
0021 
0022 class TString;
0023 
0024 //////////////////////////////////////////////////////////////////////////
0025 //                                                                      //
0026 // TGLParametricEquation                                                //
0027 //                                                                      //
0028 // Parametric equations drawing with GL.                                //
0029 //                                                                      //
0030 //////////////////////////////////////////////////////////////////////////
0031 
0032 
0033 typedef void (*ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v);
0034 
0035 class TGLParametricEquation : public TNamed {
0036 private:
0037    typedef std::unique_ptr<TF2> Ptr_t;
0038 
0039    Ptr_t                fXEquation;
0040    Ptr_t                fYEquation;
0041    Ptr_t                fZEquation;
0042 
0043    ParametricEquation_t fEquation;
0044 
0045    Rgl::Range_t         fURange;
0046    Rgl::Range_t         fVRange;
0047 
0048    Bool_t               fConstrained;
0049    Bool_t               fModified;
0050 
0051    typedef std::unique_ptr<TGLHistPainter> Painter_t;
0052    //C++ compiler do not need TGLhistPainter definition here, but I'm not sure about CINT,
0053    //so I've included TGLHistPainter definition.
0054    Painter_t            fPainter;
0055 
0056 public:
0057    TGLParametricEquation(const TString &name, const TString &xEquation,
0058                  const TString &yEquation, const TString &zEquation,
0059                  Double_t uMin, Double_t uMax,
0060                  Double_t vMin, Double_t vMax);
0061    TGLParametricEquation(const TString &name, ParametricEquation_t equation,
0062                  Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax);
0063 
0064    Rgl::Range_t GetURange()const;
0065    Rgl::Range_t GetVRange()const;
0066 
0067    Bool_t       IsConstrained()const;
0068    void         SetConstrained(Bool_t c);
0069 
0070    Bool_t       IsModified()const;
0071    void         SetModified(Bool_t m);
0072 
0073    void         EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v)const;
0074 
0075    Int_t        DistancetoPrimitive(Int_t px, Int_t py) override;
0076    void         ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0077    char        *GetObjectInfo(Int_t px, Int_t py) const override;
0078    void         Paint(Option_t *option) override;
0079 
0080 private:
0081 
0082    TGLParametricEquation(const TGLParametricEquation &);
0083    TGLParametricEquation &operator = (const TGLParametricEquation &);
0084 
0085    ClassDefOverride(TGLParametricEquation, 0)//Equation of parametric surface.
0086 };
0087 
0088 class TGLParametricPlot : public TGLPlotPainter {
0089 private:
0090    struct Vertex_t {
0091       TGLVertex3 fPos;
0092       TGLVector3 fNormal;
0093       Float_t    fRGBA[4];
0094    };
0095 
0096    enum EMeshSize {kLow = 30, kHigh = 150};
0097 
0098    Int_t                  fMeshSize;
0099    TGL2DArray<Vertex_t>   fMesh;
0100 
0101    Bool_t                 fShowMesh;
0102    Int_t                  fColorScheme;
0103 
0104    TGLParametricEquation *fEquation;
0105 
0106    TAxis                  fCartesianXAxis;
0107    TAxis                  fCartesianYAxis;
0108    TAxis                  fCartesianZAxis;
0109 
0110    TGLPlotCoordinates     fCartesianCoord;
0111 
0112 public:
0113    TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
0114 
0115    Bool_t   InitGeometry() override;
0116    void     StartPan(Int_t px, Int_t py) override;
0117    void     Pan(Int_t px, Int_t py) override;
0118    char    *GetPlotInfo(Int_t px, Int_t py) override;
0119    void     AddOption(const TString &option) override;
0120    void     ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0121 
0122 private:
0123    void     InitGL()const override;
0124    void     DeInitGL()const override;
0125 
0126    void     DrawPlot()const override;
0127 
0128    void     InitColors();
0129 
0130    void     DrawSectionXOZ()const override;
0131    void     DrawSectionYOZ()const override;
0132    void     DrawSectionXOY()const override;
0133 
0134    void     SetSurfaceColor()const;
0135 
0136    TGLParametricPlot(const TGLParametricPlot &);
0137    TGLParametricPlot &operator = (const TGLParametricPlot &);
0138 
0139    ClassDefOverride(TGLParametricPlot, 0)//Parametric plot's painter.
0140 };
0141 
0142 #endif