Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:23:58

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    Painter_t            fPainter;
0053 
0054 public:
0055    TGLParametricEquation(const TString &name, const TString &xEquation,
0056                  const TString &yEquation, const TString &zEquation,
0057                  Double_t uMin, Double_t uMax,
0058                  Double_t vMin, Double_t vMax);
0059    TGLParametricEquation(const TString &name, ParametricEquation_t equation,
0060                  Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax);
0061 
0062    Rgl::Range_t GetURange()const;
0063    Rgl::Range_t GetVRange()const;
0064 
0065    Bool_t       IsConstrained()const;
0066    void         SetConstrained(Bool_t c);
0067 
0068    Bool_t       IsModified()const;
0069    void         SetModified(Bool_t m);
0070 
0071    void         EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v)const;
0072 
0073    Int_t        DistancetoPrimitive(Int_t px, Int_t py) override;
0074    void         ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0075    char        *GetObjectInfo(Int_t px, Int_t py) const override;
0076    void         Paint(Option_t *option) override;
0077 
0078 private:
0079 
0080    TGLParametricEquation(const TGLParametricEquation &);
0081    TGLParametricEquation &operator = (const TGLParametricEquation &);
0082 
0083    ClassDefOverride(TGLParametricEquation, 0)//Equation of parametric surface.
0084 };
0085 
0086 class TGLParametricPlot : public TGLPlotPainter {
0087 private:
0088    struct Vertex_t {
0089       TGLVertex3 fPos;
0090       TGLVector3 fNormal;
0091       Float_t    fRGBA[4];
0092    };
0093 
0094    enum EMeshSize {kLow = 30, kHigh = 150};
0095 
0096    Int_t                  fMeshSize;
0097    TGL2DArray<Vertex_t>   fMesh;
0098 
0099    Bool_t                 fShowMesh;
0100    Int_t                  fColorScheme;
0101 
0102    TGLParametricEquation *fEquation;
0103 
0104    TAxis                  fCartesianXAxis;
0105    TAxis                  fCartesianYAxis;
0106    TAxis                  fCartesianZAxis;
0107 
0108    TGLPlotCoordinates     fCartesianCoord;
0109 
0110 public:
0111    TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
0112 
0113    Bool_t   InitGeometry() override;
0114    void     StartPan(Int_t px, Int_t py) override;
0115    void     Pan(Int_t px, Int_t py) override;
0116    char    *GetPlotInfo(Int_t px, Int_t py) override;
0117    void     AddOption(const TString &option) override;
0118    void     ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0119 
0120 private:
0121    void     InitGL()const override;
0122    void     DeInitGL()const override;
0123 
0124    void     DrawPlot()const override;
0125 
0126    void     InitColors();
0127 
0128    void     DrawSectionXOZ()const override;
0129    void     DrawSectionYOZ()const override;
0130    void     DrawSectionXOY()const override;
0131 
0132    void     SetSurfaceColor()const;
0133 
0134    TGLParametricPlot(const TGLParametricPlot &);
0135    TGLParametricPlot &operator = (const TGLParametricPlot &);
0136 
0137    ClassDefOverride(TGLParametricPlot, 0)//Parametric plot's painter.
0138 };
0139 
0140 #endif