Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov  31/08/2006
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2006, 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_TGLTF3Painter
0013 #define ROOT_TGLTF3Painter
0014 
0015 #include <vector>
0016 #include <list>
0017 
0018 #include "TGLPlotPainter.h"
0019 #include "TGLIsoMesh.h"
0020 #include "TGLUtil.h"
0021 
0022 class TGLPlotCamera;
0023 class TF3;
0024 
0025 /*
0026 Draw TF3 using marching cubes.
0027 */
0028 
0029 class TGLTF3Painter : public TGLPlotPainter {
0030 private:
0031    enum ETF3Style {
0032       kDefault,
0033       kMaple0,
0034       kMaple1,
0035       kMaple2
0036    };
0037 
0038    ETF3Style fStyle;
0039 
0040    Rgl::Mc::TIsoMesh<Double_t> fMesh;
0041    TF3 *fF3;
0042 
0043    TGLTH3Slice fXOZSlice;
0044    TGLTH3Slice fYOZSlice;
0045    TGLTH3Slice fXOYSlice;
0046 
0047 public:
0048    TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
0049 
0050    char   *GetPlotInfo(Int_t px, Int_t py) override;
0051    Bool_t  InitGeometry() override;
0052    void    StartPan(Int_t px, Int_t py) override;
0053    void    Pan(Int_t px, Int_t py) override;
0054    void    AddOption(const TString &stringOption) override;
0055    void    ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0056 
0057 private:
0058    void    InitGL()const override;
0059    void    DeInitGL()const override;
0060 
0061    void    DrawPlot()const override;
0062    //
0063    void    DrawToSelectionBuffer()const;
0064    void    DrawDefaultPlot()const;
0065    void    DrawMaplePlot()const;
0066    //
0067 
0068    void    SetSurfaceColor()const;
0069    Bool_t  HasSections()const;
0070 
0071    void    DrawSectionXOZ()const override;
0072    void    DrawSectionYOZ()const override;
0073    void    DrawSectionXOY()const override;
0074 
0075    ClassDefOverride(TGLTF3Painter, 0) // GL TF3 painter.
0076 };
0077 
0078 /*
0079    Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
0080    Can be one-level iso (as standard non-gl "iso" option),
0081    or multi-level iso: equidistant contours (if you only specify
0082    number of contours, or at user defined levels).
0083 */
0084 
0085 class TGLIsoPainter : public TGLPlotPainter {
0086 private:
0087    typedef Rgl::Mc::TIsoMesh<Float_t>        Mesh_t;
0088    typedef std::list<Mesh_t>                 MeshList_t;
0089    typedef std::list<Mesh_t>::iterator       MeshIter_t;
0090    typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;
0091 
0092    TGLTH3Slice           fXOZSlice;
0093    TGLTH3Slice           fYOZSlice;
0094    TGLTH3Slice           fXOYSlice;
0095 
0096    Mesh_t                fDummyMesh;
0097    //List of meshes.
0098    MeshList_t            fIsos;
0099    //Cached meshes (will be used if geometry must be rebuilt
0100    //after TPad::PaintModified)
0101    MeshList_t            fCache;
0102    //Min and max bin contents.
0103    Rgl::Range_t          fMinMax;
0104    //Palette. One color per iso-surface.
0105    TGLLevelPalette       fPalette;
0106    //Iso levels. Equidistant or user-defined.
0107    std::vector<Double_t> fColorLevels;
0108    //Now meshes are initialized only once.
0109    //To be changed in future.
0110    Bool_t                fInit;
0111 
0112 public:
0113    TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
0114 
0115    //TGLPlotPainter final-overriders.
0116    char    *GetPlotInfo(Int_t px, Int_t py) override;
0117    Bool_t   InitGeometry() override;
0118    void     StartPan(Int_t px, Int_t py) override;
0119    void     Pan(Int_t px, Int_t py) override;
0120    void     AddOption(const TString &option) override;
0121    void     ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0122 
0123 private:
0124    //TGLPlotPainter final-overriders.
0125    void     InitGL()const override;
0126    void     DeInitGL()const override;
0127 
0128    void     DrawPlot()const override;
0129    void     DrawSectionXOZ()const override;
0130    void     DrawSectionYOZ()const override;
0131    void     DrawSectionXOY()const override;
0132    //Auxiliary methods.
0133    Bool_t   HasSections()const;
0134    void     SetSurfaceColor(Int_t ind)const;
0135    void     SetMesh(Mesh_t &mesh, Double_t isoValue);
0136    void     DrawMesh(const Mesh_t &mesh, Int_t level)const;
0137    void     FindMinMax();
0138 
0139    TGLIsoPainter(const TGLIsoPainter &);
0140    TGLIsoPainter &operator = (const TGLIsoPainter &);
0141 
0142    ClassDefOverride(TGLIsoPainter, 0) // Iso option for TH3.
0143 };
0144 
0145 #endif