Logo ROOT  
Reference Guide
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 "TVirtualPS.h"
22#include "TVirtualX.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/graphics/tmathtext.C
40End_Macro
41
42The list of all available symbols is given in the following example:
43
44Begin_Macro
45../../../tutorials/graphics/tmathtext2.C
46End_Macro
47
48#### Limitation:
49TMathText rendering is not implemented for the PDF output.
50PostScript output should be used instead.
51*/
53const Double_t kPI = TMath::Pi();
55class TMathTextRenderer : public TText, public TAttFill,
56 public mathtext::math_text_renderer_t {
57private:
60 float _x0;
61 float _y0;
69 float _current_font_size[mathtext::math_text_renderer_t::NFAMILY];
70 inline size_t root_face_number(
71 const unsigned int family, const bool serif = false) const
72 {
73 static const int precision = 2;
74
75 if (family >= mathtext::math_text_renderer_t::
76 FAMILY_REGULAR &&
77 family <= mathtext::math_text_renderer_t::
78 FAMILY_BOLD_ITALIC) {
79 const unsigned int offset = family -
80 mathtext::math_text_renderer_t::FAMILY_REGULAR;
81 return serif ?
82 ((offset == 0 ? 13 : offset) * 10 + precision) :
83 ((offset + 4) * 10 + precision);
84 } else if (family >= mathtext::math_text_renderer_t::
85 FAMILY_STIX_REGULAR) {
86 const unsigned int offset = family -
87 mathtext::math_text_renderer_t::FAMILY_STIX_REGULAR;
88 return (offset + 16) * 10 + precision;
89 }
90
91 return precision;
92 }
93 inline bool is_cyrillic_or_cjk(const wchar_t c) const
94 {
95 return mathtext::math_text_renderer_t::is_cyrillic(c) ||
96 mathtext::math_text_renderer_t::is_cjk(c);
97 }
98 inline size_t root_cjk_face_number(
99 const bool serif = false) const
100 {
101 return (serif ? 28 : 29) * 10 + 2;
102 }
103protected:
104 inline mathtext::affine_transform_t
105 transform_logical_to_pixel(void) const override
106 {
107 return mathtext::affine_transform_t::identity;
108 }
109 inline mathtext::affine_transform_t
110 transform_pixel_to_logical(void) const override
111 {
112 return mathtext::affine_transform_t::identity;
113 }
114public:
115 inline TMathTextRenderer(TMathText *parent)
116 : TText(), TAttFill(0, 1001),
117 _parent(parent), _font_size(0), _angle_degree(0)
118 {
119 int i;
120 _font_size = 0;
121 _x0 = 0;
122 _y0 = 0;
123 _angle_degree = 0;
124 for (i = 0; i<6; i++) _pad_pixel_transform[i] = 0;
125 _pad_scale = 0;
126 _pad_scale_x = 0;
127 _pad_scale_y = 0;
130 for (i = 0; i < mathtext::math_text_renderer_t::NFAMILY; i++) _current_font_size[i] = 0;
131 }
132 inline float
133 font_size(const unsigned int family = FAMILY_PLAIN) const override
134 {
135 return _current_font_size[family];
136 }
137 inline void
138 point(const float /*x*/, const float /*y*/) override
139 {
140 }
141 inline void
142 set_font_size(const float size, const unsigned int family) override
143 {
144 _current_font_size[family] = size;
145 }
146 inline void
147 set_font_size(const float size) override
148 {
151 _current_font_size + NFAMILY, size);
152 }
153 inline void
154 reset_font_size(const unsigned int /*family*/) override
155 {
156 }
157 inline void
158 set_parameter(const float x, const float y, const float size,
159 const float angle_degree)
160 {
161 _x0 = gPad->XtoAbsPixel(x);
162 _y0 = gPad->YtoAbsPixel(y);
164 gPad->XtoPixel(gPad->GetX2()) -
165 gPad->XtoPixel(gPad->GetX1());
167 gPad->YtoPixel(gPad->GetY1()) -
168 gPad->YtoPixel(gPad->GetY2());
170
171 _angle_degree = angle_degree;
172
173 const float angle_radiant = _angle_degree * (kPI / 180.0);
174
175 // Initialize the affine transform
176 _pad_pixel_transform[0] = _pad_scale * cosf(angle_radiant);
177 _pad_pixel_transform[1] = -_pad_scale * sinf(angle_radiant);
182
186 }
187 inline void
188 transform_pad(double &xt, double &yt,
189 const float x, const float y) const
190 {
191 xt = gPad->AbsPixeltoX(Int_t(
194 yt = gPad->AbsPixeltoY(Int_t(
197 }
198 inline void
199 filled_rectangle(const mathtext::bounding_box_t &bounding_box_0) override
200 {
202 SetFillStyle(1001);
204
205 double xt[4];
206 double yt[4];
207
208 transform_pad(xt[0], yt[0],
209 bounding_box_0.left(),
210 bounding_box_0.bottom());
211 transform_pad(xt[1], yt[1],
212 bounding_box_0.right(),
213 bounding_box_0.bottom());
214 transform_pad(xt[2], yt[2],
215 bounding_box_0.right(),
216 bounding_box_0.top());
217 transform_pad(xt[3], yt[3],
218 bounding_box_0.left(),
219 bounding_box_0.top());
220 gPad->PaintFillArea(4, xt, yt);
221 }
222 inline void
223 rectangle(const mathtext::bounding_box_t &/*bounding_box*/) override
224 {
225 }
226 inline mathtext::bounding_box_t
227 bounding_box(const wchar_t character, float &current_x,
228 const unsigned int family)
229 {
230 const size_t old_font_index = TTF::fgCurFontIdx;
231 const bool cyrillic_or_cjk = is_cyrillic_or_cjk(character);
232
233 if (cyrillic_or_cjk) {
235 } else {
237 }
238 FT_Load_Glyph(
240 FT_Get_Char_Index(
241 TTF::fgFace[TTF::fgCurFontIdx], character),
242 FT_LOAD_NO_SCALE);
243
244 const float scale = _current_font_size[family] /
245 TTF::fgFace[TTF::fgCurFontIdx]->units_per_EM;
246 const FT_Glyph_Metrics metrics =
247 TTF::fgFace[TTF::fgCurFontIdx]->glyph->metrics;
248 const float lower_left_x = metrics.horiBearingX;
249 const float lower_left_y =
250 metrics.horiBearingY - metrics.height;
251 const float upper_right_x =
252 metrics.horiBearingX + metrics.width;
253 const float upper_right_y = metrics.horiBearingY;
254 const float advance = metrics.horiAdvance;
255 const float margin = std::max(0.0F, lower_left_x);
256 const float italic_correction =
257 upper_right_x <= advance ? 0.0F :
258 std::max(0.0F, upper_right_x + margin - advance);
259 const mathtext::bounding_box_t ret =
260 mathtext::bounding_box_t(
261 lower_left_x, lower_left_y,
262 upper_right_x, upper_right_y,
263 advance, italic_correction) * scale;
264
265 current_x += ret.advance();
266 TTF::fgCurFontIdx = old_font_index;
267
268 return ret;
269 }
270 inline mathtext::bounding_box_t
271 bounding_box(const std::wstring string,
272 const unsigned int family = FAMILY_PLAIN) override
273 {
274 if (TTF::fgCurFontIdx<0) return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
275 if (string.empty() || TTF::fgFace[TTF::fgCurFontIdx] == NULL ||
276 TTF::fgFace[TTF::fgCurFontIdx]->units_per_EM == 0) {
277 return mathtext::bounding_box_t(0, 0, 0, 0, 0, 0);
278 }
279
280 std::wstring::const_iterator iterator = string.begin();
281 float current_x = 0;
282 mathtext::bounding_box_t ret =
283 bounding_box(*iterator, current_x, family);
284
285 ++iterator;
286 for (; iterator != string.end(); ++iterator) {
287 const mathtext::point_t position =
288 mathtext::point_t(current_x, 0);
289 const mathtext::bounding_box_t glyph_bounding_box =
290 bounding_box(*iterator, current_x, family);
291 ret = ret.merge(position + glyph_bounding_box);
292 }
293
294 return ret;
295 }
296 inline void
297 text_raw(const float x, const float y,
298 const std::wstring string,
299 const unsigned int family = FAMILY_PLAIN) override
300 {
304
305 wchar_t buf[2];
306 float advance = 0;
307
308 buf[1] = L'\0';
309 for (std::wstring::const_iterator iterator = string.begin(); iterator != string.end(); ++iterator) {
310 buf[0] = *iterator;
311 const bool cyrillic_or_cjk = is_cyrillic_or_cjk(buf[0]);
312
313 if (cyrillic_or_cjk) {
316 }
317
318 const mathtext::bounding_box_t b =
319 bounding_box(buf, family);
320 double xt;
321 double yt;
322
323 transform_pad(xt, yt, x + advance, y);
324 gPad->PaintText(xt, yt, buf);
325 advance += b.advance();
326 if (cyrillic_or_cjk) {
329 }
330 }
331 }
332 inline void
333 text_with_bounding_box(const float /*x*/, const float /*y*/,
334 const std::wstring /*string*/,
335 const unsigned int /*family = FAMILY_PLAIN*/) override
336 {
337 }
338 using mathtext::math_text_renderer_t::bounding_box;
339};
340
342
343////////////////////////////////////////////////////////////////////////////////
344/// Default constructor.
347 : TAttFill(0, 1001)
348{
349 fRenderer = new TMathTextRenderer(this);
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Normal constructor.
356 : TText(x, y, text), TAttFill(0, 1001)
357{
358 fRenderer = new TMathTextRenderer(this);
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Destructor.
365{
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Copy constructor.
373{
374 ((TMathText &)text).Copy(*this);
375 fRenderer = new TMathTextRenderer(this);
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// Assignment operator.
382{
383 if (this != &rhs) {
386 }
387 return *this;
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Copy.
393void TMathText::Copy(TObject &obj) const
394{
395 ((TMathText &)obj).fRenderer = fRenderer;
396 TText::Copy(obj);
397 TAttFill::Copy((TAttFill &)obj);
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Render the text.
403void TMathText::
404Render(const Double_t x, const Double_t y, const Double_t size,
405 const Double_t angle, const Char_t *t, const Int_t /*length*/)
406{
407 const mathtext::math_text_t math_text(t);
409
410 renderer->set_parameter(x, y, size, angle);
411 renderer->text(0, 0, math_text);
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Get the text bounding box.
417void TMathText::
419 const Double_t size, const Double_t angle, const Char_t *t,
420 const Int_t /*length*/)
421{
422 const mathtext::math_text_t math_text(t);
424
425 renderer->set_parameter(0, 0, size, angle);
426
427 const mathtext::bounding_box_t bounding_box =
428 renderer->bounding_box(math_text);
429 double x[4];
430 double y[4];
431
432 renderer->transform_pad(
433 x[0], y[0], bounding_box.left(), bounding_box.bottom());
434 renderer->transform_pad(
435 x[1], y[1], bounding_box.right(), bounding_box.bottom());
436 renderer->transform_pad(
437 x[2], y[2], bounding_box.right(), bounding_box.top());
438 renderer->transform_pad(
439 x[3], y[3], bounding_box.left(), bounding_box.top());
440
441 x0 = std::min(std::min(x[0], x[1]), std::min(x[2], x[3]));
442 y0 = std::min(std::min(y[0], y[1]), std::min(y[2], y[3]));
443 x1 = std::max(std::max(x[0], x[1]), std::max(x[2], x[3]));
444 y1 = std::max(std::max(y[0], y[1]), std::max(y[2], y[3]));
445}
446
447////////////////////////////////////////////////////////////////////////////////
448/// Alignment.
450void TMathText::
452 const Double_t size, const Double_t angle,
453 const Char_t *t, const Int_t /*length*/,
454 const Short_t align)
455{
456 const mathtext::math_text_t math_text(t);
458
459 renderer->set_parameter(0, 0, size, angle);
460
461 const mathtext::bounding_box_t bounding_box =
462 renderer->bounding_box(math_text);
463 float x = 0;
464 float y = 0;
465
466 Short_t halign = align / 10;
467 Short_t valign = align - 10 * halign;
468
469 switch(halign) {
470 case 0: x = bounding_box.left(); break;
471 case 1: x = 0; break;
472 case 2: x = bounding_box.horizontal_center(); break;
473 case 3: x = bounding_box.right(); break;
474 }
475 switch(valign) {
476 case 0: y = bounding_box.bottom(); break;
477 case 1: y = 0; break;
478 case 2: y = bounding_box.vertical_center(); break;
479 case 3: y = bounding_box.top(); break;
480 }
481 renderer->transform_pad(x0, y0, x, y);
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Get the text width and height.
488{
489 const TString newText = GetTitle();
490 const Int_t length = newText.Length();
491 const Char_t *text = newText.Data();
492
493 Double_t x0;
494 Double_t y0;
495 Double_t x1;
496 Double_t y1;
498
499 GetSize(x0, y0, x1, y1, size, 0, text, length);
500 w = (UInt_t)(TMath::Abs(gPad->XtoAbsPixel(x1) - gPad->XtoAbsPixel(x0)));
501 h = (UInt_t)(TMath::Abs(gPad->YtoAbsPixel(y0) - gPad->YtoAbsPixel(y1)));
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Get X size.
508{
509 const TString newText = GetTitle();
510 const Int_t length = newText.Length();
511 const Char_t *text = newText.Data();
512 const Double_t size = GetTextSize();
513 const Double_t angle = GetTextAngle();
514
515 Double_t x0;
516 Double_t y0;
517 Double_t x1;
518 Double_t y1;
519
520 GetSize(x0, y0, x1, y1, size, angle, text, length);
521
522 return TMath::Abs(x1 - x0);
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// Get Y size.
529{
530 const TString newText = GetTitle();
531 const Int_t length = newText.Length();
532 const Char_t *text = newText.Data();
533 const Double_t size = GetTextSize();
534 const Double_t angle = GetTextAngle();
535
536 Double_t x0;
537 Double_t y0;
538 Double_t x1;
539 Double_t y1;
540
541 GetSize(x0, y0, x1, y1, size, angle, text, length);
542
543 return TMath::Abs(y0 - y1);
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Make a copy of this object with the new parameters
548/// and copy object attributes.
551{
552 TMathText *newtext = new TMathText(x, y, text);
553 TAttText::Copy(*newtext);
554
555 newtext->SetBit(kCanDelete);
556 if (TestBit(kTextNDC)) newtext->SetNDC();
557 newtext->AppendPad();
558
559 return newtext;
560}
561
562////////////////////////////////////////////////////////////////////////////////
563/// Paint text.
566{
567 Double_t xsave = fX;
568 Double_t ysave = fY;
569
570 if (TestBit(kTextNDC)) {
571 fX = gPad->GetX1() + xsave * (gPad->GetX2() - gPad->GetX1());
572 fY = gPad->GetY1() + ysave * (gPad->GetY2() - gPad->GetY1());
574 } else {
575 PaintMathText(gPad->XtoPad(fX), gPad->YtoPad(fY),
577 }
578 fX = xsave;
579 fY = ysave;
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Paint text (used by Paint()).
586 Double_t size, const Char_t *text1)
587{
588 Double_t saveSize = size;
589 Int_t saveFont = fTextFont;
590 Short_t saveAlign = fTextAlign;
591
593 if (gVirtualPS) { // Initialise TMathTextRenderer
594 if (gPad->IsBatch()) {
595 if (gVirtualPS->InheritsFrom("TImageDump")) gPad->PaintText(0, 0, "");
596 }
597 }
598
599 // Do not use Latex if font is low precision.
600 if (fTextFont % 10 < 2) {
601 if (gVirtualX) {
602 gVirtualX->SetTextAngle(angle);
603 }
604 if (gVirtualPS) {
606 }
607 gPad->PaintText(x, y, text1);
608 return;
609 }
610
611 if (fTextFont % 10 > 2) {
612 UInt_t w = TMath::Abs(gPad->XtoAbsPixel(gPad->GetX2()) -
613 gPad->XtoAbsPixel(gPad->GetX1()));
614 UInt_t h = TMath::Abs(gPad->YtoAbsPixel(gPad->GetY2()) -
615 gPad->YtoAbsPixel(gPad->GetY1()));
616 size = size / std::min(w, h);
617 SetTextFont(10 * (saveFont / 10) + 2);
618 }
619
620 TString newText = text1;
621
622 if (newText.Length() == 0) return;
623
624 // Compatibility with TLatex and Latex
625 newText.ReplaceAll("\\omicron","o");
626 newText.ReplaceAll("\\Alpha","A");
627 newText.ReplaceAll("\\Beta","B");
628 newText.ReplaceAll("\\Epsilon","E");
629 newText.ReplaceAll("\\Zeta","Z");
630 newText.ReplaceAll("\\Eta","H");
631 newText.ReplaceAll("\\Iota","I");
632 newText.ReplaceAll("\\Kappa","K");
633 newText.ReplaceAll("\\Mu","M");
634 newText.ReplaceAll("\\Nu","N");
635 newText.ReplaceAll("\\Omicron","O");
636 newText.ReplaceAll("\\Rho","P");
637 newText.ReplaceAll("\\Tau","T");
638 newText.ReplaceAll("\\Chi","X");
639 newText.ReplaceAll("\\varomega","\\varpi");
640 newText.ReplaceAll("\\mbox","\\hbox");
641 newText.ReplaceAll("\\bar","\\wwbar");
642 if (newText.Contains("\\frac")) {
643 Int_t len,i1,i2;
644 TString str;
645 while (newText.Contains("\\frac")) {
646 len = newText.Length();
647 i1 = newText.Index("\\frac");
648 str = newText(i1,len).Data();
649 i2 = str.Index("}{");
650 newText.Replace(i1+i2,2," \\over ");
651 newText.Remove(i1,5);
652 }
653 }
654 if (newText.Contains("\\splitline")) {
655 Int_t len,i1,i2;
656 TString str;
657 while (newText.Contains("\\splitline")) {
658 len = newText.Length();
659 i1 = newText.Index("\\splitline");
660 str = newText(i1,len).Data();
661 i2 = str.Index("}{");
662 newText.Replace(i1+i2,2," \\atop ");
663 newText.Remove(i1,10);
664 }
665 }
666
667 const Int_t length = newText.Length();
668 const Char_t *text = newText.Data();
669 Double_t x0;
670 Double_t y0;
672
673 Render(x - x0, y - y0, size, angle, text, length);
674
675 SetTextSize(saveSize);
676 SetTextFont(saveFont);
677 SetTextAlign(saveAlign);
678}
679
680////////////////////////////////////////////////////////////////////////////////
681/// Save primitive as a C++ statement(s) on output stream out
683void TMathText::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
684{
685 const char quote = '"';
686
687 if (gROOT->ClassSaved(TMathText::Class())) {
688 out << " ";
689 } else {
690 out << " TMathText *";
691 }
692
693 TString s = GetTitle();
694
695 s.ReplaceAll("\\","\\\\");
696 s.ReplaceAll("\"","\\\"");
697 out << "mathtex = new TMathText("<< fX << "," << fY << ","
698 << quote << s.Data() << quote << ");" << std::endl;
699 if (TestBit(kTextNDC)) {
700 out << "mathtex->SetNDC();" << std::endl;
701 }
702
703 SaveTextAttributes(out, "mathtex", 11, 0, 1, 42, 0.05);
704 SaveFillAttributes(out, "mathtex", 0, 1001);
705
706 out<<" mathtex->Draw();" << std::endl;
707}
#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
int Int_t
Definition: RtypesCore.h:45
char Char_t
Definition: RtypesCore.h:37
unsigned int UInt_t
Definition: RtypesCore.h:46
short Font_t
Definition: RtypesCore.h:88
short Short_t
Definition: RtypesCore.h:39
double Double_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:375
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 b
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 TPoint TPoint angle
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
const Double_t kPI
Definition: TMathText.cxx:52
Binding & operator=(OUT(*fun)(void))
#define gROOT
Definition: TROOT.h:404
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:81
#define gPad
Definition: TVirtualPad.h:288
#define gVirtualX
Definition: TVirtualX.h:338
Fill Area Attributes class.
Definition: TAttFill.h:19
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:204
virtual void Modify()
Change current fill area attributes if necessary.
Definition: TAttFill.cxx:213
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition: TAttFill.cxx:236
virtual Float_t GetTextSize() const
Return the text size.
Definition: TAttText.h:36
virtual void Modify()
Change current text attributes if necessary.
Definition: TAttText.cxx:334
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:42
Color_t fTextColor
Text color.
Definition: TAttText.h:24
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition: TAttText.h:43
virtual Float_t GetTextAngle() const
Return the text angle.
Definition: TAttText.h:33
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:46
Font_t fTextFont
Text font.
Definition: TAttText.h:25
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)
Save text attributes as C++ statement(s) on output stream out.
Definition: TAttText.cxx:375
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:47
virtual Float_t GetTextSizePercent(Float_t size)
Return the text in percent of the pad size.
Definition: TAttText.cxx:315
Short_t fTextAlign
Text alignment.
Definition: TAttText.h:23
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
Definition: TAttText.cxx:299
void set_font_size(const float size, const unsigned int family) override
Definition: TMathText.cxx:141
float _current_font_size[mathtext::math_text_renderer_t::NFAMILY]
Definition: TMathText.cxx:68
void text_raw(const float x, const float y, const std::wstring string, const unsigned int family=FAMILY_PLAIN) override
Definition: TMathText.cxx:296
void text_with_bounding_box(const float, const float, const std::wstring, const unsigned int) override
Definition: TMathText.cxx:332
float _pad_pixel_transform[6]
Definition: TMathText.cxx:62
float _pad_scale_x_relative
Definition: TMathText.cxx:66
TMathTextRenderer(TMathText *parent)
Definition: TMathText.cxx:114
float font_size(const unsigned int family=FAMILY_PLAIN) const override
Definition: TMathText.cxx:132
TMathText * _parent
Definition: TMathText.cxx:57
mathtext::affine_transform_t transform_pixel_to_logical(void) const override
Definition: TMathText.cxx:109
size_t root_cjk_face_number(const bool serif=false) const
Definition: TMathText.cxx:97
bool is_cyrillic_or_cjk(const wchar_t c) const
Definition: TMathText.cxx:92
size_t root_face_number(const unsigned int family, const bool serif=false) const
Definition: TMathText.cxx:69
mathtext::bounding_box_t bounding_box(const wchar_t character, float &current_x, const unsigned int family)
Definition: TMathText.cxx:226
void reset_font_size(const unsigned int) override
Definition: TMathText.cxx:153
void point(const float, const float) override
Definition: TMathText.cxx:137
void rectangle(const mathtext::bounding_box_t &) override
Definition: TMathText.cxx:222
void transform_pad(double &xt, double &yt, const float x, const float y) const
Definition: TMathText.cxx:187
void set_parameter(const float x, const float y, const float size, const float angle_degree)
Definition: TMathText.cxx:157
mathtext::affine_transform_t transform_logical_to_pixel(void) const override
Definition: TMathText.cxx:104
float _pad_scale_y_relative
Definition: TMathText.cxx:67
void filled_rectangle(const mathtext::bounding_box_t &bounding_box_0) override
Definition: TMathText.cxx:198
To draw TeX Mathematical Formula.
Definition: TMathText.h:19
friend class TMathTextRenderer
Definition: TMathText.h:51
void Paint(Option_t *option="") override
Paint text.
Definition: TMathText.cxx:564
Double_t GetYsize()
Get Y size.
Definition: TMathText.cxx:527
TMathText & operator=(const TMathText &)
TMathText Painter.
Definition: TMathText.cxx:380
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)
Get the text bounding box.
Definition: TMathText.cxx:417
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Get the text width and height.
Definition: TMathText.cxx:486
void * fRenderer
Definition: TMathText.h:21
static TClass * Class()
Double_t GetXsize()
Get X size.
Definition: TMathText.cxx:506
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)
Alignment.
Definition: TMathText.cxx:450
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition: TMathText.cxx:682
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)
Render the text.
Definition: TMathText.cxx:403
virtual ~TMathText()
Destructor.
Definition: TMathText.cxx:363
TMathText * DrawMathText(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters and copy object attributes.
Definition: TMathText.cxx:549
TMathText()
Default constructor.
Definition: TMathText.cxx:345
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Paint text (used by Paint()).
Definition: TMathText.cxx:584
@ kTextNDC
Definition: TMathText.h:37
void Copy(TObject &text) const override
Copy.
Definition: TMathText.cxx:392
const char * GetTitle() const override
Returns title of object.
Definition: TNamed.h:48
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:107
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition: TString.h:682
const char * Data() const
Definition: TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
static FT_Face fgFace[kTTMaxFonts]
font face
Definition: TTF.h:82
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TTF.cxx:491
static Int_t fgCurFontIdx
current font index
Definition: TTF.h:78
Base class for several text objects.
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 text to text.
Definition: TText.cxx:107
TText & operator=(const TText &src)
Assignment operator.
Definition: TText.cxx:98
Double_t fX
X position of text (left,center,etc..)
Definition: TText.h:25
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition: TText.cxx:813
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s
static constexpr double L
constexpr Double_t Pi()
Definition: TMath.h:37
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition: TMathBase.h:123
fill
Definition: fit1_py.py:6