Logo ROOT  
Reference Guide
TLatex.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Nicolas Brun 07/08/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 #ifndef ROOT_TLatex
12 #define ROOT_TLatex
13 
14 #include "TText.h"
15 #include "TAttLine.h"
16 
17 
18 class TLatex : public TText, public TAttLine {
19 protected:
20 
21 ////////////////////////////////////////////////////////////////////////////////
22 /// @brief TLatex helper struct holding the attributes of a piece of text.
23 
24  struct TextSpec_t {
27  };
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// @brief TLatex helper struct holding the dimensions of a piece of text.
31  struct FormSize_t {
33  };
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// @class TLatexFormSize
37 /// @brief TLatex helper class used to compute the size of a portion of a formula.
38 
40  private:
42 
43  public:
44  TLatexFormSize() = default;
45  TLatexFormSize(Double_t x, Double_t y1, Double_t y2) : fWidth(x), fOver(y1), fUnder(y2) { } // constructor
46 
47  // definition of operators + and +=
49  { return TLatexFormSize(f.Width()+fWidth,TMath::Max(f.Over(),fOver),TMath::Max(f.Under(),fUnder)); }
51  { fWidth += f.Width(); fOver = TMath::Max(fOver,f.Over()); fUnder = TMath::Max(fUnder,f.Under()); }
52 
53  inline void Set(Double_t x, Double_t y1, Double_t y2) { fWidth=x; fOver=y1; fUnder=y2; }
55  { return TLatexFormSize(f.Width()+fWidth,f.Height()+fOver,fUnder); }
57  { return TLatexFormSize(f.Width()+fWidth,fOver,f.Height()+fUnder); }
59  { return TLatexFormSize(fWidth+TMath::Max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
60 
61  // return members
62  inline Double_t Width() const { return fWidth; }
63  inline Double_t Over() const { return fOver; }
64  inline Double_t Under() const { return fUnder; }
65  inline Double_t Height() const { return fOver+fUnder; }
66  };
67 
68  Double_t fFactorSize; ///<! Relative size of subscripts and superscripts
69  Double_t fFactorPos; ///<! Relative position of subscripts and superscripts
70  Int_t fLimitFactorSize; ///< lower bound for subscripts/superscripts size
71  const Char_t *fError; ///<! error code
72  Bool_t fShow; ///<! is true during the second pass (Painting)
73  FormSize_t *fTabSize; ///<! array of values for the different zones
74  Double_t fOriginSize; ///< Font size of the starting font
75  Int_t fTabMax; ///<! Maximum allocation for array fTabSize;
76  Int_t fPos; ///<! Current position in array fTabSize;
77  Bool_t fItalic; ///<! Currently inside italic operator
78 
79  TLatex& operator=(const TLatex&);
80 
81  //Text analysis and painting
83  TLatexFormSize Anal1(TextSpec_t spec, const Char_t* t,Int_t length);
84 
88 
90 
91  Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
92 
93  void Savefs(TLatexFormSize *fs);
95 
97 
98 public:
99  // TLatex status bits
100  enum {
101  kTextNDC = BIT(14) ///< The text postion is in NDC coordinates
102  };
103 
104  TLatex();
105  TLatex(Double_t x, Double_t y, const char *text);
106  TLatex(const TLatex &text);
107  virtual ~TLatex();
108  void Copy(TObject &text) const;
109 
110  TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
111  TLatex *DrawLatexNDC(Double_t x, Double_t y, const char *text);
112 
113  Double_t GetHeight() const;
114  Double_t GetXsize();
115  Double_t GetYsize();
116  void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE);
117  virtual void Paint(Option_t *option="");
118  virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
119 
120  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
121  virtual void SetIndiceSize(Double_t factorSize);
122  virtual void SetLimitIndiceSize(Int_t limitFactorSize);
123 
124  ClassDef(TLatex,2) //The Latex-style text processor class
125 };
126 
127 #endif
TLatex::fOriginSize
Double_t fOriginSize
Font size of the starting font.
Definition: TLatex.h:74
TLatex::TLatexFormSize::Set
void Set(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:53
TLatex::TLatexFormSize::AddOver
TLatexFormSize AddOver(TLatexFormSize f)
Definition: TLatex.h:54
TLatex::TLatexFormSize::Under
Double_t Under() const
Definition: TLatex.h:64
TLatex::TLatexFormSize::Over
Double_t Over() const
Definition: TLatex.h:63
TLatex::TLatexFormSize::fOver
Double_t fOver
Definition: TLatex.h:41
TLatex::TextSpec_t::fColor
Int_t fColor
Definition: TLatex.h:26
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TLatex::DrawLine
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
Draw a line in a Latex formula.
Definition: TLatex.cxx:1950
TLatex::SetIndiceSize
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
Definition: TLatex.cxx:2698
TLatex::fItalic
Bool_t fItalic
! Currently inside italic operator
Definition: TLatex.h:77
TLatex::Analyse
TLatexFormSize Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t *t, Int_t length)
Analyse and paint the TLatex formula.
Definition: TLatex.cxx:521
TLatex::fTabSize
FormSize_t * fTabSize
! array of values for the different zones
Definition: TLatex.h:73
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TLatex::Paint
virtual void Paint(Option_t *option="")
Paint.
Definition: TLatex.cxx:2030
TLatex::fLimitFactorSize
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
Definition: TLatex.h:70
TLatex::operator=
TLatex & operator=(const TLatex &)
assignment operator
Definition: TLatex.cxx:448
TLatex::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TLatex.cxx:2672
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TLatex::GetBoundingBox
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
Definition: TLatex.cxx:2553
TLatex::DrawLatex
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Definition: TLatex.cxx:1927
TLatex
To draw Mathematical Formula.
Definition: TLatex.h:18
TLatex::TextSpec_t::fFont
Int_t fFont
Definition: TLatex.h:26
TLatex::GetXsize
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
Definition: TLatex.cxx:2522
TLatex::TextSpec_t::fSize
Double_t fSize
Definition: TLatex.h:25
TLatex::FormSize_t::fOver
Double_t fOver
Definition: TLatex.h:32
TString
Basic string class.
Definition: TString.h:136
TLatex::kTextNDC
@ kTextNDC
The text postion is in NDC coordinates.
Definition: TLatex.h:101
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
text
TText * text
Definition: entrylist_figure1.C:10
bool
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TLatex::TLatexFormSize::fWidth
Double_t fWidth
Definition: TLatex.h:41
TAttLine.h
TLatex::DrawCircle
void DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Definition: TLatex.cxx:1970
TLatex::FormSize_t::fWidth
Double_t fWidth
Definition: TLatex.h:32
TLatex::CheckLatexSyntax
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
Definition: TLatex.cxx:2261
TLatex::fTabMax
Int_t fTabMax
! Maximum allocation for array fTabSize;
Definition: TLatex.h:75
TAttLine
Line Attributes class.
Definition: TAttLine.h:18
TLatex::DrawParenthesis
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Definition: TLatex.cxx:1999
TLatex::GetYsize
Double_t GetYsize()
Return size of the formula along Y in pad coordinates.
Definition: TLatex.cxx:2609
TLatex::Savefs
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
Definition: TLatex.cxx:2650
TLatex::TLatexFormSize::TLatexFormSize
TLatexFormSize()=default
h
#define h(i)
Definition: RSha256.hxx:106
TLatex::TLatexFormSize::AddOver
TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
Definition: TLatex.h:58
TLatex::~TLatex
virtual ~TLatex()
Destructor.
Definition: TLatex.cxx:423
TLatex::FirstParse
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
Definition: TLatex.cxx:2465
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TLatex::fFactorSize
Double_t fFactorSize
! Relative size of subscripts and superscripts
Definition: TLatex.h:68
BIT
#define BIT(n)
Definition: Rtypes.h:85
TLatex::DrawLatexNDC
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
Definition: TLatex.cxx:1940
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
y
Double_t y[n]
Definition: legend1.C:17
TLatex::FormSize_t
TLatex helper struct holding the dimensions of a piece of text.
Definition: TLatex.h:31
TLatex::GetHeight
Double_t GetHeight() const
Return height of current pad in pixels.
Definition: TLatex.cxx:2509
TLatex::TLatexFormSize::operator+=
void operator+=(TLatexFormSize f)
Definition: TLatex.h:50
TLatex::FormSize_t::fUnder
Double_t fUnder
Definition: TLatex.h:32
TLatex::TLatexFormSize::operator+
TLatexFormSize operator+(TLatexFormSize f)
Definition: TLatex.h:48
TLatex::Copy
void Copy(TObject &text) const
Copy this TLatex object to another TLatex.
Definition: TLatex.cxx:470
TLatex::TLatexFormSize::Height
Double_t Height() const
Definition: TLatex.h:65
TText
Base class for several text objects.
Definition: TText.h:22
TLatex::TLatexFormSize::Width
Double_t Width() const
Definition: TLatex.h:62
f1
TF1 * f1
Definition: legend1.C:11
Double_t
double Double_t
Definition: RtypesCore.h:59
TLatex::TLatexFormSize::TLatexFormSize
TLatexFormSize(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:45
TLatex::fError
const Char_t * fError
! error code
Definition: TLatex.h:71
TLatex::fFactorPos
Double_t fFactorPos
! Relative position of subscripts and superscripts
Definition: TLatex.h:69
TLatex::Anal1
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
Definition: TLatex.cxx:489
TLatex::PaintLatex
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition: TLatex.cxx:2051
TLatex::fPos
Int_t fPos
! Current position in array fTabSize;
Definition: TLatex.h:76
TLatex::TLatexFormSize::fUnder
Double_t fUnder
Definition: TLatex.h:41
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TLatex::TLatex
TLatex()
Default constructor.
Definition: TLatex.cxx:386
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
TLatex::TLatexFormSize::AddUnder
TLatexFormSize AddUnder(TLatexFormSize f)
Definition: TLatex.h:56
TLatex::TLatexFormSize
TLatex helper class used to compute the size of a portion of a formula.
Definition: TLatex.h:39
launcher.spec
spec
Definition: launcher.py:30
TLatex::PaintLatex1
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Definition: TLatex.cxx:2144
Char_t
char Char_t
Definition: RtypesCore.h:33
TText.h
TLatex::SetLimitIndiceSize
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
Definition: TLatex.cxx:2706
TLatex::TextSpec_t
TLatex helper struct holding the attributes of a piece of text.
Definition: TLatex.h:24
TLatex::fShow
Bool_t fShow
! is true during the second pass (Painting)
Definition: TLatex.h:72
TLatex::Readfs
TLatexFormSize Readfs()
Read fs in fTabSize.
Definition: TLatex.cxx:2640
int
TLatex::TextSpec_t::fAngle
Double_t fAngle
Definition: TLatex.h:25