ROOT  6.06/09
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 #ifndef ROOT_Riosfwd
15 #include "Riosfwd.h"
16 #endif
17 #ifndef ROOT_TText
18 #include "TText.h"
19 #endif
20 #ifndef ROOT_TAttLine
21 #include "TAttLine.h"
22 #endif
23 
24 //////////////////////////////////////////////////////////////////////////
25 // //
26 // TLatex //
27 // //
28 // The Latex-style text processor class //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 
33 class TLatex : public TText, public TAttLine {
34 protected:
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 /// @brief TLatex helper struct holding the attributes of a piece of text.
38 
39  struct TextSpec_t {
42  };
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// @brief TLatex helper struct holding the dimensions of a piece of text.
46  struct FormSize_t {
48  };
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// @class TLatexFormSize
52 /// @brief TLatex helper class used to compute the size of a portion of a formula.
53 
55  private:
57 
58  public:
59  TLatexFormSize() : fWidth(0), fOver(0),fUnder(0) { } // constructeur par defaut
60  TLatexFormSize(Double_t x, Double_t y1, Double_t y2) : fWidth(x), fOver(y1), fUnder(y2) { } // constructeur
61  virtual ~TLatexFormSize() {} //destructeur
63  : fWidth(form.fWidth), fOver(form.fOver), fUnder(form.fUnder) { }
64 
65  // definition of operators + and +=
69  { fWidth += f.Width(); fOver = TMath::Max(fOver,f.Over()); fUnder = TMath::Max(fUnder,f.Under()); }
70 
71  inline void Set(Double_t x, Double_t y1, Double_t y2) { fWidth=x; fOver=y1; fUnder=y2; }
73  { return TLatexFormSize(f.Width()+fWidth,f.Height()+fOver,fUnder); }
75  { return TLatexFormSize(f.Width()+fWidth,fOver,f.Height()+fUnder); }
77  { return TLatexFormSize(fWidth+TMath::Max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
78 
79  // return members
80  inline Double_t Width() const { return fWidth; }
81  inline Double_t Over() const { return fOver; }
82  inline Double_t Under() const { return fUnder; }
83  inline Double_t Height() const { return fOver+fUnder; }
84  };
85 
86  Double_t fFactorSize; //!Relative size of subscripts and superscripts
87  Double_t fFactorPos; //!Relative position of subscripts and superscripts
88  Int_t fLimitFactorSize; // lower bound for subscripts/superscripts size
89  const Char_t *fError; //!error code
90  Bool_t fShow; //!is true during the second pass (Painting)
91  FormSize_t *fTabSize; //!array of values for the different zones
92  Double_t fOriginSize; // Font size of the starting font
93  Int_t fTabMax; //!Maximum allocation for array fTabSize;
94  Int_t fPos; //!Current position in array fTabSize;
95  Bool_t fItalic; //!Currently inside italic operator
96 
97  TLatex& operator=(const TLatex&);
98 
99  //Text analysis and painting
102 
103  void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec);
106 
107  TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text);
108 
109  Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
110 
111  void Savefs(TLatexFormSize *fs);
113 
115 
116 public:
117  // TLatex status bits
118  enum { kTextNDC = BIT(14) };
119 
120  TLatex();
121  TLatex(Double_t x, Double_t y, const char *text);
122  TLatex(const TLatex &text);
123  virtual ~TLatex();
124  void Copy(TObject &text) const;
125 
126  TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
127  TLatex *DrawLatexNDC(Double_t x, Double_t y, const char *text);
128 
129  Double_t GetHeight() const;
130  Double_t GetXsize();
131  Double_t GetYsize();
132  void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE);
133  virtual void Paint(Option_t *option="");
134  virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
135 
136  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
137  virtual void SetIndiceSize(Double_t factorSize);
138  virtual void SetLimitIndiceSize(Int_t limitFactorSize);
139 
140  ClassDef(TLatex,2) //The Latex-style text processor class
141 };
142 
143 #endif
Double_t Width() const
Definition: TLatex.h:80
Double_t Under() const
Definition: TLatex.h:82
Int_t fLimitFactorSize
Relative position of subscripts and superscripts.
Definition: TLatex.h:88
Bool_t fShow
error code
Definition: TLatex.h:90
Double_t fOriginSize
array of values for the different zones
Definition: TLatex.h:92
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
TLatexFormSize(const TLatexFormSize &form)
Definition: TLatex.h:62
Basic string class.
Definition: TString.h:137
TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
Definition: TLatex.h:76
TLatex helper struct holding the dimensions of a piece of text.
Definition: TLatex.h:46
Int_t fTabMax
Definition: TLatex.h:93
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Double_t fOver
Definition: TLatex.h:47
Double_t fAngle
Definition: TLatex.h:40
TLatex & operator=(const TLatex &)
Currently inside italic operator.
Definition: TLatex.cxx:445
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Definition: TLatex.cxx:2115
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
Definition: TLatex.cxx:1914
Double_t fSize
Definition: TLatex.h:40
static const double x2[5]
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:1924
Double_t GetYsize()
Return size of the formula along Y in pad coordinates.
Definition: TLatex.cxx:2568
Double_t x[n]
Definition: legend1.C:17
TLatexFormSize AddOver(TLatexFormSize f)
Definition: TLatex.h:72
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:1944
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
Definition: TLatex.cxx:486
To draw Mathematical Formula.
Definition: TLatex.h:33
TLatexFormSize operator+(TLatexFormSize f)
Definition: TLatex.h:66
virtual void Paint(Option_t *option="")
Paint.
Definition: TLatex.cxx:2004
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:1901
Base class for several text objects.
Definition: TText.h:42
ClassDef(TAttLine, 2)
Double_t Over() const
Definition: TLatex.h:81
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
Definition: TLatex.cxx:2220
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition: TLatex.cxx:2025
Double_t GetHeight() const
Return height of current pad in pixels.
Definition: TLatex.cxx:2468
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:1973
char * out
Definition: TBase64.cxx:29
const Char_t * fError
Definition: TLatex.h:89
void Set(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:71
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TLatex.cxx:2631
Double_t fWidth
Definition: TLatex.h:47
ROOT::R::TRInterface & r
Definition: Object.C:4
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
Definition: TLatex.cxx:2481
TLatexFormSize Readfs()
Read fs in fTabSize.
Definition: TLatex.cxx:2599
TLatexFormSize(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:60
unsigned int r1[N_CITIES]
Definition: simanTSP.cxx:321
TLatexFormSize AddUnder(TLatexFormSize f)
Definition: TLatex.h:74
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t fUnder
Definition: TLatex.h:47
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:516
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
Definition: TLatex.cxx:2512
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
Definition: TLatex.cxx:2424
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
Definition: TLatex.cxx:2609
FormSize_t * fTabSize
is true during the second pass (Painting)
Definition: TLatex.h:91
virtual ~TLatex()
Destructor.
Definition: TLatex.cxx:420
static const double x1[5]
Int_t fPos
Maximum allocation for array fTabSize;.
Definition: TLatex.h:94
double f(double x)
TLatex helper class used to compute the size of a portion of a formula.
Definition: TLatex.h:54
double Double_t
Definition: RtypesCore.h:55
TText * text
virtual ~TLatexFormSize()
Definition: TLatex.h:61
Double_t y[n]
Definition: legend1.C:17
void operator+=(TLatexFormSize f)
Definition: TLatex.h:68
Double_t fFactorPos
Relative size of subscripts and superscripts.
Definition: TLatex.h:87
void Copy(TObject &text) const
Copy this TLatex object to another TLatex.
Definition: TLatex.cxx:467
Mother of all ROOT objects.
Definition: TObject.h:58
TLatex helper struct holding the attributes of a piece of text.
Definition: TLatex.h:39
char Char_t
Definition: RtypesCore.h:29
double f2(const double *x)
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
TF1 * f1
Definition: legend1.C:11
Bool_t fItalic
Current position in array fTabSize;.
Definition: TLatex.h:95
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
Definition: TLatex.cxx:2665
Double_t Height() const
Definition: TLatex.h:83
Line Attributes class.
Definition: TAttLine.h:32
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
Double_t fFactorSize
Definition: TLatex.h:86
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
Definition: TLatex.cxx:2657