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;
41 TLatexFormSize(Double_t width, Double_t over, Double_t under) : fWidth(width), fOver(over), fUnder(under) { } // constructor
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
49 inline void Set(Double_t x, Double_t y1, Double_t y2) { fWidth=x; fOver=y1; fUnder=y2; }
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
74
75 //Text analysis and painting
76 TLatexFormSize Analyse(Double_t x, Double_t y, const TextSpec_t &spec, const Char_t *t,Int_t length);
77 TLatexFormSize Anal1(const TextSpec_t &spec, const Char_t *t,Int_t length);
78
79 void Rotate(TVirtualPad *pad, Double_t angle, Int_t np, Double_t *x, Double_t *y);
81
82 void DrawPolyLine(Int_t npoints, Double_t *xx, Double_t *yy, const TextSpec_t &spec, Double_t scale_width = 0.);
83 void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const TextSpec_t &spec);
84 void DrawCircle(Double_t x1, Double_t y1, Double_t r, const TextSpec_t &spec);
85 void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, const TextSpec_t &spec);
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
103 TLatex(Double_t x, Double_t y, const char *text);
105 ~TLatex() override;
106
107 void Copy(TObject &text) const override;
108
111
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);
121 virtual void SetLimitIndiceSize(Int_t limitFactorSize);
122
123 ClassDefOverride(TLatex,2) //The Latex-style text processor class
124};
125
126#endif
ROOT::R::TRInterface & r
Definition Object.C:4
#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
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
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
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
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
Double_t GetXsize()
void Rotate(TVirtualPad *pad, Double_t angle, Int_t np, Double_t *x, Double_t *y)
Double_t GetHeight() const
void Copy(TObject &text) const override
Copy this to obj.
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
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const TextSpec_t &spec)
@ kTextNDC
The text position is in NDC coordinates.
Definition TLatex.h:99
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, const TextSpec_t &spec)
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)
Double_t fOriginSize
Font size of the starting font.
Definition TLatex.h:70
Double_t GetYsize()
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
TLatex(Double_t x, Double_t y, const char *text)
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
TLatexFormSize Readfs()
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
void DrawCircle(Double_t x1, Double_t y1, Double_t r, const TextSpec_t &spec)
Bool_t fShow
! is true during the second pass (Painting)
Definition TLatex.h:68
~TLatex() override
virtual void SetIndiceSize(Double_t factorSize)
TLatexFormSize Anal1(const TextSpec_t &spec, const Char_t *t, Int_t length)
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
TLatex & operator=(const TLatex &)
void DrawPolyLine(Int_t npoints, Double_t *xx, Double_t *yy, const TextSpec_t &spec, Double_t scale_width=0.)
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
TLatexFormSize Analyse(Double_t x, Double_t y, const TextSpec_t &spec, const Char_t *t, Int_t length)
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
This method must be overridden if a class wants to paint itself.
void Rotate(TVirtualPad *pad, Double_t angle, Double_t x, Double_t y, Double_t &xx, Double_t &yy)
Int_t CheckLatexSyntax(TString &text)
void Savefs(TLatexFormSize *fs)
TLatex(const TLatex &text)
TObject()
TObject constructor.
Definition TObject.h:259
Basic string class.
Definition TString.h:138
TText()
Definition TText.h:35
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
TText * text
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