Logo ROOT   6.16/01
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
18class TLatex : public TText, public TAttLine {
19protected:
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() : fWidth(0), fOver(0),fUnder(0) { } // constructeur par defaut
45 TLatexFormSize(Double_t x, Double_t y1, Double_t y2) : fWidth(x), fOver(y1), fUnder(y2) { } // constructeur
46 virtual ~TLatexFormSize() {} //destructeur
48 : fWidth(form.fWidth), fOver(form.fOver), fUnder(form.fUnder) { }
49
50 // definition of operators + and +=
52 { return TLatexFormSize(f.Width()+fWidth,TMath::Max(f.Over(),fOver),TMath::Max(f.Under(),fUnder)); }
54 { fWidth += f.Width(); fOver = TMath::Max(fOver,f.Over()); fUnder = TMath::Max(fUnder,f.Under()); }
55
56 inline void Set(Double_t x, Double_t y1, Double_t y2) { fWidth=x; fOver=y1; fUnder=y2; }
58 { return TLatexFormSize(f.Width()+fWidth,f.Height()+fOver,fUnder); }
60 { return TLatexFormSize(f.Width()+fWidth,fOver,f.Height()+fUnder); }
62 { return TLatexFormSize(fWidth+TMath::Max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
63
64 // return members
65 inline Double_t Width() const { return fWidth; }
66 inline Double_t Over() const { return fOver; }
67 inline Double_t Under() const { return fUnder; }
68 inline Double_t Height() const { return fOver+fUnder; }
69 };
70
71 Double_t fFactorSize; ///<! Relative size of subscripts and superscripts
72 Double_t fFactorPos; ///<! Relative position of subscripts and superscripts
73 Int_t fLimitFactorSize; ///< lower bound for subscripts/superscripts size
74 const Char_t *fError; ///<! error code
75 Bool_t fShow; ///<! is true during the second pass (Painting)
76 FormSize_t *fTabSize; ///<! array of values for the different zones
77 Double_t fOriginSize; ///< Font size of the starting font
78 Int_t fTabMax; ///<! Maximum allocation for array fTabSize;
79 Int_t fPos; ///<! Current position in array fTabSize;
80 Bool_t fItalic; ///<! Currently inside italic operator
81
82 TLatex& operator=(const TLatex&);
83
84 //Text analysis and painting
86 TLatexFormSize Anal1(TextSpec_t spec, const Char_t* t,Int_t length);
87
90 void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec);
91
93
94 Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
95
96 void Savefs(TLatexFormSize *fs);
98
100
101public:
102 // TLatex status bits
103 enum {
104 kTextNDC = BIT(14) ///< The text postion is in NDC coordinates
105 };
106
107 TLatex();
108 TLatex(Double_t x, Double_t y, const char *text);
109 TLatex(const TLatex &text);
110 virtual ~TLatex();
111 void Copy(TObject &text) const;
112
113 TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
114 TLatex *DrawLatexNDC(Double_t x, Double_t y, const char *text);
115
116 Double_t GetHeight() const;
119 void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE);
120 virtual void Paint(Option_t *option="");
121 virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
122
123 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
124 virtual void SetIndiceSize(Double_t factorSize);
125 virtual void SetLimitIndiceSize(Int_t limitFactorSize);
126
127 ClassDef(TLatex,2) //The Latex-style text processor class
128};
129
130#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
#define BIT(n)
Definition: Rtypes.h:82
Line Attributes class.
Definition: TAttLine.h:18
TLatex helper class used to compute the size of a portion of a formula.
Definition: TLatex.h:39
Double_t Height() const
Definition: TLatex.h:68
TLatexFormSize(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:45
Double_t Over() const
Definition: TLatex.h:66
Double_t Under() const
Definition: TLatex.h:67
TLatexFormSize(const TLatexFormSize &form)
Definition: TLatex.h:47
void operator+=(TLatexFormSize f)
Definition: TLatex.h:53
TLatexFormSize AddOver(TLatexFormSize f)
Definition: TLatex.h:57
Double_t Width() const
Definition: TLatex.h:65
void Set(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:56
TLatexFormSize AddUnder(TLatexFormSize f)
Definition: TLatex.h:59
virtual ~TLatexFormSize()
Definition: TLatex.h:46
TLatexFormSize operator+(TLatexFormSize f)
Definition: TLatex.h:51
TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
Definition: TLatex.h:61
To draw Mathematical Formula.
Definition: TLatex.h:18
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
Definition: TLatex.cxx:2694
Int_t fPos
! Current position in array fTabSize;
Definition: TLatex.h:79
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
Definition: TLatex.cxx:2510
Double_t GetHeight() const
Return height of current pad in pixels.
Definition: TLatex.cxx:2497
Double_t fFactorPos
! Relative position of subscripts and superscripts
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:1957
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
Definition: TLatex.h:73
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
Definition: TLatex.cxx:2686
FormSize_t * fTabSize
! array of values for the different zones
Definition: TLatex.h:76
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Definition: TLatex.cxx:2131
Double_t fOriginSize
Font size of the starting font.
Definition: TLatex.h:77
Double_t GetYsize()
Return size of the formula along Y in pad coordinates.
Definition: TLatex.cxx:2597
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
Definition: TLatex.cxx:488
Int_t fTabMax
! Maximum allocation for array fTabSize;
Definition: TLatex.h:78
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
Definition: TLatex.cxx:2453
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TLatex.cxx:2660
TLatexFormSize Readfs()
Read fs in fTabSize.
Definition: TLatex.cxx:2628
void Copy(TObject &text) const
Copy this TLatex object to another TLatex.
Definition: TLatex.cxx:469
@ kTextNDC
The text postion is in NDC coordinates.
Definition: TLatex.h:104
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
Definition: TLatex.cxx:1927
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
Definition: TLatex.cxx:2541
virtual ~TLatex()
Destructor.
Definition: TLatex.cxx:422
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition: TLatex.cxx:2038
TLatex()
Default constructor.
Definition: TLatex.cxx:385
Bool_t fShow
! is true during the second pass (Painting)
Definition: TLatex.h:75
TLatex & operator=(const TLatex &)
assignment operator
Definition: TLatex.cxx:447
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:1937
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:1914
Double_t fFactorSize
! Relative size of subscripts and superscripts
Definition: TLatex.h:71
const Char_t * fError
! error code
Definition: TLatex.h:74
Bool_t fItalic
! Currently inside italic operator
Definition: TLatex.h:80
virtual void Paint(Option_t *option="")
Paint.
Definition: TLatex.cxx:2017
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:520
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
Definition: TLatex.cxx:2249
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:1986
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
Definition: TLatex.cxx:2638
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
Base class for several text objects.
Definition: TText.h:23
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TF1 * f1
Definition: legend1.C:11
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TLatex helper struct holding the dimensions of a piece of text.
Definition: TLatex.h:31
Double_t fWidth
Definition: TLatex.h:32
Double_t fOver
Definition: TLatex.h:32
Double_t fUnder
Definition: TLatex.h:32
TLatex helper struct holding the attributes of a piece of text.
Definition: TLatex.h:24
Double_t fSize
Definition: TLatex.h:25
Double_t fAngle
Definition: TLatex.h:25