229 #pragma optimize("",off)
250 #include "../../../graf2d/mathtext/inc/fontembed.h"
253 const Float_t kScale = 0.93376068;
256 static Bool_t MustEmbed[32];
258 Int_t TPostScript::fgLineJoin = 0;
260 ClassImp(TPostScript);
265 TPostScript::TPostScript() : TVirtualPS()
271 fBoundingBox = kFALSE;
274 fClipStatus = kFALSE;
292 fNBSameColorCell = 0;
326 for (i=0; i<32; i++) fPatterns[i] = 0;
327 for (i=0; i<32; i++) MustEmbed[i] = kFALSE;
343 TPostScript::TPostScript(
const char *fname, Int_t wtype)
344 :TVirtualPS(fname, wtype)
354 void TPostScript::Open(
const char *fname, Int_t wtype)
357 Warning(
"Open",
"postscript file already open");
373 SetLineJoin(gStyle->GetJoinLinePS());
374 SetLineScale(gStyle->GetLineScalePS());
375 gStyle->GetPaperSize(fXsize, fYsize);
377 Float_t xrange, yrange;
379 Double_t ww = gPad->GetWw();
380 Double_t wh = gPad->GetWh();
382 ww *= gPad->GetWNDC();
383 wh *= gPad->GetHNDC();
385 Double_t ratio = wh/ww;
388 yrange = xrange*ratio;
389 if (yrange > fXsize) { yrange = fXsize; xrange = yrange/ratio;}
392 yrange = fXsize*ratio;
393 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
395 fXsize = xrange; fYsize = yrange;
400 fStream =
new std::ofstream(fFileName.Data(),std::ios::out);
401 if (fStream == 0 || gSystem->AccessPathName(fFileName.Data(),kWritePermission)) {
402 printf(
"ERROR in TPostScript::Open: Cannot open file:%s\n",fFileName.Data());
407 for (Int_t i=0;i<fSizBuffer;i++) fBuffer[i] =
' ';
409 fBoundingBox = kFALSE;
410 PrintStr(
"%!PS-Adobe-2.0 EPSF-2.0@");
412 fBoundingBox = kTRUE;
413 PrintStr(
"%!PS-Adobe-2.0@");
417 fClipStatus = kFALSE;
421 Range(fXsize, fYsize);
424 if (fType == 113) NewPage();
430 TPostScript::~TPostScript()
438 void TPostScript::Close(Option_t *)
440 if (!gVirtualPS)
return;
441 if (!fStream)
return;
442 if (gPad) gPad->Update();
445 if( fPrinted ) { PrintStr(
"showpage@"); SaveRestore(-1);}
447 PrintStr(
"%%Trailer@");
448 PrintStr(
"%%Pages: ");
449 WriteInteger(fNpages);
451 while (fSave > 0) { SaveRestore(-1); }
454 while (fSave > 0) { SaveRestore(-1); }
455 PrintStr(
"showpage@");
466 fStream->close();
delete fStream; fStream = 0;
470 TString tmpname = Form(
"%s_tmp_%d",fFileName.Data(),gSystem->GetPid());
471 if (gSystem->Rename( fFileName.Data() , tmpname.Data())) {
472 Error(
"Text",
"Cannot open temporary file: %s\n", tmpname.Data());
477 fStream =
new std::ofstream(fFileName.Data(),std::ios::out);
478 if (fStream == 0 || gSystem->AccessPathName(fFileName.Data(),kWritePermission)) {
479 Error(
"Text",
"Cannot open file: %s\n", fFileName.Data());
484 FILE *sg = fopen(tmpname.Data(),
"r");
486 Error(
"Text",
"Cannot open file: %s\n", tmpname.Data());
490 while (fgets(line,255,sg)) {
491 if (strstr(line,
"EndComments")) PrintStr(
"%%DocumentNeededResources: ProcSet (FontSetInit)@");
492 fStream->write(line,strlen(line));
493 if (!fFontEmbed && strstr(line,
"m5")) {
499 if (gSystem->Unlink(tmpname.Data()))
return;
506 if (fStream) { fStream->close();
delete fStream; fStream = 0;}
514 void TPostScript::On()
517 Error(
"On",
"no postscript file open");
527 void TPostScript::Off()
554 void TPostScript::CellArrayBegin(Int_t W, Int_t , Double_t x1, Double_t x2,
555 Double_t y1, Double_t y2)
557 Int_t ix1 = XtoPS(x1);
558 Int_t iy1 = YtoPS(y1);
560 Float_t wt = (288/2.54)*gPad->GetAbsWNDC()*
561 fXsize*((x2 - x1)/(gPad->GetX2()-gPad->GetX1()));
562 Float_t ht = (288/2.54)*gPad->GetAbsHNDC()*
563 fYsize*((y2 - y1)/(gPad->GetY2()-gPad->GetY1()));
566 fLastCellGreen = 300;
568 fNBSameColorCell = 0;
573 fMaxLines = 40000/(3*fNbCellW);
576 PrintStr(
"@/WT"); WriteReal(wt) ; PrintStr(
" def");
577 PrintStr(
" /HT"); WriteReal(ht) ; PrintStr(
" def");
578 PrintStr(
" /XS"); WriteInteger(ix1) ; PrintStr(
" def");
579 PrintStr(
" /YY"); WriteInteger(iy1) ; PrintStr(
" def");
580 PrintStr(
" /NX"); WriteInteger(W) ; PrintStr(
" def");
581 PrintStr(
" /NY"); WriteInteger(fMaxLines); PrintStr(
" def");
584 PrintStr(
" /DrawCell ");
585 PrintStr(
"{WT HT XX YY bf");
586 PrintStr(
" /NBBD NBBD 1 add def");
587 PrintStr(
" NBBD NBB eq {exit} if");
588 PrintStr(
" /XX WT XX add def");
589 PrintStr(
" IX NX eq ");
590 PrintStr(
"{/YY YY HT sub def");
591 PrintStr(
" /XX XS def");
592 PrintStr(
" /IX 0 def} if");
593 PrintStr(
" /IX IX 1 add def} def");
598 PrintStr(
" /DrawCT ");
599 PrintStr(
"{/NBB NX NY mul def");
600 PrintStr(
" /XX XS def");
601 PrintStr(
" /IX 1 def");
602 PrintStr(
" /NBBD 0 def");
603 PrintStr(
" /RC 0 def /GC 1 def /BC 2 def");
604 PrintStr(
" 1 1 NBB ");
605 PrintStr(
"{/NB CT RC get def");
606 PrintStr(
" NB 301 ge ");
607 PrintStr(
"{/NBL NB 300 sub def");
608 PrintStr(
" 1 1 NBL ");
609 PrintStr(
"{DrawCell}");
611 PrintStr(
" /RC RC 1 add def");
612 PrintStr(
" /GC RC 1 add def");
613 PrintStr(
" /BC RC 2 add def}");
614 PrintStr(
"{CT RC get 255 div CT GC get 255 div CT BC get 255 div setrgbcolor");
615 PrintStr(
" DrawCell");
616 PrintStr(
" /RC RC 3 add def");
617 PrintStr(
" /GC GC 3 add def");
618 PrintStr(
" /BC BC 3 add def} ifelse NBBD NBB eq {exit} if} for");
619 PrintStr(
" /YY YY HT sub def clear} def");
627 void TPostScript::CellArrayFill(Int_t r, Int_t g, Int_t b)
629 if (fLastCellRed == r && fLastCellGreen == g && fLastCellBlue == b) {
632 if (fNBSameColorCell != 0 ) {
633 WriteInteger(fNBSameColorCell+300);
634 fNBSameColorCell = 0;
645 if (fNbinCT == fNbCellW) {
650 if (fNbCellLine == fMaxLines) {
651 if (fNBSameColorCell != 0) WriteInteger(fNBSameColorCell+300);
652 PrintStr(
"] def DrawCT /CT [");
655 fLastCellGreen = 300;
657 fNBSameColorCell = 0;
665 void TPostScript::CellArrayEnd()
667 if (fNBSameColorCell != 0 ) WriteInteger(fNBSameColorCell+300);
668 PrintStr(
"] def /NY");
669 WriteInteger(fNbCellLine);
670 PrintStr(
" def DrawCT ");
676 void TPostScript::DefineMarkers()
678 PrintStr(
"/mp {newpath /y exch def /x exch def} def@");
679 PrintStr(
"/side {[w .77 mul w .23 mul] .385 w mul sd w 0 l currentpoint t -144 r} def@");
680 PrintStr(
"/mr {mp x y w2 0 360 arc} def /m24 {mr s} def /m20 {mr f} def@");
681 PrintStr(
"/mb {mp x y w2 add m w2 neg 0 d 0 w neg d w 0 d 0 w d cl} def@");
682 PrintStr(
"/mt {mp x y w2 add m w2 neg w neg d w 0 d cl} def@");
683 PrintStr(
"/w4 {w 4 div} def@");
684 PrintStr(
"/w6 {w 6 div} def@");
685 PrintStr(
"/w8 {w 8 div} def@");
686 PrintStr(
"/m21 {mb f} def /m25 {mb s} def /m22 {mt f} def /m26{mt s} def@");
687 PrintStr(
"/m23 {mp x y w2 sub m w2 w d w neg 0 d cl f} def@");
688 PrintStr(
"/m27 {mp x y w2 add m w3 neg w2 neg d w3 w2 neg d w3 w2 d cl s} def@");
689 PrintStr(
"/m28 {mp x w2 sub y w2 sub w3 add m w3 0 d ");
690 PrintStr(
" 0 w3 neg d w3 0 d 0 w3 d w3 0 d ");
691 PrintStr(
" 0 w3 d w3 neg 0 d 0 w3 d w3 neg 0 d");
692 PrintStr(
" 0 w3 neg d w3 neg 0 d cl s } def@");
693 PrintStr(
"/m29 {mp gsave x w2 sub y w2 add w3 sub m currentpoint t");
694 PrintStr(
" 4 {side} repeat cl fill gr} def@");
695 PrintStr(
"/m30 {mp gsave x w2 sub y w2 add w3 sub m currentpoint t");
696 PrintStr(
" 4 {side} repeat cl s gr} def@");
697 PrintStr(
"/m31 {mp x y w2 sub m 0 w d x w2 sub y m w 0 d");
698 PrintStr(
" x w2 sub y w2 add m w w neg d x w2 sub y w2");
699 PrintStr(
" sub m w w d s} def@");
700 PrintStr(
"/m32 {mp x y w2 sub m w2 w d w neg 0 d cl s} def@");
701 PrintStr(
"/m33 {mp x y w2 add m w3 neg w2 neg d w3 w2 neg d w3 w2 d cl f} def@");
702 PrintStr(
"/m34 {mp x w2 sub y w2 sub w3 add m w3 0 d ");
703 PrintStr(
" 0 w3 neg d w3 0 d 0 w3 d w3 0 d ");
704 PrintStr(
" 0 w3 d w3 neg 0 d 0 w3 d w3 neg 0 d");
705 PrintStr(
" 0 w3 neg d w3 neg 0 d cl f } def@");
706 PrintStr(
"/m35 {mp x y w2 add m w2 neg w2 neg d w2 w2 neg d w2 w2 d w2 neg w2 d");
707 PrintStr(
" x y w2 sub m 0 w d x w2 sub y m w 0 d s} def@");
708 PrintStr(
"/m36 {mb x w2 sub y w2 add m w w neg d x w2 sub y w2 sub m w w d s} def@");
709 PrintStr(
"/m37 {mp x y m w4 neg w2 d w4 neg w2 neg d w2 0 d ");
710 PrintStr(
" w4 neg w2 neg d w2 0 d w4 neg w2 d w2 0 d w4 neg w2 d w4 neg w2 neg d cl s} def@");
711 PrintStr(
"/m38 {mp x w4 sub y w2 add m w4 neg w4 neg d 0 w2 neg d w4 w4 neg d");
712 PrintStr(
" w2 0 d w4 w4 d 0 w2 d w4 neg w4 d w2 neg 0 d");
713 PrintStr(
" x y w2 sub m 0 w d x w2 sub y m w 0 d cl s} def@");
714 PrintStr(
"/m39 {mp x y m w4 neg w2 d w4 neg w2 neg d w2 0 d ");
715 PrintStr(
" w4 neg w2 neg d w2 0 d w4 neg w2 d w2 0 d w4 neg w2 d w4 neg w2 neg d cl f} def@");
716 PrintStr(
"/m40 {mp x y m w4 w2 d w4 w4 neg d w2 neg w4 neg d w2 w4 neg d w4 neg w4 neg d");
717 PrintStr(
" w4 neg w2 d w4 neg w2 neg d w4 neg w4 d w2 w4 d w2 neg w4 d w4 w4 d w4 w2 neg d cl s} def@");
718 PrintStr(
"/m41 {mp x y m w4 w2 d w4 w4 neg d w2 neg w4 neg d w2 w4 neg d w4 neg w4 neg d");
719 PrintStr(
" w4 neg w2 d w4 neg w2 neg d w4 neg w4 d w2 w4 d w2 neg w4 d w4 w4 d w4 w2 neg d cl f} def@");
720 PrintStr(
"/m42 {mp x y w2 add m w8 neg w2 -3 4 div mul d w2 -3 4 div mul w8 neg d");
721 PrintStr(
" w2 3 4 div mul w8 neg d w8 w2 -3 4 div mul d");
722 PrintStr(
" w8 w2 3 4 div mul d w2 3 4 div mul w8 d");
723 PrintStr(
" w2 -3 4 div mul w8 d w8 neg w2 3 4 div mul d cl s} def@");
724 PrintStr(
"/m43 {mp x y w2 add m w8 neg w2 -3 4 div mul d w2 -3 4 div mul w8 neg d");
725 PrintStr(
" w2 3 4 div mul w8 neg d w8 w2 -3 4 div mul d");
726 PrintStr(
" w8 w2 3 4 div mul d w2 3 4 div mul w8 d");
727 PrintStr(
" w2 -3 4 div mul w8 d w8 neg w2 3 4 div mul d cl f} def@");
728 PrintStr(
"/m44 {mp x y m w6 neg w2 d w2 2 3 div mul 0 d w6 neg w2 neg d");
729 PrintStr(
" w2 w6 d 0 w2 -2 3 div mul d w2 neg w6 d");
730 PrintStr(
" w6 w2 neg d w2 -2 3 div mul 0 d w6 w2 d");
731 PrintStr(
" w2 neg w6 neg d 0 w2 2 3 div mul d w2 w6 neg d cl s} def@");
732 PrintStr(
"/m45 {mp x y m w6 neg w2 d w2 2 3 div mul 0 d w6 neg w2 neg d");
733 PrintStr(
" w2 w6 d 0 w2 -2 3 div mul d w2 neg w6 d");
734 PrintStr(
" w6 w2 neg d w2 -2 3 div mul 0 d w6 w2 d");
735 PrintStr(
" w2 neg w6 neg d 0 w2 2 3 div mul d w2 w6 neg d cl f} def@");
736 PrintStr(
"/m46 {mp x y w4 add m w4 neg w4 d w4 neg w4 neg d ");
737 PrintStr(
" w4 w4 neg d w4 neg w4 neg d w4 w4 neg d w4 w4 d");
738 PrintStr(
" w4 w4 neg d w4 w4 d w4 neg w4 d w4 w4 d w4 neg w4 d w4 neg w4 neg d cl s} def@");
739 PrintStr(
"/m47 {mp x y w4 add m w4 neg w4 d w4 neg w4 neg d");
740 PrintStr(
" w4 w4 neg d w4 neg w4 neg d w4 w4 neg d w4 w4 d");
741 PrintStr(
" w4 w4 neg d w4 w4 d w4 neg w4 d w4 w4 d w4 neg w4 d w4 neg w4 neg d cl f} def@");
742 PrintStr(
"/m48 {mp x y w4 add m w4 neg w4 d w4 neg w4 neg d w4 w4 neg d ");
743 PrintStr(
" w4 neg w4 neg d w4 w4 neg d w4 w4 d w4 w4 neg d w4 w4 d");
744 PrintStr(
" w4 neg w4 d w4 w4 d w4 neg w4 d w4 neg w4 neg d ");
745 PrintStr(
" w4 w4 neg d w4 neg w4 neg d w4 neg w4 d w4 w4 d cl f} def@");
746 PrintStr(
"/m49 {mp x w2 sub w3 add y w2 sub w3 add m ");
747 PrintStr(
" 0 w3 neg d w3 0 d 0 w3 d w3 0 d 0 w3 d w3 neg 0 d 0 w3 d w3 neg 0 d");
748 PrintStr(
" 0 w3 neg d w3 neg 0 d 0 w3 neg d w3 0 d 0 w3 d w3 0 d 0 w3 neg d w3 neg 0 d cl f } def@");
749 PrintStr(
"/m2 {mp x y w2 sub m 0 w d x w2 sub y m w 0 d s} def@");
750 PrintStr(
"/m5 {mp x w2 sub y w2 sub m w w d x w2 sub y w2 add m w w neg d s} def@");
756 void TPostScript::DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
758 static Double_t x[4], y[4];
759 Int_t ix1 = XtoPS(x1);
760 Int_t ix2 = XtoPS(x2);
761 Int_t iy1 = YtoPS(y1);
762 Int_t iy2 = YtoPS(y2);
763 Int_t fillis = fFillStyle/1000;
764 Int_t fillsi = fFillStyle%1000;
766 if (fillis == 3 || fillis == 2) {
768 x[0] = x1; y[0] = y1;
769 x[1] = x2; y[1] = y1;
770 x[2] = x2; y[2] = y2;
771 x[3] = x1; y[3] = y2;
774 if (fillsi > 0 && fillsi < 26) {
775 x[0] = x1; y[0] = y1;
776 x[1] = x2; y[1] = y1;
777 x[2] = x2; y[2] = y2;
778 x[3] = x1; y[3] = y2;
779 DrawPS(-4, &x[0], &y[0]);
783 WriteInteger(ix2 - ix1);
784 WriteInteger(iy2 - iy1);
791 SetColor(fFillColor);
792 WriteInteger(ix2 - ix1);
793 WriteInteger(iy2 - iy1);
799 if (fLineWidth<=0)
return;
800 SetColor(fLineColor);
801 WriteInteger(ix2 - ix1);
802 WriteInteger(iy2 - iy1);
818 void TPostScript::DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt,
819 Int_t mode, Int_t border, Int_t dark, Int_t light)
821 static Int_t xps[7], yps[7];
822 Int_t i, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
825 if (mode == -1) SetColor(dark);
826 else SetColor(light);
827 Int_t bordPS = 4*border;
828 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
829 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
830 xps[2] = xps[1]; yps[2] = YtoPS(yt) - bordPS;
831 xps[3] = XtoPS(xt) - bordPS; yps[3] = yps[2];
832 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
833 xps[5] = xps[0]; yps[5] = yps[4];
834 xps[6] = xps[0]; yps[6] = yps[0];
852 if( idx ) { MovePS(idx,0); idx = 0; }
853 if( idy ) { MovePS(0,idy); idy = 0; }
858 if( idy ) { MovePS(0,idy); idy = 0; }
859 if( !idx ) { idx = ix;
continue;}
860 if( ix*idx > 0 ) idx += ix;
861 else { MovePS(idx,0); idx = ix; }
865 if( idx ) { MovePS(idx,0); idx = 0; }
866 if( !idy) { idy = iy;
continue;}
867 if( iy*idy > 0 ) idy += iy;
868 else { MovePS(0,idy); idy = iy; }
871 if( idx ) MovePS(idx,0);
872 if( idy ) MovePS(0,idy);
876 if (mode == -1) SetColor(light);
878 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
879 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
880 xps[2] = XtoPS(xt) - bordPS; yps[2] = yps[1];
881 xps[3] = xps[2]; yps[3] = YtoPS(yt) - bordPS;
882 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
883 xps[5] = xps[4]; yps[5] = yps[0];
884 xps[6] = xps[0]; yps[6] = yps[0];
902 if( idx ) { MovePS(idx,0); idx = 0; }
903 if( idy ) { MovePS(0,idy); idy = 0; }
908 if( idy ) { MovePS(0,idy); idy = 0; }
909 if( !idx ) { idx = ix;
continue;}
910 if( ix*idx > 0 ) idx += ix;
911 else { MovePS(idx,0); idx = ix; }
915 if( idx ) { MovePS(idx,0); idx = 0; }
916 if( !idy) { idy = iy;
continue;}
917 if( iy*idy > 0 ) idy += iy;
918 else { MovePS(0,idy); idy = iy; }
921 if( idx ) MovePS(idx,0);
922 if( idy ) MovePS(0,idy);
936 void TPostScript::DrawPolyLine(Int_t nn, TPoints *xy)
938 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
939 Style_t linestylesav = fLineStyle;
940 Width_t linewidthsav = fLineWidth;
942 if (fLineWidth<=0)
return;
944 SetLineStyle(fLineStyle);
945 SetLineWidth(fLineWidth);
946 SetColor(Int_t(fLineColor));
951 SetColor(Int_t(fLineColor));
954 ixd0 = XtoPS(xy[0].GetX());
955 iyd0 = YtoPS(xy[0].GetY());
959 if( n == 0)
goto END;
968 ixdi = XtoPS(xy[i].GetX());
969 iydi = YtoPS(xy[i].GetY());
975 if( idx ) { MovePS(idx,0); idx = 0; }
976 if( idy ) { MovePS(0,idy); idy = 0; }
981 if( idy ) { MovePS(0,idy); idy = 0; }
982 if( !idx ) { idx = ix;
continue;}
983 if( ix*idx > 0 ) idx += ix;
984 else { MovePS(idx,0); idx = ix; }
988 if( idx ) { MovePS(idx,0); idx = 0; }
989 if( !idy) { idy = iy;
continue;}
990 if( iy*idy > 0 ) idy += iy;
991 else { MovePS(0,idy); idy = iy; }
994 if( idx ) MovePS(idx,0);
995 if( idy ) MovePS(0,idy);
998 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3,
" cl");
1005 SetLineStyle(linestylesav);
1006 SetLineWidth(linewidthsav);
1020 void TPostScript::DrawPolyLineNDC(Int_t nn, TPoints *xy)
1022 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
1023 Style_t linestylesav = fLineStyle;
1024 Width_t linewidthsav = fLineWidth;
1026 if (fLineWidth<=0)
return;
1028 SetLineStyle(fLineStyle);
1029 SetLineWidth(fLineWidth);
1030 SetColor(Int_t(fLineColor));
1035 SetColor(Int_t(fLineColor));
1038 ixd0 = UtoPS(xy[0].GetX());
1039 iyd0 = VtoPS(xy[0].GetY());
1043 if( n == 0)
goto END;
1052 ixdi = UtoPS(xy[i].GetX());
1053 iydi = VtoPS(xy[i].GetY());
1059 if( idx ) { MovePS(idx,0); idx = 0; }
1060 if( idy ) { MovePS(0,idy); idy = 0; }
1065 if( idy ) { MovePS(0,idy); idy = 0; }
1066 if( !idx ) { idx = ix;
continue;}
1067 if( ix*idx > 0 ) idx += ix;
1068 else { MovePS(idx,0); idx = ix; }
1072 if( idx ) { MovePS(idx,0); idx = 0; }
1073 if( !idy) { idy = iy;
continue;}
1074 if( iy*idy > 0 ) idy += iy;
1075 else { MovePS(0,idy); idy = iy; }
1078 if( idx ) MovePS(idx,0);
1079 if( idy ) MovePS(0,idy);
1082 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3,
" cl");
1089 SetLineStyle(linestylesav);
1090 SetLineWidth(linewidthsav);
1097 void TPostScript::DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
1099 Int_t i, np, markerstyle;
1101 static char chtemp[10];
1103 if (!fMarkerSize)
return;
1104 Style_t linestylesav = fLineStyle;
1105 Width_t linewidthsav = fLineWidth;
1108 SetColor(Int_t(fMarkerColor));
1109 markerstyle = abs(fMarkerStyle);
1110 if (markerstyle <= 0) strlcpy(chtemp,
" m20",10);
1111 if (markerstyle == 1) strlcpy(chtemp,
" m20",10);
1112 if (markerstyle == 2) strlcpy(chtemp,
" m2",10);
1113 if (markerstyle == 3) strlcpy(chtemp,
" m31",10);
1114 if (markerstyle == 4) strlcpy(chtemp,
" m24",10);
1115 if (markerstyle == 5) strlcpy(chtemp,
" m5",10);
1116 if (markerstyle >= 6 && markerstyle <= 19) strlcpy(chtemp,
" m20",10);
1117 if (markerstyle >= 20 && markerstyle <= 49 ) snprintf(chtemp,10,
" m%d", markerstyle);
1118 if (markerstyle >= 50) strlcpy(chtemp,
" m20",10);
1121 if (markerstyle == 1) {
1123 }
else if (markerstyle == 6) {
1125 }
else if (markerstyle == 7) {
1128 Float_t symbolsize = fMarkerSize;
1129 const Int_t kBASEMARKER = 8;
1130 Float_t sbase = symbolsize*kBASEMARKER;
1131 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
1132 markersize = this->UtoPS(s2x) - this->UtoPS(0);
1135 if (fMarkerSizeCur != markersize) {
1136 fMarkerSizeCur = markersize;
1138 WriteInteger(Int_t(markersize+0.5));
1139 PrintFast(40,
" def /w2 {w 2 div} def /w3 {w 3 div} def");
1142 WriteInteger(XtoPS(x[0]));
1143 WriteInteger(YtoPS(y[0]));
1146 SetLineStyle(linestylesav);
1147 SetLineWidth(linewidthsav);
1152 WriteInteger(XtoPS(x[i]));
1153 WriteInteger(YtoPS(y[i]));
1155 if (np == 100 || i == n-1) {
1163 SetLineStyle(linestylesav);
1164 SetLineWidth(linewidthsav);
1170 void TPostScript::DrawPolyMarker(Int_t n, Double_t *x, Double_t *y)
1172 Int_t i, np, markerstyle;
1174 static char chtemp[10];
1176 if (!fMarkerSize)
return;
1177 Style_t linestylesav = fLineStyle;
1178 Width_t linewidthsav = fLineWidth;
1181 SetColor(Int_t(fMarkerColor));
1182 markerstyle = abs(fMarkerStyle);
1183 if (markerstyle <= 0) strlcpy(chtemp,
" m20",10);
1184 if (markerstyle == 1) strlcpy(chtemp,
" m20",10);
1185 if (markerstyle == 2) strlcpy(chtemp,
" m2",10);
1186 if (markerstyle == 3) strlcpy(chtemp,
" m31",10);
1187 if (markerstyle == 4) strlcpy(chtemp,
" m24",10);
1188 if (markerstyle == 5) strlcpy(chtemp,
" m5",10);
1189 if (markerstyle >= 6 && markerstyle <= 19) strlcpy(chtemp,
" m20",10);
1190 if (markerstyle >= 20 && markerstyle <= 49 ) snprintf(chtemp,10,
" m%d", markerstyle);
1191 if (markerstyle >= 50) strlcpy(chtemp,
" m20",10);
1194 if (markerstyle == 1) {
1196 }
else if (markerstyle == 6) {
1198 }
else if (markerstyle == 7) {
1201 Float_t symbolsize = fMarkerSize;
1202 const Int_t kBASEMARKER = 8;
1203 Float_t sbase = symbolsize*kBASEMARKER;
1204 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
1205 markersize = this->UtoPS(s2x) - this->UtoPS(0);
1208 if (fMarkerSizeCur != markersize) {
1209 fMarkerSizeCur = markersize;
1211 WriteInteger(Int_t(markersize+0.5));
1212 PrintFast(40,
" def /w2 {w 2 div} def /w3 {w 3 div} def");
1215 WriteInteger(XtoPS(x[0]));
1216 WriteInteger(YtoPS(y[0]));
1219 SetLineStyle(linestylesav);
1220 SetLineWidth(linewidthsav);
1225 WriteInteger(XtoPS(x[i]));
1226 WriteInteger(YtoPS(y[i]));
1228 if (np == 100 || i == n-1) {
1236 SetLineStyle(linestylesav);
1237 SetLineWidth(linewidthsav);
1250 void TPostScript::DrawPS(Int_t nn, Float_t *xw, Float_t *yw)
1252 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1253 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1254 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1255 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1256 180, 90,135, 45,150, 30,120, 60,
1257 180, 90,135, 45,150, 30,120, 60};
1258 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1259 fais = fasi = n = 0;
1260 Int_t jxd0 = XtoPS(xw[0]);
1261 Int_t jyd0 = YtoPS(yw[0]);
1262 Style_t linestylesav = fLineStyle;
1263 Width_t linewidthsav = fLineWidth;
1266 if (fLineWidth<=0)
return;
1268 SetLineStyle(fLineStyle);
1269 SetLineWidth(fLineWidth);
1270 SetColor(Int_t(fLineColor));
1276 SetColor(Int_t(fFillColor));
1277 fais = fFillStyle/1000;
1278 fasi = fFillStyle%1000;
1279 if (fais == 3 || fais == 2) {
1280 if (fasi > 100 && fasi <125) {
1281 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1284 if (fasi > 0 && fasi < 26) {
1285 SetFillPatterns(fasi, Int_t(fFillColor));
1295 if( n == 0)
goto END;
1303 ixdi = XtoPS(xw[i]);
1304 iydi = YtoPS(yw[i]);
1310 if( idx ) { MovePS(idx,0); idx = 0; }
1311 if( idy ) { MovePS(0,idy); idy = 0; }
1314 if( idy ) { MovePS(0,idy); idy = 0;}
1315 if( !idx ) { idx = ix;}
1316 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1317 else { MovePS(idx,0); idx = ix;}
1319 if( idx ) { MovePS(idx,0); idx = 0;}
1320 if( !idy) { idy = iy;}
1321 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1322 else { MovePS(0,idy); idy = iy;}
1325 if (idx) MovePS(idx,0);
1326 if (idy) MovePS(0,idy);
1329 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3,
" cl");
1332 if (fais == 0) {PrintFast(5,
" cl s");
goto END;}
1333 if (fais == 3 || fais == 2) {
1334 if (fasi > 0 && fasi < 26) {
1346 SetLineStyle(linestylesav);
1347 SetLineWidth(linewidthsav);
1361 void TPostScript::DrawPS(Int_t nn, Double_t *xw, Double_t *yw)
1363 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1364 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1365 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1366 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1367 180, 90,135, 45,150, 30,120, 60,
1368 180, 90,135, 45,150, 30,120, 60};
1369 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1370 fais = fasi = n = 0;
1371 Int_t jxd0 = XtoPS(xw[0]);
1372 Int_t jyd0 = YtoPS(yw[0]);
1373 Style_t linestylesav = fLineStyle;
1374 Width_t linewidthsav = fLineWidth;
1377 if (fLineWidth<=0)
return;
1379 SetLineStyle(fLineStyle);
1380 SetLineWidth(fLineWidth);
1381 SetColor(Int_t(fLineColor));
1387 SetColor(Int_t(fFillColor));
1388 fais = fFillStyle/1000;
1389 fasi = fFillStyle%1000;
1390 if (fais == 3 || fais == 2) {
1391 if (fasi > 100 && fasi <125) {
1392 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1395 if (fasi > 0 && fasi < 26) {
1396 SetFillPatterns(fasi, Int_t(fFillColor));
1406 if( n == 0)
goto END;
1414 ixdi = XtoPS(xw[i]);
1415 iydi = YtoPS(yw[i]);
1421 if( idx ) { MovePS(idx,0); idx = 0; }
1422 if( idy ) { MovePS(0,idy); idy = 0; }
1425 if( idy ) { MovePS(0,idy); idy = 0;}
1426 if( !idx ) { idx = ix;}
1427 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1428 else { MovePS(idx,0); idx = ix;}
1430 if( idx ) { MovePS(idx,0); idx = 0;}
1431 if( !idy) { idy = iy;}
1432 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1433 else { MovePS(0,idy); idy = iy;}
1436 if (idx) MovePS(idx,0);
1437 if (idy) MovePS(0,idy);
1440 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3,
" cl");
1443 if (fais == 0) {PrintFast(5,
" cl s");
goto END;}
1444 if (fais == 3 || fais == 2) {
1445 if (fasi > 0 && fasi < 26) {
1457 SetLineStyle(linestylesav);
1458 SetLineWidth(linewidthsav);
1465 void TPostScript::DrawHatch(Float_t, Float_t, Int_t, Float_t *, Float_t *)
1467 Warning(
"DrawHatch",
"hatch fill style not yet implemented");
1473 void TPostScript::DrawHatch(Float_t, Float_t, Int_t, Double_t *, Double_t *)
1475 Warning(
"DrawHatch",
"hatch fill style not yet implemented");
1480 Bool_t TPostScript::FontEmbedType1(
const char *filename)
1482 std::ifstream font_file(filename, std::ios::binary);
1486 font_file.seekg(0, std::ios::end);
1488 const size_t font_file_length = font_file.tellg();
1490 font_file.seekg(0, std::ios::beg);
1492 std::vector<unsigned char> font_data(font_file_length,
'\0');
1494 font_file.read(reinterpret_cast<char *>(&font_data[0]),
1497 std::string font_name;
1498 std::string postscript_string =
1499 mathtext::font_embed_postscript_t::font_embed_type_1(
1500 font_name, font_data);
1502 if (!postscript_string.empty()) {
1503 PrintRaw(postscript_string.size(), postscript_string.data());
1514 Bool_t TPostScript::FontEmbedType2(
const char *filename)
1516 std::ifstream font_file(filename, std::ios::binary);
1520 font_file.seekg(0, std::ios::end);
1522 const size_t font_file_length = font_file.tellg();
1524 font_file.seekg(0, std::ios::beg);
1526 std::vector<unsigned char> font_data(font_file_length,
'\0');
1528 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1530 std::string font_name;
1531 std::string postscript_string =
1532 mathtext::font_embed_postscript_t::font_embed_type_2(font_name, font_data);
1534 if (!postscript_string.empty()) {
1535 PrintRaw(postscript_string.size(), postscript_string.data());
1546 Bool_t TPostScript::FontEmbedType42(
const char *filename)
1548 std::ifstream font_file(filename, std::ios::binary);
1552 font_file.seekg(0, std::ios::end);
1554 const size_t font_file_length = font_file.tellg();
1556 font_file.seekg(0, std::ios::beg);
1558 std::vector<unsigned char> font_data(font_file_length,
'\0');
1560 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1562 std::string font_name;
1563 std::string postscript_string =
1564 mathtext::font_embed_postscript_t::font_embed_type_42(font_name, font_data);
1566 if (!postscript_string.empty()) {
1567 PrintRaw(postscript_string.size(), postscript_string.data());
1572 fprintf(stderr,
"%s:%d:\n", __FILE__, __LINE__);
1580 void TPostScript::FontEmbed(
void)
1582 static const char *fonttable[32][2] = {
1583 {
"Root.TTFont.0",
"FreeSansBold.otf" },
1584 {
"Root.TTFont.1",
"FreeSerifItalic.otf" },
1585 {
"Root.TTFont.2",
"FreeSerifBold.otf" },
1586 {
"Root.TTFont.3",
"FreeSerifBoldItalic.otf" },
1587 {
"Root.TTFont.4",
"FreeSans.otf" },
1588 {
"Root.TTFont.5",
"FreeSansOblique.otf" },
1589 {
"Root.TTFont.6",
"FreeSansBold.otf" },
1590 {
"Root.TTFont.7",
"FreeSansBoldOblique.otf" },
1591 {
"Root.TTFont.8",
"FreeMono.otf" },
1592 {
"Root.TTFont.9",
"FreeMonoOblique.otf" },
1593 {
"Root.TTFont.10",
"FreeMonoBold.otf" },
1594 {
"Root.TTFont.11",
"FreeMonoBoldOblique.otf" },
1595 {
"Root.TTFont.12",
"symbol.ttf" },
1596 {
"Root.TTFont.13",
"FreeSerif.otf" },
1597 {
"Root.TTFont.14",
"wingding.ttf" },
1598 {
"Root.TTFont.15",
"symbol.ttf" },
1599 {
"Root.TTFont.STIXGen",
"STIXGeneral.otf" },
1600 {
"Root.TTFont.STIXGenIt",
"STIXGeneralItalic.otf" },
1601 {
"Root.TTFont.STIXGenBd",
"STIXGeneralBol.otf" },
1602 {
"Root.TTFont.STIXGenBdIt",
"STIXGeneralBolIta.otf" },
1603 {
"Root.TTFont.STIXSiz1Sym",
"STIXSiz1Sym.otf" },
1604 {
"Root.TTFont.STIXSiz1SymBd",
"STIXSiz1SymBol.otf" },
1605 {
"Root.TTFont.STIXSiz2Sym",
"STIXSiz2Sym.otf" },
1606 {
"Root.TTFont.STIXSiz2SymBd",
"STIXSiz2SymBol.otf" },
1607 {
"Root.TTFont.STIXSiz3Sym",
"STIXSiz3Sym.otf" },
1608 {
"Root.TTFont.STIXSiz3SymBd",
"STIXSiz3SymBol.otf" },
1609 {
"Root.TTFont.STIXSiz4Sym",
"STIXSiz4Sym.otf" },
1610 {
"Root.TTFont.STIXSiz4SymBd",
"STIXSiz4SymBol.otf" },
1611 {
"Root.TTFont.STIXSiz5Sym",
"STIXSiz5Sym.otf" },
1612 {
"Root.TTFont.ME",
"DroidSansFallback.ttf" },
1613 {
"Root.TTFont.CJKMing",
"DroidSansFallback.ttf" },
1614 {
"Root.TTFont.CJKCothic",
"DroidSansFallback.ttf" }
1617 PrintStr(
"%%IncludeResource: ProcSet (FontSetInit)@");
1620 const char *ttpath = gEnv->GetValue(
"Root.TTFontPath",
1621 TROOT::GetTTFFontDir());
1623 for (Int_t fontid = 1; fontid < 30; fontid++) {
1624 if (fontid != 15 && MustEmbed[fontid-1]) {
1625 const char *filename = gEnv->GetValue(
1626 fonttable[fontid][0], fonttable[fontid][1]);
1627 char *ttfont = gSystem->Which(ttpath, filename, kReadPermission);
1629 Error(
"TPostScript::FontEmbed",
1630 "font %d (filename `%s') not found in path",
1633 if (FontEmbedType2(ttfont)) {
1635 }
else if(FontEmbedType1(ttfont)) {
1637 }
else if(FontEmbedType42(ttfont)) {
1640 Error(
"TPostScript::FontEmbed",
1641 "failed to embed font %d (filename `%s')",
1648 PrintStr(
"%%IncludeResource: font Times-Roman@");
1649 PrintStr(
"%%IncludeResource: font Times-Italic@");
1650 PrintStr(
"%%IncludeResource: font Times-Bold@");
1651 PrintStr(
"%%IncludeResource: font Times-BoldItalic@");
1652 PrintStr(
"%%IncludeResource: font Helvetica@");
1653 PrintStr(
"%%IncludeResource: font Helvetica-Oblique@");
1654 PrintStr(
"%%IncludeResource: font Helvetica-Bold@");
1655 PrintStr(
"%%IncludeResource: font Helvetica-BoldOblique@");
1656 PrintStr(
"%%IncludeResource: font Courier@");
1657 PrintStr(
"%%IncludeResource: font Courier-Oblique@");
1658 PrintStr(
"%%IncludeResource: font Courier-Bold@");
1659 PrintStr(
"%%IncludeResource: font Courier-BoldOblique@");
1660 PrintStr(
"%%IncludeResource: font Symbol@");
1661 PrintStr(
"%%IncludeResource: font ZapfDingbats@");
1669 void TPostScript::FontEncode()
1671 PrintStr(
"/reEncode ");
1672 PrintStr(
"{exch findfont");
1673 PrintStr(
" dup length dict begin");
1674 PrintStr(
" {1 index /FID eq ");
1675 PrintStr(
" {pop pop}");
1676 PrintStr(
" {def} ifelse");
1677 PrintStr(
" } forall");
1678 PrintStr(
" /Encoding exch def");
1679 PrintStr(
" currentdict end");
1680 PrintStr(
" dup /FontName get exch");
1681 PrintStr(
" definefont pop");
1683 PrintStr(
" [/Times-Bold /Times-Italic /Times-BoldItalic /Helvetica");
1684 PrintStr(
" /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique");
1685 PrintStr(
" /Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique");
1686 PrintStr(
" /Times-Roman /AvantGarde-Book /AvantGarde-BookOblique");
1687 PrintStr(
" /AvantGarde-Demi /AvantGarde-DemiOblique /Bookman-Demi");
1688 PrintStr(
" /Bookman-DemiItalic /Bookman-Light /Bookman-LightItalic");
1689 PrintStr(
" /Helvetica-Narrow /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique");
1690 PrintStr(
" /Helvetica-Narrow-Oblique /NewCenturySchlbk-Roman /NewCenturySchlbk-Bold");
1691 PrintStr(
" /NewCenturySchlbk-BoldItalic /NewCenturySchlbk-Italic");
1692 PrintStr(
" /Palatino-Bold /Palatino-BoldItalic /Palatino-Italic /Palatino-Roman");
1693 PrintStr(
" ] {ISOLatin1Encoding reEncode } forall");
1731 void TPostScript::Initialize()
1733 Double_t rpxmin, rpymin, width, heigth;
1734 rpxmin = rpymin = width = heigth = 0;
1737 for (Int_t i=0;i<32;i++) fPatterns[i]=0;
1744 Int_t atype = abs(fType);
1746 if( fMode <= 0 || fMode > 5) {
1747 Error(
"Initialize",
"invalid file type %d", fMode);
1752 fNXzone = (atype%1000)/100;
1753 fNYzone = (atype%100)/10;
1754 if( fNXzone <= 0 ) fNXzone = 1;
1755 if( fNYzone <= 0 ) fNYzone = 1;
1763 format = atype/1000;
1764 if( format == 0 ) format = 4;
1765 if( format == 99 ) format = 0;
1767 PrintStr(
"%%Title: ");
1768 const char *pstitle = gStyle->GetTitlePS();
1769 if (gPad && !pstitle[0]) pstitle = gPad->GetMother()->GetTitle();
1770 if (strlen(GetName())<=80) PrintStr(GetName());
1771 if(!pstitle[0] && fMode != 3) {;
1773 if ( format <= 99 ) {;
1775 WriteInteger(format);
1779 if ( format == 100 ) PrintFast(8,
" Letter)");
1780 if ( format == 200 ) PrintFast(7,
" Legal)");
1781 if ( format == 300 ) PrintFast(8,
" Ledger)");
1784 PrintStr(
"%%Pages: (atend)@");
1787 if (!strchr(pstitle,
'\n')) {
1794 PrintFast(24,
"%%Creator: ROOT Version ");
1795 PrintStr(gROOT->GetVersion());
1797 PrintFast(16,
"%%CreationDate: ");
1799 PrintStr(t.AsString());
1802 if ( fMode == 1 || fMode == 4) PrintStr(
"%%Orientation: Portrait@");
1803 if ( fMode == 2 || fMode == 5) PrintStr(
"%%Orientation: Landscape@");
1805 PrintStr(
"%%EndComments@");
1806 PrintStr(
"%%BeginProlog@");
1808 if( fMode == 3)PrintStr(
"80 dict begin@");
1811 PrintStr(
"/s {stroke} def /l {lineto} def /m {moveto} def /t {translate} def@");
1812 PrintStr(
"/r {rotate} def /rl {roll} def /R {repeat} def@");
1813 PrintStr(
"/d {rlineto} def /rm {rmoveto} def /gr {grestore} def /f {eofill} def@");
1814 if (gStyle->GetColorModelPS()) {
1815 PrintStr(
"/c {setcmykcolor} def /black {0 0 0 1 setcmykcolor} def /sd {setdash} def@");
1817 PrintStr(
"/c {setrgbcolor} def /black {0 setgray} def /sd {setdash} def@");
1819 PrintStr(
"/cl {closepath} def /sf {scalefont setfont} def /lw {setlinewidth} def@");
1820 PrintStr(
"/box {m dup 0 exch d exch 0 d 0 exch neg d cl} def@");
1821 PrintStr(
"/NC{systemdict begin initclip end}def/C{NC box clip newpath}def@");
1822 PrintStr(
"/bl {box s} def /bf {gsave box gsave f grestore 1 lw [] 0 sd s grestore} def /Y { 0 exch d} def /X { 0 d} def @");
1823 PrintStr(
"/K {{pop pop 0 moveto} exch kshow} bind def@");
1824 PrintStr(
"/ita {/ang 15 def gsave [1 0 ang dup sin exch cos div 1 0 0] concat} def @");
1833 rpymin = TMath::Sqrt(2.)*rpxmin;
1836 width = (8.5*2.54)-2.*rpxmin;
1837 heigth = (11.*2.54)-2.*rpymin;
1840 width = (8.5*2.54)-2.*rpxmin;
1841 heigth = (14.*2.54)-2.*rpymin;
1844 width = (11.*2.54)-2.*rpxmin;
1845 heigth = (17.*2.54)-2.*rpymin;
1848 width = 21.0-2.*rpxmin;
1849 heigth = 29.7-2.*rpymin;
1856 rpxmin = TMath::Sqrt(2.)*rpymin;
1859 width = (11.*2.54)-2.*rpxmin;
1860 heigth = (8.5*2.54)-2.*rpymin;
1863 width = (14.*2.54)-2.*rpxmin;
1864 heigth = (8.5*2.54)-2.*rpymin;
1867 width = (17.*2.54)-2.*rpxmin;
1868 heigth = (11.*2.54)-2.*rpymin;
1871 width = 29.7-2.*rpxmin;
1872 heigth = 21-2.*rpymin;
1891 width = (8.5*2.54)-2.*rpxmin;
1892 heigth = (11.*2.54)-2.*rpymin;
1895 width = (8.5*2.54)-2.*rpxmin;
1896 heigth = (14.*2.54)-2.*rpymin;
1899 width = (11.*2.54)-2.*rpxmin;
1900 heigth = (17.*2.54)-2.*rpymin;
1903 width = (21.0-2*rpxmin);
1904 heigth = (29.7-2.*rpymin);
1914 width = (11.*2.54)-2.*rpxmin;
1915 heigth = (8.5*2.54)-2.*rpymin;
1918 width = (14.*2.54)-2.*rpxmin;
1919 heigth = (8.5*2.54)-2.*rpymin;
1922 width = (17.*2.54)-2.*rpxmin;
1923 heigth = (11.*2.54)-2.*rpymin;
1926 width = (29.7-2*rpxmin);
1927 heigth = (21-2.*rpymin);
1932 if (format < 100) value = 21*TMath::Power(TMath::Sqrt(2.), 4-format);
1933 else if (format == 100) value = 8.5*2.54;
1934 else if (format == 200) value = 8.5*2.54;
1935 else if (format == 300) value = 11.*2.54;
1936 if (format >= 100) format = 4;
1939 Double_t sizex = width/Double_t(fNXzone)*TMath::Power(TMath::Sqrt(2.), 4-format);
1940 Double_t sizey = heigth/Double_t(fNYzone)*TMath::Power(TMath::Sqrt(2.), 4-format);
1941 Int_t npx = 4*CMtoPS(sizex);
1942 Int_t npy = 4*CMtoPS(sizey);
1943 if (sizex > sizey) fMaxsize = CMtoPS(sizex);
1944 else fMaxsize = CMtoPS(sizey);
1948 PrintFast(33,
"/Zone {/iy exch def /ix exch def ");
1949 PrintFast(10,
" ix 1 sub ");
1951 PrintFast(5,
" mul ");
1952 WriteReal(Float_t(fNYzone));
1953 PrintFast(8,
" iy sub ");
1955 PrintStr(
" mul t} def@");
1960 PrintStr(
"%%EndProlog@");
1961 PrintStr(
"%%BeginSetup@");
1962 PrintStr(
"%%EndSetup@");
1963 PrintFast(8,
"newpath ");
1965 if (fMode == 1 || fMode == 4) {
1966 WriteInteger(CMtoPS(rpxmin));
1967 WriteInteger(CMtoPS(rpymin));
1970 if (fMode == 2 || fMode == 5) {
1971 PrintFast(7,
" 90 r 0");
1972 WriteInteger(CMtoPS(-value));
1974 WriteInteger(CMtoPS(rpxmin));
1975 WriteInteger(CMtoPS(rpymin));
1979 PrintFast(15,
" .25 .25 scale ");
1983 PrintStr(
"%%Page: 1 1@");
1988 Int_t nh = strlen(gStyle->GetHeaderPS());
1990 PrintFast(nh,gStyle->GetHeaderPS());
1991 if (fMode != 3) SaveRestore(1);
1998 void TPostScript::MovePS(Int_t ix, Int_t iy)
2000 if (ix != 0 && iy != 0) {
2004 }
else if (ix != 0) {
2007 }
else if (iy != 0) {
2016 void TPostScript::NewPage()
2021 Double_t ww = gPad->GetWw();
2022 Double_t wh = gPad->GetWh();
2023 fYsize = fXsize*wh/ww;
2026 if(fType == 113 && !fBoundingBox) {
2027 Bool_t psave = fPrinted;
2028 PrintStr(
"@%%BoundingBox: ");
2029 Double_t xlow=0, ylow=0, xup=1, yup=1;
2031 xlow = gPad->GetAbsXlowNDC();
2032 xup = xlow + gPad->GetAbsWNDC();
2033 ylow = gPad->GetAbsYlowNDC();
2034 yup = ylow + gPad->GetAbsHNDC();
2036 WriteInteger(CMtoPS(fXsize*xlow));
2037 WriteInteger(CMtoPS(fYsize*ylow));
2038 WriteInteger(CMtoPS(fXsize*xup));
2039 WriteInteger(CMtoPS(fYsize*yup));
2042 fBoundingBox = kTRUE;
2046 if (fSave) SaveRestore(-1);
2056 void TPostScript::Range(Float_t xsize, Float_t ysize)
2058 Float_t xps=0, yps=0, xncm=0, yncm=0, dxwn=0, dywn=0, xwkwn=0, ywkwn=0, xymax=0;
2062 if( fType != 113) { xps = fXsize; yps = fYsize; }
2063 else { xps = xsize; yps = ysize; }
2065 if( xsize <= xps && ysize < yps) {
2066 if ( xps > yps ) xymax = xps;
2070 dxwn = ((xps/xymax)-xncm)/2;
2071 dywn = ((yps/xymax)-yncm)/2;
2073 if (xps/yps < 1) xwkwn = xps/yps;
2075 if (yps/xps < 1) ywkwn = yps/xps;
2078 if (xsize < ysize) {
2079 xncm = ywkwn*xsize/ysize;
2081 dxwn = (xwkwn-xncm)/2;
2086 yncm = xwkwn*ysize/xsize;
2087 dywn = (ywkwn-yncm)/2;
2091 yncm = xwkwn*ysize/xsize;
2093 dywn = (ywkwn-yncm)/2;
2097 xncm = ywkwn*xsize/ysize;
2098 dxwn = (xwkwn-xncm)/2;
2114 void TPostScript::SaveRestore(Int_t flag)
2116 if (flag == 1) { PrintFast(7,
" gsave "); fSave++; }
2117 else { PrintFast(4,
" gr "); fSave--; }
2123 void TPostScript::SetFillColor( Color_t cindex )
2125 fFillColor = cindex;
2126 if (gStyle->GetFillColor() <= 0) cindex = 0;
2127 SetColor(Int_t(cindex));
2145 void TPostScript::SetFillPatterns(Int_t ipat, Int_t color)
2149 snprintf(cpat,5,
" P%2.2d", ipat);
2156 if (fPatterns[ipat] == 0) {
2162 PrintFast(5,
" 1 lw");
2163 PrintStr(
" << /PatternType 1 /PaintType 2 /TilingType 1");
2166 PrintStr(
" /BBox [ 0 0 98 4 ]");
2167 PrintStr(
" /XStep 98 /YStep 4");
2168 PrintStr(
" /PaintProc { begin gsave");
2169 PrintStr(
" [1] 0 sd 2 4 m 99 4 l s 1 3 m 98 3 l s");
2170 PrintStr(
" 2 2 m 99 2 l s 1 1 m 98 1 l s");
2171 PrintStr(
" gr end } >> [ 4.0 0 0 4.0 0 0 ]");
2174 PrintStr(
" /BBox [ 0 0 96 4 ]");
2175 PrintStr(
" /XStep 96 /YStep 4");
2176 PrintStr(
" /PaintProc { begin gsave");
2177 PrintStr(
" [1 3] 0 sd 2 4 m 98 4 l s 0 3 m 96 3 l s");
2178 PrintStr(
" 2 2 m 98 2 l s 0 1 m 96 1 l s");
2179 PrintStr(
" gr end } >> [ 3.0 0 0 3.0 0 0 ]");
2182 PrintStr(
" /BBox [ 0 0 96 16 ]");
2183 PrintStr(
" /XStep 96 /YStep 16");
2184 PrintStr(
" /PaintProc { begin gsave");
2185 PrintStr(
" [1 3] 0 sd 2 13 m 98 13 l s 0 9 m 96 9 l s");
2186 PrintStr(
" 2 5 m 98 5 l s 0 1 m 96 1 l s");
2187 PrintStr(
" gr end } >> [ 2.0 0 0 2.0 0 0 ]");
2190 PrintStr(
" /BBox [ 0 0 100 100 ]");
2191 PrintStr(
" /XStep 100 /YStep 100");
2192 PrintStr(
" /PaintProc { begin gsave");
2193 PrintStr(
" 0 0 m 100 100 l s");
2194 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2197 PrintStr(
" /BBox [ 0 0 100 100 ]");
2198 PrintStr(
" /XStep 100 /YStep 100");
2199 PrintStr(
" /PaintProc { begin gsave");
2200 PrintStr(
" 0 100 m 100 0 l s");
2201 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2204 PrintStr(
" /BBox [ 0 0 100 100 ]");
2205 PrintStr(
" /XStep 100 /YStep 100");
2206 PrintStr(
" /PaintProc { begin gsave");
2207 PrintStr(
" 50 0 m 50 100 l s");
2208 PrintStr(
" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2211 PrintStr(
" /BBox [ 0 0 100 100 ]");
2212 PrintStr(
" /XStep 100 /YStep 100");
2213 PrintStr(
" /PaintProc { begin gsave");
2214 PrintStr(
" 0 50 m 100 50 l s");
2215 PrintStr(
" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2218 PrintStr(
" /BBox [ 0 0 101 101 ]");
2219 PrintStr(
" /XStep 100 /YStep 100");
2220 PrintStr(
" /PaintProc { begin gsave");
2221 PrintStr(
" 0 0 m 0 30 l 30 0 l f 0 70 m 0 100 l 30 100 l f");
2222 PrintStr(
" 70 100 m 100 100 l 100 70 l f 70 0 m 100 0 l");
2223 PrintStr(
" 100 30 l f 50 20 m 20 50 l 50 80 l 80 50 l f");
2224 PrintStr(
" 50 80 m 30 100 l s 20 50 m 0 30 l s 50 20 m");
2225 PrintStr(
" 70 0 l s 80 50 m 100 70 l s");
2226 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2229 PrintStr(
" /BBox [ 0 0 100 100 ]");
2230 PrintStr(
" /XStep 100 /YStep 100");
2231 PrintStr(
" /PaintProc { begin gsave");
2232 PrintStr(
" 0 50 m 50 50 50 180 360 arc");
2233 PrintStr(
" 0 50 m 0 100 50 270 360 arc");
2234 PrintStr(
" 50 100 m 100 100 50 180 270 arc s");
2235 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2238 PrintStr(
" /BBox [ 0 0 100 100 ]");
2239 PrintStr(
" /XStep 100 /YStep 100");
2240 PrintStr(
" /PaintProc { begin gsave");
2241 PrintStr(
" 0 50 m 100 50 l 1 1 m 100 1 l");
2242 PrintStr(
" 0 0 m 0 50 l 100 0 m 100 50 l");
2243 PrintStr(
" 50 50 m 50 100 l s");
2244 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2247 PrintStr(
" /BBox [ 0 0 100 100 ]");
2248 PrintStr(
" /XStep 100 /YStep 100");
2249 PrintStr(
" /PaintProc { begin gsave");
2250 PrintStr(
" 0 0 m 0 20 l 50 0 m 50 20 l");
2251 PrintStr(
" 100 0 m 100 20 l 0 80 m 0 100 l");
2252 PrintStr(
" 50 80 m 50 100 l 100 80 m 100 100 l");
2253 PrintStr(
" 25 30 m 25 70 l 75 30 m 75 70 l");
2254 PrintStr(
" 0 100 m 20 85 l 50 100 m 30 85 l");
2255 PrintStr(
" 50 100 m 70 85 l 100 100 m 80 85 l");
2256 PrintStr(
" 0 0 m 20 15 l 50 0 m 30 15 l");
2257 PrintStr(
" 50 0 m 70 15 l 100 0 m 80 15 l");
2258 PrintStr(
" 5 35 m 45 65 l 5 65 m 45 35 l");
2259 PrintStr(
" 55 35 m 95 65 l 55 65 m 95 35 l s");
2260 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2263 PrintStr(
" /BBox [ 0 0 100 100 ]");
2264 PrintStr(
" /XStep 100 /YStep 100");
2265 PrintStr(
" /PaintProc { begin gsave");
2266 PrintStr(
" 0 80 m 0 100 20 270 360 arc");
2267 PrintStr(
" 30 100 m 50 100 20 180 360 arc");
2268 PrintStr(
" 80 100 m 100 100 20 180 270 arc");
2269 PrintStr(
" 20 0 m 0 0 20 0 90 arc");
2270 PrintStr(
" 70 0 m 50 0 20 0 180 arc");
2271 PrintStr(
" 100 20 m 100 0 20 90 180 arc");
2272 PrintStr(
" 45 50 m 25 50 20 0 360 arc");
2273 PrintStr(
" 95 50 m 75 50 20 0 360 arc s");
2274 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2277 PrintStr(
" /BBox [ 0 0 100 100 ]");
2278 PrintStr(
" /XStep 100 /YStep 100");
2279 PrintStr(
" /PaintProc { begin gsave");
2280 PrintStr(
" 0 0 m 100 100 l 0 100 m 100 0 l s");
2281 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2284 PrintStr(
" /BBox [ 0 0 100 100 ]");
2285 PrintStr(
" /XStep 80 /YStep 80");
2286 PrintStr(
" /PaintProc { begin gsave");
2287 PrintStr(
" 0 20 m 100 20 l 20 0 m 20 100 l");
2288 PrintStr(
" 0 80 m 100 80 l 80 0 m 80 100 l");
2289 PrintStr(
" 20 40 m 60 40 l 60 20 m 60 60 l");
2290 PrintStr(
" 40 40 m 40 80 l 40 60 m 80 60 l s");
2291 PrintStr(
" gr end } >> [ 0.60 0 0 0.60 0 0 ]");
2294 PrintStr(
" /BBox [ 0 0 60 60 ]");
2295 PrintStr(
" /XStep 60 /YStep 60");
2296 PrintStr(
" /PaintProc { begin gsave");
2297 PrintStr(
" 0 55 m 0 60 5 270 360 arc");
2298 PrintStr(
" 25 60 m 30 60 5 180 360 arc");
2299 PrintStr(
" 55 60 m 60 60 5 180 270 arc");
2300 PrintStr(
" 20 30 m 15 30 5 0 360 arc");
2301 PrintStr(
" 50 30 m 45 30 5 0 360");
2302 PrintStr(
" arc 5 0 m 0 0 5 0 90 arc");
2303 PrintStr(
" 35 0 m 30 0 5 0 180 arc");
2304 PrintStr(
" 60 5 m 60 0 5 90 180 arc s");
2305 PrintStr(
" gr end } >> [ 0.41 0 0 0.41 0 0 ]");
2308 PrintStr(
" /BBox [ 0 0 100 100 ]");
2309 PrintStr(
" /XStep 100 /YStep 100");
2310 PrintStr(
" /PaintProc { begin gsave");
2311 PrintStr(
" 50 50 m 25 50 25 0 180 arc s");
2312 PrintStr(
" 50 50 m 75 50 25 180 360 arc s");
2313 PrintStr(
" gr end } >> [ 0.4 0 0 0.2 0 0 ]");
2316 PrintStr(
" /BBox [ 0 0 100 100 ]");
2317 PrintStr(
" /XStep 100 /YStep 100");
2318 PrintStr(
" /PaintProc { begin gsave");
2319 PrintStr(
" [24] 0 setdash 0 0 m 100 100 l s");
2320 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2323 PrintStr(
" /BBox [ 0 0 100 100 ]");
2324 PrintStr(
" /XStep 100 /YStep 100");
2325 PrintStr(
" /PaintProc { begin gsave");
2326 PrintStr(
" [24] 0 setdash 0 100 m 100 0 l s");
2327 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2330 PrintStr(
" /BBox [ 0 0 100 100 ]");
2331 PrintStr(
" /XStep 100 /YStep 100");
2332 PrintStr(
" /PaintProc { begin gsave");
2333 PrintStr(
" 90 50 m 50 50 40 0 360 arc");
2334 PrintStr(
" 0 50 m 0 100 50 270 360 arc");
2335 PrintStr(
" 50 0 m 0 0 50 0 90 arc");
2336 PrintStr(
" 100 50 m 100 0 50 90 180 arc");
2337 PrintStr(
" 50 100 m 100 100 50 180 270 arc s");
2338 PrintStr(
" gr end } >> [ 0.47 0 0 0.47 0 0 ]");
2341 PrintStr(
" /BBox [ 0 0 100 100 ]");
2342 PrintStr(
" /XStep 100 /YStep 100");
2343 PrintStr(
" /PaintProc { begin gsave");
2344 PrintStr(
" 50 50 m 50 75 25 270 450 arc s");
2345 PrintStr(
" 50 50 m 50 25 25 90 270 arc s");
2346 PrintStr(
" gr end } >> [ 0.2 0 0 0.4 0 0 ]");
2349 PrintStr(
" /BBox [ 0 0 101 101 ]");
2350 PrintStr(
" /XStep 100 /YStep 100");
2351 PrintStr(
" /PaintProc { begin gsave");
2352 PrintStr(
" 1 1 m 25 1 l 25 25 l 50 25 l 50 50 l");
2353 PrintStr(
" 75 50 l 75 75 l 100 75 l 100 100 l");
2354 PrintStr(
" 50 1 m 75 1 l 75 25 l 100 25 l 100 50 l");
2355 PrintStr(
" 0 50 m 25 50 l 25 75 l 50 75 l 50 100 l s");
2356 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2359 PrintStr(
" /BBox [ 0 0 101 101 ]");
2360 PrintStr(
" /XStep 100 /YStep 100");
2361 PrintStr(
" /PaintProc { begin gsave");
2362 PrintStr(
" 1 100 m 25 100 l 25 75 l 50 75 l 50 50 l");
2363 PrintStr(
" 75 50 l 75 25 l 100 25 l 100 1 l");
2364 PrintStr(
" 50 100 m 75 100 l 75 75 l 100 75 l 100 50 l");
2365 PrintStr(
" 0 50 m 25 50 l 25 25 l 50 25 l 50 1 l s");
2366 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2369 PrintStr(
" /BBox [ 0 0 100 100 ]");
2370 PrintStr(
" /XStep 100 /YStep 100");
2371 PrintStr(
" /PaintProc { begin gsave");
2372 PrintStr(
" [1 7] 0 sd 0 8 50 { dup dup m 2 mul 0 l s } for");
2373 PrintStr(
" 0 8 50 { dup dup 2 mul 100 m 50 add exch 50");
2374 PrintStr(
" add l s } for 100 0 m 100 100 l 50 50 l f");
2375 PrintStr(
" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2378 PrintStr(
" /BBox [ 0 0 100 100 ]");
2379 PrintStr(
" /XStep 100 /YStep 100");
2380 PrintStr(
" /PaintProc { begin gsave");
2381 PrintStr(
" 100 100 m 100 36 l 88 36 l 88 88 l f");
2382 PrintStr(
" 100 0 m 100 12 l 56 12 l 50 0 l f");
2383 PrintStr(
" 0 0 m 48 0 l 48 48 l 50 48 l 56 60 l");
2384 PrintStr(
" 36 60 l 36 12 l 0 12 l f [1 7] 0 sd");
2385 PrintStr(
" 61 8 87 { dup dup dup 12 exch m 88 exch l s");
2386 PrintStr(
" 16 exch 4 sub m 88 exch 4 sub l s } for");
2387 PrintStr(
" 13 8 35 { dup dup dup 0 exch m 36 exch l s");
2388 PrintStr(
" 4 exch 4 sub m 36 exch 4 sub l s } for");
2389 PrintStr(
" 37 8 59 { dup dup dup 12 exch m 36 exch l s");
2390 PrintStr(
" 16 exch 4 sub m 36 exch 4 sub l s } for");
2391 PrintStr(
" 13 8 60 { dup dup dup 56 exch m 100 exch l s");
2392 PrintStr(
" 60 exch 4 sub m 100 exch 4 sub l s } for");
2393 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2396 PrintStr(
" /BBox [ 0 0 101 101 ]");
2397 PrintStr(
" /XStep 100 /YStep 100");
2398 PrintStr(
" /PaintProc { begin gsave");
2399 PrintStr(
" 0 0 m 30 30 l 70 30 l 70 70 l 100 100 l 100 0 l");
2400 PrintStr(
" f 30 30 m 30 70 l 70 70 l f");
2401 PrintStr(
" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2403 snprintf(cdef,28,
" makepattern /%s exch def",&cpat[1]);
2405 fPatterns[ipat] = 1;
2409 if (fPatterns[26] == 0) {
2410 if (gStyle->GetColorModelPS()) {
2411 PrintStr(
" /cs {[/Pattern /DeviceCMYK] setcolorspace} def");
2412 PrintStr(
" /FA {f [/DeviceCMYK] setcolorspace} def");
2414 PrintStr(
" /cs {[/Pattern /DeviceRGB] setcolorspace} def");
2415 PrintStr(
" /FA {f [/DeviceRGB] setcolorspace} def");
2422 TColor *col = gROOT->GetColor(color);
2424 Double_t colRed = col->GetRed();
2425 Double_t colGreen = col->GetGreen();
2426 Double_t colBlue = col->GetBlue();
2427 if (gStyle->GetColorModelPS()) {
2428 Double_t colBlack = TMath::Min(TMath::Min(1-colRed,1-colGreen),1-colBlue);
2433 WriteReal(colBlack);
2435 Double_t colCyan = (1-colRed-colBlack)/(1-colBlack);
2436 Double_t colMagenta = (1-colGreen-colBlack)/(1-colBlack);
2437 Double_t colYellow = (1-colBlue-colBlack)/(1-colBlack);
2439 WriteReal(colMagenta);
2440 WriteReal(colYellow);
2441 WriteReal(colBlack);
2445 WriteReal(colGreen);
2450 PrintFast(9,
" setcolor");
2456 void TPostScript::SetLineColor( Color_t cindex )
2458 fLineColor = cindex;
2459 SetColor(Int_t(cindex));
2479 void TPostScript::SetLineJoin( Int_t linejoin )
2481 fgLineJoin = linejoin;
2482 if (fgLineJoin<0) fgLineJoin=0;
2483 if (fgLineJoin>2) fgLineJoin=2;
2496 void TPostScript::SetLineStyle(Style_t linestyle)
2498 if ( linestyle == fLineStyle)
return;
2499 fLineStyle = linestyle;
2500 const char *st = gStyle->GetLineStyleString(linestyle);
2502 Int_t nch = strlen(st);
2504 PrintFast(6,
"] 0 sd");
2510 void TPostScript::SetLineWidth(Width_t linewidth)
2512 if ( linewidth == fLineWidth)
return;
2513 fLineWidth = linewidth;
2514 if (fLineWidth!=0) {
2515 WriteInteger(Int_t(fLineScale*fLineWidth));
2523 void TPostScript::SetMarkerColor( Color_t cindex )
2525 fMarkerColor = cindex;
2526 SetColor(Int_t(cindex));
2532 void TPostScript::SetColor(Int_t color)
2534 if (color < 0) color = 0;
2535 fCurrentColor = color;
2536 TColor *col = gROOT->GetColor(color);
2538 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
2540 SetColor(1., 1., 1.);
2546 void TPostScript::SetColor(Float_t r, Float_t g, Float_t b)
2548 if (r == fRed && g == fGreen && b == fBlue)
return;
2554 if (fRed <= 0 && fGreen <= 0 && fBlue <= 0 ) {
2555 PrintFast(6,
" black");
2557 if (gStyle->GetColorModelPS()) {
2558 Double_t colBlack = TMath::Min(TMath::Min(1-fRed,1-fGreen),1-fBlue);
2559 Double_t colCyan = (1-fRed-colBlack)/(1-colBlack);
2560 Double_t colMagenta = (1-fGreen-colBlack)/(1-colBlack);
2561 Double_t colYellow = (1-fBlue-colBlack)/(1-colBlack);
2563 WriteReal(colMagenta);
2564 WriteReal(colYellow);
2565 WriteReal(colBlack);
2578 void TPostScript::SetTextColor( Color_t cindex )
2580 fTextColor = cindex;
2582 SetColor( Int_t(cindex) );
2591 void TPostScript::Text(Double_t xx, Double_t yy,
const char *chars)
2593 static const char *psfont[31][2] = {
2594 {
"Root.PSFont.1",
"/Times-Italic" },
2595 {
"Root.PSFont.2",
"/Times-Bold" },
2596 {
"Root.PSFont.3",
"/Times-BoldItalic" },
2597 {
"Root.PSFont.4",
"/Helvetica" },
2598 {
"Root.PSFont.5",
"/Helvetica-Oblique" },
2599 {
"Root.PSFont.6",
"/Helvetica-Bold" },
2600 {
"Root.PSFont.7",
"/Helvetica-BoldOblique" },
2601 {
"Root.PSFont.8",
"/Courier" },
2602 {
"Root.PSFont.9",
"/Courier-Oblique" },
2603 {
"Root.PSFont.10",
"/Courier-Bold" },
2604 {
"Root.PSFont.11",
"/Courier-BoldOblique" },
2605 {
"Root.PSFont.12",
"/Symbol" },
2606 {
"Root.PSFont.13",
"/Times-Roman" },
2607 {
"Root.PSFont.14",
"/ZapfDingbats" },
2608 {
"Root.PSFont.15",
"/Symbol" },
2609 {
"Root.PSFont.STIXGen",
"/STIXGeneral" },
2610 {
"Root.PSFont.STIXGenIt",
"/STIXGeneral-Italic" },
2611 {
"Root.PSFont.STIXGenBd",
"/STIXGeneral-Bold" },
2612 {
"Root.PSFont.STIXGenBdIt",
"/STIXGeneral-BoldItalic" },
2613 {
"Root.PSFont.STIXSiz1Sym",
"/STIXSize1Symbols" },
2614 {
"Root.PSFont.STIXSiz1SymBd",
"/STIXSize1Symbols-Bold" },
2615 {
"Root.PSFont.STIXSiz2Sym",
"/STIXSize2Symbols" },
2616 {
"Root.PSFont.STIXSiz2SymBd",
"/STIXSize2Symbols-Bold" },
2617 {
"Root.PSFont.STIXSiz3Sym",
"/STIXSize3Symbols" },
2618 {
"Root.PSFont.STIXSiz3SymBd",
"/STIXSize3Symbols-Bold" },
2619 {
"Root.PSFont.STIXSiz4Sym",
"/STIXSize4Symbols" },
2620 {
"Root.PSFont.STIXSiz4SymBd",
"/STIXSize4Symbols-Bold" },
2621 {
"Root.PSFont.STIXSiz5Sym",
"/STIXSize5Symbols" },
2622 {
"Root.PSFont.ME",
"/DroidSansFallback" },
2623 {
"Root.PSFont.CJKMing",
"/DroidSansFallback" },
2624 {
"Root.PSFont.CJKGothic",
"/DroidSansFallback" }
2627 const Double_t kDEGRAD = TMath::Pi()/180.;
2635 Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
2636 Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
2637 Float_t tsize, ftsize;
2640 tsize = fTextSize*wh;
2641 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5);
2642 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2644 tsize = fTextSize*hh;
2645 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5);
2646 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2648 Double_t fontsize = 4*(72*(ftsize)/2.54);
2649 if( fontsize <= 0)
return;
2651 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2652 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2654 Int_t font = abs(fTextFont)/10;
2655 if( font > 31 || font < 1) font = 1;
2658 SetColor(Int_t(fTextColor));
2661 Int_t txalh = fTextAlign/10;
2662 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
2663 Int_t txalv = fTextAlign%10;
2664 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
2666 y -= 0.8*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2667 x += 0.8*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2668 }
else if (txalv == 2) {
2669 y -= 0.4*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2670 x += 0.4*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2673 UInt_t w = 0, w0 = 0;
2679 const Float_t scale = 16.0;
2682 saveAttText.TAttText::operator=(*this);
2683 const Int_t len=strlen(chars);
2684 Int_t *charWidthsCumul = 0;
2686 t.SetTextSize(fTextSize * scale);
2687 t.SetTextFont(fTextFont);
2688 t.GetTextAdvance(w, chars);
2689 t.GetTextAdvance(w0, chars, kFALSE);
2690 t.TAttText::Modify();
2691 if (w0-w != 0) kerning = kTRUE;
2692 else kerning = kFALSE;
2695 charWidthsCumul =
new Int_t[len];
2696 for (Int_t i = len - 1;i >= 0;i--) {
2698 t.GetTextAdvance(ww, chars + i);
2699 Double_t wwl = (gPad->AbsPixeltoX(ww)-gPad->AbsPixeltoX(0));
2700 charWidthsCumul[i] = (Int_t)((XtoPS(wwl) - XtoPS(0)) / scale);
2704 saveAttText.TAttText::Modify();
2706 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2707 Int_t psCharsLength = (Int_t)((XtoPS(charsLength)-XtoPS(0)) / scale);
2710 Int_t psangle = Int_t(0.5 + fTextAngle);
2717 Int_t xc1 = XtoPS(gPad->GetX1());
2718 Int_t xc2 = XtoPS(gPad->GetX2());
2719 Int_t yc1 = YtoPS(gPad->GetY1());
2720 Int_t yc2 = YtoPS(gPad->GetY2());
2721 WriteInteger(xc2 - xc1);
2722 WriteInteger(yc2 - yc1);
2729 Double_t vx = (x - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
2730 Double_t cmx = fXsize*(gPad->GetAbsXlowNDC()+vx*gPad->GetAbsWNDC());
2731 WriteReal((288.*cmx)/2.54);
2732 Double_t vy = (y - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
2733 Double_t cmy = fYsize*(gPad->GetAbsYlowNDC()+vy*gPad->GetAbsHNDC());
2734 WriteReal((288.*cmy)/2.54);
2735 PrintStr(Form(
" t %d r ", psangle));
2736 if(txalh == 2) PrintStr(Form(
" %d 0 t ", -psCharsLength/2));
2737 if(txalh == 3) PrintStr(Form(
" %d 0 t ", -psCharsLength));
2738 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2740 PrintStr(Form(
" findfont %g sf 0 0 m ",fontsize));
2742 PrintStr(Form(
" findfont %g sf 0 0 m ita ",fontsize));
2748 for (Int_t i = len-1; i >= 1; i--) {
2749 WriteInteger(charWidthsCumul[0] - charWidthsCumul[i]);
2751 delete [] charWidthsCumul;
2759 const char *crsave = fImplicitCREsc;
2760 fImplicitCREsc =
"\\";
2763 for (Int_t i=0; i<len;i++) {
2764 if (chars[i]!=
'\n') {
2765 if (chars[i]==
'(' || chars[i]==
')' || chars[i]==
'\\') {
2766 snprintf(str,8,
"\\%c",chars[i]);
2768 }
else if ((chars[i]==
'-') && (font != 12)) {
2771 snprintf(str,8,
"%c",chars[i]);
2777 fImplicitCREsc = crsave;
2780 if (font != 15) PrintStr(
" K NC");
2781 else PrintStr(
" K gr NC");
2783 if (font != 15) PrintStr(
" show NC");
2784 else PrintStr(
" show gr NC");
2796 void TPostScript::Text(Double_t xx, Double_t yy,
const wchar_t *chars)
2798 static const char *psfont[31][2] = {
2799 {
"Root.PSFont.1",
"/FreeSerifItalic" },
2800 {
"Root.PSFont.2",
"/FreeSerifBold" },
2801 {
"Root.PSFont.3",
"/FreeSerifBoldItalic" },
2802 {
"Root.PSFont.4",
"/FreeSans" },
2803 {
"Root.PSFont.5",
"/FreeSansOblique" },
2804 {
"Root.PSFont.6",
"/FreeSansBold" },
2805 {
"Root.PSFont.7",
"/FreeSansBoldOblique" },
2806 {
"Root.PSFont.8",
"/FreeMono" },
2807 {
"Root.PSFont.9",
"/FreeMonoOblique" },
2808 {
"Root.PSFont.10",
"/FreeMonoBold" },
2809 {
"Root.PSFont.11",
"/FreeMonoBoldOblique" },
2810 {
"Root.PSFont.12",
"/SymbolMT" },
2811 {
"Root.PSFont.13",
"/FreeSerif" },
2812 {
"Root.PSFont.14",
"/Wingdings-Regular" },
2813 {
"Root.PSFont.15",
"/SymbolMT" },
2814 {
"Root.PSFont.STIXGen",
"/STIXGeneral" },
2815 {
"Root.PSFont.STIXGenIt",
"/STIXGeneral-Italic" },
2816 {
"Root.PSFont.STIXGenBd",
"/STIXGeneral-Bold" },
2817 {
"Root.PSFont.STIXGenBdIt",
"/STIXGeneral-BoldItalic" },
2818 {
"Root.PSFont.STIXSiz1Sym",
"/STIXSize1Symbols" },
2819 {
"Root.PSFont.STIXSiz1SymBd",
"/STIXSize1Symbols-Bold" },
2820 {
"Root.PSFont.STIXSiz2Sym",
"/STIXSize2Symbols" },
2821 {
"Root.PSFont.STIXSiz2SymBd",
"/STIXSize2Symbols-Bold" },
2822 {
"Root.PSFont.STIXSiz3Sym",
"/STIXSize3Symbols" },
2823 {
"Root.PSFont.STIXSiz3SymBd",
"/STIXSize3Symbols-Bold" },
2824 {
"Root.PSFont.STIXSiz4Sym",
"/STIXSize4Symbols" },
2825 {
"Root.PSFont.STIXSiz4SymBd",
"/STIXSize4Symbols-Bold" },
2826 {
"Root.PSFont.STIXSiz5Sym",
"/STIXSize5Symbols" },
2827 {
"Root.PSFont.ME",
"/DroidSansFallback" },
2828 {
"Root.PSFont.CJKMing",
"/DroidSansFallback" },
2829 {
"Root.PSFont.CJKGothic",
"/DroidSansFallback" }
2832 Int_t len = wcslen(chars);
2835 const Double_t kDEGRAD = TMath::Pi()/180.;
2843 Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
2844 Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
2845 Float_t tsize, ftsize;
2848 tsize = fTextSize*wh;
2849 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5);
2850 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2852 tsize = fTextSize*hh;
2853 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5);
2854 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2856 Double_t fontsize = 4*(72*(ftsize)/2.54);
2857 if( fontsize <= 0)
return;
2859 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2860 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2862 Int_t font = abs(fTextFont)/10;
2863 if( font > 29 || font < 1) font = 1;
2866 SetColor(Int_t(fTextColor));
2869 Int_t txalh = fTextAlign/10;
2870 if (txalh <1) txalh = 1;
else if (txalh > 3) txalh = 3;
2871 Int_t txalv = fTextAlign%10;
2872 if (txalv <1) txalv = 1;
else if (txalv > 3) txalv = 3;
2874 y -= 0.8*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2875 x += 0.8*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2876 }
else if (txalv == 2) {
2877 y -= 0.4*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2878 x += 0.4*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2880 UInt_t w = 0, h = 0;
2883 t.SetTextSize(fTextSize);
2884 t.SetTextFont(fTextFont);
2885 t.GetTextExtent(w, h, chars);
2886 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2887 Int_t psCharsLength = XtoPS(charsLength)-XtoPS(0);
2890 Int_t psangle = Int_t(0.5 + fTextAngle);
2897 Int_t xc1 = XtoPS(gPad->GetX1());
2898 Int_t xc2 = XtoPS(gPad->GetX2());
2899 Int_t yc1 = YtoPS(gPad->GetY1());
2900 Int_t yc2 = YtoPS(gPad->GetY2());
2901 WriteInteger(xc2 - xc1);
2902 WriteInteger(yc2 - yc1);
2908 WriteInteger(XtoPS(x));
2909 WriteInteger(YtoPS(y));
2910 PrintStr(Form(
" t %d r ", psangle));
2911 if(txalh == 2) PrintStr(Form(
" %d 0 t ", -psCharsLength/2));
2912 if(txalh == 3) PrintStr(Form(
" %d 0 t ", -psCharsLength));
2913 MustEmbed[font-1] = kTRUE;
2914 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2915 PrintStr(Form(
" findfont %g sf 0 0 m ",fontsize));
2918 if (len > 1) PrintStr(Form(
"%d ", len));
2919 for(Int_t i = 0; i < len; i++) {
2923 const wchar_t *lower = std::lower_bound(
2924 adobe_glyph_ucs, adobe_glyph_ucs + nadobe_glyph,
2926 if(lower < adobe_glyph_ucs + nadobe_glyph &&
2927 *lower == chars[i]) {
2929 const unsigned long index =
2930 lower - adobe_glyph_ucs;
2931 PrintStr(Form(
"/%s ", adobe_glyph_name[index]));
2933 else if((
unsigned int)chars[i] < 0xffff) {
2935 PrintStr(Form(
"/uni%04X ",
2936 (
unsigned int)chars[i]));
2940 PrintStr(Form(
"/u%04X ",
2941 (
unsigned int)chars[i]));
2945 PrintStr(
"{glyphshow} repeat ");
2948 PrintStr(
"glyphshow ");
2959 void TPostScript::TextNDC(Double_t u, Double_t v,
const char *chars)
2961 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2962 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2969 void TPostScript::TextNDC(Double_t u, Double_t v,
const wchar_t *chars)
2971 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2972 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2979 Int_t TPostScript::UtoPS(Double_t u)
2981 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
2982 return Int_t(0.5 + 288*cm/2.54);
2988 Int_t TPostScript::VtoPS(Double_t v)
2990 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
2991 return Int_t(0.5 + 288*cm/2.54);
2997 Int_t TPostScript::XtoPS(Double_t x)
2999 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
3006 Int_t TPostScript::YtoPS(Double_t y)
3008 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
3015 void TPostScript::Zone()
3017 if( !fClear )
return;
3023 if( fIYzone > fNYzone) {
3026 PrintStr(
"@showpage");
3029 PrintStr(
"@%%Page:");
3030 WriteInteger(fNpages);
3031 WriteInteger(fNpages);
3034 PrintFast(9,
" showpage");
3041 if( fIXzone != 1 || fIYzone != 1) SaveRestore(-1);
3044 WriteInteger(fIXzone);
3045 WriteInteger(fIYzone);
3046 PrintFast(5,
" Zone");
3049 if( fIXzone > fNXzone) { fIXzone=1; fIYzone++; }
3055 WriteInteger(fgLineJoin);
3056 PrintFast(12,
" setlinejoin");
3058 PrintFast(6,
" 0 0 t");
3068 fMarkerSizeCur = -1;