Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:13:14

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 // clang++ <v20 (-Wshadow) complains about shadowing TSystem.h global enum ESendRecvOptions. Let's silence warning:
0033 #if defined(__clang__) && __clang_major__ < 20
0034 #pragma clang diagnostic push
0035 #pragma clang diagnostic ignored "-Wshadow"
0036 #endif
0037       kDefault,
0038 #if defined(__clang__) && __clang_major__ < 20
0039 #pragma clang diagnostic pop
0040 #endif
0041       kMaple0,
0042       kMaple1,
0043       kMaple2
0044    };
0045 
0046    ETF3Style fStyle;
0047 
0048    Rgl::Mc::TIsoMesh<Double_t> fMesh;
0049    TF3 *fF3;
0050 
0051    TGLTH3Slice fXOZSlice;
0052    TGLTH3Slice fYOZSlice;
0053    TGLTH3Slice fXOYSlice;
0054 
0055 public:
0056    TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
0057 
0058    char   *GetPlotInfo(Int_t px, Int_t py) override;
0059    Bool_t  InitGeometry() override;
0060    void    StartPan(Int_t px, Int_t py) override;
0061    void    Pan(Int_t px, Int_t py) override;
0062    void    AddOption(const TString &stringOption) override;
0063    void    ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0064 
0065 private:
0066    void    InitGL()const override;
0067    void    DeInitGL()const override;
0068 
0069    void    DrawPlot()const override;
0070    //
0071    void    DrawToSelectionBuffer()const;
0072    void    DrawDefaultPlot()const;
0073    void    DrawMaplePlot()const;
0074    //
0075 
0076    void    SetSurfaceColor()const;
0077    Bool_t  HasSections()const;
0078 
0079    void    DrawSectionXOZ()const override;
0080    void    DrawSectionYOZ()const override;
0081    void    DrawSectionXOY()const override;
0082 
0083    ClassDefOverride(TGLTF3Painter, 0) // GL TF3 painter.
0084 };
0085 
0086 /*
0087    Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
0088    Can be one-level iso (as standard non-gl "iso" option),
0089    or multi-level iso: equidistant contours (if you only specify
0090    number of contours, or at user defined levels).
0091 */
0092 
0093 class TGLIsoPainter : public TGLPlotPainter {
0094 private:
0095    typedef Rgl::Mc::TIsoMesh<Float_t>        Mesh_t;
0096    typedef std::list<Mesh_t>                 MeshList_t;
0097    typedef std::list<Mesh_t>::iterator       MeshIter_t;
0098    typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;
0099 
0100    TGLTH3Slice           fXOZSlice;
0101    TGLTH3Slice           fYOZSlice;
0102    TGLTH3Slice           fXOYSlice;
0103 
0104    Mesh_t                fDummyMesh;
0105    //List of meshes.
0106    MeshList_t            fIsos;
0107    //Cached meshes (will be used if geometry must be rebuilt
0108    //after TPad::PaintModified)
0109    MeshList_t            fCache;
0110    //Min and max bin contents.
0111    Rgl::Range_t          fMinMax;
0112    //Palette. One color per iso-surface.
0113    TGLLevelPalette       fPalette;
0114    //Iso levels. Equidistant or user-defined.
0115    std::vector<Double_t> fColorLevels;
0116    //Now meshes are initialized only once.
0117    //To be changed in future.
0118    Bool_t                fInit;
0119 
0120 public:
0121    TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
0122 
0123    //TGLPlotPainter final-overriders.
0124    char    *GetPlotInfo(Int_t px, Int_t py) override;
0125    Bool_t   InitGeometry() override;
0126    void     StartPan(Int_t px, Int_t py) override;
0127    void     Pan(Int_t px, Int_t py) override;
0128    void     AddOption(const TString &option) override;
0129    void     ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0130 
0131 private:
0132    //TGLPlotPainter final-overriders.
0133    void     InitGL()const override;
0134    void     DeInitGL()const override;
0135 
0136    void     DrawPlot()const override;
0137    void     DrawSectionXOZ()const override;
0138    void     DrawSectionYOZ()const override;
0139    void     DrawSectionXOY()const override;
0140    //Auxiliary methods.
0141    Bool_t   HasSections()const;
0142    void     SetSurfaceColor(Int_t ind)const;
0143    void     SetMesh(Mesh_t &mesh, Double_t isoValue);
0144    void     DrawMesh(const Mesh_t &mesh, Int_t level)const;
0145    void     FindMinMax();
0146 
0147    TGLIsoPainter(const TGLIsoPainter &);
0148    TGLIsoPainter &operator = (const TGLIsoPainter &);
0149 
0150    ClassDefOverride(TGLIsoPainter, 0) // Iso option for TH3.
0151 };
0152 
0153 #endif