392 fLimitFactorSize = 3;
411 fLimitFactorSize = 3;
437 ((
TLatex&)text).Copy(*
this);
472 ((
TLatex&)obj).fTabSize = 0;
516 const char *tab[] = {
"alpha",
"beta",
"chi",
"delta",
"varepsilon",
"phi",
"gamma",
"eta",
"iota",
"varphi",
"kappa",
"lambda",
517 "mu",
"nu",
"omicron",
"pi",
"theta",
"rho",
"sigma",
"tau",
"upsilon",
"varomega",
"omega",
"xi",
"psi",
"zeta",
518 "Alpha",
"Beta",
"Chi",
"Delta",
"Epsilon",
"Phi",
"Gamma",
"Eta",
"Iota",
"vartheta",
519 "Kappa",
"Lambda",
"Mu",
"Nu",
"Omicron",
"Pi",
"Theta",
"Rho",
"Sigma",
"Tau",
520 "Upsilon",
"varsigma",
"Omega",
"Xi",
"Psi",
"Zeta",
"varUpsilon",
"epsilon"};
522 const char *
tab2[] = {
"leq",
"/",
"infty",
"voidb",
"club",
"diamond",
"heart",
523 "spade",
"leftrightarrow",
"leftarrow",
"uparrow",
"rightarrow",
524 "downarrow",
"circ",
"pm",
"doublequote",
"geq",
"times",
"propto",
525 "partial",
"bullet",
"divide",
"neq",
"equiv",
"approx",
"3dots",
526 "cbar",
"topbar",
"downleftarrow",
"aleph",
"Jgothic",
"Rgothic",
"voidn",
527 "otimes",
"oplus",
"oslash",
"cap",
"cup",
"supset",
"supseteq",
528 "notsubset",
"subset",
"subseteq",
"in",
"notin",
"angle",
"nabla",
529 "oright",
"ocopyright",
"trademark",
"prod",
"surd",
"upoint",
"corner",
"wedge",
530 "vee",
"Leftrightarrow",
"Leftarrow",
"Uparrow",
"Rightarrow",
531 "Downarrow",
"diamond",
"LT",
"void1",
"copyright",
"void3",
"sum",
532 "arctop",
"lbar",
"arcbottom",
"topbar",
"void8",
"bottombar",
"arcbar",
533 "ltbar",
"AA",
"aa",
"void06",
"GT",
"int",
"forall",
"exists" };
535 const char *
tab3[] = {
"bar",
"vec",
"dot",
"hat",
"ddot",
"acute",
"grave",
"check",
"tilde",
"slash"};
537 if (
fError != 0)
return TLatexFormSize(0,0,0);
539 Int_t nBlancDeb=0,nBlancFin=0,l_nBlancDeb=0,l_nBlancFin=0;
547 if (nBlancDeb==length)
return TLatexFormSize(0,0,0);
552 if (nBlancDeb==l_nBlancDeb && nBlancFin==l_nBlancFin) cont =
kFALSE;
555 if (t[nBlancDeb]==
'{' && t[length-nBlancFin-1]==
'}') {
558 for(i=nBlancDeb;i<length-nBlancFin;i++) {
559 if (t[i] ==
'{' && !(i>0 && t[i-1] ==
'@')) nBrackets++;
560 if (t[i] ==
'}' && t[i-1]!=
'@') nBrackets--;
561 if (nBrackets==0 && i<length-nBlancFin-2) {
571 if (nBlancDeb+nBlancFin==length)
return TLatexFormSize(0,0,0);
577 l_nBlancDeb = nBlancDeb;
578 l_nBlancFin = nBlancFin;
583 length -= nBlancFin+nBlancDeb;
585 strncpy(text,t+nBlancDeb,length);
591 indiceSize = spec.fSize;
593 TextSpec_t specNewSize = spec;
594 specNewSize.fSize = indiceSize;
603 Int_t opCurlyCurly = -1;
604 Int_t opSquareCurly = -1;
605 Int_t opCloseCurly = -2;
612 Int_t opSquareBracket = 0 ;
613 Int_t opBigCurly = 0 ;
616 Int_t abovePlace = 0 ;
624 Int_t opBackslash = 0;
625 Int_t opParallel = 0;
626 Int_t opSplitLine = -1;
638 case '\'' : quote1 = !quote1 ; break ;
639 case '"' : quote2 = !quote2 ; break ;
645 if (!(i>0 && text[i-1] ==
'@')) nBrackets++;
650 if (!(i>0 && text[i-1] ==
'@')) nBrackets--;
652 if (i<length-1)
if (text[i+1]==
'{' && opCurlyCurly==-1) opCurlyCurly=i;
654 if (text[i+1]!=
'{' && !(text[i+2]==
'{' && (text[i+1]==
'^' || text[i+1]==
'_'))
655 && opCloseCurly==-2) opCloseCurly=i;
657 else if (i<length-1) {
658 if (text[i+1]!=
'{' && opCloseCurly==-2) opCloseCurly=i;
660 else if (opCloseCurly==-2) opCloseCurly=i;
666 if (!(i>0 && text[i-1] ==
'@')) nCroch++;
671 if (!(i>0 && text[i-1] ==
'@')) nCroch--;
676 return TLatexFormSize(0,0,0);
683 strncpy(buf,&text[i],2);
684 if (strncmp(buf,
"^{",2)==0) {
685 if (opPower==-1 && nBrackets==0 && nCroch==0) opPower=i;
688 strncpy(buf1,&text[i-4],4);
689 if (strncmp(buf1,
"#int",4)==0) {
691 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
693 if (strncmp(buf1,
"#sum",4)==0) {
695 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
699 if (strncmp(buf,
"_{",2)==0) {
700 if (opUnder==-1 && nBrackets==0 && nCroch==0) opUnder=i;
703 strncpy(buf2,&text[i-4],4);
704 if (strncmp(buf2,
"#int",4)==0) {
706 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
708 if (strncmp(buf2,
"#sum",4)==0) {
710 if (i>4 && opCloseCurly==-2) opCloseCurly=i-5;
714 if (strncmp(buf,
"]{",2)==0)
715 if (opSquareCurly==-1 && nBrackets==0 && nCroch==0) opSquareCurly=i;
718 if (text[i]==
'\\' || (text[i]==
'#' && !opFound && nBrackets==0 && nCroch==0)) {
722 strncpy(buf,&text[i+1],10);
723 if (strncmp(buf,
"splitline{",10)==0) {
724 opSplitLine=i; opFound =
kTRUE;
725 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
731 strncpy(buf,&text[i+1],9);
732 if (!opBackslash && strncmp(buf,
"backslash",9)==0) {
733 opBackslash=1; opFound =
kTRUE;
734 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
740 strncpy(buf,&text[i+1],8);
741 if (!opParallel && strncmp(buf,
"parallel",8)==0) {
742 opParallel=1; opFound =
kTRUE;
743 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
749 strncpy(buf,&text[i+1],6);
750 if (strncmp(buf,
"lower[",6)==0 || strncmp(buf,
"lower{",6)==0) {
751 opLower=i; opFound =
kTRUE;
752 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
755 if (strncmp(buf,
"scale[",6)==0 || strncmp(buf,
"scale{",6)==0) {
756 opScale=i; opFound =
kTRUE;
757 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
760 if (strncmp(buf,
"color[",6)==0 || strncmp(buf,
"color{",6)==0) {
761 opColor=i; opFound =
kTRUE;
762 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
768 strncpy(buf,&text[i+1],5);
769 if (strncmp(buf,
"frac{",5)==0) {
770 opFrac=i; opFound =
kTRUE;
771 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
774 if (strncmp(buf,
"sqrt{",5)==0 || strncmp(buf,
"sqrt[",5)==0) {
775 opSqrt=i; opFound =
kTRUE;
776 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
779 if (strncmp(buf,
"font{",5)==0 || strncmp(buf,
"font[",5)==0) {
780 opFont=i; opFound =
kTRUE;
781 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
784 if (strncmp(buf,
"kern[",5)==0 || strncmp(buf,
"kern{",5)==0) {
785 opKern=i; opFound =
kTRUE;
786 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
789 if (!opMinus && strncmp(buf,
"minus",5)==0) {
790 opMinus=1; opFound =
kTRUE;
791 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
794 if (strncmp(buf,
"mbox[",5)==0 || strncmp(buf,
"mbox{",5)==0) {
795 opMbox=i; opFound =
kTRUE;
796 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
802 strncpy(buf,&text[i+1],4);
803 if (!opOdot && strncmp(buf,
"odot",4)==0) {
804 opOdot=1; opFound =
kTRUE;
805 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
808 if (!opHbar && strncmp(buf,
"hbar",4)==0) {
809 opHbar=1; opFound =
kTRUE;
810 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
813 if (!opPerp && strncmp(buf,
"perp",4)==0) {
814 opPerp=1; opFound =
kTRUE;
815 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
818 if (!opPlus && strncmp(buf,
"plus",4)==0) {
819 opPlus=1; opFound =
kTRUE;
820 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
826 strncpy(buf,&text[i+1],3);
828 if (strncmp(buf,
"[]{",3)==0) {
829 opSquareBracket=1; opFound =
kTRUE;
830 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
833 if (strncmp(buf,
"{}{",3)==0 ) {
834 opBigCurly=1; opFound =
kTRUE;
835 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
838 if (strncmp(buf,
"||{",3)==0) {
839 opAbs=1; opFound =
kTRUE;
840 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
843 if (strncmp(buf,
"(){",3)==0) {
844 opParen=1; opFound =
kTRUE;
845 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
848 if (!opBox && strncmp(buf,
"Box",3)==0) {
849 opBox=1; opFound =
kTRUE;
850 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
853 if (strncmp(buf,
"bf[",3)==0 || strncmp(buf,
"bf{",3)==0) {
854 opBf=i; opFound =
kTRUE;
855 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
858 if (strncmp(buf,
"it[",3)==0 || strncmp(buf,
"it{",3)==0) {
859 opIt=i; opFound =
kTRUE;
860 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
866 strncpy(buf,&text[i+1],2);
867 if (!opMp && strncmp(buf,
"mp",2)==0) {
868 opMp=1; opFound =
kTRUE;
869 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
874 if (!opFound &&
UInt_t(length)>i+strlen(tab[k])) {
875 if (strncmp(&text[i+1],tab[k],strlen(tab[k]))==0) {
878 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
883 if (!opFound &&
UInt_t(length)>i+strlen(tab3[k])) {
884 if (strncmp(&text[i+1],tab3[k],strlen(tab3[k]))==0) {
887 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
894 if ((opSpec==-1 || strlen(tab2[k])>lastsize) &&
UInt_t(length)>i+strlen(tab2[k])) {
895 if (strncmp(&text[i+1],tab2[k],strlen(tab2[k]))==0) {
896 lastsize = strlen(tab2[k]);
899 if (i>0 && opCloseCurly==-2) opCloseCurly=i-1;
912 if (opCloseCurly>-1 && opCloseCurly<length-1) {
914 fs1 =
Anal1(spec,text,opCloseCurly+1);
915 fs2 =
Anal1(spec,text+opCloseCurly+1,length-opCloseCurly-1);
919 Analyse(x+fs1.Width(),
y,spec,text+opCloseCurly+1,length-opCloseCurly-1);
920 Analyse(x,y,spec,text,opCloseCurly+1);
925 else if (opPower>-1 && opUnder>-1) {
930 switch (abovePlace) {
932 prop = .8 ; propU = 1.75 ;
935 prop = .9 ; propU = 1.75 ;
944 if (min >= 2 && strncmp(&text[min-2],
"{}",2)==0) {
947 snprintf(&text[ltext-2],length-(ltext-2),
"I ") ;
950 fs1 =
Anal1(spec,text,ltext);
951 fs2 =
Anal1(specNewSize,text+min+1,
max-min-1);
962 Double_t addW = fs1.Width()+xfpos, addH1, addH2;
963 if (opPower<opUnder) {
971 Analyse(x+addW,y+addH1,specNewSize,text+min+1,
max-min-1);
973 Double_t addW1, addW2, addH1, addH2;
975 pos = (m-fs1.Width())/2;
976 if (opPower<opUnder) {
977 addH1 = -fs1.Over()*propU-fs2.Under();
978 addW1 = (m-fs2.Width())/2;
979 addH2 = fs1.Under()*prop+fs3.Over();
980 addW2 = (m-fs3.Width())/2;
982 addH1 = fs1.Under()*prop+fs2.Over();
983 addW1 = (m-fs2.Width())/2;
984 addH2 = -fs1.Over()*propU-fs3.Under();
985 addW2 = (m-fs3.Width())/2;
988 Analyse(x+addW2,y+addH2,specNewSize,text+
max+1,length-
max-1);
989 Analyse(x+addW1,y+addH1,specNewSize,text+min+1,
max-min-1);
992 if (min >= 2 && strncmp(&text[min-2],
"{}",2)==0) {
993 snprintf(&text[min-2],length-(min-2),
" ") ;
994 Analyse(x+pos,y,spec,text,min-1);
996 Analyse(x+pos,y,spec,text,min);
1001 if (opPower<opUnder) {
1002 result.Set(fs1.Width()+xfpos+
TMath::Max(fs2.Width(),fs3.Width()),
1004 fs1.Under()+fs3.Height()-fs3.Over()*(1-
fFactorPos));
1006 result.Set(fs1.Width()+xfpos+
TMath::Max(fs2.Width(),fs3.Width()),
1008 fs1.Under()+fs2.Height()-fs2.Over()*(1-
fFactorPos));
1011 if (opPower<opUnder) {
1013 fs1.Over()*propU+fs2.Height(),fs1.Under()*prop+fs3.Height());
1016 fs1.Over()*propU+fs3.Height(),fs1.Under()*prop+fs2.Height());
1020 else if (opPower>-1) {
1023 switch (abovePlace) {
1025 prop = 1.75 ; break ;
1027 prop = 1.75; break ;
1031 Int_t ltext = opPower ;
1032 if (ltext >= 2 && strncmp(&text[ltext-2],
"{}",2)==0) {
1035 snprintf(&text[ltext-2],length-(ltext-2),
"I ") ;
1038 fs1 =
Anal1(spec,text,ltext);
1039 fs2 =
Anal1(specNewSize,text+opPower+1,length-opPower-1);
1048 if (over <= 0) over = 1.5*fs2.Over();
1049 Analyse(x+fs1.Width()+xfpos,y-over*
fFactorPos-fs2.Under(),specNewSize,text+opPower+1,length-opPower-1);
1052 if (fs2.Width()>fs1.Width())
1053 pos=
Int_t((fs2.Width()-fs1.Width())/2);
1055 pos2=
Int_t((fs1.Width()-fs2.Width())/2);
1057 Analyse(x+pos2,y-fs1.Over()*prop-fs2.Under(),specNewSize,text+opPower+1,length-opPower-1);
1059 if (opPower >= 2 && strncmp(&text[opPower-2],
"{}",2)==0) {
1060 snprintf(&text[opPower-2],length-(opPower-2),
" ") ;
1061 Analyse(x+pos,y,spec,text,opPower-1);
1063 Analyse(x+pos,y,spec,text,opPower);
1068 result.Set(fs1.Width()+xfpos+fs2.Width(),
1069 fs1.Over()*
fFactorPos+fs2.Over(),fs1.Under());
1071 result.Set(
TMath::Max(fs1.Width(),fs2.Width()),fs1.Over()*prop+fs2.Height(),fs1.Under());
1074 else if (opUnder>-1) {
1080 Int_t ltext = opUnder ;
1081 if (ltext >= 2 && strncmp(&text[ltext-2],
"{}",2)==0) {
1084 snprintf(&text[ltext-2],length-(ltext-2),
"I ") ;
1087 fs1 =
Anal1(spec,text,ltext);
1088 fs2 =
Anal1(specNewSize,text+opUnder+1,length-opUnder-1);
1096 Analyse(x+fs1.Width()+xfpos,y+fs1.Under()+fs2.Over()*fpos,specNewSize,text+opUnder+1,length-opUnder-1);
1099 if (fs2.Width()>fs1.Width())
1100 pos=
Int_t((fs2.Width()-fs1.Width())/2);
1102 pos2=
Int_t((fs1.Width()-fs2.Width())/2);
1104 Analyse(x+pos2,y+fs1.Under()*prop+fs2.Over(),specNewSize,text+opUnder+1,length-opUnder-1);
1106 if (opUnder >= 2 && strncmp(&text[opUnder-2],
"{}",2)==0) {
1107 snprintf(&text[opUnder-2],length-(opUnder-2),
" ") ;
1108 Analyse(x+pos,y,spec,text,opUnder-1);
1110 Analyse(x+pos,y,spec,text,opUnder);
1114 result.Set(fs1.Width()+xfpos+fs2.Width(),fs1.Over(),
1115 fs1.Under()+fs2.Under()+fs2.Over()*fpos);
1117 result.Set(
TMath::Max(fs1.Width(),fs2.Width()),fs1.Over(),fs1.Under()*prop+fs2.Height());
1122 fs1 =
Anal1(spec,text+4,length-4);
1124 fs1 =
Analyse(x+square,y,spec,text+4,length-4);
1135 result = fs1 + TLatexFormSize(square,square,0);
1140 fs1 =
Anal1(spec,text+5,length-5);
1142 fs1 =
Analyse(x+1.3*square,y,spec,text+5,length-5);
1149 result = fs1 + TLatexFormSize(square,square,0);
1154 fs1 =
Anal1(spec,text+5,length-5);
1156 fs1 =
Analyse(x+square,y,spec,text+5,length-5);
1169 DrawLine(x,y-0.8*square,x+0.75*square,y-square,spec);
1171 result = fs1 + TLatexFormSize(square,square,0);
1176 fs1 =
Anal1(spec,text+6,length-6);
1178 fs1 =
Analyse(x+square,y,spec,text+6,length-6);
1192 result = fs1 + TLatexFormSize(square,square,0);
1197 fs1 =
Anal1(spec,text+5,length-5);
1199 fs1 =
Analyse(x+square,y,spec,text+5,length-5);
1213 result = fs1 + TLatexFormSize(square,square,0);
1218 fs1 =
Anal1(spec,text+3,length-3);
1220 fs1 =
Analyse(x+square,y,spec,text+3,length-3);
1234 result = fs1 + TLatexFormSize(square,square,0);
1239 fs1 =
Anal1(spec,text+5,length-5);
1241 fs1 =
Analyse(x+0.5*square,y,spec,text+5,length-5);
1252 else if (opBackslash) {
1255 fs1 =
Anal1(spec,text+10,length-10);
1257 fs1 =
Analyse(x+square,y,spec,text+10,length-10);
1271 result = fs1 + TLatexFormSize(square,square,0);
1273 else if (opParallel) {
1276 fs1 =
Anal1(spec,text+9,length-9);
1278 fs1 =
Analyse(x+0.5*square,y,spec,text+9,length-9);
1286 result = fs1 + TLatexFormSize(square,square,0);
1288 else if (opGreek>-1) {
1289 TextSpec_t newSpec = spec;
1290 newSpec.fFont =
fItalic ? 152 : 122;
1291 char letter = 97 + opGreek;
1293 if (opGreek>25) letter -= 58;
1294 if (opGreek == 52) letter =
'\241';
1295 if (opGreek == 53) letter =
'\316';
1297 fs1 =
Anal1(newSpec,&letter,1);
1298 fs2 =
Anal1(spec,text+strlen(tab[opGreek])+1,length-strlen(tab[opGreek])-1);
1302 Analyse(x+fs1.Width(),
y,spec,text+strlen(tab[opGreek])+1,length-strlen(tab[opGreek])-1);
1303 Analyse(x,y-yoffset,newSpec,&letter,1);
1305 fs1.AddOver(TLatexFormSize(0,yoffset,0)) ;
1309 else if (opSpec>-1) {
1310 TextSpec_t newSpec = spec;
1311 newSpec.fFont =
fItalic ? 152 : 122;
1312 char letter =
'\243' + opSpec;
1313 if(opSpec == 75 || opSpec == 76) {
1315 if (opSpec == 75) letter =
'\305';
1316 if (opSpec == 76) letter =
'\345';
1318 if(opSpec == 80 || opSpec == 81) {
1319 if (opSpec == 80) letter =
'\042';
1320 if (opSpec == 81) letter =
'\044';
1327 newSpec.fSize = spec.fSize*props;
1328 }
else if (opSpec==79) {
1329 newSpec.fSize = spec.fSize*propi;
1332 fs1 =
Anal1(newSpec,&letter,1);
1333 if (opSpec == 79 || opSpec == 66)
1334 fs1.Set(fs1.Width(),fs1.Over()*0.45,fs1.Over()*0.45);
1336 fs2 =
Anal1(spec,text+strlen(tab2[opSpec])+1,length-strlen(tab2[opSpec])-1);
1340 Analyse(x+fs1.Width(),
y,spec,text+strlen(tab2[opSpec])+1,length-strlen(tab2[opSpec])-1);
1341 if (opSpec!=66 && opSpec!=79)
1342 Analyse(x,y,newSpec,&letter,1);
1344 Analyse(x,y+fs1.Under()/2.,newSpec,&letter,1);
1349 else if (opAbove>-1) {
1351 fs1 =
Anal1(spec,text+strlen(tab3[opAbove])+1,length-strlen(tab3[opAbove])-1);
1355 Analyse(x,y,spec,text+strlen(tab3[opAbove])+1,length-strlen(tab3[opAbove])-1);
1361 ypos = y-fs1.Over()-sub ;
1362 DrawLine(x,ypos,x+fs1.Width(),ypos,spec);
1366 y0 = y-sub-fs1.Over() ;
1368 x1 = x+fs1.Width() ;
1374 x1 = x+fs1.Width()/2-3*sub/4 ;
1375 x2 = x+fs1.Width()/2+3*sub/4 ;
1376 y1 = y-sub-fs1.Over() ;
1380 x2 = x+fs1.Width()/2 ;
1383 x1 = x2-fs1.Width()/3 ;
1384 x3 = x2+fs1.Width()/3 ;
1389 x1 = x+fs1.Width()/2-9*sub/4 ;
1390 x2 = x+fs1.Width()/2-3*sub/4 ;
1391 x3 = x+fs1.Width()/2+9*sub/4 ;
1392 x4 = x+fs1.Width()/2+3*sub/4 ;
1393 y1 = y-sub-fs1.Over() ;
1398 x1 = x+fs1.Width()/2;
1399 y1 = y +sub -fs1.Over() ;
1405 x1 = x+fs1.Width()/2-sub;
1406 y1 = y-sub-fs1.Over() ;
1412 x1 = x+fs1.Width()/2 ;
1415 y1 = y-sub-fs1.Over() ;
1420 x2 = x+fs1.Width()/2 ;
1421 y2 = y -fs1.Over() ;
1428 if (
gVirtualX->InheritsFrom(
"TGCocoa")) y2 -= 3*sub;
1433 Double_t xx =
gPad->AbsPixeltoX(
Int_t((x2-xOrigin)*cosang+(y2-yOrigin)*sinang+xOrigin));
1434 Double_t yy =
gPad->AbsPixeltoY(
Int_t((x2-xOrigin)*-sinang+(y2-yOrigin)*cosang+yOrigin));
1445 xx =
gPad->AbsPixeltoX(
Int_t((x2-xOrigin)*cosang+(y22-yOrigin)*sinang+xOrigin));
1446 yy =
gPad->AbsPixeltoY(
Int_t((x2-xOrigin)*-sinang+(y22-yOrigin)*cosang+yOrigin));
1453 x1 = x + 0.8*fs1.Width();
1454 y1 = y -fs1.Over() ;
1455 x2 = x + 0.3*fs1.Width();
1456 y2 = y1 + 1.2*fs1.Height();
1462 if (opAbove==1) div=4;
1463 result.Set(fs1.Width(),fs1.Over()+
GetHeight()*spec.fSize/div,fs1.Under());
1465 else if (opSquareBracket) {
1469 fs1 =
Anal1(spec,text+3,length-3);
1473 Analyse(x+l2+l,y,spec,text+3,length-3);
1474 DrawLine(x+l2,y-fs1.Over(),x+l2,y+fs1.Under(),spec);
1475 DrawLine(x+l2,y-fs1.Over(),x+l2+
l,y-fs1.Over(),spec);
1476 DrawLine(x+l2,y+fs1.Under(),x+l2+
l,y+fs1.Under(),spec);
1477 DrawLine(x+l2+fs1.Width()+2*
l,y-fs1.Over(),x+l2+fs1.Width()+2*
l,y+fs1.Under(),spec);
1478 DrawLine(x+l2+fs1.Width()+2*
l,y-fs1.Over(),x+l2+fs1.Width()+
l,y-fs1.Over(),spec);
1479 DrawLine(x+l2+fs1.Width()+2*
l,y+fs1.Under(),x+l2+fs1.Width()+
l,y+fs1.Under(),spec);
1481 result.Set(fs1.Width()+3*
l,fs1.Over(),fs1.Under());
1485 Double_t radius2,radius1 , dw, l2 = l/2 ;
1488 fs1 =
Anal1(spec,text+3,length-3);
1490 radius2 = fs1.Height() ;
1491 radius1 = radius2 * 2 / 3;
1495 radius2 = fs1.Height();
1496 radius1 = radius2 * 2 / 3;
1499 Double_t x2 = x+5*l2+2*dw+fs1.Width()-radius1 ;
1500 Double_t y1 = y - (fs1.Over() - fs1.Under())/2. ;
1503 Analyse(x+3*l2+dw,y,spec,text+3,length-3);
1506 result.Set(fs1.Width()+3*l+2*dw,fs1.Over(),fs1.Under());
1512 fs1 =
Anal1(spec,text+3,length-3);
1516 Analyse(x+l2+l,y,spec,text+3,length-3);
1517 DrawLine(x+l2,y-fs1.Over(),x+l2,y+fs1.Under(),spec);
1518 DrawLine(x+l2+fs1.Width()+2*
l,y-fs1.Over(),x+l2+fs1.Width()+2*
l,y+fs1.Under(),spec);
1520 result.Set(fs1.Width()+3*
l,fs1.Over(),fs1.Under());
1522 else if (opBigCurly) {
1528 fs1 =
Anal1(spec,text+3,length-3);
1529 l8 = fs1.Height()/8 ;
1535 Double_t y2 = y + (fs1.Under()-fs1.Over())/2 ;
1536 l8 = fs1.Height()/8 ;
1539 Analyse(x+l+ltip+l2,y,spec,text+3,length-3);
1542 DrawLine(x+l2+ltip,y-fs1.Over(),x+l2+ltip,y2-ltip,spec);
1543 DrawLine(x+l2+ltip,y2+ltip,x+l2+ltip,y+fs1.Under(),spec);
1545 DrawLine(x+l2+ltip,y-fs1.Over(),x+l2+ltip+
l,y-fs1.Over(),spec);
1546 DrawLine(x+l2+ltip,y+fs1.Under(),x+l2+ltip+
l,y+fs1.Under(),spec);
1548 DrawLine(x+l2,y2,x+l2+ltip,y2-ltip,spec);
1549 DrawLine(x+l2,y2,x+l2+ltip,y2+ltip,spec);
1553 DrawLine(x+l2+ltip+fs1.Width()+2*
l,y-fs1.Over(),x+l2+ltip+fs1.Width()+2*
l,y2-ltip,spec);
1554 DrawLine(x+l2+ltip+fs1.Width()+2*
l,y2+ltip,x+l2+ltip+fs1.Width()+2*
l,y+fs1.Under(),spec);
1556 DrawLine(x+l2+fs1.Width()+l+ltip,y-fs1.Over(),x+l2+ltip+fs1.Width()+2*
l,y-fs1.Over(),spec);
1557 DrawLine(x+l2+fs1.Width()+l+ltip,y+fs1.Under(),x+l2+ltip+fs1.Width()+2*
l,y+fs1.Under(),spec);
1559 DrawLine(x+l2+ltip+2*l+fs1.Width(),y2-ltip,x+l2+2*l+2*ltip+fs1.Width(),y2,spec);
1560 DrawLine(x+l2+ltip+2*l+fs1.Width(),y2+ltip,x+l2+2*l+2*ltip+fs1.Width(),y2,spec);
1562 result.Set(fs1.Width()+3*l+2*ltip,fs1.Over(),fs1.Under()) ;;
1564 else if (opFrac>-1) {
1565 if (opCurlyCurly==-1) {
1567 fError =
"Missing denominator for #frac";
1568 return TLatexFormSize(0,0,0);
1572 fs1 =
Anal1(spec,text+opFrac+6,opCurlyCurly-opFrac-6);
1573 fs2 =
Anal1(spec,text+opCurlyCurly+2,length-opCurlyCurly-3);
1580 if (fs1.Width()<fs2.Width()) {
1581 addW1 = (fs2.Width()-fs1.Width())/2;
1585 addW2 = (fs1.Width()-fs2.Width())/2;
1587 Analyse(x+addW2,y+fs2.Over()-height,spec,text+opCurlyCurly+2,length-opCurlyCurly-3);
1588 Analyse(x+addW1,y-fs1.Under()-3*height,spec,text+opFrac+6,opCurlyCurly-opFrac-6);
1593 result.Set(
TMath::Max(fs1.Width(),fs2.Width()),fs1.Height()+3*height,fs2.Height()-height);
1596 else if (opSplitLine>-1) {
1597 if (opCurlyCurly==-1) {
1599 fError =
"Missing second line for #splitline";
1600 return TLatexFormSize(0,0,0);
1604 fs1 =
Anal1(spec,text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1605 fs2 =
Anal1(spec,text+opCurlyCurly+2,length-opCurlyCurly-3);
1611 Analyse(x,y+fs2.Over()-height,spec,text+opCurlyCurly+2,length-opCurlyCurly-3);
1612 Analyse(x,y-fs1.Under()-3*height,spec,text+opSplitLine+11,opCurlyCurly-opSplitLine-11);
1615 result.
Set(
TMath::Max(fs1.Width(),fs2.Width()),fs1.Height()+3*height,fs2.Height()-height);
1618 else if (opSqrt>-1) {
1620 if (opSquareCurly>-1) {
1622 fs1 =
Anal1(specNewSize,text+opSqrt+6,opSquareCurly-opSqrt-6);
1623 fs2 =
Anal1(spec,text+opSquareCurly+1,length-opSquareCurly-1);
1627 fs2.Over()+fs1.Height()+
GetHeight()*spec.fSize/4,fs2.Under());
1629 fs1 =
Anal1(spec,text+opSqrt+5,length-opSqrt-5);
1631 result.Set(fs1.Width()+
GetHeight()*spec.fSize/2,fs1.Over()+
GetHeight()*spec.fSize/4,fs1.Under());
1634 if (opSquareCurly>-1) {
1642 Analyse(x+pas2,y,spec,text+opSquareCurly+1,length-opSquareCurly-1);
1643 Analyse(x,y-fs2.Over()-fs1.Under(),specNewSize,text+opSqrt+6,opSquareCurly-opSqrt-6);
1646 DrawLine(x+pas,y3,x+pas2+fs2.Width(),y3,spec);
1663 DrawLine(x1-2*dx,y1,x1-dx,y2,spec);
1671 else if (opColor>-1) {
1672 if (opSquareCurly==-1) {
1674 fError =
"Missing color number. Syntax is #color[(Int_t)nb]{ ... }";
1675 return TLatexFormSize(0,0,0);
1677 TextSpec_t newSpec = spec;
1679 strncpy(nb,text+opColor+7,opSquareCurly-opColor-7);
1680 nb[opSquareCurly-opColor-7] = 0;
1681 if (sscanf(nb,
"%d",&newSpec.fColor) < 1) {
1684 fError =
"Invalid color number. Syntax is #color[(Int_t)nb]{ ... }";
1685 return TLatexFormSize(0,0,0);
1689 result =
Anal1(newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1691 Analyse(x,y,newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1694 else if (opFont>-1) {
1695 if (opSquareCurly==-1) {
1697 fError =
"Missing font number. Syntax is #font[nb]{ ... }";
1698 return TLatexFormSize(0,0,0);
1700 TextSpec_t newSpec = spec;
1702 strncpy(nb,text+opFont+6,opSquareCurly-opFont-6);
1703 nb[opSquareCurly-opFont-6] = 0;
1704 if (sscanf(nb,
"%d",&newSpec.fFont) < 1) {
1707 fError =
"Invalid font number. Syntax is #font[(Int_t)nb]{ ... }";
1708 return TLatexFormSize(0,0,0);
1712 result =
Anal1(newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1714 Analyse(x,y,newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1717 else if (opKern>-1) {
1718 if (opSquareCurly==-1) {
1720 fError =
"Missing horizontal shift number. Syntax is #kern[dx]{ ... }";
1721 return TLatexFormSize(0,0,0);
1724 strncpy(dxc,text+opKern+6,opSquareCurly-opKern-6);
1725 dxc[opSquareCurly-opKern-6] = 0;
1727 if (sscanf(dxc,
"%f",&dx) < 1) {
1730 fError =
"Invalid horizontal shift number. Syntax is #kern[(Float_t)dx]{ ... }";
1731 return TLatexFormSize(0,0,0);
1735 fs1 =
Anal1(spec,text+opSquareCurly+1,length-opSquareCurly-1);
1738 result = TLatexFormSize(fs1.Width() + ddx, fs1.Over(), fs1.Under());
1742 Analyse(x + ddx,y,spec,text+opSquareCurly+1,length-opSquareCurly-1);
1745 else if (opLower>-1) {
1746 if (opSquareCurly==-1) {
1748 fError =
"Missing vertical shift number. Syntax is #lower[dy]{ ... }";
1749 return TLatexFormSize(0,0,0);
1752 strncpy(dyc,text+opLower+7,opSquareCurly-opLower-7);
1753 dyc[opSquareCurly-opLower-7] = 0;
1755 if (sscanf(dyc,
"%f",&dy) < 1) {
1758 fError =
"Invalid vertical shift number. Syntax is #lower[(Float_t)dy]{ ... }";
1759 return TLatexFormSize(0,0,0);
1763 fs1 =
Anal1(spec,text+opSquareCurly+1,length-opSquareCurly-1);
1765 Double_t ddy = dy * (fs1.Over() + fs1.Under());
1766 result = TLatexFormSize(fs1.Width(), fs1.Over() + ddy, fs1.Under() + ddy);
1769 Double_t ddy = dy * (fs1.Over() + fs1.Under());
1770 Analyse(x,y + ddy,spec,text+opSquareCurly+1,length-opSquareCurly-1);
1773 else if (opScale>-1) {
1774 if (opSquareCurly==-1) {
1776 fError =
"Missing scale factor. Syntax is #scale[(Double_t)nb]{ ... }";
1777 return TLatexFormSize(0,0,0);
1779 TextSpec_t newSpec = spec;
1781 strncpy(nb,text+opScale+7,opSquareCurly-opScale-7);
1782 nb[opSquareCurly-opScale-7] = 0;
1783 if (sscanf(nb,
"%lf",&newSpec.fSize) < 1) {
1786 fError =
"Invalid scale factor. Syntax is #factor[(Double_t)nb]{ ... }";
1787 return TLatexFormSize(0,0,0);
1789 newSpec.fSize *= spec.fSize;
1792 result =
Anal1(newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1794 Analyse(x,y,newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
1798 TextSpec_t newSpec = spec;
1799 Int_t lut[] = {3, 13, 1, 6, 7, 4, 5, 10, 11, 8, 9, 12, 2, 14, 15};
1800 Int_t fontId = (newSpec.fFont/10);
1801 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1802 newSpec.fFont = fontId*10 + newSpec.fFont%10;
1804 fs1 =
Anal1(newSpec,text+3,length-3);
1808 Analyse(x,y,newSpec,text+3,length-3);
1812 else if (opMbox>-1) {
1813 TextSpec_t newSpec = spec;
1815 fs1 =
Anal1(newSpec,text+5,length-5);
1819 Analyse(x,y,newSpec,text+5,length-5);
1824 TextSpec_t newSpec = spec;
1825 Int_t lut[] = {13, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 15, 1, 14, 12};
1826 Int_t fontId = (newSpec.fFont/10);
1827 if ((fontId >= 1) && (fontId <= (
Int_t)(
sizeof(lut)/
sizeof(lut[0])))) fontId = lut[fontId-1];
1828 newSpec.fFont = fontId*10 + newSpec.fFont%10;
1831 fs1 =
Anal1(newSpec,text+3,length-3);
1835 Analyse(x,y,newSpec,text+3,length-3);
1849 Int_t leng = strlen(text) ;
1851 quote1 = quote2 =
kFALSE ;
1853 for (i=0 ; i<leng ; i++) {
1855 case '\'' : quote1 = !quote1 ; break ;
1856 case '"' : quote2 = !quote2 ; break ;
1859 if (text[i] ==
'@') {
1861 if ( *(p+1) ==
'{' || *(p+1) ==
'}' || *(p+1) ==
'[' || *(p+1) ==
']') {
1878 gPad->PaintText(xx,yy,text);
1928 Double_t xx =
gPad->AbsPixeltoX(
Int_t((x1-xOrigin)*cosang+(y1-yOrigin)*sinang+xOrigin));
1929 Double_t yy =
gPad->AbsPixeltoY(
Int_t((x1-xOrigin)*-sinang+(y1-yOrigin)*cosang+yOrigin));
1931 Double_t xx2 =
gPad->AbsPixeltoX(
Int_t((x2-xOrigin)*cosang+(y2-yOrigin)*sinang+xOrigin));
1932 Double_t yy2 =
gPad->AbsPixeltoY(
Int_t((x2-xOrigin)*-sinang+(y2-yOrigin)*cosang+yOrigin));
1936 gPad->PaintLine(xx,yy,xx2,yy2);
1962 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+ dy*sinang +xOrigin));
1963 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+ dy*cosang +yOrigin));
1965 gPad->PaintPolyLine(np+1,x,y);
1981 const Int_t np = 40;
1993 x[i] =
gPad->AbsPixeltoX(
Int_t( dx*cosang+dy*sinang +xOrigin));
1994 y[i] =
gPad->AbsPixeltoY(
Int_t(-dx*sinang+dy*cosang +yOrigin));
1996 gPad->PaintPolyLine(np+1,x,y);
2033 if (t.Index(
"#")>=0 || t.Index(
"^")>=0 || t.Index(
"\\")>=0) {
2034 t.ReplaceAll(
"#LT",
"\\langle");
2035 t.ReplaceAll(
"#GT",
"\\rangle");
2036 t.ReplaceAll(
"#club",
"\\clubsuit");
2037 t.ReplaceAll(
"#spade",
"\\spadesuit");
2038 t.ReplaceAll(
"#heart",
"\\heartsuit");
2039 t.ReplaceAll(
"#diamond",
"\\diamondsuit");
2040 t.ReplaceAll(
"#voidn",
"\\wp");
2041 t.ReplaceAll(
"#voidb",
"f");
2042 t.ReplaceAll(
"#ocopyright",
"\\copyright");
2043 t.ReplaceAll(
"#trademark",
"TM");
2044 t.ReplaceAll(
"#void3",
"TM");
2045 t.ReplaceAll(
"#oright",
"R");
2046 t.ReplaceAll(
"#void1",
"R");
2047 t.ReplaceAll(
"#3dots",
"\\ldots");
2048 t.ReplaceAll(
"#lbar",
"\\mid");
2049 t.ReplaceAll(
"#void8",
"\\mid");
2050 t.ReplaceAll(
"#divide",
"\\div");
2051 t.ReplaceAll(
"#Jgothic",
"\\Im");
2052 t.ReplaceAll(
"#Rgothic",
"\\Re");
2053 t.ReplaceAll(
"#doublequote",
"\"");
2054 t.ReplaceAll(
"#plus",
"+");
2055 t.ReplaceAll(
"#minus",
"-");
2056 t.ReplaceAll(
"#/",
"/");
2057 t.ReplaceAll(
"#upoint",
".");
2058 t.ReplaceAll(
"#aa",
"\\mbox{\\aa}");
2059 t.ReplaceAll(
"#AA",
"\\mbox{\\AA}");
2061 t.ReplaceAll(
"#omicron",
"o");
2062 t.ReplaceAll(
"#Alpha",
"A");
2063 t.ReplaceAll(
"#Beta",
"B");
2064 t.ReplaceAll(
"#Epsilon",
"E");
2065 t.ReplaceAll(
"#Zeta",
"Z");
2066 t.ReplaceAll(
"#Eta",
"H");
2067 t.ReplaceAll(
"#Iota",
"I");
2068 t.ReplaceAll(
"#Kappa",
"K");
2069 t.ReplaceAll(
"#Mu",
"M");
2070 t.ReplaceAll(
"#Nu",
"N");
2071 t.ReplaceAll(
"#Omicron",
"O");
2072 t.ReplaceAll(
"#Rho",
"P");
2073 t.ReplaceAll(
"#Tau",
"T");
2074 t.ReplaceAll(
"#Chi",
"X");
2075 t.ReplaceAll(
"#varomega",
"\\varpi");
2077 t.ReplaceAll(
"#varUpsilon",
"?");
2078 t.ReplaceAll(
"#corner",
"?");
2079 t.ReplaceAll(
"#ltbar",
"?");
2080 t.ReplaceAll(
"#bottombar",
"?");
2081 t.ReplaceAll(
"#notsubset",
"?");
2082 t.ReplaceAll(
"#arcbottom",
"?");
2083 t.ReplaceAll(
"#cbar",
"?");
2084 t.ReplaceAll(
"#arctop",
"?");
2085 t.ReplaceAll(
"#topbar",
"?");
2086 t.ReplaceAll(
"#arcbar",
"?");
2087 t.ReplaceAll(
"#downleftarrow",
"?");
2088 t.ReplaceAll(
"#splitline",
"\\genfrac{}{}{0pt}{}");
2090 t.ReplaceAll(
"#",
"\\");
2091 t.ReplaceAll(
"%",
"\\%");
2101 gPad->SetBatch(saveb);
2116 if( newText.
Length() == 0)
return 0;
2121 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2122 std::cout<<
"==> "<<text1<<std::endl;
2131 gPad->PaintText(x,y,text1);
2136 if (strstr(text1,
"\\")) {
2163 x =
gPad->XtoAbsPixel(x);
2164 y =
gPad->YtoAbsPixel(y);
2166 TLatexFormSize fs =
FirstParse(angle,size,text);
2176 spec.fAngle = angle;
2182 TextSpec_t newSpec = spec;
2184 std::cout<<
"*ERROR<TLatex>: "<<
fError<<std::endl;
2185 std::cout<<
"==> "<<text<<std::endl;
2188 newSpec.fSize = size;
2191 case 0: y -= fs.Under() ;
break;
2193 case 2: y += fs.Height()*0.5-fs.Under(); y++;
break;
2194 case 3: y += fs.Over() ;
break;
2197 case 2: x -= fs.Width()/2 ;
break;
2198 case 3: x -= fs.Width() ;
break;
2200 Analyse(x,y,newSpec,text,length);
2211 if (
fError != 0)
return 0;
2220 const Char_t *kWord1[] = {
"{}^{",
"{}_{",
"^{",
"_{",
"#scale{",
"#color{",
"#font{",
"#sqrt{",
"#[]{",
"#{}{",
"#||{",
2221 "#bar{",
"#vec{",
"#dot{",
"#hat{",
"#ddot{",
"#acute{",
"#grave{",
"#check{",
"#tilde{",
"#slash{",
"#bf{",
"#it{",
"#mbox{",
2222 "\\scale{",
"\\color{",
"\\font{",
"\\sqrt{",
"\\[]{",
"\\{}{",
"\\||{",
"#(){",
"\\(){",
2223 "\\bar{",
"\\vec{",
"\\dot{",
"\\hat{",
"\\ddot{",
"\\acute{",
"\\grave{",
"\\check{",
"\\bf{",
"\\it{",
"\\mbox{"};
2224 const Char_t *kWord2[] = {
"#scale[",
"#color[",
"#font[",
"#sqrt[",
"#kern[",
"#lower[",
"\\scale[",
"\\color[",
"\\font[",
"\\sqrt[",
"\\kern[",
"\\lower["};
2225 const Char_t *kWord3[] = {
"#frac{",
"\\frac{",
"#splitline{",
"\\splitline{"};
2226 const Char_t *kLeft1[] = {
"#left[",
"\\left[",
"#left{",
"\\left{",
"#left|",
"\\left|",
"#left(",
"\\left("};
2227 const Char_t *kLeft2[] = {
"#[]{",
"#[]{",
"#{}{",
"#{}{",
"#||{",
"#||{",
"#(){",
"#(){"};
2228 const Char_t *kRight[] = {
"#right]",
"\\right]",
"#right}",
"\\right}",
"#right|",
"\\right|",
"#right)",
"\\right)"};
2229 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};
2230 const Int_t lkWord2[] = {7,7,6,6,6,7,7,7,6,6,6,7} ;
2231 const Int_t lkWord3[] = {6,6,11,11} ;
2232 Int_t nkWord1 = 44, nkWord2 = 12, nkWord3 = 4;
2234 Int_t nLeft1 , nRight , nOfLeft, nOfRight;
2238 nLeft1 = nRight = 8 ;
2239 nOfLeft = nOfRight = 0 ;
2241 Char_t buf[11] ;
for (i=0;i<11;i++) buf[i]=0;
2246 Int_t nOfCurlyBracket, nOfKW1, nOfKW2, nOfKW3, nOfSquareCurly, nOfCurlyCurly ;
2247 Int_t nOfExtraCurly = 0 , nOfExtraSquare = 0;
2248 Int_t nOfSquareBracket = 0 ;
2255 while (i < length) {
2258 strncpy(buf,&text[i],
TMath::Min(7,length-i));
2260 for (k = 0 ; k < nLeft1 ; k++) {
2261 if (strncmp(buf,kLeft1[k],lLeft1)==0) {
2270 for(k=0;k<nRight;k++) {
2271 if (strncmp(buf,kRight[k],lRight)==0) {
2280 if (nOfLeft != nOfRight) {
2281 printf(
" nOfLeft = %d, nOfRight = %d\n",nOfLeft,nOfRight) ;
2283 fError =
"Operators \"#left\" and \"#right\" don't match !" ;
2287 for (k = 0 ; k < nLeft1 ; k++) {
2288 text.
ReplaceAll(kLeft1[k],lLeft1,kLeft2[k],lLeft2) ;
2290 for (k = 0 ; k < nRight ; k++) {
2295 i = nOfCurlyBracket = nOfKW1 = nOfKW2 = nOfKW3 = nOfSquareCurly = nOfCurlyCurly =0 ;
2298 case '"' : quote1 = !quote1 ; break ;
2299 case '\'': quote2 = !quote2 ; break ;
2303 strncpy(buf,&text[i],
TMath::Min(11,length-i));
2306 for(k=0;k<nkWord1;k++) {
2307 if (strncmp(buf,kWord1[k],lkWord1[k])==0) {
2317 for(k=0;k<nkWord2;k++) {
2318 if (strncmp(buf,kWord2[k],lkWord2[k])==0) {
2328 for(k=0;k<nkWord3;k++) {
2329 if (strncmp(buf,kWord3[k],lkWord3[k])==0) {
2339 if (strncmp(buf,
"}{",2) == 0 && opFrac) {
2344 else if (strncmp(buf,
"]{",2) == 0 && nOfSquareBracket) {
2348 nOfSquareBracket-- ;
2350 else if (strncmp(buf,
"@{",2) == 0 || strncmp(buf,
"@}",2) == 0) {
2353 else if (strncmp(buf,
"@[",2) == 0 || strncmp(buf,
"@]",2) == 0) {
2356 else if (text[i] ==
']' ) {
2362 else if (text[i] ==
'[' ) {
2368 else if (text[i] ==
'{' ) {
2374 else if (text[i] ==
'}' ) {
2375 if ( nOfCurlyBracket) {
2390 if (nOfKW2 != nOfSquareCurly) {
2392 fError =
"Invalid number of \"]{\"" ;
2394 else if (nOfKW3 != nOfCurlyCurly) {
2396 fError =
"Error in syntax of \"#frac\"" ;
2398 else if (nOfCurlyBracket < 0) {
2400 fError =
"Missing \"{\"" ;
2402 else if (nOfCurlyBracket > 0) {
2404 fError =
"Missing \"}\"" ;
2406 else if (nOfSquareBracket < 0) {
2408 fError =
"Missing \"[\"" ;
2410 else if (nOfSquareBracket > 0) {
2412 fError =
"Missing \"]\"" ;
2442 spec.
fSize = size/hw;
2451 TLatexFormSize fs =
Anal1(spec,text,strlen(text));
2483 if( newText.
Length() == 0)
return 0;
2493 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2494 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2514 if( newText.
Length() == 0)
return;
2525 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2526 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2532 Int_t cBoxX[4], cBoxY[4];
2535 ptx =
gPad->UtoPixel(
fX);
2536 pty =
gPad->VtoPixel(
fY);
2542 Int_t x1 = cBoxX[0];
2543 Int_t x2 = cBoxX[0];
2544 Int_t y1 = cBoxY[0];
2545 Int_t y2 = cBoxY[0];
2546 for (
Int_t i=1; i<4; i++) {
2547 if (cBoxX[i] < x1) x1 = cBoxX[i];
2548 if (cBoxX[i] > x2) x2 = cBoxX[i];
2549 if (cBoxY[i] < y1) y1 = cBoxY[i];
2550 if (cBoxY[i] > y2) y2 = cBoxY[i];
2570 if( newText.
Length() == 0)
return 0;
2580 std::cout<<
"\n*ERROR<TLatex>: "<<
fError<<std::endl;
2581 std::cout<<
"==> "<<
GetTitle()<<std::endl;
2643 out<<
" tex = new TLatex("<<
fX<<
","<<
fY<<
","<<quote<<s.
Data()<<quote<<
");"<<std::endl;
2649 out<<
" tex->Draw();"<<std::endl;
virtual const char * GetTitle() const
Returns title of object.
virtual void SetLineWidth(Width_t lwidth)
Int_t fLimitFactorSize
Relative position of subscripts and superscripts.
virtual void PaintMathText(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Paint text (used by Paint()).
virtual Float_t GetTextAngle() const
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
virtual Font_t GetTextFont() const
Double_t fOriginSize
array of values for the different zones
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
void Copy(TAttText &atttext) const
Copy this text attributes to a new TAttText.
TString & ReplaceAll(const TString &s1, const TString &s2)
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
virtual Float_t GetTextSize() const
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.
Short_t Min(Short_t a, Short_t b)
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Get the text width and height.
virtual void Modify()
Change current line attributes if necessary.
TLatex & operator=(const TLatex &)
Currently inside italic operator.
TString & Insert(Ssiz_t pos, const char *s)
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Int_t PaintLatex1(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Drawing function.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void Modify()
Change current text attributes if necessary.
TLatex * DrawLatexNDC(Double_t x, Double_t y, const char *text)
Draw this TLatex with new coordinates in NDC.
const char * Data() const
virtual void SetTextFont(Font_t tfont=62)
static const double x2[5]
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
Draw a line in a Latex formula.
Double_t GetYsize()
Return size of the formula along Y in pad coordinates.
virtual Short_t GetTextAlign() const
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)
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.
TLatexFormSize Anal1(TextSpec_t spec, const Char_t *t, Int_t length)
Analyse function.
virtual void GetTextAscentDescent(UInt_t &a, UInt_t &d, const char *text) const
Return text ascent and descent for string text.
To draw Mathematical Formula.
virtual Color_t GetTextColor() const
virtual void Paint(Option_t *option="")
Paint.
static const double x4[22]
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.
if on multiple lines(like in C++).**The" * configuration fragment. * * The "import myobject continue
Parses the configuration file.
Base class for several text objects.
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Int_t CheckLatexSyntax(TString &text)
Check if the Latex syntax is correct.
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
Double_t GetHeight() const
Return height of current pad in pixels.
virtual void Text(Double_t x, Double_t y, const char *string)=0
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)
virtual void SetTextAlign(Short_t align=11)
virtual void SetLineColor(Color_t lcolor)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Double_t length(const TVector2 &v)
Double_t GetXsize()
Return size of the formula along X in pad coordinates.
TLatexFormSize Readfs()
Read fs in fTabSize.
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.
void Copy(TObject &text) const
Copy this text to text.
unsigned int r1[N_CITIES]
virtual void SetTextAngle(Float_t tangle=0)
Bool_t TestBit(UInt_t f) const
TLatexFormSize Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t *t, Int_t length)
Analyse and paint the TLatex formula.
virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const
Return text extent for string text.
void GetBoundingBox(UInt_t &w, UInt_t &h, Bool_t angle=kFALSE)
Return text size in pixels.
virtual Color_t GetLineColor() const
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t *text)
First parsing of the analyse sequence.
void Savefs(TLatexFormSize *fs)
Save fs values in array fTabSize.
FormSize_t * fTabSize
is true during the second pass (Painting)
virtual ~TLatex()
Destructor.
static const double x1[5]
Int_t fPos
Maximum allocation for array fTabSize;.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
To draw TeX Mathematical Formula.
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Double_t fFactorPos
Relative size of subscripts and superscripts.
void Copy(TObject &text) const
Copy this TLatex object to another TLatex.
Binding & operator=(OUT(*fun)(void))
Mother of all ROOT objects.
TLatex helper struct holding the attributes of a piece of text.
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Bool_t fItalic
Current position in array fTabSize;.
R__EXTERN TVirtualPS * gVirtualPS
virtual void SetLimitIndiceSize(Int_t limitFactorSize)
Set limit for text resizing of subscripts and superscripts.
virtual void SetTextColor(Color_t tcolor=1)
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
virtual void SetTextSize(Float_t tsize=1)
virtual Width_t GetLineWidth() const
virtual void PaintText(Double_t x, Double_t y, const char *text)
Draw this text with new coordinates.
Double_t GetYsize(void)
Get Y size.
Double_t GetXsize(void)
Get X size.
unsigned int r2[N_CITIES]
virtual void SetIndiceSize(Double_t factorSize)
Set relative size of subscripts and superscripts.
static const double x3[11]