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#include <vector>
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/// @class TLatexFormSize
31/// @brief TLatex helper class used to compute the size of a portion of a formula.
32
34 private:
36
37 public:
38 TLatexFormSize() = default;
39 TLatexFormSize(Double_t width, Double_t over, Double_t under) : fWidth(width), fOver(over), fUnder(under) { } // constructor
40
41 // definition of operators + and +=
43 { return TLatexFormSize(f.Width()+fWidth,TMath::Max(f.Over(),fOver),TMath::Max(f.Under(),fUnder)); }
45 { fWidth += f.Width(); fOver = TMath::Max(fOver,f.Over()); fUnder = TMath::Max(fUnder,f.Under()); }
46
49 { return TLatexFormSize(f.Width()+fWidth,f.Height()+fOver,fUnder); }
51 { return TLatexFormSize(f.Width()+fWidth,fOver,f.Height()+fUnder); }
53 { return TLatexFormSize(fWidth+TMath::Max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
54
55 // return members
56 inline Double_t Width() const { return fWidth; }
57 inline Double_t Over() const { return fOver; }
58 inline Double_t Under() const { return fUnder; }
59 inline Double_t Height() const { return fOver+fUnder; }
60 };
61
62 Double_t fFactorSize; ///<! Relative size of subscripts and superscripts
63 Double_t fFactorPos; ///<! Relative position of subscripts and superscripts
64 Int_t fLimitFactorSize; ///< lower bound for subscripts/superscripts size
65 const Char_t *fError; ///<! error code
66 Bool_t fShow; ///<! is true during the second pass (Painting)
67 std::vector<TLatexFormSize> fTabSize; ///<! array of values for the different zones
68 Double_t fOriginSize; ///< Font size of the starting font
69 Bool_t fItalic; ///<! Currently inside italic operator
70
71 TLatex& operator=(const TLatex&);
72
73 //Text analysis and painting
76
80
82
84
87
89
90public:
91 // TLatex status bits
92 enum {
93 kTextNDC = BIT(14) ///< The text position is in NDC coordinates
94 };
95
96 TLatex();
97 TLatex(Double_t x, Double_t y, const char *text);
98 TLatex(const TLatex &text);
99 virtual ~TLatex();
100
101 void Copy(TObject &text) const override;
102
103 TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
104 TLatex *DrawLatexNDC(Double_t x, Double_t y, const char *text);
105
106 Double_t GetHeight() const;
109 void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE) override;
110 void Paint(Option_t *option="") override;
111 virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
112
113 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
114 virtual void SetIndiceSize(Double_t factorSize);
115 virtual void SetLimitIndiceSize(Int_t limitFactorSize);
116
117 ClassDefOverride(TLatex,2) //The Latex-style text processor class
118};
119
120#endif
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
char Char_t
Definition: RtypesCore.h:37
const Bool_t kFALSE
Definition: RtypesCore.h:101
unsigned int UInt_t
Definition: RtypesCore.h:46
double Double_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:66
#define BIT(n)
Definition: Rtypes.h:85
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
Line Attributes class.
Definition: TAttLine.h:18
TLatex helper class used to compute the size of a portion of a formula.
Definition: TLatex.h:33
Double_t Height() const
Definition: TLatex.h:59
Double_t Over() const
Definition: TLatex.h:57
Double_t Under() const
Definition: TLatex.h:58
TLatexFormSize(Double_t width, Double_t over, Double_t under)
Definition: TLatex.h:39
void operator+=(TLatexFormSize f)
Definition: TLatex.h:44
TLatexFormSize AddOver(TLatexFormSize f)
Definition: TLatex.h:48
Double_t Width() const
Definition: TLatex.h:56
void Set(Double_t x, Double_t y1, Double_t y2)
Definition: TLatex.h:47
TLatexFormSize AddUnder(TLatexFormSize f)
Definition: TLatex.h:50
TLatexFormSize operator+(TLatexFormSize f)
Definition: TLatex.h:42
TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
Definition: TLatex.h:52
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:2683
Double_t GetXsize()
Return size of the formula along X in pad coordinates when the text precision is smaller than 3.
Definition: TLatex.cxx:2507
Double_t GetHeight() const
Return height of current pad in pixels.
Definition: TLatex.cxx:2493
void Copy(TObject &text) const override
Copy this TLatex object to another TLatex.
Definition: TLatex.cxx:473
Double_t fFactorPos
! Relative position of subscripts and superscripts
Definition: TLatex.h:63
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:1972
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
Definition: TLatex.h:64
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
Definition: TLatex.cxx:2675
std::vector< TLatexFormSize > fTabSize
! array of values for the different zones
Definition: TLatex.h:67
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Definition: TLatex.cxx:2146
Double_t fOriginSize
Font size of the starting font.
Definition: TLatex.h:68
Double_t GetYsize()
Return size of the formula along Y in pad coordinates when the text precision is smaller than 3.
Definition: TLatex.cxx:2595
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
Definition: TLatex.cxx:490
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
Definition: TLatex.cxx:2460
TLatexFormSize Readfs()
Read fs in fTabSize.
Definition: TLatex.cxx:2626
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Return text size in pixels.
Definition: TLatex.cxx:2538
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
Definition: TLatex.cxx:1942
virtual ~TLatex()
Destructor.
Definition: TLatex.cxx:431
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition: TLatex.cxx:2053
TLatex()
Default constructor.
Definition: TLatex.cxx:400
Bool_t fShow
! is true during the second pass (Painting)
Definition: TLatex.h:66
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition: TLatex.cxx:2649
TLatex & operator=(const TLatex &)
assignment operator
Definition: TLatex.cxx:453
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:1952
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:1928
Double_t fFactorSize
! Relative size of subscripts and superscripts
Definition: TLatex.h:62
const Char_t * fError
! error code
Definition: TLatex.h:65
Bool_t fItalic
! Currently inside italic operator
Definition: TLatex.h:69
void Paint(Option_t *option="") override
Paint.
Definition: TLatex.cxx:2032
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:522
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
Definition: TLatex.cxx:2256
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:2001
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
Definition: TLatex.cxx:2641
@ kTextNDC
The text position is in NDC coordinates.
Definition: TLatex.h:93
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:136
Base class for several text objects.
Definition: TText.h:22
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)
Returns the largest of a and b.
Definition: TMathBase.h:250
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