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