Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 TVirtualPad;
19
20class TLatex : public TText, public TAttLine {
21protected:
22
23////////////////////////////////////////////////////////////////////////////////
24/// @brief TLatex helper struct holding the attributes of a piece of text.
25
30
31////////////////////////////////////////////////////////////////////////////////
32/// @class TLatexFormSize
33/// @brief TLatex helper class used to compute the size of a portion of a formula.
34
36 private:
38
39 public:
40 TLatexFormSize() = default;
42
43 // definition of operators + and +=
45 { return TLatexFormSize(f.Width()+fWidth,std::max(f.Over(),fOver),std::max(f.Under(),fUnder)); }
47 { fWidth += f.Width(); fOver = std::max(fOver,f.Over()); fUnder = std::max(fUnder,f.Under()); }
48
55 { return TLatexFormSize(fWidth+std::max(f1.Width(),f2.Width()),fOver+f1.Over(),fUnder+f2.Under()); }
56
57 // return members
58 inline Double_t Width() const { return fWidth; }
59 inline Double_t Over() const { return fOver; }
60 inline Double_t Under() const { return fUnder; }
61 inline Double_t Height() const { return fOver+fUnder; }
62 };
63
64 Double_t fFactorSize; ///<! Relative size of subscripts and superscripts
65 Double_t fFactorPos; ///<! Relative position of subscripts and superscripts
66 Int_t fLimitFactorSize; ///< lower bound for subscripts/superscripts size
67 const Char_t *fError{nullptr}; ///<! error code
68 Bool_t fShow; ///<! is true during the second pass (Painting)
69 std::vector<TLatexFormSize> fTabSize; ///<! array of values for the different zones
70 Double_t fOriginSize; ///< Font size of the starting font
71 Bool_t fItalic; ///<! Currently inside italic operator
72
73 TLatex& operator=(const TLatex&);
74
75 //Text analysis and painting
78
81
86
88
90
93
95
96public:
97 // TLatex status bits
98 enum {
99 kTextNDC = BIT(14) ///< The text position is in NDC coordinates
100 };
101
102 TLatex();
103 TLatex(Double_t x, Double_t y, const char *text);
104 TLatex(const TLatex &text);
105 ~TLatex() override;
106
107 void Copy(TObject &text) const override;
108
109 TLatex *DrawLatex(Double_t x, Double_t y, const char *text);
110 TLatex *DrawLatexNDC(Double_t x, Double_t y, const char *text);
111
112 Double_t GetHeight() const;
115 void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle = kFALSE) override;
116 void Paint(Option_t *option="") override;
117 virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text);
118
119 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
120 virtual void SetIndiceSize(Double_t factorSize);
122
123 ClassDefOverride(TLatex,2) //The Latex-style text processor class
124};
125
126#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
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define BIT(n)
Definition Rtypes.h:91
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
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 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 np
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 TPoint TPoint const char DrawLine
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:20
TLatex helper class used to compute the size of a portion of a formula.
Definition TLatex.h:35
Double_t Height() const
Definition TLatex.h:61
Double_t Over() const
Definition TLatex.h:59
Double_t Under() const
Definition TLatex.h:60
TLatexFormSize(Double_t width, Double_t over, Double_t under)
Definition TLatex.h:41
void operator+=(TLatexFormSize f)
Definition TLatex.h:46
TLatexFormSize AddOver(TLatexFormSize f)
Definition TLatex.h:50
Double_t Width() const
Definition TLatex.h:58
void Set(Double_t x, Double_t y1, Double_t y2)
Definition TLatex.h:49
TLatexFormSize AddUnder(TLatexFormSize f)
Definition TLatex.h:52
TLatexFormSize operator+(TLatexFormSize f)
Definition TLatex.h:44
TLatexFormSize AddOver(TLatexFormSize f1, TLatexFormSize f2)
Definition TLatex.h:54
To draw Mathematical Formula.
Definition TLatex.h:20
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
Definition TLatex.cxx:2726
Double_t GetXsize()
Return size of the formula along X in pad coordinates when the text precision is smaller than 3.
Definition TLatex.cxx:2558
void Rotate(TVirtualPad *pad, Double_t angle, Int_t np, Double_t *x, Double_t *y)
Rotate array of points around fX, fY coordinate by specified angle.
Definition TLatex.cxx:489
Double_t GetHeight() const
Return height of current pad in pixels.
Definition TLatex.cxx:2543
void Copy(TObject &text) const override
Copy this TLatex object to another TLatex.
Definition TLatex.cxx:472
Double_t fFactorPos
! Relative position of subscripts and superscripts
Definition TLatex.h:65
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
Definition TLatex.h:66
TLatexFormSize Anal1(const TextSpec_t &spec, const Char_t *t, Int_t length)
Analyse function.
Definition TLatex.cxx:519
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, const TextSpec_t &spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Definition TLatex.cxx:2049
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
Definition TLatex.cxx:2718
std::vector< TLatexFormSize > fTabSize
! array of values for the different zones
Definition TLatex.h:69
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Definition TLatex.cxx:2195
Double_t fOriginSize
Font size of the starting font.
Definition TLatex.h:70
Double_t GetYsize()
Return size of the formula along Y in pad coordinates when the text precision is smaller than 3.
Definition TLatex.cxx:2646
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
Definition TLatex.cxx:2510
TLatexFormSize Readfs()
Read fs in fTabSize.
Definition TLatex.cxx:2677
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Return text size in pixels.
Definition TLatex.cxx:2589
@ kTextNDC
The text position is in NDC coordinates.
Definition TLatex.h:99
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
Definition TLatex.cxx:1963
void DrawCircle(Double_t x1, Double_t y1, Double_t r, const TextSpec_t &spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Definition TLatex.cxx:2022
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Definition TLatex.cxx:2102
TLatex()
Default constructor.
Definition TLatex.cxx:399
Bool_t fShow
! is true during the second pass (Painting)
Definition TLatex.h:68
~TLatex() override
Destructor.
Definition TLatex.cxx:430
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TLatex.cxx:2700
TLatex & operator=(const TLatex &)
assignment operator
Definition TLatex.cxx:452
void DrawPolyLine(Int_t npoints, Double_t *xx, Double_t *yy, const TextSpec_t &spec, Double_t scale_width=0.)
Draw a poly line in a Latex formula Is scale_width parameter >=1, fill area will be drawn Otherwise l...
Definition TLatex.cxx:1976
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:1949
Double_t fFactorSize
! Relative size of subscripts and superscripts
Definition TLatex.h:64
const Char_t * fError
! error code
Definition TLatex.h:67
Bool_t fItalic
! Currently inside italic operator
Definition TLatex.h:71
void Paint(Option_t *option="") override
Paint.
Definition TLatex.cxx:2080
TLatexFormSize Analyse(Double_t x, Double_t y, const TextSpec_t &spec, const Char_t *t, Int_t length)
Analyse and paint the TLatex formula.
Definition TLatex.cxx:551
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
Definition TLatex.cxx:2311
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
Definition TLatex.cxx:2692
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:138
Base class for several text objects.
Definition TText.h:22
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
TLatex helper struct holding the attributes of a piece of text.
Definition TLatex.h:26
Double_t fSize
Definition TLatex.h:27
Double_t fAngle
Definition TLatex.h:27