Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/THistPainter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/histpainter:$Id$
0002 // Author: Rene Brun, Olivier Couet
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 #ifndef ROOT_THistPainter
0012 #define ROOT_THistPainter
0013 
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // THistPainter                                                         //
0018 //                                                                      //
0019 // helper class to draw histograms                                      //
0020 //                                                                      //
0021 //////////////////////////////////////////////////////////////////////////
0022 
0023 
0024 #include "TVirtualHistPainter.h"
0025 #include "TString.h"
0026 
0027 #include <vector>
0028 #include <utility>
0029 #include <memory>
0030 
0031 
0032 class TH1;
0033 class TAxis;
0034 class TCutG;
0035 class TGaxis;
0036 class TPainter3dAlgorithms;
0037 class TGraph2DPainter;
0038 class TPie;
0039 class TF3;
0040 
0041 const Int_t kMaxCuts = 16;
0042 
0043 struct THistRenderingRegion
0044 {
0045    std::pair<Int_t, Int_t> fPixelRange;
0046    std::pair<Int_t, Int_t> fBinRange;
0047 };
0048 
0049 
0050 class THistPainter : public TVirtualHistPainter {
0051 
0052 protected:
0053    TH1                  *fH;                      ///< Pointer to histogram to paint
0054    TAxis                *fXaxis;                  ///< Pointer to X axis
0055    TAxis                *fYaxis;                  ///< Pointer to Y axis
0056    TAxis                *fZaxis;                  ///< Pointer to Z axis
0057    TList                *fFunctions;              ///< Pointer to histogram list of functions
0058    std::unique_ptr<TPainter3dAlgorithms> fLego;   ///< Pointer to a TPainter3dAlgorithms object
0059    std::unique_ptr<TGraph2DPainter> fGraph2DPainter; ///< Pointer to a TGraph2DPainter object
0060    std::unique_ptr<TPie> fPie;                    ///< Pointer to a TPie in case of option PIE
0061    std::vector<Double_t> fXbuf;                   ///< X buffer coordinates
0062    std::vector<Double_t> fYbuf;                   ///< Y buffer coordinates
0063    Int_t                 fNcuts;                  ///< Number of graphical cuts
0064    Int_t                 fCutsOpt[kMaxCuts];      ///< Sign of each cut
0065    TCutG                *fCuts[kMaxCuts];         ///< Pointers to graphical cuts
0066    TList                *fStack;                  ///< Pointer to stack of histograms (if any)
0067    Int_t                 fShowProjection;         ///< True if a projection must be drawn
0068    Int_t                 fShowProjection2;        ///< True if a second projection must be drawn (when calling SetShowProjectionXY on a TH2)
0069    TString               fShowOption;             ///< Option to draw the projection
0070    Int_t                 fXHighlightBin;          ///< X highlight bin
0071    Int_t                 fYHighlightBin;          ///< Y highlight bin
0072    TF3                  *fCurrentF3;              ///< Current TF3 function
0073 
0074 private:
0075    mutable TString fObjectInfo;
0076 
0077 public:
0078    THistPainter();
0079    ~THistPainter() override;
0080    virtual void       DefineColorLevels(Int_t ndivz);
0081    Int_t      DistancetoPrimitive(Int_t px, Int_t py) override;
0082    void       DrawPanel() override;
0083    void       ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
0084    TList     *GetContourList(Double_t contour) const override;
0085    char      *GetObjectInfo(Int_t px, Int_t py) const override;
0086    TList     *GetStack() const override {return fStack;}
0087    virtual Int_t      GetXHighlightBin() const { return fXHighlightBin; }
0088    virtual Int_t      GetYHighlightBin() const { return fYHighlightBin; }
0089    virtual void       HighlightBin(Int_t px, Int_t py);
0090    Bool_t     IsInside(Int_t x, Int_t y) override;
0091    Bool_t     IsInside(Double_t x, Double_t y) override;
0092    virtual Int_t      MakeChopt(Option_t *option);
0093    Int_t      MakeCuts(char *cutsopt) override;
0094    void       Paint(Option_t *option="") override;
0095    virtual void       PaintArrows(Option_t *option);
0096    virtual void       PaintAxis(Bool_t drawGridOnly=kFALSE);
0097    virtual void       PaintBar(Option_t *option);
0098    virtual void       PaintBarH(Option_t *option);
0099    virtual void       PaintBoxes(Option_t *option);
0100    virtual void       PaintCandlePlot(Option_t *option);
0101    virtual void       PaintColorLevels(Option_t *option);
0102    virtual void       PaintColorLevelsFast(Option_t *option);
0103    virtual std::vector<THistRenderingRegion> ComputeRenderingRegions(TAxis *pAxis, Int_t nPixels, bool isLog);
0104 
0105    virtual void       PaintTH2PolyBins(Option_t *option);
0106    virtual void       PaintTH2PolyColorLevels(Option_t *option);
0107    virtual void       PaintTH2PolyScatterPlot(Option_t *option);
0108    virtual void       PaintTH2PolyText(Option_t *option);
0109    virtual void       PaintContour(Option_t *option);
0110    virtual Int_t      PaintContourLine(Double_t elev1, Int_t icont1, Double_t x1, Double_t y1,
0111                                        Double_t elev2, Int_t icont2, Double_t x2, Double_t y2,
0112                                        Double_t *xarr, Double_t *yarr, Int_t *itarr, Double_t *levels);
0113    virtual void       PaintErrors(Option_t *option);
0114    virtual void       Paint2DErrors(Option_t *option);
0115    virtual void       PaintFrame();
0116    virtual void       PaintFunction(Option_t *option);
0117    virtual void       PaintHighlightBin(Option_t *option="");
0118    virtual void       PaintHist(Option_t *option);
0119    virtual void       PaintH3(Option_t *option="");
0120    virtual void       PaintH3Box(Int_t iopt);
0121    virtual void       PaintH3BoxRaster();
0122    virtual void       PaintH3Iso();
0123    virtual Int_t      PaintInit();
0124    virtual Int_t      PaintInitH();
0125    virtual void       PaintLego(Option_t *option);
0126    virtual void       PaintLegoAxis(TGaxis *axis, Double_t ang);
0127    virtual void       PaintPalette();
0128    virtual void       PaintScatterPlot(Option_t *option);
0129    void       PaintStat(Int_t dostat, TF1 *fit) override;
0130    virtual void       PaintStat2(Int_t dostat, TF1 *fit);
0131    virtual void       PaintStat3(Int_t dostat, TF1 *fit);
0132    virtual void       PaintSurface(Option_t *option);
0133    virtual void       PaintTriangles(Option_t *option);
0134    virtual void       PaintTable(Option_t *option);
0135    virtual void       PaintText(Option_t *option);
0136    virtual void       PaintTitle();
0137    virtual void       PaintTF3();
0138    void       ProcessMessage(const char *mess, const TObject *obj) override;
0139    static  Int_t      ProjectAitoff2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
0140    static  Int_t      ProjectMercator2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
0141    static  Int_t      ProjectSinusoidal2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
0142    static  Int_t      ProjectParabolic2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
0143    static  Int_t      ProjectMollweide2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab);
0144    virtual void       RecalculateRange();
0145    void       RecursiveRemove(TObject *) override {}
0146    void       SetHighlight() override;
0147    void       SetHistogram(TH1 *h) override;
0148    void       SetStack(TList *stack) override {fStack = stack;}
0149    void       SetShowProjection(const char *option,Int_t nbins) override;
0150    void       SetShowProjectionXY(const char *option,Int_t nbinsY,Int_t nbinsX) override;
0151    virtual void       ShowProjectionX(Int_t px, Int_t py);
0152    virtual void       ShowProjectionY(Int_t px, Int_t py);
0153    virtual void       ShowProjection3(Int_t px, Int_t py);
0154    virtual Int_t      TableInit();
0155 
0156    static const char *GetBestFormat(Double_t v, Double_t e, const char *f);
0157    static void        PaintSpecialObjects(const TObject *obj, Option_t *option);
0158 
0159    ClassDefOverride(THistPainter,0)  //Helper class to draw histograms
0160 };
0161 
0162 #endif