478 ((
TLatex&)obj).fTabSize = 0;
524 const char *tab[] = {
"alpha",
"beta",
"chi",
"delta",
"varepsilon",
"phi",
"gamma",
"eta",
"iota",
"varphi",
"kappa",
"lambda",
525 "mu",
"nu",
"omicron",
"pi",
"theta",
"rho",
"sigma",
"tau",
"upsilon",
"varomega",
"omega",
"xi",
"psi",
"zeta",
526 "Alpha",
"Beta",
"Chi",
"Delta",
"Epsilon",
"Phi",
"Gamma",
"Eta",
"Iota",
"vartheta",
527 "Kappa",
"Lambda",
"Mu",
"Nu",
"Omicron",
"Pi",
"Theta",
"Rho",
"Sigma",
"Tau",
528 "Upsilon",
"varsigma",
"Omega",
"Xi",
"Psi",
"Zeta",
"varUpsilon",
"epsilon"};
530 const char *
tab2[] = {
"leq",
"/",
"infty",
"voidb",
"club",
"diamond",
"heart",
531 "spade",
"leftrightarrow",
"leftarrow",
"uparrow",
"rightarrow",
532 "downarrow",
"circ",
"pm",
"doublequote",
"geq",
"times",
"propto",
533 "partial",
"bullet",
"divide",
"neq",
"equiv",
"approx",
"3dots",
534 "cbar",
"topbar",
"downleftarrow",
"aleph",
"Jgothic",
"Rgothic",
"voidn",
535 "otimes",
"oplus",
"oslash",
"cap",
"cup",
"supset",
"supseteq",
536 "notsubset",
"subset",
"subseteq",
"in",
"notin",
"angle",
"nabla",
537 "oright",
"ocopyright",
"trademark",
"prod",
"surd",
"upoint",
"corner",
"wedge",
538 "vee",
"Leftrightarrow",
"Leftarrow",
"Uparrow",
"Rightarrow",
539 "Downarrow",
"diamond",
"LT",
"void1",
"copyright",
"void3",
"sum",
540 "arctop",
"lbar",
"arcbottom",
"topbar",
"void8",
"bottombar",
"arcbar",
541 "ltbar",
"AA",
"aa",
"void06",
"GT",
"int",
"forall",
"exists" };
543 const char *
tab3[] = {
"bar",
"vec",
"dot",
"hat",
"ddot",
"acute",
"grave",
"check",
"tilde",
"slash"};
547 Int_t nBlancDeb=0,nBlancFin=0,l_nBlancDeb=0,l_nBlancFin=0;
560 if (nBlancDeb==l_nBlancDeb && nBlancFin==l_nBlancFin) cont =
kFALSE;
563 if (t[nBlancDeb]==
'{' && t[length-nBlancFin-1]==
'}') {
566 for(i=nBlancDeb;i<length-nBlancFin;i++) {
567 if (t[i] ==
'{' && !(i>0 && t[i-1] ==
'@')) nBrackets++;
568 if (t[i] ==
'}' && t[i-1]!=
'@') nBrackets--;
569 if (nBrackets==0 && i<length-nBlancFin-2) {
585 l_nBlancDeb = nBlancDeb;
586 l_nBlancFin = nBlancFin;
591 length -= nBlancFin+nBlancDeb;
593 Error(
"Analyse",
"It seems there is a syntax error in the TLatex string");
597 strncpy(
text,t+nBlancDeb,length);
603 indiceSize =
spec.fSize;
606 specNewSize.
fSize = indiceSize;
615 Int_t opCurlyCurly = -1;
616 Int_t opSquareCurly = -1;
617 Int_t opCloseCurly = -2;
624 Int_t opSquareBracket = 0 ;
625 Int_t opBigCurly = 0 ;
628 Int_t abovePlace = 0 ;
636 Int_t opBackslash = 0;
637 Int_t opParallel = 0;
638 Int_t opSplitLine = -1;
648 for(i=0;i<length;i++) {
650 case '\'' : quote1 = !quote1 ; break ;
651 case '"' : quote2 = !quote2 ; break ;
657 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets++;
662 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets--;
664 if (i<length-1)
if (
text[i+1]==
'{' && opCurlyCurly==-1) opCurlyCurly=i;
666 if (
text[i+1]!=
'{' && !(
text[i+2]==
'{' && (
text[i+1]==
'^' ||
text[i+1]==
'_'))
667 && opCloseCurly==-2) opCloseCurly=i;
669 else if (i<length-1) {
670 if (
text[i+1]!=
'{' && opCloseCurly==-2) opCloseCurly=i;
672 else if (opCloseCurly==-2) opCloseCurly=i;
678 if (!(i>0 &&
text[i-1] ==
'@')) nCroch++;
683 if (!(i>0 &&
text[i-1] ==
'@')) nCroch--;
695 strncpy(buf,&
text[i],2);
696 if (strncmp(buf,
"^{",2)==0) {
697 if (opPower==-1 && nBrackets==0 && nCroch==0) opPower=i;
700 strncpy(buf1,&
text[i-4],4);
701 if (strncmp(buf1,
"#int",4)==0) {
703 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
705 if (strncmp(buf1,
"#sum",4)==0) {
707 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
711 if (strncmp(buf,
"_{",2)==0) {
712 if (opUnder==-1 && nBrackets==0 && nCroch==0) opUnder=i;
715 strncpy(buf2,&
text[i-4],4);
716 if (strncmp(buf2,
"#int",4)==0) {
718 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
720 if (strncmp(buf2,
"#sum",4)==0) {
722 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
726 if (strncmp(buf,
"]{",2)==0)
727 if (opSquareCurly==-1 && nBrackets==0 && nCroch==0) opSquareCurly=i;
730 if (
text[i]==
'\\' || (
text[i]==
'#' && !opFound && nBrackets==0 && nCroch==0)) {
734 strncpy(buf,&
text[i+1],10);
735 if (strncmp(buf,
"splitline{",10)==0) {
736 opSplitLine=i; opFound =
kTRUE;
737 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
743 strncpy(buf,&
text[i+1],9);
744 if (!opBackslash && strncmp(buf,
"backslash",9)==0) {
745 opBackslash=1; opFound =
kTRUE;
746 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
752 strncpy(buf,&
text[i+1],8);
753 if (!opParallel && strncmp(buf,
"parallel",8)==0) {
754 opParallel=1; opFound =
kTRUE;
755 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
761 strncpy(buf,&
text[i+1],6);
762 if (strncmp(buf,
"lower[",6)==0 || strncmp(buf,
"lower{",6)==0) {
763 opLower=i; opFound =
kTRUE;
764 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
767 if (strncmp(buf,
"scale[",6)==0 || strncmp(buf,
"scale{",6)==0) {
768 opScale=i; opFound =
kTRUE;
769 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
772 if (strncmp(buf,
"color[",6)==0 || strncmp(buf,
"color{",6)==0) {
773 opColor=i; opFound =
kTRUE;
774 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
780 strncpy(buf,&
text[i+1],5);
781 if (strncmp(buf,
"frac{",5)==0) {
782 opFrac=i; opFound =
kTRUE;
783 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
786 if (strncmp(buf,
"sqrt{",5)==0 || strncmp(buf,
"sqrt[",5)==0) {
787 opSqrt=i; opFound =
kTRUE;
788 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
791 if (strncmp(buf,
"font{",5)==0 || strncmp(buf,
"font[",5)==0) {
792 opFont=i; opFound =
kTRUE;
793 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
796 if (strncmp(buf,
"kern[",5)==0 || strncmp(buf,
"kern{",5)==0) {
797 opKern=i; opFound =
kTRUE;
798 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
801 if (!opMinus && strncmp(buf,
"minus",5)==0) {
802 opMinus=1; opFound =
kTRUE;
803 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
806 if (strncmp(buf,
"mbox[",5)==0 || strncmp(buf,
"mbox{",5)==0) {
807 opMbox=i; opFound =
kTRUE;
808 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
814 strncpy(buf,&
text[i+1],4);
815 if (!opOdot && strncmp(buf,
"odot",4)==0) {
816 opOdot=1; opFound =
kTRUE;
817 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
820 if (!opHbar && strncmp(buf,
"hbar",4)==0) {
821 opHbar=1; opFound =
kTRUE;
822 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
825 if (!opPerp && strncmp(buf,
"perp",4)==0) {
826 opPerp=1; opFound =
kTRUE;
827 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
830 if (!opPlus && strncmp(buf,
"plus",4)==0) {
831 opPlus=1; opFound =
kTRUE;
832 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
838 strncpy(buf,&
text[i+1],3);
840 if (strncmp(buf,
"[]{",3)==0) {
841 opSquareBracket=1; opFound =
kTRUE;
842 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
845 if (strncmp(buf,
"{}{",3)==0 ) {
846 opBigCurly=1; opFound =
kTRUE;
847 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
850 if (strncmp(buf,
"||{",3)==0) {
851 opAbs=1; opFound =
kTRUE;
852 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
855 if (strncmp(buf,
"(){",3)==0) {
856 opParen=1; opFound =
kTRUE;
857 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
860 if (!opBox && strncmp(buf,
"Box",3)==0) {
861 opBox=1; opFound =
kTRUE;
862 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
865 if (strncmp(buf,
"bf[",3)==0 || strncmp(buf,
"bf{",3)==0) {
866 opBf=i; opFound =
kTRUE;
867 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
870 if (strncmp(buf,
"it[",3)==0 || strncmp(buf,
"it{",3)==0) {
871 opIt=i; opFound =
kTRUE;
872 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
878 strncpy(buf,&
text[i+1],2);
879 if (!opMp && strncmp(buf,
"mp",2)==0) {
880 opMp=1; opFound =
kTRUE;
881 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
886 if (!opFound &&
UInt_t(length)>i+strlen(tab[k])) {
887 if (strncmp(&
text[i+1],tab[k],strlen(tab[k]))==0) {
890 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
895 if (!opFound &&
UInt_t(length)>i+strlen(
tab3[k])) {
899 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
906 if ((opSpec==-1 || strlen(
tab2[k])>lastsize) &&
UInt_t(length)>i+strlen(
tab2[k])) {
908 lastsize = strlen(
tab2[k]);
911 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
924 if (opCloseCurly>-1 && opCloseCurly<length-1) {
937 else if (opPower>-1 && opUnder>-1) {
942 switch (abovePlace) {
944 prop = .8 ; propU = 1.75 ;
947 prop = .9 ; propU = 1.75 ;
956 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
963 fs2 =
Anal1(specNewSize,
text+min+1,max-min-1);
964 fs3 =
Anal1(specNewSize,
text+max+1,length-max-1);
975 if (opPower<opUnder) {
985 Double_t addW1, addW2, addH1, addH2;
988 if (opPower<opUnder) {
990 addW1 = (
m-fs2.
Width())/2;
992 addW2 = (
m-fs3.
Width())/2;
995 addW1 = (
m-fs2.
Width())/2;
997 addW2 = (
m-fs3.
Width())/2;
1000 Analyse(
x+addW2,
y+addH2,specNewSize,
text+max+1,length-max-1);
1004 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
1013 if (opPower<opUnder) {
1023 if (opPower<opUnder) {
1032 else if (opPower>-1) {
1035 switch (abovePlace) {
1037 prop = 1.75 ; break ;
1039 prop = 1.75; break ;
1043 Int_t ltext = opPower ;
1044 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1051 fs2 =
Anal1(specNewSize,
text+opPower+1,length-opPower-1);
1060 if (over <= 0) over = 1.5*fs2.
Over();
1071 if (opPower >= 2 && strncmp(&
text[opPower-2],
"{}",2)==0) {
1086 else if (opUnder>-1) {
1092 Int_t ltext = opUnder ;
1093 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1100 fs2 =
Anal1(specNewSize,
text+opUnder+1,length-opUnder-1);
1118 if (opUnder >= 2 && strncmp(&
text[opUnder-2],
"{}",2)==0) {
1264 else if (opBackslash) {
1285 else if (opParallel) {
1300 else if (opGreek>-1) {
1303 char letter = 97 + opGreek;
1305 if (opGreek>25) letter -= 58;
1306 if (opGreek == 52) letter =
'\241';
1307 if (opGreek == 53) letter =
'\316';
1309 fs1 =
Anal1(newSpec,&letter,1);
1310 fs2 =
Anal1(
spec,
text+strlen(tab[opGreek])+1,length-strlen(tab[opGreek])-1);
1321 else if (opSpec>-1) {
1324 char letter =
'\243' + opSpec;
1325 if(opSpec == 75 || opSpec == 76) {
1327 if (
gVirtualX->InheritsFrom(
"TGCocoa")) {
1328 if (opSpec == 75) letter =
'\201';
1329 if (opSpec == 76) letter =
'\214';
1331 if (opSpec == 75) letter =
'\305';
1332 if (opSpec == 76) letter =
'\345';
1335 if(opSpec == 80 || opSpec == 81) {
1336 if (opSpec == 80) letter =
'\042';
1337 if (opSpec == 81) letter =
'\044';
1345 }
else if (opSpec==79) {
1349 fs1 =
Anal1(newSpec,&letter,1);
1350 if (opSpec == 79 || opSpec == 66)
1358 if (opSpec!=66 && opSpec!=79)
1366 else if (opAbove>-1) {
1378 ypos =
y-fs1.
Over()-sub ;
1383 y0 =
y-sub-fs1.
Over() ;
1393 y1 =
y-sub-fs1.
Over() ;
1410 y1 =
y-sub-fs1.
Over() ;
1416 y1 =
y +sub -fs1.
Over() ;
1423 y1 =
y-sub-fs1.
Over() ;
1432 y1 =
y-sub-fs1.
Over() ;
1438 y2 =
y -fs1.
Over() ;
1445 if (
gVirtualX->InheritsFrom(
"TGCocoa")) y2 -= 4.7*sub;
1462 xx =
gPad->AbsPixeltoX(
Int_t((
x2-xOrigin)*cosang+(y22-yOrigin)*sinang+xOrigin));
1463 yy =
gPad->AbsPixeltoY(
Int_t((
x2-xOrigin)*-sinang+(y22-yOrigin)*cosang+yOrigin));
1471 y1 =
y -fs1.
Over() ;
1473 y2 = y1 + 1.2*fs1.
Height();
1479 if (opAbove==1) div=4;
1482 else if (opSquareBracket) {
1502 Double_t radius2,radius1 , dw, l2 =
l/2 ;
1508 radius1 = radius2 * 2 / 3;
1513 radius1 = radius2 * 2 / 3;
1539 else if (opBigCurly) {
1581 else if (opFrac>-1) {
1582 if (opCurlyCurly==-1) {
1584 fError =
"Missing denominator for #frac";
1591 fs2 =
Anal1(
spec,
text+opCurlyCurly+2,length-opCurlyCurly-3);
1614 else if (opSplitLine>-1) {
1615 if (opCurlyCurly==-1) {
1617 fError =
"Missing second line for #splitline";
1623 fs1 =
Anal1(
spec,
text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1624 fs2 =
Anal1(
spec,
text+opCurlyCurly+2,length-opCurlyCurly-3);
1637 else if (opSqrt>-1) {
1639 if (opSquareCurly>-1) {
1641 fs1 =
Anal1(specNewSize,
text+opSqrt+6,opSquareCurly-opSqrt-6);
1642 fs2 =
Anal1(
spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1653 if (opSquareCurly>-1) {
1690 else if (opColor>-1) {
1691 if (opSquareCurly==-1) {
1693 fError =
"Missing color number. Syntax is #color[(Int_t)nb]{ ... }";
1699 strncpy(nb,
text+opColor+7,opSquareCurly-opColor-7);
1700 nb[opSquareCurly-opColor-7] = 0;
1701 if (sscanf(nb,
"%d",&newSpec.
fColor) < 1) {
1704 fError =
"Invalid color number. Syntax is #color[(Int_t)nb]{ ... }";
1710 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1712 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1715 else if (opFont>-1) {
1716 if (opSquareCurly==-1) {
1718 fError =
"Missing font number. Syntax is #font[nb]{ ... }";
1724 strncpy(nb,
text+opFont+6,opSquareCurly-opFont-6);
1725 nb[opSquareCurly-opFont-6] = 0;
1726 if (sscanf(nb,
"%d",&newSpec.
fFont) < 1) {
1729 fError =
"Invalid font number. Syntax is #font[(Int_t)nb]{ ... }";
1735 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1737 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1740 else if (opKern>-1) {
1741 if (opSquareCurly==-1) {
1743 fError =
"Missing horizontal shift number. Syntax is #kern[dx]{ ... }";
1748 strncpy(dxc,
text+opKern+6,opSquareCurly-opKern-6);
1749 dxc[opSquareCurly-opKern-6] = 0;
1751 if (sscanf(dxc,
"%f",&dx) < 1) {
1754 fError =
"Invalid horizontal shift number. Syntax is #kern[(Float_t)dx]{ ... }";
1760 fs1 =
Anal1(
spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1770 else if (opLower>-1) {
1771 if (opSquareCurly==-1) {
1773 fError =
"Missing vertical shift number. Syntax is #lower[dy]{ ... }";
1778 strncpy(dyc,
text+opLower+7,opSquareCurly-opLower-7);
1779 dyc[opSquareCurly-opLower-7] = 0;
1781 if (sscanf(dyc,
"%f",&dy) < 1) {
1784 fError =
"Invalid vertical shift number. Syntax is #lower[(Float_t)dy]{ ... }";
1790 fs1 =
Anal1(
spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1800 else if (opScale>-1) {
1801 if (opSquareCurly==-1) {
1803 fError =
"Missing scale factor. Syntax is #scale[(Double_t)nb]{ ... }";
1809 strncpy(nb,
text+opScale+7,opSquareCurly-opScale-7);
1810 nb[opSquareCurly-opScale-7] = 0;
1811 if (sscanf(nb,
"%lf",&newSpec.
fSize) < 1) {
1814 fError =
"Invalid scale factor. Syntax is #factor[(Double_t)nb]{ ... }";
1821 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1823 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1828 Int_t lut[] = {3, 13, 1, 6, 7, 4, 5, 10, 11, 8, 9, 12, 2, 14, 15};
1830 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1831 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1841 else if (opMbox>-1) {
1854 Int_t lut[] = {13, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 1, 14, 12};
1856 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1857 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1880 quote1 = quote2 =
kFALSE ;
1882 for (i=0 ; i<leng ; i++) {
1884 case '\'' : quote1 = !quote1 ; break ;
1885 case '"' : quote2 = !quote2 ; break ;
1888 if (
text[i] ==
'@') {
1890 if ( *(p+1) ==
'{' || *(p+1) ==
'}' || *(p+1) ==
'[' || *(p+1) ==
']') {
1961 Double_t yy2 =
gPad->AbsPixeltoY(
Int_t((
x2-xOrigin)*-sinang+(y2-yOrigin)*cosang+yOrigin));
1965 gPad->PaintLine(xx,yy,xx2,yy2);
1979 const Int_t np = 40;
1987 for (
Int_t i=0;i<=np;i++) {
1991 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+ dy*sinang +xOrigin));
1992 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+ dy*cosang +yOrigin));
1994 gPad->PaintPolyLine(np+1,
x,
y);
2010 const Int_t np = 40;
2018 for (
Int_t i=0;i<=np;i++) {
2022 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+dy*sinang +xOrigin));
2023 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+dy*cosang +yOrigin));
2025 gPad->PaintPolyLine(np+1,
x,
y);
2054 if (size<=0 || strlen(text1) <= 0)
return;
2120 t.
ReplaceAll(
"#splitline",
"\\genfrac{}{}{0pt}{}");
2133 gPad->SetBatch(saveb);
2148 if( newText.
Length() == 0)
return 0;
2153 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2154 std::cout<<
"==> "<<text1<<std::endl;
2163 gPad->PaintText(
x,
y,text1);
2169 if (strstr(text1,
"\\")) {
2207 x =
gPad->XtoAbsPixel(
x);
2208 y =
gPad->YtoAbsPixel(
y);
2219 spec.fAngle = angle;
2227 std::cout<<
"*ERROR<TLatex>: "<<
fError<<std::endl;
2228 std::cout<<
"==> "<<
text<<std::endl;
2231 newSpec.
fSize = size;
2234 case 0:
y -= fs.
Under() ;
break;
2237 case 3:
y += fs.
Over() ;
break;
2240 case 2:
x -= fs.
Width()/2 ;
break;
2241 case 3:
x -= fs.
Width() ;
break;
2246 gPad->SetBatch(saveb);
2255 if (
fError != 0)
return 0;
2264 const Char_t *kWord1[] = {
"{}^{",
"{}_{",
"^{",
"_{",
"#scale{",
"#color{",
"#font{",
"#sqrt{",
"#[]{",
"#{}{",
"#||{",
2265 "#bar{",
"#vec{",
"#dot{",
"#hat{",
"#ddot{",
"#acute{",
"#grave{",
"#check{",
"#tilde{",
"#slash{",
"#bf{",
"#it{",
"#mbox{",
2266 "\\scale{",
"\\color{",
"\\font{",
"\\sqrt{",
"\\[]{",
"\\{}{",
"\\||{",
"#(){",
"\\(){",
2267 "\\bar{",
"\\vec{",
"\\dot{",
"\\hat{",
"\\ddot{",
"\\acute{",
"\\grave{",
"\\check{",
"\\bf{",
"\\it{",
"\\mbox{"};
2268 const Char_t *kWord2[] = {
"#scale[",
"#color[",
"#font[",
"#sqrt[",
"#kern[",
"#lower[",
"\\scale[",
"\\color[",
"\\font[",
"\\sqrt[",
"\\kern[",
"\\lower["};
2269 const Char_t *kWord3[] = {
"#frac{",
"\\frac{",
"#splitline{",
"\\splitline{"};
2270 const Char_t *kLeft1[] = {
"#left[",
"\\left[",
"#left{",
"\\left{",
"#left|",
"\\left|",
"#left(",
"\\left("};
2271 const Char_t *kLeft2[] = {
"#[]{",
"#[]{",
"#{}{",
"#{}{",
"#||{",
"#||{",
"#(){",
"#(){"};
2272 const Char_t *kRight[] = {
"#right]",
"\\right]",
"#right}",
"\\right}",
"#right|",
"\\right|",
"#right)",
"\\right)"};
2273 const Int_t lkWord1[] = {4,4,2,2,7,7,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};
2274 const Int_t lkWord2[] = {7,7,6,6,6,7,7,7,6,6,6,7} ;
2275 const Int_t lkWord3[] = {6,6,11,11} ;
2276 Int_t nkWord1 = 44, nkWord2 = 12, nkWord3 = 4;
2278 Int_t nLeft1 , nRight , nOfLeft, nOfRight;
2282 nLeft1 = nRight = 8 ;
2283 nOfLeft = nOfRight = 0 ;
2285 Char_t buf[11] ;
for (i=0;i<11;i++) buf[i]=0;
2290 Int_t nOfCurlyBracket, nOfKW1, nOfKW2, nOfKW3, nOfSquareCurly, nOfCurlyCurly ;
2291 Int_t nOfExtraCurly = 0 , nOfExtraSquare = 0;
2292 Int_t nOfSquareBracket = 0 ;
2299 while (i < length) {
2304 for (k = 0 ; k < nLeft1 ; k++) {
2305 if (strncmp(buf,kLeft1[k],lLeft1)==0) {
2312 if (opFound) continue ;
2314 for(k=0;k<nRight;k++) {
2315 if (strncmp(buf,kRight[k],lRight)==0) {
2324 if (nOfLeft != nOfRight) {
2325 printf(
" nOfLeft = %d, nOfRight = %d\n",nOfLeft,nOfRight) ;
2327 fError =
"Operators \"#left\" and \"#right\" don't match !" ;
2331 for (k = 0 ; k < nLeft1 ; k++) {
2332 text.ReplaceAll(kLeft1[k],lLeft1,kLeft2[k],lLeft2) ;
2334 for (k = 0 ; k < nRight ; k++) {
2335 text.ReplaceAll(kRight[k],lRight,
"}",1) ;
2337 length =
text.Length() ;
2339 i = nOfCurlyBracket = nOfKW1 = nOfKW2 = nOfKW3 = nOfSquareCurly = nOfCurlyCurly =0 ;
2342 case '"' : quote1 = !quote1 ; break ;
2343 case '\'': quote2 = !quote2 ; break ;
2350 for(k=0;k<nkWord1;k++) {
2351 if (strncmp(buf,kWord1[k],lkWord1[k])==0) {
2359 if (opFound) continue ;
2361 for(k=0;k<nkWord2;k++) {
2362 if (strncmp(buf,kWord2[k],lkWord2[k])==0) {
2370 if (opFound) continue ;
2372 for(k=0;k<nkWord3;k++) {
2373 if (strncmp(buf,kWord3[k],lkWord3[k])==0) {
2382 if (opFound) continue ;
2383 if (strncmp(buf,
"}{",2) == 0 && opFrac) {
2388 else if (strncmp(buf,
"]{",2) == 0 && nOfSquareBracket) {
2392 nOfSquareBracket-- ;
2394 else if (strncmp(buf,
"@{",2) == 0 || strncmp(buf,
"@}",2) == 0) {
2397 else if (strncmp(buf,
"@[",2) == 0 || strncmp(buf,
"@]",2) == 0) {
2400 else if (
text[i] ==
']' ) {
2401 text.Insert(i,
"@") ;
2406 else if (
text[i] ==
'[' ) {
2407 text.Insert(i,
"@") ;
2412 else if (
text[i] ==
'{' ) {
2413 text.Insert(i,
"@") ;
2418 else if (
text[i] ==
'}' ) {
2419 if ( nOfCurlyBracket) {
2423 text.Insert(i,
"@") ;
2434 if (nOfKW2 != nOfSquareCurly) {
2436 fError =
"Invalid number of \"]{\"" ;
2438 else if (nOfKW3 != nOfCurlyCurly) {
2440 fError =
"Error in syntax of \"#frac\"" ;
2442 else if (nOfCurlyBracket < 0) {
2444 fError =
"Missing \"{\"" ;
2446 else if (nOfCurlyBracket > 0) {
2448 fError =
"Missing \"}\"" ;
2450 else if (nOfSquareBracket < 0) {
2452 fError =
"Missing \"[\"" ;
2454 else if (nOfSquareBracket > 0) {
2456 fError =
"Missing \"]\"" ;
2482 spec.fAngle = angle;
2486 spec.fSize = size/hw;
2525 if (!
gPad)
return 0;
2527 if( newText.
Length() == 0)
return 0;
2537 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2538 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2558 if( newText.
Length() == 0)
return;
2569 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2570 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2576 Int_t cBoxX[4], cBoxY[4];
2579 ptx =
gPad->UtoPixel(
fX);
2580 pty =
gPad->VtoPixel(
fY);
2588 Int_t y1 = cBoxY[0];
2589 Int_t y2 = cBoxY[0];
2590 for (
Int_t i=1; i<4; i++) {
2591 if (cBoxX[i] <
x1)
x1 = cBoxX[i];
2592 if (cBoxX[i] >
x2)
x2 = cBoxX[i];
2593 if (cBoxY[i] < y1) y1 = cBoxY[i];
2594 if (cBoxY[i] > y2) y2 = cBoxY[i];
2612 if (!
gPad)
return 0;
2614 if( newText.
Length() == 0)
return 0;
2624 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2625 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2685 s.ReplaceAll(
"\\",
"\\\\");
2686 s.ReplaceAll(
"\"",
"\\\"");
2687 out<<
" tex = new TLatex("<<
fX<<
","<<
fY<<
","<<quote<<
s.Data()<<quote<<
");"<<std::endl;
2693 out<<
" tex->Draw();"<<std::endl;
static const double x2[5]
static const double x4[22]
static const double x1[5]
static const double x3[11]
include TDocParser_001 C image html pict1_TDocParser_001 png width
Binding & operator=(OUT(*fun)(void))
R__EXTERN TVirtualPS * gVirtualPS
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
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.
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.
Int_t fPos
! Current position in array fTabSize;
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
Double_t GetHeight() const
Return height of current pad in pixels.
Double_t fFactorPos
! Relative position of subscripts and superscripts
void DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
Int_t fLimitFactorSize
lower bound for subscripts/superscripts size
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
FormSize_t * 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.
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
Int_t fTabMax
! Maximum allocation for array fTabSize;
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
TLatexFormSize Readfs()
Read fs in fTabSize.
void Copy(TObject &text) const
Copy this TLatex object to another TLatex.
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
virtual ~TLatex()
Destructor.
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 & operator=(const TLatex &)
assignment operator
@ kTextNDC
The text postion is in NDC coordinates.
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
Draw a line in a Latex formula.
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
virtual void Paint(Option_t *option="")
Paint.
TLatexFormSize Analyse(Double_t x, Double_t y, 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 DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec)
Draw an arc of ellipse in a Latex formula (right or left parenthesis)
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
To draw TeX Mathematical Formula.
Double_t GetYsize(void)
Get Y size.
Double_t GetXsize(void)
Get X size.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Get the text width and height.
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Paint text (used by Paint()).
virtual const char * GetTitle() const
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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kCanDelete
if object in a list can be deleted
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
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..)
TText & operator=(const TText &src)
Assignment operator.
Double_t fX
X position of text (left,center,etc..)
void Copy(TObject &text) const
Copy this text to text.
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.
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
virtual void Text(Double_t x, Double_t y, const char *string)=0
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)
TLatex helper struct holding the attributes of a piece of text.