Logo ROOT   6.12/07
Reference Guide
TGLAxisPainter.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Alja Mrak-Tadel 2009
3 
4 /*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11 
12 #ifndef ROOT_TGLAxisPainter
13 #define ROOT_TGLAxisPainter
14 
15 #include "TGLUtil.h"
16 #include "TGLFontManager.h"
17 
18 class TAttAxis;
19 class TAxis;
20 class TH1;
21 class TPMERegexp;
22 class TGLRnrCtx;
23 
24 
25 //==============================================================================
26 // TGLAxisPainter
27 //==============================================================================
28 
30 {
31 public:
32  typedef std::pair <Float_t, Float_t> Lab_t; // label <pos, value> pair
33  typedef std::vector<Lab_t> LabVec_t;
34  typedef std::pair <Float_t, Int_t> TM_t; // tick-mark <pos, order> pair
35  typedef std::vector<TM_t> TMVec_t; // vector od tick lines
36 
37 private:
38  TGLAxisPainter(const TGLAxisPainter&); // Not implemented
39  TGLAxisPainter& operator=(const TGLAxisPainter&); // Not implemented
40 
41  // Print format derived from attributers.
46 
47  // Font derived from axis attributes.
50 
51  // Print format.
52  void LabelsLimits(const char *label, Int_t &first, Int_t &last) const;
53  void FormAxisValue(Double_t x, TString &s) const;
54 
55 protected:
56  TAttAxis *fAttAxis; // Model.
57  Bool_t fUseAxisColors; // Use colors from axes or from GL-rnr-ctx.
58  TGLFont::EMode fFontMode; // To be put into TAttAxis
59  LabVec_t fLabVec; // List of Labels position-value pairs
60  TMVec_t fTMVec; // List of tick-mark position-value pairs
61 
62  //
63  // Additional axis attributes required for GL rendering:
64 
65  // Orientation
69 
70  // Font.
75 
76  // Labels options. Allready exist in TAttAxis, but can't be set.
81 
82 public:
84  virtual ~TGLAxisPainter();
85 
86  // GetSets.
87  Int_t GetTMNDim() const { return fTMNDim; }
88  void SetTMNDim(Int_t x) { fTMNDim = x; }
89 
90  TGLVector3& RefDir() { return fDir; }
91  TGLVector3& RefTMOff(Int_t i) { return fTMOff[i]; }
92 
93  TGLFont::EMode GetFontMode() const { return fFontMode; }
94  void SetFontMode(TGLFont::EMode m) { fFontMode=m; }
95 
96  // this setter not necessary
97  void SetLabelPixelFontSize(Int_t fs) { fLabelPixelFontSize=fs; }
99  void SetTitlePixelFontSize(Int_t fs) { fTitlePixelFontSize=fs; }
101 
103 
104 
106 
107  LabVec_t& RefLabVec() { return fLabVec; }
108  TMVec_t& RefTMVec() { return fTMVec; }
109 
110  void SetAttAxis(TAttAxis* a) { fAttAxis = a; }
111  TAttAxis* GetAttAxis() { return fAttAxis; }
112 
113  void SetUseAxisColors(Bool_t x) { fUseAxisColors = x; }
115 
116  // Utility.
117  void SetLabelFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
118  void SetTitleFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
119 
120  void SetTextFormat(Double_t min, Double_t max, Double_t binWidth);
121 
122  // Renderers.
123  void RnrText (const TString &txt, const TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV, const TGLFont &font) const;
124  void RnrTitle(const TString &title, TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV) const;
125  void RnrLabels() const;
126  void RnrLines() const;
127 
128  void PaintAxis(TGLRnrCtx& ctx, TAxis* ax);
129 
130  ClassDef(TGLAxisPainter, 0); // GL axis painter.
131 };
132 
133 
134 //==============================================================================
135 // TGLAxisPainterBox
136 //==============================================================================
137 
139 {
140 protected:
141  TGLVector3 fAxisTitlePos[3];
142  TAxis* fAxis[3];
143 
144 public:
146  virtual ~TGLAxisPainterBox();
147 
148  void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx);
149  void DrawAxis3D(TGLRnrCtx &rnrCtx);
150 
151  void PlotStandard(TGLRnrCtx &rnrCtx, TH1* histo, const TGLBoundingBox& bbox);
152 
153  ClassDef(TGLAxisPainterBox, 0); // Painter of GL axes for a 3D box.
154 };
155 
156 #endif
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
TGLVector3 fDir
void RnrText(const TString &txt, const TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV, const TGLFont &font) const
Render text at the given position. Offset depends of text alignment.
void SetUseAxisColors(Bool_t x)
auto * m
Definition: textangle.C:8
void SetTitlePixelFontSize(Int_t fs)
std::vector< TM_t > TMVec_t
TGLVector3 fTMOff[3]
Bool_t GetUseAxisColors() const
void SetFontMode(TGLFont::EMode m)
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGLFont fLabelFont
TGLVector3 & RefDir()
Int_t fTitlePixelFontSize
std::pair< Float_t, Int_t > TM_t
Manages histogram axis attributes.
Definition: TAttAxis.h:18
TGLVector3 fTitlePos
void FormAxisValue(Double_t x, TString &s) const
Returns formatted text suitable for display of value.
TMVec_t & RefTMVec()
TGLVector3 & RefTMOff(Int_t i)
std::pair< Float_t, Float_t > Lab_t
std::vector< Lab_t > LabVec_t
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
Utility class to paint axis in GL.
TGLVector3 & RefTitlePos()
3 component (x/y/z) vector class.
Definition: TGLUtil.h:246
void PaintAxis(TGLRnrCtx &ctx, TAxis *ax)
GL render TAxis.
TGLFont fTitleFont
Class to manage histogram axis.
Definition: TAxis.h:30
Int_t fLabelPixelFontSize
auto * a
Definition: textangle.C:12
TGLAxisPainter & operator=(const TGLAxisPainter &)
Int_t GetLabelPixelFontSize() const
TAttAxis * GetAttAxis()
TPMERegexp * fAllZeroesRE
void RnrLabels() const
Render label reading prepared list ov value-pos pairs.
void SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e)
Set label align.
double Double_t
Definition: RtypesCore.h:55
void SetTitleFont(TGLRnrCtx &rnrCtx, const char *fontName, Int_t pixelSize=64, Double_t font3DSize=-1)
Set title font derived from TAttAxis.
void RnrLines() const
Render axis main line and tick-marks.
The TH1 histogram class.
Definition: TH1.h:56
static constexpr double s
Double_t fTitle3DFontSize
void RnrTitle(const TString &title, TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV) const
Draw title at given position.
LabVec_t & RefLabVec()
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
Bool_t fUseAxisColors
Wrapper for PCRE library (Perl Compatible Regular Expressions).
Definition: TPRegexp.h:97
void SetLabelPixelFontSize(Int_t fs)
TAttAxis * fAttAxis
Int_t GetTitlePixelFontSize() const
LabVec_t fLabVec
void SetLabelFont(TGLRnrCtx &rnrCtx, const char *fontName, Int_t pixelSize=64, Double_t font3DSize=-1)
Set label font derived from TAttAxis.
A wrapper class for FTFont.
Definition: first.py:1
void SetTMNDim(Int_t x)
void SetTextFormat(Double_t min, Double_t max, Double_t binWidth)
Construct print format from given primary bin width.
TGLFont::EMode fFontMode
Int_t GetTMNDim() const
void LabelsLimits(const char *label, Int_t &first, Int_t &last) const
Find first and last character of a label.
Double_t fLabel3DFontSize
virtual ~TGLAxisPainter()
Destructor.
TGLFont::ETextAlignH_e fLabelAlignH
TGLFont::ETextAlignV_e fLabelAlignV
TGLFont::EMode GetFontMode() const
void SetAttAxis(TAttAxis *a)