466 latex.TLatex::Copy(*
this);
476 TAttLine::operator=(lt);
518 pad->
AbsPixeltoXY( cos_angle * (
x[
n]-xOrigin) + sin_angle * (
y[
n]-yOrigin) + xOrigin,
519 -sin_angle * (
x[
n]-xOrigin) + cos_angle * (
y[
n]-yOrigin) + yOrigin,
573 const char *tab[] = {
"alpha",
"beta",
"chi",
"delta",
"varepsilon",
"phi",
"gamma",
"eta",
"iota",
"varphi",
"kappa",
"lambda",
574 "mu",
"nu",
"omicron",
"pi",
"theta",
"rho",
"sigma",
"tau",
"upsilon",
"varomega",
"omega",
"xi",
"psi",
"zeta",
575 "Alpha",
"Beta",
"Chi",
"Delta",
"Epsilon",
"Phi",
"Gamma",
"Eta",
"Iota",
"vartheta",
576 "Kappa",
"Lambda",
"Mu",
"Nu",
"Omicron",
"Pi",
"Theta",
"Rho",
"Sigma",
"Tau",
577 "Upsilon",
"varsigma",
"Omega",
"Xi",
"Psi",
"Zeta",
"varUpsilon",
"epsilon"};
579 const char *
tab2[] = {
"leq",
"/",
"infty",
"voidb",
"club",
"diamond",
"heart",
580 "spade",
"leftrightarrow",
"leftarrow",
"uparrow",
"rightarrow",
581 "downarrow",
"circ",
"pm",
"doublequote",
"geq",
"times",
"propto",
582 "partial",
"bullet",
"divide",
"neq",
"equiv",
"approx",
"3dots",
583 "cbar",
"topbar",
"downleftarrow",
"aleph",
"Jgothic",
"Rgothic",
"voidn",
584 "otimes",
"oplus",
"oslash",
"cap",
"cup",
"supset",
"supseteq",
585 "notsubset",
"subset",
"subseteq",
"in",
"notin",
"angle",
"nabla",
586 "oright",
"ocopyright",
"trademark",
"prod",
"surd",
"upoint",
"corner",
"wedge",
587 "vee",
"Leftrightarrow",
"Leftarrow",
"Uparrow",
"Rightarrow",
588 "Downarrow",
"diamond",
"LT",
"void1",
"copyright",
"void3",
"sum",
589 "arctop",
"lbar",
"arcbottom",
"topbar",
"void8",
"bottombar",
"arcbar",
590 "ltbar",
"AA",
"aa",
"void06",
"GT",
"int",
"forall",
"exists",
"textendash",
"textemdash" };
592 const char *
tab3[] = {
"bar",
"vec",
"dot",
"hat",
"ddot",
"acute",
"grave",
"check",
"tilde",
"slash"};
596 Int_t nBlancDeb = 0, nBlancFin = 0, l_nBlancDeb = 0, l_nBlancFin = 0;
598 Int_t min = 0, max = 0;
609 if (nBlancDeb==l_nBlancDeb && nBlancFin==l_nBlancFin) cont =
kFALSE;
612 if (t[nBlancDeb]==
'{' && t[
length-nBlancFin-1]==
'}') {
615 for(i=nBlancDeb;i<
length-nBlancFin;i++) {
616 if (t[i] ==
'{' && !(i>0 && t[i-1] ==
'@')) nBrackets++;
617 if (t[i] ==
'}' && t[i-1]!=
'@') nBrackets--;
618 if (nBrackets==0 && i<
length-nBlancFin-2) {
634 l_nBlancDeb = nBlancDeb;
635 l_nBlancFin = nBlancFin;
640 length -= nBlancFin+nBlancDeb;
642 Error(
"Analyse",
"It seems there is a syntax error in the TLatex string");
652 indiceSize = spec.
fSize;
655 specNewSize.
fSize = indiceSize;
664 Int_t opCurlyCurly = -1;
665 Int_t opSquareCurly = -1;
666 Int_t opCloseCurly = -2;
674 Int_t opSquareBracket = 0 ;
675 Int_t opBigCurly = 0 ;
678 Int_t abovePlace = 0 ;
686 Int_t opBackslash = 0;
687 Int_t opParallel = 0;
688 Int_t opSplitLine = -1;
700 case '\'' : quote1 = !quote1 ; break ;
701 case '"' : quote2 = !quote2 ; break ;
707 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets++;
712 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets--;
714 if (i<
length-1)
if (
text[i+1]==
'{' && opCurlyCurly==-1) opCurlyCurly=i;
716 if (
text[i+1]!=
'{' && !(
text[i+2]==
'{' && (
text[i+1]==
'^' ||
text[i+1]==
'_'))
717 && opCloseCurly==-2) opCloseCurly=i;
720 if (
text[i+1]!=
'{' && opCloseCurly==-2) opCloseCurly=i;
722 else if (opCloseCurly==-2) opCloseCurly=i;
728 if (!(i>0 &&
text[i-1] ==
'@')) nCroch++;
733 if (!(i>0 &&
text[i-1] ==
'@')) nCroch--;
745 strncpy(buf,&
text[i],2);
746 if (strncmp(buf,
"^{",2)==0) {
747 if (opPower==-1 && nBrackets==0 && nCroch==0) opPower=i;
750 strncpy(buf1,&
text[i-4],4);
751 if (strncmp(buf1,
"#int",4)==0) {
753 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
755 if (strncmp(buf1,
"#sum",4)==0) {
757 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
761 if (strncmp(buf,
"_{",2)==0) {
762 if (opUnder==-1 && nBrackets==0 && nCroch==0) opUnder=i;
765 strncpy(buf2,&
text[i-4],4);
766 if (strncmp(buf2,
"#int",4)==0) {
768 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
770 if (strncmp(buf2,
"#sum",4)==0) {
772 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
776 if (strncmp(buf,
"]{",2)==0)
777 if (opSquareCurly==-1 && nBrackets==0 && nCroch==0) opSquareCurly=i;
780 if (
text[i]==
'\\' || (
text[i]==
'#' && !opFound && nBrackets==0 && nCroch==0)) {
784 strncpy(buf,&
text[i+1],10);
785 if (strncmp(buf,
"splitline{",10)==0) {
786 opSplitLine=i; opFound =
kTRUE;
787 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
793 strncpy(buf,&
text[i+1],9);
794 if (!opBackslash && strncmp(buf,
"backslash",9)==0) {
795 opBackslash=1; opFound =
kTRUE;
796 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
802 strncpy(buf,&
text[i+1],8);
803 if (!opParallel && strncmp(buf,
"parallel",8)==0) {
804 opParallel=1; opFound =
kTRUE;
805 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
811 strncpy(buf,&
text[i+1],6);
812 if (strncmp(buf,
"lower[",6)==0 || strncmp(buf,
"lower{",6)==0) {
813 opLower=i; opFound =
kTRUE;
814 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
817 if (strncmp(buf,
"scale[",6)==0 || strncmp(buf,
"scale{",6)==0) {
818 opScale=i; opFound =
kTRUE;
819 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
822 if (strncmp(buf,
"color[",6)==0 || strncmp(buf,
"color{",6)==0) {
823 opColor=i; opFound =
kTRUE;
824 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
830 strncpy(buf,&
text[i+1],5);
831 if (strncmp(buf,
"frac{",5)==0) {
832 opFrac=i; opFound =
kTRUE;
833 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
836 if (strncmp(buf,
"sqrt{",5)==0 || strncmp(buf,
"sqrt[",5)==0) {
837 opSqrt=i; opFound =
kTRUE;
838 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
841 if (strncmp(buf,
"font{",5)==0 || strncmp(buf,
"font[",5)==0) {
842 opFont=i; opFound =
kTRUE;
843 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
846 if (strncmp(buf,
"kern[",5)==0 || strncmp(buf,
"kern{",5)==0) {
847 opKern=i; opFound =
kTRUE;
848 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
851 if (!opMinus && strncmp(buf,
"minus",5)==0) {
852 opMinus=1; opFound =
kTRUE;
853 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
856 if (strncmp(buf,
"mbox[",5)==0 || strncmp(buf,
"mbox{",5)==0) {
857 opMbox=i; opFound =
kTRUE;
858 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
864 strncpy(buf,&
text[i+1],4);
865 if (!opOdot && strncmp(buf,
"odot",4)==0) {
866 opOdot=1; opFound =
kTRUE;
867 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
870 if (!opHbar && strncmp(buf,
"hbar",4)==0) {
871 opHbar=1; opFound =
kTRUE;
872 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
875 if (!opPerp && strncmp(buf,
"perp",4)==0) {
876 opPerp=1; opFound =
kTRUE;
877 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
880 if (!opPlus && strncmp(buf,
"plus",4)==0) {
881 opPlus=1; opFound =
kTRUE;
882 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
885 if (strncmp(buf,
"url[",4)==0 || strncmp(buf,
"url{",4)==0) {
886 opUrl=i; opFound =
kTRUE;
887 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
893 strncpy(buf,&
text[i+1],3);
895 if (strncmp(buf,
"[]{",3)==0) {
896 opSquareBracket=1; opFound =
kTRUE;
897 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
900 if (strncmp(buf,
"{}{",3)==0 ) {
901 opBigCurly=1; opFound =
kTRUE;
902 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
905 if (strncmp(buf,
"||{",3)==0) {
906 opAbs=1; opFound =
kTRUE;
907 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
910 if (strncmp(buf,
"(){",3)==0) {
911 opParen=1; opFound =
kTRUE;
912 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
915 if (!opBox && strncmp(buf,
"Box",3)==0) {
916 opBox=1; opFound =
kTRUE;
917 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
920 if (strncmp(buf,
"bf[",3)==0 || strncmp(buf,
"bf{",3)==0) {
921 opBf=i; opFound =
kTRUE;
922 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
925 if (strncmp(buf,
"it[",3)==0 || strncmp(buf,
"it{",3)==0) {
926 opIt=i; opFound =
kTRUE;
927 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
933 strncpy(buf,&
text[i+1],2);
934 if (!opMp && strncmp(buf,
"mp",2)==0) {
935 opMp=1; opFound =
kTRUE;
936 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
942 if (strncmp(&
text[i+1],tab[k],strlen(tab[k]))==0) {
945 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
954 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
959 constexpr Int_t lenTab2 =
sizeof(
tab2) /
sizeof(
const char *);
961 for (k = 0; k < lenTab2; k++) {
963 if (strncmp(&
text[i + 1],
tab2[k], strlen(
tab2[k])) == 0) {
964 lastsize = strlen(
tab2[k]);
967 if (i > 0 && opCloseCurly == -2)
968 opCloseCurly = i - 1;
982 if (opCloseCurly>-1 && opCloseCurly<
length-1) {
995 else if (opPower>-1 && opUnder>-1) {
997 max = std::max(opPower,opUnder);
1000 switch (abovePlace) {
1002 prop = .8 ; propU = 1.75 ;
1005 prop = .9 ; propU = 1.75 ;
1014 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
1017 snprintf(&
text[ltext-2],
length-(ltext-2),
"I ") ;
1021 fs2 =
Anal1(specNewSize,
text+min+1,max-min-1);
1033 if (opPower<opUnder) {
1043 Double_t addW1, addW2, addH1, addH2;
1046 if (opPower<opUnder) {
1048 addW1 = (
m-fs2.
Width())/2;
1050 addW2 = (
m-fs3.
Width())/2;
1053 addW1 = (
m-fs2.
Width())/2;
1055 addW2 = (
m-fs3.
Width())/2;
1062 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
1071 if (opPower<opUnder) {
1081 if (opPower<opUnder) {
1090 else if (opPower>-1) {
1093 switch (abovePlace) {
1095 prop = 1.75 ; break ;
1097 prop = 1.75; break ;
1101 Int_t ltext = opPower ;
1102 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1105 snprintf(&
text[ltext-2],
length-(ltext-2),
"I ") ;
1118 if (over <= 0) over = 1.5*fs2.
Over();
1129 if (opPower >= 2 && strncmp(&
text[opPower-2],
"{}",2)==0) {
1130 snprintf(&
text[opPower-2],
length-(opPower-2),
" ") ;
1144 else if (opUnder>-1) {
1150 Int_t ltext = opUnder ;
1151 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1154 snprintf(&
text[ltext-2],
length-(ltext-2),
"I ") ;
1176 if (opUnder >= 2 && strncmp(&
text[opUnder-2],
"{}",2)==0) {
1177 snprintf(&
text[opUnder-2],
length-(opUnder-2),
" ") ;
1310 else if (opBackslash) {
1328 else if (opParallel) {
1343 else if (opGreek>-1) {
1346 char letter = 97 + opGreek;
1348 if (opGreek>25) letter -= 58;
1349 if (opGreek == 52) letter =
'\241';
1350 if (opGreek == 53) letter =
'\316';
1352 fs1 =
Anal1(newSpec,&letter,1);
1353 fs2 =
Anal1(spec,
text+strlen(tab[opGreek])+1,
length-strlen(tab[opGreek])-1);
1364 else if (opSpec > -1) {
1367 char letter =
'\243' + opSpec;
1371 }
else if (opSpec == 76) {
1374 }
else if (opSpec == 80)
1376 else if (opSpec == 81)
1378 else if (opSpec == 82)
1380 else if (opSpec == 83)
1389 }
else if (opSpec==79) {
1393 fs1 =
Anal1(newSpec,&letter,1);
1394 if (opSpec == 79 || opSpec == 66)
1402 if (opSpec!=66 && opSpec!=79)
1410 else if (opAbove>-1) {
1421 xx[0] =
x; xx[1] =
x + fs1.
Width();
1422 yy[0] = yy[1] =
y - sub - fs1.
Over();
1429 midy =
y - sub - fs1.
Over() - dd;
1430 xx[0] =
x; xx[1] =
x + fs1.
Width();
1431 yy[0] = yy[1] = midy;
1433 xx[1] =
x + fs1.
Width(); xx[0] = xx[2] = xx[1] - 2*dd;
1434 yy[0] = midy - dd; yy[1] = midy; yy[2] = midy + dd;
1440 midx =
x + fs1.
Width()/2,
1441 midy =
y - sub - fs1.
Over() - dd;
1442 Double_t xx[5] = { midx - dd, midx - dd, midx + dd, midx + dd, midx - dd },
1443 yy[5] = { midy + dd, midy - dd, midy - dd, midy + dd, midy + dd };
1449 xx[1] =
x + fs1.
Width()/2;
1450 xx[0] = xx[1] - fs1.
Width()/3;
1451 xx[2] = xx[1] + fs1.
Width()/3;
1452 yy[0] =
y - sub - fs1.
Over();
1453 yy[1] = yy[0] - 2*sub;
1460 midx =
x + fs1.
Width()/2 - 1.5*sub,
1461 midy =
y - sub - fs1.
Over() - dd;
1462 Double_t xx1[5] = { midx - dd, midx - dd, midx + dd, midx + dd, midx - dd },
1463 yy1[5] = { midy + dd, midy - dd, midy - dd, midy + dd, midy + dd };
1465 midx =
x + fs1.
Width()/2 + 1.5*sub;
1466 Double_t xx2[5] = { midx - dd, midx - dd, midx + dd, midx + dd, midx - dd },
1467 yy2[5] = { midy + dd, midy - dd, midy - dd, midy + dd, midy + dd };
1473 xx[0] =
x + fs1.
Width()/2; xx[1] = xx[0] + 3*sub;
1474 yy[0] =
y - sub - fs1.
Over();
1475 yy[1] = yy[0] - 2.5*sub;
1481 xx[0] =
x + fs1.
Width()/2 + sub; xx[1] = xx[0] - 2*sub;
1482 yy[0] =
y - sub - fs1.
Over();
1483 yy[1] = yy[0] - 2*sub;
1489 xx[1] =
x+fs1.
Width()/2; xx[0] = xx[1] - 2*sub; xx[2] = xx[1] + 2*sub;
1490 yy[1] =
y - sub - fs1.
Over();
1491 yy[0] = yy[2] = yy[1] - 2*sub;
1501 if (
auto ps =
gPad->GetPainter()->GetPS()) {
1502 if (!strstr(ps->GetTitle(),
"IMG"))
1505 ps->SetTextAlign(22);
1506 ps->Text(xx, yy,
"~");
1522 xx[0] =
x + 0.8*fs1.
Width();
1523 yy[0] =
y - fs1.
Over() - sub;
1524 xx[1] =
x + 0.3*fs1.
Width();
1525 yy[1] = yy[0] + fs1.
Height() + 2*sub;
1532 if (opAbove==1) div=4;
1535 else if (opSquareBracket) {
1555 Double_t radius2,radius1 , dw, l2 =
l/2 ;
1561 radius1 = radius2 * 2 / 3;
1566 radius1 = radius2 * 2 / 3;
1592 else if (opBigCurly) {
1634 else if (opFrac>-1) {
1635 if (opCurlyCurly==-1) {
1637 fError =
"Missing denominator for #frac";
1643 fs1 =
Anal1(spec,
text+opFrac+6,opCurlyCurly-opFrac-6);
1667 else if (opSplitLine>-1) {
1668 if (opCurlyCurly==-1) {
1670 fError =
"Missing second line for #splitline";
1676 fs1 =
Anal1(spec,
text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1690 else if (opSqrt>-1) {
1692 if (opSquareCurly>-1) {
1694 fs1 =
Anal1(specNewSize,
text+opSqrt+6,opSquareCurly-opSqrt-6);
1706 if (opSquareCurly>-1) {
1743 else if (opColor>-1) {
1744 if (opSquareCurly==-1) {
1746 fError =
"Missing color number. Syntax is #color[(Int_t)nb]{ ... }";
1752 strncpy(nb,
text+opColor+7,opSquareCurly-opColor-7);
1753 nb[opSquareCurly-opColor-7] = 0;
1754 if (sscanf(nb,
"%d",&newSpec.
fColor) < 1) {
1757 fError =
"Invalid color number. Syntax is #color[(Int_t)nb]{ ... }";
1768 else if (opUrl>-1) {
1769 if (opSquareCurly==-1) {
1771 fError =
"Missing url. Syntax is #url[http://...]{ ... }";
1784 else if (opFont>-1) {
1785 if (opSquareCurly==-1) {
1787 fError =
"Missing font number. Syntax is #font[nb]{ ... }";
1793 strncpy(nb,
text+opFont+6,opSquareCurly-opFont-6);
1794 nb[opSquareCurly-opFont-6] = 0;
1795 if (sscanf(nb,
"%d",&newSpec.
fFont) < 1) {
1798 fError =
"Invalid font number. Syntax is #font[(Int_t)nb]{ ... }";
1809 else if (opKern>-1) {
1810 if (opSquareCurly==-1) {
1812 fError =
"Missing horizontal shift number. Syntax is #kern[dx]{ ... }";
1817 strncpy(dxc,
text+opKern+6,opSquareCurly-opKern-6);
1818 dxc[opSquareCurly-opKern-6] = 0;
1820 if (sscanf(dxc,
"%f",&dx) < 1) {
1823 fError =
"Invalid horizontal shift number. Syntax is #kern[(Float_t)dx]{ ... }";
1839 else if (opLower>-1) {
1840 if (opSquareCurly==-1) {
1842 fError =
"Missing vertical shift number. Syntax is #lower[dy]{ ... }";
1847 strncpy(dyc,
text+opLower+7,opSquareCurly-opLower-7);
1848 dyc[opSquareCurly-opLower-7] = 0;
1850 if (sscanf(dyc,
"%f",&dy) < 1) {
1853 fError =
"Invalid vertical shift number. Syntax is #lower[(Float_t)dy]{ ... }";
1869 else if (opScale>-1) {
1870 if (opSquareCurly==-1) {
1872 fError =
"Missing scale factor. Syntax is #scale[(Double_t)nb]{ ... }";
1878 strncpy(nb,
text+opScale+7,opSquareCurly-opScale-7);
1879 nb[opSquareCurly-opScale-7] = 0;
1880 if (sscanf(nb,
"%lf",&newSpec.
fSize) < 1) {
1883 fError =
"Invalid scale factor. Syntax is #factor[(Double_t)nb]{ ... }";
1897 Int_t lut[] = {3, 13, 1, 6, 7, 4, 5, 10, 11, 8, 9, 12, 2, 14, 15};
1899 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1900 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1910 else if (opMbox>-1) {
1923 Int_t lut[] = {13, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 1, 14, 12};
1925 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1926 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1949 quote1 = quote2 =
kFALSE ;
1951 for (i=0 ; i<leng ; i++) {
1953 case '\'' : quote1 = !quote1 ; break ;
1954 case '"' : quote2 = !quote2 ; break ;
1957 if (
text[i] ==
'@') {
1959 if ( *(
p+1) ==
'{' || *(
p+1) ==
'}' || *(
p+1) ==
'[' || *(
p+1) ==
']') {
1974 else gPad->PaintText(xx, yy,
text);
2029 if (scale_width >= 1.) {
2032 gPad->PaintFillArea(npoints, xx, yy,
"f");
2039 SetLineWidth(lineWidth > prevWidth ? lineWidth : prevWidth);
2045 gPad->PaintPolyLine(npoints, xx, yy);
2062 gPad->PaintLine(xx[0], yy[0], xx[1], yy[1]);
2082 for (
Int_t i = 0; i <=
np; i++) {
2112 for (
Int_t i = 0; i <=
np; i++) {
2150 if (
size<=0 || strlen(text1) <= 0)
return;
2154 auto ps =
gPad->GetPainter()->GetPS();
2156 if (ps && ps->InheritsFrom(
"TTeXDump")) {
2214 t.
ReplaceAll(
"#splitline",
"\\genfrac{}{}{0pt}{}");
2219 ps->SetTextAngle(
angle);
2220 ps->Text(
x,
y, t.
Data());
2234 if(newText.
Length() == 0)
2240 Error(
"PaintLatex1",
"%s\n==> %s",
fError, text1);
2247 gPad->GetPainter()->SetTextAngle(
angle);
2248 gPad->PaintText(
x,
y, text1);
2253 if (strstr(text1,
"\\")) {
2254 auto ps =
gPad->GetPainter()->GetPS();
2256 if (ps && (ps->InheritsFrom(
"TPDF") || ps->InheritsFrom(
"TSVG"))) {
2307 case 0:
y -=
fs.Under();
break;
2309 case 2:
y +=
fs.Height()*0.5-
fs.Under() + 1.;
break;
2310 case 3:
y +=
fs.Over();
break;
2313 case 2:
x -=
fs.Width()/2;
break;
2314 case 3:
x -=
fs.Width();
break;
2337 const Char_t *kWord1[] = {
"{}^{",
"{}_{",
"^{",
"_{",
"#scale{",
"#color{",
"#url{",
"#font{",
"#sqrt{",
"#[]{",
"#{}{",
"#||{",
2338 "#bar{",
"#vec{",
"#dot{",
"#hat{",
"#ddot{",
"#acute{",
"#grave{",
"#check{",
"#tilde{",
"#slash{",
"#bf{",
"#it{",
"#mbox{",
2339 "\\scale{",
"\\color{",
"\\font{",
"\\sqrt{",
"\\[]{",
"\\{}{",
"\\||{",
"#(){",
"\\(){",
2340 "\\bar{",
"\\vec{",
"\\dot{",
"\\hat{",
"\\ddot{",
"\\acute{",
"\\grave{",
"\\check{",
"\\bf{",
"\\it{",
"\\mbox{"};
2341 const Char_t *kWord2[] = {
"#scale[",
"#color[",
"#url[",
"#font[",
"#sqrt[",
"#kern[",
"#lower[",
"\\scale[",
"\\color[",
"\\font[",
"\\sqrt[",
"\\kern[",
"\\lower["};
2342 const Char_t *kWord3[] = {
"#frac{",
"\\frac{",
"#splitline{",
"\\splitline{"};
2343 const Char_t *kLeft1[] = {
"#left[",
"\\left[",
"#left{",
"\\left{",
"#left|",
"\\left|",
"#left(",
"\\left("};
2344 const Char_t *kLeft2[] = {
"#[]{",
"#[]{",
"#{}{",
"#{}{",
"#||{",
"#||{",
"#(){",
"#(){"};
2345 const Char_t *kRight[] = {
"#right]",
"\\right]",
"#right}",
"\\right}",
"#right|",
"\\right|",
"#right)",
"\\right)"};
2346 const Int_t lkWord1[] = {4,4,2,2,7,7,5,6,6,4,4,4,5,5,5,5,6,7,7,7,7,7,4,4,6,7,7,6,6,4,4,4,4,4,5,5,5,5,6,7,7,7,4,4,6};
2347 const Int_t lkWord2[] = {7,7,5,6,6,6,7,7,7,6,6,6,7} ;
2348 const Int_t lkWord3[] = {6,6,11,11} ;
2349 Int_t nkWord1 = 45, nkWord2 = 13, nkWord3 = 4;
2351 Int_t nLeft1 , nRight , nOfLeft, nOfRight;
2355 nLeft1 = nRight = 8 ;
2356 nOfLeft = nOfRight = 0 ;
2358 Char_t buf[11] ;
for (i=0;i<11;i++) buf[i]=0;
2363 Int_t nOfCurlyBracket, nOfKW1, nOfKW2, nOfKW3, nOfSquareCurly, nOfCurlyCurly ;
2364 Int_t nOfSquareBracket = 0 ;
2376 for (k = 0 ; k < nLeft1 ; k++) {
2377 if (strncmp(buf,kLeft1[k],lLeft1)==0) {
2384 if (opFound) continue ;
2386 for(k=0;k<nRight;k++) {
2387 if (strncmp(buf,kRight[k],lRight)==0) {
2396 if (nOfLeft != nOfRight) {
2397 printf(
" nOfLeft = %d, nOfRight = %d\n",nOfLeft,nOfRight) ;
2399 fError =
"Operators \"#left\" and \"#right\" don't match !" ;
2403 for (k = 0 ; k < nLeft1 ; k++) {
2404 text.ReplaceAll(kLeft1[k],lLeft1,kLeft2[k],lLeft2) ;
2406 for (k = 0 ; k < nRight ; k++) {
2407 text.ReplaceAll(kRight[k],lRight,
"}",1) ;
2411 i = nOfCurlyBracket = nOfKW1 = nOfKW2 = nOfKW3 = nOfSquareCurly = nOfCurlyCurly =0 ;
2414 case '"' : quote1 = !quote1 ; break ;
2415 case '\'': quote2 = !quote2 ; break ;
2422 for(k=0;k<nkWord1;k++) {
2423 if (strncmp(buf,kWord1[k],lkWord1[k])==0) {
2431 if (opFound) continue ;
2433 for(k=0;k<nkWord2;k++) {
2434 if (strncmp(buf,kWord2[k],lkWord2[k])==0) {
2442 if (opFound) continue ;
2444 for(k=0;k<nkWord3;k++) {
2445 if (strncmp(buf,kWord3[k],lkWord3[k])==0) {
2454 if (opFound) continue ;
2455 if (strncmp(buf,
"}{",2) == 0 && opFrac) {
2460 else if (strncmp(buf,
"]{",2) == 0 && nOfSquareBracket) {
2464 nOfSquareBracket-- ;
2466 else if (strncmp(buf,
"@{",2) == 0 || strncmp(buf,
"@}",2) == 0) {
2469 else if (strncmp(buf,
"@[",2) == 0 || strncmp(buf,
"@]",2) == 0) {
2472 else if (
text[i] ==
']' ) {
2473 text.Insert(i,
"@") ;
2477 else if (
text[i] ==
'[' ) {
2478 text.Insert(i,
"@") ;
2482 else if (
text[i] ==
'{' ) {
2483 text.Insert(i,
"@") ;
2487 else if (
text[i] ==
'}' ) {
2488 if ( nOfCurlyBracket) {
2492 text.Insert(i,
"@") ;
2502 if (nOfKW2 != nOfSquareCurly) {
2504 fError =
"Invalid number of \"]{\"" ;
2506 else if (nOfKW3 != nOfCurlyCurly) {
2508 fError =
"Error in syntax of \"#frac\"" ;
2510 else if (nOfCurlyBracket < 0) {
2512 fError =
"Missing \"{\"" ;
2514 else if (nOfCurlyBracket > 0) {
2516 fError =
"Missing \"}\"" ;
2518 else if (nOfSquareBracket < 0) {
2520 fError =
"Missing \"[\"" ;
2522 else if (nOfSquareBracket > 0) {
2524 fError =
"Missing \"]\"" ;
2569 if (!
gPad)
return 0.;
2584 if (!
gPad)
return 0.;
2586 if( newText.
Length() == 0)
return 0;
2606 return std::abs(
gPad->AbsPixeltoX(
fs.Width()) -
gPad->AbsPixeltoX(0));
2616 if( newText.
Length() == 0)
return;
2633 Int_t cBoxX[4], cBoxY[4];
2636 ptx =
gPad->UtoPixel(
fX);
2637 pty =
gPad->VtoPixel(
fY);
2647 for (
Int_t i=1; i<4; i++) {
2648 if (cBoxX[i] <
x1)
x1 = cBoxX[i];
2649 if (cBoxX[i] >
x2)
x2 = cBoxX[i];
2650 if (cBoxY[i] <
y1)
y1 = cBoxY[i];
2651 if (cBoxY[i] >
y2)
y2 = cBoxY[i];
2670 if (!
gPad)
return 0.;
2672 if( newText.
Length() == 0)
return 0;
2692 return std::abs(
gPad->AbsPixeltoY(
fs.Height()) -
gPad->AbsPixeltoY(0));
2701 Error(
"Readfs",
"No data in fTabSize stack");
2724 out,
Class(),
"tex",
2731 out <<
" tex->SetNDC();\n";
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
char Char_t
Character 1 byte (char)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
float Float_t
Float 4 bytes (float)
short Short_t
Signed Short integer 2 bytes (short)
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetLineWidth
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 np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
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 result
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 SetLineColor
Option_t Option_t TPoint TPoint const char x2
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 TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char DrawLine
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
Fill Area Attributes class.
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void Modify()
Change current line attributes if necessary.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Float_t GetTextSize() const
Return the text size.
virtual void Modify()
Change current text attributes if necessary.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual Short_t GetTextAlign() const
Return the text alignment.
virtual Font_t GetTextFont() const
Return the text font.
Float_t fTextAngle
Text angle.
virtual Color_t GetTextColor() const
Return the text color.
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
virtual Float_t GetTextAngle() const
Return the text angle.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Font_t fTextFont
Text font.
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.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual Float_t GetTextSizePercent(Float_t size)
Return the text in percent of the pad size.
Short_t fTextAlign
Text alignment.
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
To draw Mathematical Formula.
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
Double_t GetXsize()
Return size of the formula along X in pad coordinates when the text precision is smaller than 3.
void Rotate(TVirtualPad *pad, Double_t angle, Int_t np, Double_t *x, Double_t *y)
Rotate array of points around fX, fY coordinate by specified angle.
Double_t GetHeight() const
Return height of current pad in pixels.
void Copy(TObject &text) const override
Copy this TLatex object to another TLatex.
Double_t fFactorPos
! Relative position of subscripts and superscripts
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const TextSpec_t &spec)
Draw a line in a Latex formula.
TLatexFormSize Anal1(const TextSpec_t &spec, const Char_t *t, Int_t length)
Analyse function.
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, const TextSpec_t &spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
std::vector< TLatexFormSize > fTabSize
! array of values for the different zones
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
Double_t fOriginSize
Font size of the starting font.
Double_t GetYsize()
Return size of the formula along Y in pad coordinates when the text precision is smaller than 3.
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
TLatexFormSize Readfs()
Read fs in fTabSize.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Return text size in pixels.
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
void DrawCircle(Double_t x1, Double_t y1, Double_t r, const TextSpec_t &spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
TLatex()
Default constructor.
Bool_t fShow
! is true during the second pass (Painting)
~TLatex() override
Destructor.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TLatex & operator=(const TLatex &)
assignment operator
void DrawPolyLine(Int_t npoints, Double_t *xx, Double_t *yy, const TextSpec_t &spec, Double_t scale_width=0.)
Draw a poly line in a Latex formula Is scale_width parameter >=1, fill area will be drawn Otherwise l...
TLatex * DrawLatex(Double_t x, Double_t y, const char *text)
Make a copy of this object with the new parameters And copy object attributes.
Double_t fFactorSize
! Relative size of subscripts and superscripts
const Char_t * fError
! error code
Bool_t fItalic
! Currently inside italic operator
void Paint(Option_t *option="") override
Paint.
TLatexFormSize Analyse(Double_t x, Double_t y, const TextSpec_t &spec, const Char_t *t, Int_t length)
Analyse and paint the TLatex formula.
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
@ kTextNDC
The text position is in NDC coordinates.
To draw TeX Mathematical Formula.
Double_t GetYsize()
Get Y size.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE) override
Get the text width and height.
Double_t GetXsize()
Get X size.
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Paint text (used by Paint()).
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
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".
@ kCanDelete
if object in a list can be deleted
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Base class for several text objects.
Double_t fY
Y position of text (left,center,etc..)
void Copy(TObject &text) const override
Copy this text to text.
TText & operator=(const TText &src)
Assignment operator.
Double_t fX
X position of text (left,center,etc..)
virtual void PaintText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const
Return text extent for string text.
virtual void GetTextAscentDescent(UInt_t &a, UInt_t &d, const char *text) const
Return text ascent and descent for string text.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
virtual void GetControlBox(Int_t x, Int_t y, Double_t theta, Int_t cBoxX[4], Int_t cBoxY[4])
Return the text control box.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual void AbsPixeltoXY(Double_t xpixel, Double_t ypixel, Double_t &x, Double_t &y)=0
virtual void XYtoAbsPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const =0
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
TLatex helper struct holding the attributes of a piece of text.