Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TMathText.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id: TMathText.cxx $
2// Author: Yue Shi Lai 16/10/12
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
12#include <iostream>
13#include "TROOT.h"
14#include <ft2build.h>
15#include FT_FREETYPE_H
16#include FT_GLYPH_H
17#include "TTF.h"
18#include "TMathText.h"
19#include "TMath.h"
20#include "TVirtualPad.h"
21#include "TVirtualPadPainter.h"
22#include "TVirtualPS.h"
23#include "TText.h"
24
25#include "../../../graf2d/mathtext/inc/mathtext.h"
26#include "../../../graf2d/mathtext/inc/mathrender.h"
27
28/** \class TMathText
29\ingroup BasicGraphics
30
31To draw TeX Mathematical Formula
32
33TMathText's purpose is to write mathematical equations, exactly as TeX would
34do it. The syntax is the same as the TeX's one.
35
36The following example demonstrate how to use TMathText:
37
38Begin_Macro(source)
39../../../tutorials/visualisation/graphics/tmathtext.C
40End_Macro
41
42The list of all available symbols is given in the following example:
43
44Begin_Macro
45../../../tutorials/visualisation/graphics/tmathtext2.C
46End_Macro
47
48#### Limitation:
49TMathText rendering is not implemented for the PDF output.
50PostScript output should be used instead.
51*/
52
53const Double_t kPI = TMath::Pi();
54
55class TMathTextRenderer : public TText, public TAttFill,
56 public mathtext::math_text_renderer_t {
57private:
58 TMathText *_parent;
59 float _font_size;
60 float _x0;
61 float _y0;
62 float _angle_degree;
63 float _pad_pixel_transform[6];
64 float _pad_scale;
65 float _pad_scale_x;
66 float _pad_scale_y;
67 float _current_font_size[mathtext::math_text_renderer_t::NFAMILY];
68 inline size_t root_face_number(
69 const unsigned int family, const bool serif = false) const
70 {
71 static const int precision = 2;
72
73 if (family >= mathtext::math_text_renderer_t::
74 FAMILY_REGULAR &&
75 family <= mathtext::math_text_renderer_t::
76 FAMILY_BOLD_ITALIC) {
77 const unsigned int offset = family -
78 mathtext::math_text_renderer_t::FAMILY_REGULAR;
79 return serif ?
80 ((offset == 0 ? 13 : offset) * 10 + precision) :
81 ((offset + 4) * 10 + precision);
82 } else if (family >= mathtext::math_text_renderer_t::
83 FAMILY_STIX_REGULAR) {
84 const unsigned int offset = family -
85 mathtext::math_text_renderer_t::FAMILY_STIX_REGULAR;
86 return (offset + 16) * 10 + precision;
87 }
88
89 return precision;
90 }
91 inline bool is_cyrillic_or_cjk(const wchar_t c) const
92 {
93 return mathtext::math_text_renderer_t::is_cyrillic(c) ||
94 mathtext::math_text_renderer_t::is_cjk(c);
95 }
96 inline size_t root_cjk_face_number(
97 const bool serif = false) const
98 {
99 return (serif ? 28 : 29) * 10 + 2;
100 }
101protected:
102 inline mathtext::affine_transform_t
103 transform_logical_to_pixel(void) const override
104 {
105 return mathtext::affine_transform_t::identity;
106 }
107 inline mathtext::affine_transform_t
108 transform_pixel_to_logical(void) const override
109 {
110 return mathtext::affine_transform_t::identity;
111 }
112public:
113 inline TMathTextRenderer(TMathText *parent)
114 : TText(), TAttFill(0, 1001),
115 _parent(parent), _font_size(0), _angle_degree(0)
116 {
117 _font_size = 0;
118 _x0 = 0;
119 _y0 = 0;
120 _angle_degree = 0;
121 for (int i = 0; i<6; i++)
122 _pad_pixel_transform[i] = 0;
123 _pad_scale = 0;
124 _pad_scale_x = 0;
125 _pad_scale_y = 0;
126 for (int i = 0; i < mathtext::math_text_renderer_t::NFAMILY; i++)
127 _current_font_size[i] = 0;
128 }
129 inline float
130 font_size(const unsigned int family = FAMILY_PLAIN) const override
131 {
132 return _current_font_size[family];
133 }
134 inline void
135 point(const float /*x*/, const float /*y*/) override
136 {
137 }
138 inline void
139 set_font_size(const float size, const unsigned int family) override
140 {
141 _current_font_size[family] = size;
142 }
143 inline void
144 set_font_size(const float size) override
145 {
146 _font_size = size;
147 std::fill(_current_font_size,
148 _current_font_size + NFAMILY, size);
149 }
150 inline void
151 reset_font_size(const unsigned int /*family*/) override
152 {
153 }
154 inline void
155 set_parameter(const float x, const float y, const float size,
156 const float angle_degree)
157 {
158 _x0 = gPad->XtoAbsPixel(x);
159 _y0 = gPad->YtoAbsPixel(y);
160 _pad_scale_x = gPad->GetPadWidth();
161 _pad_scale_y = gPad->GetPadHeight();
162 _pad_scale = std::min(_pad_scale_x, _pad_scale_y);
163
164 _angle_degree = angle_degree;
165
166 const float angle_radiant = _angle_degree * (kPI / 180.0);
167
168 // Initialize the affine transform
169 _pad_pixel_transform[0] = _pad_scale * cosf(angle_radiant);
170 _pad_pixel_transform[1] = -_pad_scale * sinf(angle_radiant);
171 _pad_pixel_transform[2] = _x0;
172 _pad_pixel_transform[3] = _pad_pixel_transform[1];
173 _pad_pixel_transform[4] = -_pad_pixel_transform[0];
174 _pad_pixel_transform[5] = _y0;
175
176 set_font_size(size);
177 SetTextAngle(_angle_degree);
178 SetTextColor(_parent->fTextColor);
179 }
180 inline void
181 transform_pad(double &xt, double &yt,
182 const float x, const float y) const
183 {
184 xt = gPad->AbsPixeltoX(Int_t(
185 x * _pad_pixel_transform[0] +
186 y * _pad_pixel_transform[1] + _pad_pixel_transform[2]));
187 yt = gPad->AbsPixeltoY(Int_t(
188 x * _pad_pixel_transform[3] +
189 y * _pad_pixel_transform[4] + _pad_pixel_transform[5]));
190 }
191 inline void
192 filled_rectangle(const mathtext::bounding_box_t &bounding_box_0) override
193 {
194 SetFillColor(_parent->fTextColor);
195 SetFillStyle(1001);
197
198 double xt[4];
199 double yt[4];
200
201 transform_pad(xt[0], yt[0],
202 bounding_box_0.left(),
203 bounding_box_0.bottom());
204 transform_pad(xt[1], yt[1],
205 bounding_box_0.right(),
206 bounding_box_0.bottom());
207 transform_pad(xt[2], yt[2],
208 bounding_box_0.right(),
209 bounding_box_0.top());
210 transform_pad(xt[3], yt[3],
211 bounding_box_0.left(),
212 bounding_box_0.top());
213 gPad->PaintFillArea(4, xt, yt);
214 }
215 inline void
216 rectangle(const mathtext::bounding_box_t &/*bounding_box*/) override
217 {
218 }
219 inline mathtext::bounding_box_t
220 bounding_box_char(const wchar_t character, float &current_x, const unsigned int family)
221 {
222 TTFhandle h;
223 h.SetTextFont(is_cyrillic_or_cjk(character) ? root_cjk_face_number() : root_face_number(family));
224 h.SetTextSize(_current_font_size[family] * _pad_scale);
225
226 auto font_face = h.GetFontFace();
227 if (!font_face || font_face->units_per_EM == 0)
228 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
229
230 FT_Load_Glyph(
231 font_face,
232 FT_Get_Char_Index(font_face, character),
233 FT_LOAD_NO_SCALE);
234
235 const float scale = _current_font_size[family] / font_face->units_per_EM;
236 const FT_Glyph_Metrics metrics = font_face->glyph->metrics;
237 const float lower_left_x = metrics.horiBearingX;
238 const float lower_left_y =
239 metrics.horiBearingY - metrics.height;
240 const float upper_right_x =
241 metrics.horiBearingX + metrics.width;
242 const float upper_right_y = metrics.horiBearingY;
243 const float advance = metrics.horiAdvance;
244 const float margin = std::max(0.0F, lower_left_x);
245 const float italic_correction =
246 upper_right_x <= advance ? 0.0F :
247 std::max(0.0F, upper_right_x + margin - advance);
248 const mathtext::bounding_box_t ret =
249 mathtext::bounding_box_t(
250 lower_left_x, lower_left_y,
251 upper_right_x, upper_right_y,
252 advance, italic_correction) * scale;
253
254 current_x += ret.advance();
255
256 return ret;
257 }
258 inline mathtext::bounding_box_t
259 bounding_box(const std::wstring string, const unsigned int family = FAMILY_PLAIN) override
260 {
261 if (string.empty())
262 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
263
264 std::wstring::const_iterator iterator = string.begin();
265 float current_x = 0;
266 mathtext::bounding_box_t ret =
267 bounding_box_char(*iterator, current_x, family);
268
269 ++iterator;
270 for (; iterator != string.end(); ++iterator) {
271 const mathtext::point_t position =
272 mathtext::point_t(current_x, 0);
273 const mathtext::bounding_box_t glyph_bounding_box =
274 bounding_box_char(*iterator, current_x, family);
275 ret = ret.merge(position + glyph_bounding_box);
276 }
277
278 return ret;
279 }
280 void text_raw(const float x, const float y,
281 const std::wstring string,
282 const unsigned int family = FAMILY_PLAIN) override
283 {
284 SetTextSize(_current_font_size[family]);
285
286 wchar_t buf[2];
287 float current_x = 0;
288
289 buf[1] = L'\0';
290 for (auto character : string) {
291 buf[0] = character;
292 const bool cyrillic_or_cjk = is_cyrillic_or_cjk(character);
293 if (cyrillic_or_cjk)
294 SetTextFont((Font_t) root_cjk_face_number());
295 else
296 SetTextFont((Font_t) root_face_number(family));
297
298 double xt, yt;
299
300 transform_pad(xt, yt, x + current_x, y);
301
303 gPad->PaintText(xt, yt, buf);
304
305 // use bounding function to advance current_x
306 bounding_box_char(character, current_x, family);
307 }
308 }
309 inline void
310 text_with_bounding_box(const float /*x*/, const float /*y*/,
311 const std::wstring /*string*/,
312 const unsigned int /*family = FAMILY_PLAIN*/) override
313 {
314 }
315 using mathtext::math_text_renderer_t::bounding_box;
316};
317
318
319////////////////////////////////////////////////////////////////////////////////
320/// Default constructor.
321
323 : TAttFill(0, 1001)
324{
325 fRenderer = new TMathTextRenderer(this);
326}
327
328////////////////////////////////////////////////////////////////////////////////
329/// Normal constructor.
330
332 : TText(x, y, text), TAttFill(0, 1001)
333{
334 fRenderer = new TMathTextRenderer(this);
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Destructor.
339
341{
342 delete fRenderer;
343}
344
345////////////////////////////////////////////////////////////////////////////////
346/// Copy constructor.
347
350{
351 fRenderer = new TMathTextRenderer(this);
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Assignment operator.
356
358{
359 if (this != &rhs) {
360 TText::operator=(rhs);
361 TAttFill::operator=(rhs);
362 delete fRenderer;
363 fRenderer = new TMathTextRenderer(this);
364 }
365 return *this;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Copy.
370
371void TMathText::Copy(TObject &obj) const
372{
373 TMathText &tgt = (TMathText &)obj;
374 delete tgt.fRenderer;
375 TText::Copy(tgt);
376 TAttFill::Copy(tgt);
377 tgt.fRenderer = new TMathTextRenderer(&tgt);
378
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Render the text.
383
384void TMathText::Render(const Double_t x, const Double_t y, const Double_t size,
385 const Double_t angle, const Char_t *t, const Int_t /*length*/)
386{
387 const mathtext::math_text_t math_text(t);
388
389 fRenderer->set_parameter(x, y, size, angle);
390 fRenderer->text(0, 0, math_text);
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Get the text bounding box.
395
397 const Double_t size, const Double_t angle, const Char_t *t,
398 const Int_t /*length*/)
399{
400 const mathtext::math_text_t math_text(t);
401
402 fRenderer->set_parameter(0, 0, size, angle);
403
404 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
405 double x[4], y[4];
406
407 fRenderer->transform_pad(x[0], y[0], bounding_box.left(), bounding_box.bottom());
408 fRenderer->transform_pad(x[1], y[1], bounding_box.right(), bounding_box.bottom());
409 fRenderer->transform_pad(x[2], y[2], bounding_box.right(), bounding_box.top());
410 fRenderer->transform_pad(x[3], y[3], bounding_box.left(), bounding_box.top());
411
412 x0 = std::min(std::min(x[0], x[1]), std::min(x[2], x[3]));
413 y0 = std::min(std::min(y[0], y[1]), std::min(y[2], y[3]));
414 x1 = std::max(std::max(x[0], x[1]), std::max(x[2], x[3]));
415 y1 = std::max(std::max(y[0], y[1]), std::max(y[2], y[3]));
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Alignment.
420
422 const Double_t size, const Double_t angle,
423 const Char_t *t, const Int_t /*length*/,
424 const Short_t align)
425{
426 const mathtext::math_text_t math_text(t);
427
428 fRenderer->set_parameter(0, 0, size, angle);
429
430 const mathtext::bounding_box_t bounding_box = fRenderer->bounding_box(math_text);
431 float x = 0, y = 0;
432
433 Short_t halign = align / 10;
434 Short_t valign = align - 10 * halign;
435
436 switch(halign) {
437 case 0: x = bounding_box.left(); break;
438 case 1: x = 0; break;
439 case 2: x = bounding_box.horizontal_center(); break;
440 case 3: x = bounding_box.right(); break;
441 }
442 switch(valign) {
443 case 0: y = bounding_box.bottom(); break;
444 case 1: y = 0; break;
445 case 2: y = bounding_box.vertical_center(); break;
446 case 3: y = bounding_box.top(); break;
447 }
448 fRenderer->transform_pad(x0, y0, x, y);
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// Get the text width and height.
453
455{
456 if (!gPad) return;
457 const TString newText = GetTitle();
458 const Int_t length = newText.Length();
459 const Char_t *text = newText.Data();
460
461 Double_t x0;
462 Double_t y0;
463 Double_t x1;
464 Double_t y1;
466
467 GetSize(x0, y0, x1, y1, size, 0, text, length);
468 w = (UInt_t)(TMath::Abs(gPad->XtoAbsPixel(x1) - gPad->XtoAbsPixel(x0)));
469 h = (UInt_t)(TMath::Abs(gPad->YtoAbsPixel(y0) - gPad->YtoAbsPixel(y1)));
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// Get X size.
474
476{
477 const TString newText = GetTitle();
478 const Int_t length = newText.Length();
479 const Char_t *text = newText.Data();
480 const Double_t size = GetTextSize();
481 const Double_t angle = GetTextAngle();
482
483 Double_t x0;
484 Double_t y0;
485 Double_t x1;
486 Double_t y1;
487
488 GetSize(x0, y0, x1, y1, size, angle, text, length);
489
490 return TMath::Abs(x1 - x0);
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Get Y size.
495
497{
498 const TString newText = GetTitle();
499 const Int_t length = newText.Length();
500 const Char_t *text = newText.Data();
501 const Double_t size = GetTextSize();
502 const Double_t angle = GetTextAngle();
503
504 Double_t x0;
505 Double_t y0;
506 Double_t x1;
507 Double_t y1;
508
509 GetSize(x0, y0, x1, y1, size, angle, text, length);
510
511 return TMath::Abs(y0 - y1);
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Make a copy of this object with the new parameters
516/// and copy object attributes.
517
519{
520 TMathText *newtext = new TMathText(x, y, text);
521 TAttText::Copy(*newtext);
522
523 newtext->SetBit(kCanDelete);
524 if (TestBit(kTextNDC)) newtext->SetNDC();
525 newtext->AppendPad();
526
527 return newtext;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531/// Paint text.
532
534{
535 if (!gPad) return;
536 Double_t xsave = fX;
537 Double_t ysave = fY;
538
539 if (TestBit(kTextNDC)) {
540 fX = gPad->GetX1() + xsave * (gPad->GetX2() - gPad->GetX1());
541 fY = gPad->GetY1() + ysave * (gPad->GetY2() - gPad->GetY1());
543 } else {
544 PaintMathText(gPad->XtoPad(fX), gPad->YtoPad(fY),
546 }
547 fX = xsave;
548 fY = ysave;
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Paint text (used by Paint()).
553
555 Double_t size, const Char_t *text1)
556{
557 if (!gPad) return;
558 Double_t saveSize = size;
559 Int_t saveFont = fTextFont;
560 Short_t saveAlign = fTextAlign;
561
563 if (auto ps = gPad->GetPainter()->GetPS()) { // Initialise TMathTextRenderer
564 if (ps->InheritsFrom("TImageDump")) gPad->PaintText(0, 0, "");
565 }
566
567 // Do not use Latex if font is low precision.
568 if (fTextFont % 10 < 2) {
569 gPad->GetPainter()->SetTextAngle(angle);
570 gPad->PaintText(x, y, text1);
571 return;
572 }
573
574 if (fTextFont % 10 > 2) {
575 UInt_t w = TMath::Abs(gPad->XtoAbsPixel(gPad->GetX2()) -
576 gPad->XtoAbsPixel(gPad->GetX1()));
577 UInt_t h = TMath::Abs(gPad->YtoAbsPixel(gPad->GetY2()) -
578 gPad->YtoAbsPixel(gPad->GetY1()));
579 size = size / std::min(w, h);
580 SetTextFont(10 * (saveFont / 10) + 2);
581 }
582
583 TString newText = text1;
584
585 if (newText.Length() == 0) return;
586
587 // Compatibility with TLatex and Latex
588 newText.ReplaceAll("\\omicron","o");
589 newText.ReplaceAll("\\Alpha","A");
590 newText.ReplaceAll("\\Beta","B");
591 newText.ReplaceAll("\\Epsilon","E");
592 newText.ReplaceAll("\\Zeta","Z");
593 newText.ReplaceAll("\\Eta","H");
594 newText.ReplaceAll("\\Iota","I");
595 newText.ReplaceAll("\\Kappa","K");
596 newText.ReplaceAll("\\Mu","M");
597 newText.ReplaceAll("\\Nu","N");
598 newText.ReplaceAll("\\Omicron","O");
599 newText.ReplaceAll("\\Rho","P");
600 newText.ReplaceAll("\\Tau","T");
601 newText.ReplaceAll("\\Chi","X");
602 newText.ReplaceAll("\\varomega","\\varpi");
603 newText.ReplaceAll("\\mbox","\\hbox");
604 newText.ReplaceAll("\\bar","\\wwbar");
605 if (newText.Contains("\\frac")) {
606 Int_t len,i1,i2;
607 TString str;
608 while (newText.Contains("\\frac")) {
609 len = newText.Length();
610 i1 = newText.Index("\\frac");
611 str = newText(i1,len).Data();
612 i2 = str.Index("}{");
613 newText.Replace(i1+i2,2," \\over ");
614 newText.Remove(i1,5);
615 }
616 }
617 if (newText.Contains("\\splitline")) {
618 Int_t len,i1,i2;
619 TString str;
620 while (newText.Contains("\\splitline")) {
621 len = newText.Length();
622 i1 = newText.Index("\\splitline");
623 str = newText(i1,len).Data();
624 i2 = str.Index("}{");
625 newText.Replace(i1+i2,2," \\atop ");
626 newText.Remove(i1,10);
627 }
628 }
629
630 const Int_t length = newText.Length();
631 const Char_t *text = newText.Data();
632 Double_t x0;
633 Double_t y0;
635
636 Render(x - x0, y - y0, size, angle, text, length);
637
638 SetTextSize(saveSize);
639 SetTextFont(saveFont);
640 SetTextAlign(saveAlign);
641}
642
643////////////////////////////////////////////////////////////////////////////////
644/// Save primitive as a C++ statement(s) on output stream out
645
646void TMathText::SavePrimitive(std::ostream &out, Option_t *option)
647{
649 out, Class(), "mathtex",
650 TString::Format("%g, %g, \"%s\"", fX, fY, TString(GetTitle()).ReplaceSpecialCppChars().Data()), kFALSE);
651
652 if (TestBit(kTextNDC))
653 out << " mathtex->SetNDC();\n";
654
655 SaveTextAttributes(out, "mathtex", 11, 0, 1, 42, 0.05);
656 SaveFillAttributes(out, "mathtex", 0, 1001);
657
658 SavePrimitiveDraw(out, "mathtex", option);
659}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char * ret
Definition Rotated.cxx:221
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
short Font_t
Font number (short).
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short).
Definition RtypesCore.h:53
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
constexpr Double_t kPI
Definition TEllipse.cxx:24
Option_t Option_t option
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t SetTextSize
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 offset
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 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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint angle
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
#define gPad
void Copy(TAttFill &attfill) const
virtual void Modify()
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
Color_t fTextColor
Text color.
Definition TAttText.h:27
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:36
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
Font_t fTextFont
Text font.
Definition TAttText.h:28
virtual void ModifyOn(TVirtualPad &pad)
virtual Float_t GetTextSizePercent(Float_t size)
Return the text in percent of the pad size.
Short_t fTextAlign
Text alignment.
Definition TAttText.h:26
void Copy(TAttText &atttext) const
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1)
virtual void Modify()
friend class TMathTextRenderer
Definition TMathText.h:22
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
Double_t GetYsize()
TMathText & operator=(const TMathText &)
void GetSize(Double_t &x0, Double_t &y0, Double_t &x1, Double_t &y1, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length)
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
TMathTextRenderer * fRenderer
!TMathText Painter
Definition TMathText.h:24
static TClass * Class()
Double_t GetXsize()
void GetAlignPoint(Double_t &x0, Double_t &y0, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length, const Short_t align)
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void Render(const Double_t x, const Double_t y, const Double_t size, const Double_t angle, const Char_t *t, const Int_t length)
~TMathText() override
TMathText * DrawMathText(Double_t x, Double_t y, const char *text)
void Copy(TObject &text) const override
Copy this to obj.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:204
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:845
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:777
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
Ssiz_t Length() const
Definition TString.h:425
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:703
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
TString & Remove(Ssiz_t pos)
Definition TString.h:694
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2385
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660
Definition TText.h:22
Double_t fY
Y position of text (left,center,etc..).
Definition TText.h:26
void Copy(TObject &text) const override
Copy this to obj.
TText & operator=(const TText &src)
virtual void SetNDC(Bool_t isNDC=kTRUE)
Double_t fX
X position of text (left,center,etc..).
Definition TText.h:25
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
RooArgList L(Args_t &&... args)
Definition RooArgList.h:156
constexpr Double_t Pi()
Definition TMath.h:40
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122