Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:28:35

0001 // @(#)root/gl:$Id$
0002 // Author:  Timur Pocheptsov  07/08/2009
0003 
0004 #ifndef ROOT_TGLTH3Composition
0005 #define ROOT_TGLTH3Composition
0006 
0007 #include <utility>
0008 #include <memory>
0009 #include <vector>
0010 
0011 #include "TGLHistPainter.h"
0012 #include "TGLPlotPainter.h"
0013 #include "TGLQuadric.h"
0014 #include "TH3.h"
0015 
0016 //
0017 //Composition of TH3 objects. All TH3 must have the same axis range
0018 //and the same number of bins. If this condition is violated,
0019 //AddTH3 will throw.
0020 //IMPORTANT: TGLTH3Composition does not own TH3 objects
0021 //it contains.
0022 //This class inherits TH3 - to re-use TH3 editor.
0023 //I use TH3C to reduce memory usage.
0024 //Slising is not implemeted yet.
0025 //
0026 
0027 class TGLTH3Composition : public TH3C {
0028    friend class TGLTH3CompositionPainter;
0029 public:
0030    TGLTH3Composition();//I need it only because of explicit private copy ctor.
0031 
0032    enum ETH3BinShape {
0033 // clang++ <v20 (-Wshadow) complains about shadowing Buttons.h global enum EEditMode. Let's silence warning:
0034 #if defined(__clang__) && __clang_major__ < 20
0035 #pragma clang diagnostic push
0036 #pragma clang diagnostic ignored "-Wshadow"
0037 #endif
0038       kBox,
0039 #if defined(__clang__) && __clang_major__ < 20
0040 #pragma clang diagnostic pop
0041 #endif
0042       kSphere
0043    };
0044 
0045    void AddTH3(const TH3 *hist, ETH3BinShape shape = kBox);
0046 
0047    //These are functions for TPad and
0048    //TPad's standard machinery (picking, painting).
0049    Int_t    DistancetoPrimitive(Int_t px, Int_t py) override;
0050    void     ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0051    char    *GetObjectInfo(Int_t px, Int_t py) const override;
0052    void     Paint(Option_t *option) override;
0053 
0054 private:
0055    void CheckRanges(const TH3 *hist);
0056 
0057    typedef std::pair<const TH3 *, ETH3BinShape> TH3Pair_t;
0058 
0059    std::vector<TH3Pair_t>        fHists;
0060    std::unique_ptr<TGLHistPainter> fPainter;
0061 
0062    TGLTH3Composition(const TGLTH3Composition &) = delete;
0063    TGLTH3Composition &operator = (const TGLTH3Composition &) = delete;
0064 
0065    ClassDefOverride(TGLTH3Composition, 0)//Composition of TH3 objects.
0066 };
0067 
0068 //
0069 //TGLTH3CompositionPainter class.
0070 //
0071 class TGLTH3CompositionPainter: public TGLPlotPainter {
0072 public:
0073    TGLTH3CompositionPainter(TGLTH3Composition *data, TGLPlotCamera *camera,
0074                             TGLPlotCoordinates *coord);
0075 
0076    //TGLPlotPainter final-overriders.
0077    char      *GetPlotInfo(Int_t px, Int_t py) override;
0078    Bool_t     InitGeometry() override;
0079    void       StartPan(Int_t px, Int_t py) override;
0080    void       Pan(Int_t px, Int_t py) override;
0081    void       AddOption(const TString &option) override;
0082    void       ProcessEvent(Int_t event, Int_t px, Int_t py) override;
0083 
0084 private:
0085    //TGLPlotPainter final-overriders.
0086    void       InitGL()const override;
0087    void       DeInitGL()const override;
0088 
0089    void       DrawPlot()const override;
0090 
0091    //Empty overriders.
0092    void       DrawSectionXOZ()const override {}
0093    void       DrawSectionYOZ()const override {}
0094    void       DrawSectionXOY()const override {}
0095 
0096    void       SetColor(Int_t color)const;
0097 
0098    TGLTH3Composition            *fData;
0099    std::pair<Double_t, Double_t> fMinMaxVal;
0100 
0101    mutable TGLQuadric            fQuadric;
0102 
0103    TGLTH3CompositionPainter(const TGLTH3CompositionPainter &) = delete;
0104    TGLTH3CompositionPainter &operator = (const TGLTH3CompositionPainter &)  = delete;
0105 
0106    ClassDefOverride(TGLTH3CompositionPainter, 0)//Painter to draw several TH3.
0107 };
0108 
0109 
0110 #endif