Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:58

0001 // @(#)root/gl:$Id$
0002 // Author: Alja Mrak-Tadel 2009
0003 
0004 /*************************************************************************
0005 * Copyright (C) 1995-2007, 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_TGLAxisPainter
0013 #define ROOT_TGLAxisPainter
0014 
0015 #include "TGLUtil.h"
0016 #include "TGLFontManager.h"
0017 
0018 #include <vector>
0019 #include <utility>
0020 
0021 class TAttAxis;
0022 class TAxis;
0023 class TH1;
0024 class TPMERegexp;
0025 class TGLRnrCtx;
0026 
0027 
0028 //==============================================================================
0029 // TGLAxisPainter
0030 //==============================================================================
0031 
0032 class TGLAxisPainter
0033 {
0034 public:
0035    typedef std::pair  <Float_t, Float_t>    Lab_t; // label <pos, value> pair
0036    typedef std::vector<Lab_t>               LabVec_t;
0037    typedef std::pair  <Float_t, Int_t>      TM_t;  // tick-mark <pos, order> pair
0038    typedef std::vector<TM_t>                TMVec_t; // vector od tick lines
0039 
0040 private:
0041    TGLAxisPainter(const TGLAxisPainter&) = delete;
0042    TGLAxisPainter& operator=(const TGLAxisPainter&) = delete;
0043 
0044    // Print format derived from attributers.
0045    Int_t fExp;
0046    Int_t fMaxDigits;
0047    Int_t fDecimals;
0048    TString fFormat;
0049 
0050    // Font derived from axis attributes.
0051    TGLFont fLabelFont;
0052    TGLFont fTitleFont;
0053 
0054    // Print format.
0055    void LabelsLimits(const char *label, Int_t &first, Int_t &last) const;
0056    void FormAxisValue(Double_t x, TString &s) const;
0057 
0058 protected:
0059    TAttAxis        *fAttAxis;    // Model.
0060    Bool_t           fUseAxisColors; // Use colors from axes or from GL-rnr-ctx.
0061    TGLFont::EMode   fFontMode;   // To be put into TAttAxis
0062    LabVec_t         fLabVec;     // List of Labels position-value pairs
0063    TMVec_t          fTMVec;      // List of tick-mark position-value pairs
0064 
0065    //
0066    // Additional axis attributes required for GL rendering:
0067 
0068    // Orientation
0069    TGLVector3 fDir;
0070    TGLVector3 fTMOff[3];
0071    Int_t      fTMNDim;
0072 
0073    // Font.
0074    Int_t    fLabelPixelFontSize;
0075    Double_t fLabel3DFontSize;
0076    Int_t    fTitlePixelFontSize;
0077    Double_t fTitle3DFontSize;
0078 
0079    // Labels options. Allready exist in TAttAxis, but can't be set.
0080    TGLFont::ETextAlignH_e fLabelAlignH;
0081    TGLFont::ETextAlignV_e fLabelAlignV;
0082    TGLVector3  fTitlePos;
0083    TPMERegexp *fAllZeroesRE;
0084 
0085 public:
0086    TGLAxisPainter();
0087    virtual ~TGLAxisPainter();
0088 
0089    // GetSets.
0090    Int_t        GetTMNDim() const { return fTMNDim; }
0091    void         SetTMNDim(Int_t x) { fTMNDim = x; }
0092 
0093    TGLVector3&  RefDir() { return fDir; }
0094    TGLVector3&  RefTMOff(Int_t i) { return fTMOff[i]; }
0095 
0096    TGLFont::EMode GetFontMode() const { return fFontMode; }
0097    void  SetFontMode(TGLFont::EMode m) { fFontMode=m; }
0098 
0099    // this setter not necessary
0100    void         SetLabelPixelFontSize(Int_t fs) { fLabelPixelFontSize=fs; }
0101    Int_t        GetLabelPixelFontSize() const { return fLabelPixelFontSize; }
0102    void         SetTitlePixelFontSize(Int_t fs) { fTitlePixelFontSize=fs; }
0103    Int_t        GetTitlePixelFontSize() const { return fTitlePixelFontSize; }
0104 
0105    TGLVector3&  RefTitlePos() { return fTitlePos; }
0106 
0107 
0108    void         SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e);
0109 
0110    LabVec_t& RefLabVec() { return fLabVec; }
0111    TMVec_t&  RefTMVec()  { return fTMVec; }
0112 
0113    void      SetAttAxis(TAttAxis* a) { fAttAxis = a; }
0114    TAttAxis* GetAttAxis() { return fAttAxis; }
0115 
0116    void   SetUseAxisColors(Bool_t x) { fUseAxisColors = x;    }
0117    Bool_t GetUseAxisColors() const   { return fUseAxisColors; }
0118 
0119    // Utility.
0120    void SetLabelFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
0121    void SetTitleFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
0122 
0123    void SetTextFormat(Double_t min, Double_t max, Double_t binWidth);
0124 
0125    // Renderers.
0126    void RnrText (const TString &txt, const TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV, const TGLFont &font) const;
0127    void RnrTitle(const TString &title, TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV) const;
0128    void RnrLabels() const;
0129    void RnrLines() const;
0130 
0131    void PaintAxis(TGLRnrCtx& ctx, TAxis* ax);
0132 
0133    ClassDef(TGLAxisPainter, 0); // GL axis painter.
0134 };
0135 
0136 
0137 //==============================================================================
0138 // TGLAxisPainterBox
0139 //==============================================================================
0140 
0141 class TGLAxisPainterBox : public TGLAxisPainter
0142 {
0143 protected:
0144    TGLVector3          fAxisTitlePos[3];
0145    TAxis*                      fAxis[3];
0146 
0147 public:
0148    TGLAxisPainterBox();
0149    ~TGLAxisPainterBox() override;
0150 
0151    void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx);
0152    void DrawAxis3D(TGLRnrCtx &rnrCtx);
0153 
0154    void PlotStandard(TGLRnrCtx &rnrCtx, TH1* histo, const TGLBoundingBox& bbox);
0155 
0156    ClassDefOverride(TGLAxisPainterBox, 0); // Painter of GL axes for a 3D box.
0157 };
0158 
0159 #endif