454 TAttLine::operator=(lt);
479 ((
TLatex&)obj).fTabSize = 0;
493 return Analyse(0,0,spec,t,length);
525 const char *tab[] = {
"alpha",
"beta",
"chi",
"delta",
"varepsilon",
"phi",
"gamma",
"eta",
"iota",
"varphi",
"kappa",
"lambda",
526 "mu",
"nu",
"omicron",
"pi",
"theta",
"rho",
"sigma",
"tau",
"upsilon",
"varomega",
"omega",
"xi",
"psi",
"zeta",
527 "Alpha",
"Beta",
"Chi",
"Delta",
"Epsilon",
"Phi",
"Gamma",
"Eta",
"Iota",
"vartheta",
528 "Kappa",
"Lambda",
"Mu",
"Nu",
"Omicron",
"Pi",
"Theta",
"Rho",
"Sigma",
"Tau",
529 "Upsilon",
"varsigma",
"Omega",
"Xi",
"Psi",
"Zeta",
"varUpsilon",
"epsilon"};
531 const char *
tab2[] = {
"leq",
"/",
"infty",
"voidb",
"club",
"diamond",
"heart",
532 "spade",
"leftrightarrow",
"leftarrow",
"uparrow",
"rightarrow",
533 "downarrow",
"circ",
"pm",
"doublequote",
"geq",
"times",
"propto",
534 "partial",
"bullet",
"divide",
"neq",
"equiv",
"approx",
"3dots",
535 "cbar",
"topbar",
"downleftarrow",
"aleph",
"Jgothic",
"Rgothic",
"voidn",
536 "otimes",
"oplus",
"oslash",
"cap",
"cup",
"supset",
"supseteq",
537 "notsubset",
"subset",
"subseteq",
"in",
"notin",
"angle",
"nabla",
538 "oright",
"ocopyright",
"trademark",
"prod",
"surd",
"upoint",
"corner",
"wedge",
539 "vee",
"Leftrightarrow",
"Leftarrow",
"Uparrow",
"Rightarrow",
540 "Downarrow",
"diamond",
"LT",
"void1",
"copyright",
"void3",
"sum",
541 "arctop",
"lbar",
"arcbottom",
"topbar",
"void8",
"bottombar",
"arcbar",
542 "ltbar",
"AA",
"aa",
"void06",
"GT",
"int",
"forall",
"exists" };
544 const char *
tab3[] = {
"bar",
"vec",
"dot",
"hat",
"ddot",
"acute",
"grave",
"check",
"tilde",
"slash"};
548 Int_t nBlancDeb=0,nBlancFin=0,l_nBlancDeb=0,l_nBlancFin=0;
561 if (nBlancDeb==l_nBlancDeb && nBlancFin==l_nBlancFin) cont =
kFALSE;
564 if (t[nBlancDeb]==
'{' && t[length-nBlancFin-1]==
'}') {
567 for(i=nBlancDeb;i<length-nBlancFin;i++) {
568 if (t[i] ==
'{' && !(i>0 && t[i-1] ==
'@')) nBrackets++;
569 if (t[i] ==
'}' && t[i-1]!=
'@') nBrackets--;
570 if (nBrackets==0 && i<length-nBlancFin-2) {
586 l_nBlancDeb = nBlancDeb;
587 l_nBlancFin = nBlancFin;
592 length -= nBlancFin+nBlancDeb;
594 Error(
"Analyse",
"It seems there is a syntax error in the TLatex string");
598 strncpy(
text,t+nBlancDeb,length);
604 indiceSize = spec.fSize;
607 specNewSize.
fSize = indiceSize;
616 Int_t opCurlyCurly = -1;
617 Int_t opSquareCurly = -1;
618 Int_t opCloseCurly = -2;
625 Int_t opSquareBracket = 0 ;
626 Int_t opBigCurly = 0 ;
629 Int_t abovePlace = 0 ;
637 Int_t opBackslash = 0;
638 Int_t opParallel = 0;
639 Int_t opSplitLine = -1;
649 for(i=0;i<length;i++) {
651 case '\'' : quote1 = !quote1 ; break ;
652 case '"' : quote2 = !quote2 ; break ;
658 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets++;
663 if (!(i>0 &&
text[i-1] ==
'@')) nBrackets--;
665 if (i<length-1)
if (
text[i+1]==
'{' && opCurlyCurly==-1) opCurlyCurly=i;
667 if (
text[i+1]!=
'{' && !(
text[i+2]==
'{' && (
text[i+1]==
'^' ||
text[i+1]==
'_'))
668 && opCloseCurly==-2) opCloseCurly=i;
670 else if (i<length-1) {
671 if (
text[i+1]!=
'{' && opCloseCurly==-2) opCloseCurly=i;
673 else if (opCloseCurly==-2) opCloseCurly=i;
679 if (!(i>0 &&
text[i-1] ==
'@')) nCroch++;
684 if (!(i>0 &&
text[i-1] ==
'@')) nCroch--;
696 strncpy(buf,&
text[i],2);
697 if (strncmp(buf,
"^{",2)==0) {
698 if (opPower==-1 && nBrackets==0 && nCroch==0) opPower=i;
701 strncpy(buf1,&
text[i-4],4);
702 if (strncmp(buf1,
"#int",4)==0) {
704 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
706 if (strncmp(buf1,
"#sum",4)==0) {
708 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
712 if (strncmp(buf,
"_{",2)==0) {
713 if (opUnder==-1 && nBrackets==0 && nCroch==0) opUnder=i;
716 strncpy(buf2,&
text[i-4],4);
717 if (strncmp(buf2,
"#int",4)==0) {
719 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
721 if (strncmp(buf2,
"#sum",4)==0) {
723 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
727 if (strncmp(buf,
"]{",2)==0)
728 if (opSquareCurly==-1 && nBrackets==0 && nCroch==0) opSquareCurly=i;
731 if (
text[i]==
'\\' || (
text[i]==
'#' && !opFound && nBrackets==0 && nCroch==0)) {
735 strncpy(buf,&
text[i+1],10);
736 if (strncmp(buf,
"splitline{",10)==0) {
737 opSplitLine=i; opFound =
kTRUE;
738 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
744 strncpy(buf,&
text[i+1],9);
745 if (!opBackslash && strncmp(buf,
"backslash",9)==0) {
746 opBackslash=1; opFound =
kTRUE;
747 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
753 strncpy(buf,&
text[i+1],8);
754 if (!opParallel && strncmp(buf,
"parallel",8)==0) {
755 opParallel=1; opFound =
kTRUE;
756 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
762 strncpy(buf,&
text[i+1],6);
763 if (strncmp(buf,
"lower[",6)==0 || strncmp(buf,
"lower{",6)==0) {
764 opLower=i; opFound =
kTRUE;
765 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
768 if (strncmp(buf,
"scale[",6)==0 || strncmp(buf,
"scale{",6)==0) {
769 opScale=i; opFound =
kTRUE;
770 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
773 if (strncmp(buf,
"color[",6)==0 || strncmp(buf,
"color{",6)==0) {
774 opColor=i; opFound =
kTRUE;
775 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
781 strncpy(buf,&
text[i+1],5);
782 if (strncmp(buf,
"frac{",5)==0) {
783 opFrac=i; opFound =
kTRUE;
784 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
787 if (strncmp(buf,
"sqrt{",5)==0 || strncmp(buf,
"sqrt[",5)==0) {
788 opSqrt=i; opFound =
kTRUE;
789 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
792 if (strncmp(buf,
"font{",5)==0 || strncmp(buf,
"font[",5)==0) {
793 opFont=i; opFound =
kTRUE;
794 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
797 if (strncmp(buf,
"kern[",5)==0 || strncmp(buf,
"kern{",5)==0) {
798 opKern=i; opFound =
kTRUE;
799 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
802 if (!opMinus && strncmp(buf,
"minus",5)==0) {
803 opMinus=1; opFound =
kTRUE;
804 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
807 if (strncmp(buf,
"mbox[",5)==0 || strncmp(buf,
"mbox{",5)==0) {
808 opMbox=i; opFound =
kTRUE;
809 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
815 strncpy(buf,&
text[i+1],4);
816 if (!opOdot && strncmp(buf,
"odot",4)==0) {
817 opOdot=1; opFound =
kTRUE;
818 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
821 if (!opHbar && strncmp(buf,
"hbar",4)==0) {
822 opHbar=1; opFound =
kTRUE;
823 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
826 if (!opPerp && strncmp(buf,
"perp",4)==0) {
827 opPerp=1; opFound =
kTRUE;
828 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
831 if (!opPlus && strncmp(buf,
"plus",4)==0) {
832 opPlus=1; opFound =
kTRUE;
833 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
839 strncpy(buf,&
text[i+1],3);
841 if (strncmp(buf,
"[]{",3)==0) {
842 opSquareBracket=1; opFound =
kTRUE;
843 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
846 if (strncmp(buf,
"{}{",3)==0 ) {
847 opBigCurly=1; opFound =
kTRUE;
848 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
851 if (strncmp(buf,
"||{",3)==0) {
852 opAbs=1; opFound =
kTRUE;
853 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
856 if (strncmp(buf,
"(){",3)==0) {
857 opParen=1; opFound =
kTRUE;
858 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
861 if (!opBox && strncmp(buf,
"Box",3)==0) {
862 opBox=1; opFound =
kTRUE;
863 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
866 if (strncmp(buf,
"bf[",3)==0 || strncmp(buf,
"bf{",3)==0) {
867 opBf=i; opFound =
kTRUE;
868 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
871 if (strncmp(buf,
"it[",3)==0 || strncmp(buf,
"it{",3)==0) {
872 opIt=i; opFound =
kTRUE;
873 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
879 strncpy(buf,&
text[i+1],2);
880 if (!opMp && strncmp(buf,
"mp",2)==0) {
881 opMp=1; opFound =
kTRUE;
882 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
887 if (!opFound &&
UInt_t(length)>i+strlen(tab[k])) {
888 if (strncmp(&
text[i+1],tab[k],strlen(tab[k]))==0) {
891 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
896 if (!opFound &&
UInt_t(length)>i+strlen(
tab3[k])) {
900 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
907 if ((opSpec==-1 || strlen(
tab2[k])>lastsize) &&
UInt_t(length)>i+strlen(
tab2[k])) {
909 lastsize = strlen(
tab2[k]);
912 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
925 if (opCloseCurly>-1 && opCloseCurly<length-1) {
928 fs2 =
Anal1(spec,
text+opCloseCurly+1,length-opCloseCurly-1);
938 else if (opPower>-1 && opUnder>-1) {
943 switch (abovePlace) {
945 prop = .8 ; propU = 1.75 ;
948 prop = .9 ; propU = 1.75 ;
957 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
964 fs2 =
Anal1(specNewSize,
text+min+1,max-min-1);
965 fs3 =
Anal1(specNewSize,
text+max+1,length-max-1);
976 if (opPower<opUnder) {
986 Double_t addW1, addW2, addH1, addH2;
989 if (opPower<opUnder) {
991 addW1 = (
m-fs2.
Width())/2;
993 addW2 = (
m-fs3.
Width())/2;
996 addW1 = (
m-fs2.
Width())/2;
998 addW2 = (
m-fs3.
Width())/2;
1001 Analyse(
x+addW2,
y+addH2,specNewSize,
text+max+1,length-max-1);
1005 if (min >= 2 && strncmp(&
text[min-2],
"{}",2)==0) {
1014 if (opPower<opUnder) {
1024 if (opPower<opUnder) {
1033 else if (opPower>-1) {
1036 switch (abovePlace) {
1038 prop = 1.75 ; break ;
1040 prop = 1.75; break ;
1044 Int_t ltext = opPower ;
1045 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1052 fs2 =
Anal1(specNewSize,
text+opPower+1,length-opPower-1);
1061 if (over <= 0) over = 1.5*fs2.
Over();
1072 if (opPower >= 2 && strncmp(&
text[opPower-2],
"{}",2)==0) {
1087 else if (opUnder>-1) {
1093 Int_t ltext = opUnder ;
1094 if (ltext >= 2 && strncmp(&
text[ltext-2],
"{}",2)==0) {
1101 fs2 =
Anal1(specNewSize,
text+opUnder+1,length-opUnder-1);
1119 if (opUnder >= 2 && strncmp(&
text[opUnder-2],
"{}",2)==0) {
1265 else if (opBackslash) {
1286 else if (opParallel) {
1301 else if (opGreek>-1) {
1304 char letter = 97 + opGreek;
1306 if (opGreek>25) letter -= 58;
1307 if (opGreek == 52) letter =
'\241';
1308 if (opGreek == 53) letter =
'\316';
1310 fs1 =
Anal1(newSpec,&letter,1);
1311 fs2 =
Anal1(spec,
text+strlen(tab[opGreek])+1,length-strlen(tab[opGreek])-1);
1315 Analyse(
x+fs1.
Width(),
y,spec,
text+strlen(tab[opGreek])+1,length-strlen(tab[opGreek])-1);
1322 else if (opSpec>-1) {
1325 char letter =
'\243' + opSpec;
1326 if(opSpec == 75 || opSpec == 76) {
1328 if (
gVirtualX->InheritsFrom(
"TGCocoa")) {
1329 if (opSpec == 75) letter =
'\201';
1330 if (opSpec == 76) letter =
'\214';
1332 if (opSpec == 75) letter =
'\305';
1333 if (opSpec == 76) letter =
'\345';
1336 if(opSpec == 80 || opSpec == 81) {
1337 if (opSpec == 80) letter =
'\042';
1338 if (opSpec == 81) letter =
'\044';
1345 newSpec.
fSize = spec.fSize*props;
1346 }
else if (opSpec==79) {
1347 newSpec.
fSize = spec.fSize*propi;
1350 fs1 =
Anal1(newSpec,&letter,1);
1351 if (opSpec == 79 || opSpec == 66)
1359 if (opSpec!=66 && opSpec!=79)
1367 else if (opAbove>-1) {
1379 ypos =
y-fs1.
Over()-sub ;
1384 y0 =
y-sub-fs1.
Over() ;
1394 y1 =
y-sub-fs1.
Over() ;
1411 y1 =
y-sub-fs1.
Over() ;
1417 y1 =
y +sub -fs1.
Over() ;
1424 y1 =
y-sub-fs1.
Over() ;
1433 y1 =
y-sub-fs1.
Over() ;
1439 y2 =
y -fs1.
Over() ;
1446 if (
gVirtualX->InheritsFrom(
"TGCocoa")) y2 -= 4.7*sub;
1463 xx =
gPad->AbsPixeltoX(
Int_t((
x2-xOrigin)*cosang+(y22-yOrigin)*sinang+xOrigin));
1464 yy =
gPad->AbsPixeltoY(
Int_t((
x2-xOrigin)*-sinang+(y22-yOrigin)*cosang+yOrigin));
1472 y1 =
y -fs1.
Over() ;
1474 y2 = y1 + 1.2*fs1.
Height();
1480 if (opAbove==1) div=4;
1483 else if (opSquareBracket) {
1503 Double_t radius2,radius1 , dw, l2 =
l/2 ;
1509 radius1 = radius2 * 2 / 3;
1514 radius1 = radius2 * 2 / 3;
1540 else if (opBigCurly) {
1582 else if (opFrac>-1) {
1583 if (opCurlyCurly==-1) {
1585 fError =
"Missing denominator for #frac";
1591 fs1 =
Anal1(spec,
text+opFrac+6,opCurlyCurly-opFrac-6);
1592 fs2 =
Anal1(spec,
text+opCurlyCurly+2,length-opCurlyCurly-3);
1606 Analyse(
x+addW2,
y+fs2.
Over()-height,spec,
text+opCurlyCurly+2,length-opCurlyCurly-3);
1615 else if (opSplitLine>-1) {
1616 if (opCurlyCurly==-1) {
1618 fError =
"Missing second line for #splitline";
1624 fs1 =
Anal1(spec,
text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1625 fs2 =
Anal1(spec,
text+opCurlyCurly+2,length-opCurlyCurly-3);
1632 Analyse(
x,
y-fs1.
Under()-3*height,spec,
text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1638 else if (opSqrt>-1) {
1640 if (opSquareCurly>-1) {
1642 fs1 =
Anal1(specNewSize,
text+opSqrt+6,opSquareCurly-opSqrt-6);
1643 fs2 =
Anal1(spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1649 fs1 =
Anal1(spec,
text+opSqrt+5,length-opSqrt-5);
1654 if (opSquareCurly>-1) {
1662 Analyse(
x+pas2,
y,spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1691 else if (opColor>-1) {
1692 if (opSquareCurly==-1) {
1694 fError =
"Missing color number. Syntax is #color[(Int_t)nb]{ ... }";
1700 strncpy(nb,
text+opColor+7,opSquareCurly-opColor-7);
1701 nb[opSquareCurly-opColor-7] = 0;
1702 if (sscanf(nb,
"%d",&newSpec.
fColor) < 1) {
1705 fError =
"Invalid color number. Syntax is #color[(Int_t)nb]{ ... }";
1711 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1713 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1716 else if (opFont>-1) {
1717 if (opSquareCurly==-1) {
1719 fError =
"Missing font number. Syntax is #font[nb]{ ... }";
1725 strncpy(nb,
text+opFont+6,opSquareCurly-opFont-6);
1726 nb[opSquareCurly-opFont-6] = 0;
1727 if (sscanf(nb,
"%d",&newSpec.
fFont) < 1) {
1730 fError =
"Invalid font number. Syntax is #font[(Int_t)nb]{ ... }";
1736 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1738 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1741 else if (opKern>-1) {
1742 if (opSquareCurly==-1) {
1744 fError =
"Missing horizontal shift number. Syntax is #kern[dx]{ ... }";
1749 strncpy(dxc,
text+opKern+6,opSquareCurly-opKern-6);
1750 dxc[opSquareCurly-opKern-6] = 0;
1752 if (sscanf(dxc,
"%f",&dx) < 1) {
1755 fError =
"Invalid horizontal shift number. Syntax is #kern[(Float_t)dx]{ ... }";
1761 fs1 =
Anal1(spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1768 Analyse(
x + ddx,
y,spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1771 else if (opLower>-1) {
1772 if (opSquareCurly==-1) {
1774 fError =
"Missing vertical shift number. Syntax is #lower[dy]{ ... }";
1779 strncpy(dyc,
text+opLower+7,opSquareCurly-opLower-7);
1780 dyc[opSquareCurly-opLower-7] = 0;
1782 if (sscanf(dyc,
"%f",&dy) < 1) {
1785 fError =
"Invalid vertical shift number. Syntax is #lower[(Float_t)dy]{ ... }";
1791 fs1 =
Anal1(spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1798 Analyse(
x,
y + ddy,spec,
text+opSquareCurly+1,length-opSquareCurly-1);
1801 else if (opScale>-1) {
1802 if (opSquareCurly==-1) {
1804 fError =
"Missing scale factor. Syntax is #scale[(Double_t)nb]{ ... }";
1810 strncpy(nb,
text+opScale+7,opSquareCurly-opScale-7);
1811 nb[opSquareCurly-opScale-7] = 0;
1812 if (sscanf(nb,
"%lf",&newSpec.
fSize) < 1) {
1815 fError =
"Invalid scale factor. Syntax is #factor[(Double_t)nb]{ ... }";
1819 newSpec.
fSize *= spec.fSize;
1822 result =
Anal1(newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1824 Analyse(
x,
y,newSpec,
text+opSquareCurly+1,length-opSquareCurly-1);
1829 Int_t lut[] = {3, 13, 1, 6, 7, 4, 5, 10, 11, 8, 9, 12, 2, 14, 15};
1831 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1832 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1842 else if (opMbox>-1) {
1855 Int_t lut[] = {13, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 1, 14, 12};
1857 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1858 newSpec.
fFont = fontId*10 + newSpec.
fFont%10;
1881 quote1 = quote2 =
kFALSE ;
1883 for (i=0 ; i<leng ; i++) {
1885 case '\'' : quote1 = !quote1 ; break ;
1886 case '"' : quote2 = !quote2 ; break ;
1889 if (
text[i] ==
'@') {
1891 if ( *(p+1) ==
'{' || *(p+1) ==
'}' || *(p+1) ==
'[' || *(p+1) ==
']') {
1962 Double_t yy2 =
gPad->AbsPixeltoY(
Int_t((
x2-xOrigin)*-sinang+(y2-yOrigin)*cosang+yOrigin));
1966 gPad->PaintLine(xx,yy,xx2,yy2);
1980 const Int_t np = 40;
1988 for (
Int_t i=0;i<=np;i++) {
1992 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+ dy*sinang +xOrigin));
1993 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+ dy*cosang +yOrigin));
1995 gPad->PaintPolyLine(np+1,
x,
y);
2011 const Int_t np = 40;
2019 for (
Int_t i=0;i<=np;i++) {
2023 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+dy*sinang +xOrigin));
2024 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+dy*cosang +yOrigin));
2026 gPad->PaintPolyLine(np+1,
x,
y);
2055 if (size<=0 || strlen(text1) <= 0)
return;
2121 t.
ReplaceAll(
"#splitline",
"\\genfrac{}{}{0pt}{}");
2134 gPad->SetBatch(saveb);
2149 if( newText.
Length() == 0)
return 0;
2154 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2155 std::cout<<
"==> "<<text1<<std::endl;
2164 gPad->PaintText(
x,
y,text1);
2170 if (strstr(text1,
"\\")) {
2208 x =
gPad->XtoAbsPixel(
x);
2209 y =
gPad->YtoAbsPixel(
y);
2220 spec.fAngle = angle;
2228 std::cout<<
"*ERROR<TLatex>: "<<
fError<<std::endl;
2229 std::cout<<
"==> "<<
text<<std::endl;
2232 newSpec.
fSize = size;
2235 case 0:
y -= fs.
Under() ;
break;
2238 case 3:
y += fs.
Over() ;
break;
2241 case 2:
x -= fs.
Width()/2 ;
break;
2242 case 3:
x -= fs.
Width() ;
break;
2247 gPad->SetBatch(saveb);
2256 if (
fError != 0)
return 0;
2265 const Char_t *kWord1[] = {
"{}^{",
"{}_{",
"^{",
"_{",
"#scale{",
"#color{",
"#font{",
"#sqrt{",
"#[]{",
"#{}{",
"#||{",
2266 "#bar{",
"#vec{",
"#dot{",
"#hat{",
"#ddot{",
"#acute{",
"#grave{",
"#check{",
"#tilde{",
"#slash{",
"#bf{",
"#it{",
"#mbox{",
2267 "\\scale{",
"\\color{",
"\\font{",
"\\sqrt{",
"\\[]{",
"\\{}{",
"\\||{",
"#(){",
"\\(){",
2268 "\\bar{",
"\\vec{",
"\\dot{",
"\\hat{",
"\\ddot{",
"\\acute{",
"\\grave{",
"\\check{",
"\\bf{",
"\\it{",
"\\mbox{"};
2269 const Char_t *kWord2[] = {
"#scale[",
"#color[",
"#font[",
"#sqrt[",
"#kern[",
"#lower[",
"\\scale[",
"\\color[",
"\\font[",
"\\sqrt[",
"\\kern[",
"\\lower["};
2270 const Char_t *kWord3[] = {
"#frac{",
"\\frac{",
"#splitline{",
"\\splitline{"};
2271 const Char_t *kLeft1[] = {
"#left[",
"\\left[",
"#left{",
"\\left{",
"#left|",
"\\left|",
"#left(",
"\\left("};
2272 const Char_t *kLeft2[] = {
"#[]{",
"#[]{",
"#{}{",
"#{}{",
"#||{",
"#||{",
"#(){",
"#(){"};
2273 const Char_t *kRight[] = {
"#right]",
"\\right]",
"#right}",
"\\right}",
"#right|",
"\\right|",
"#right)",
"\\right)"};
2274 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};
2275 const Int_t lkWord2[] = {7,7,6,6,6,7,7,7,6,6,6,7} ;
2276 const Int_t lkWord3[] = {6,6,11,11} ;
2277 Int_t nkWord1 = 44, nkWord2 = 12, nkWord3 = 4;
2279 Int_t nLeft1 , nRight , nOfLeft, nOfRight;
2283 nLeft1 = nRight = 8 ;
2284 nOfLeft = nOfRight = 0 ;
2286 Char_t buf[11] ;
for (i=0;i<11;i++) buf[i]=0;
2291 Int_t nOfCurlyBracket, nOfKW1, nOfKW2, nOfKW3, nOfSquareCurly, nOfCurlyCurly ;
2292 Int_t nOfExtraCurly = 0 , nOfExtraSquare = 0;
2293 Int_t nOfSquareBracket = 0 ;
2300 while (i < length) {
2305 for (k = 0 ; k < nLeft1 ; k++) {
2306 if (strncmp(buf,kLeft1[k],lLeft1)==0) {
2313 if (opFound) continue ;
2315 for(k=0;k<nRight;k++) {
2316 if (strncmp(buf,kRight[k],lRight)==0) {
2325 if (nOfLeft != nOfRight) {
2326 printf(
" nOfLeft = %d, nOfRight = %d\n",nOfLeft,nOfRight) ;
2328 fError =
"Operators \"#left\" and \"#right\" don't match !" ;
2332 for (k = 0 ; k < nLeft1 ; k++) {
2333 text.ReplaceAll(kLeft1[k],lLeft1,kLeft2[k],lLeft2) ;
2335 for (k = 0 ; k < nRight ; k++) {
2336 text.ReplaceAll(kRight[k],lRight,
"}",1) ;
2338 length =
text.Length() ;
2340 i = nOfCurlyBracket = nOfKW1 = nOfKW2 = nOfKW3 = nOfSquareCurly = nOfCurlyCurly =0 ;
2343 case '"' : quote1 = !quote1 ; break ;
2344 case '\'': quote2 = !quote2 ; break ;
2351 for(k=0;k<nkWord1;k++) {
2352 if (strncmp(buf,kWord1[k],lkWord1[k])==0) {
2360 if (opFound) continue ;
2362 for(k=0;k<nkWord2;k++) {
2363 if (strncmp(buf,kWord2[k],lkWord2[k])==0) {
2371 if (opFound) continue ;
2373 for(k=0;k<nkWord3;k++) {
2374 if (strncmp(buf,kWord3[k],lkWord3[k])==0) {
2383 if (opFound) continue ;
2384 if (strncmp(buf,
"}{",2) == 0 && opFrac) {
2389 else if (strncmp(buf,
"]{",2) == 0 && nOfSquareBracket) {
2393 nOfSquareBracket-- ;
2395 else if (strncmp(buf,
"@{",2) == 0 || strncmp(buf,
"@}",2) == 0) {
2398 else if (strncmp(buf,
"@[",2) == 0 || strncmp(buf,
"@]",2) == 0) {
2401 else if (
text[i] ==
']' ) {
2402 text.Insert(i,
"@") ;
2407 else if (
text[i] ==
'[' ) {
2408 text.Insert(i,
"@") ;
2413 else if (
text[i] ==
'{' ) {
2414 text.Insert(i,
"@") ;
2419 else if (
text[i] ==
'}' ) {
2420 if ( nOfCurlyBracket) {
2424 text.Insert(i,
"@") ;
2435 if (nOfKW2 != nOfSquareCurly) {
2437 fError =
"Invalid number of \"]{\"" ;
2439 else if (nOfKW3 != nOfCurlyCurly) {
2441 fError =
"Error in syntax of \"#frac\"" ;
2443 else if (nOfCurlyBracket < 0) {
2445 fError =
"Missing \"{\"" ;
2447 else if (nOfCurlyBracket > 0) {
2449 fError =
"Missing \"}\"" ;
2451 else if (nOfSquareBracket < 0) {
2453 fError =
"Missing \"[\"" ;
2455 else if (nOfSquareBracket > 0) {
2457 fError =
"Missing \"]\"" ;
2483 spec.fAngle = angle;
2487 spec.fSize = size/hw;
2526 if (!
gPad)
return 0;
2528 if( newText.
Length() == 0)
return 0;
2538 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2539 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2559 if( newText.
Length() == 0)
return;
2570 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2571 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2577 Int_t cBoxX[4], cBoxY[4];
2580 ptx =
gPad->UtoPixel(
fX);
2581 pty =
gPad->VtoPixel(
fY);
2589 Int_t y1 = cBoxY[0];
2590 Int_t y2 = cBoxY[0];
2591 for (
Int_t i=1; i<4; i++) {
2592 if (cBoxX[i] <
x1)
x1 = cBoxX[i];
2593 if (cBoxX[i] >
x2)
x2 = cBoxX[i];
2594 if (cBoxY[i] < y1) y1 = cBoxY[i];
2595 if (cBoxY[i] > y2) y2 = cBoxY[i];
2613 if (!
gPad)
return 0;
2615 if( newText.
Length() == 0)
return 0;
2625 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2626 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2678 if (
gROOT->ClassSaved(TLatex::Class())) {
2688 out<<
" tex = new TLatex("<<
fX<<
","<<
fY<<
","<<quote<<s.
Data()<<quote<<
");"<<std::endl;
2694 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
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.
@ kTextNDC
The text postion is in NDC coordinates.
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
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
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.