Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPostScript.cxx
Go to the documentation of this file.
1// @(#)root/postscript:$Id$
2// Author: Rene Brun, Olivier Couet, Pierre Juillot, Oleksandr Grebenyuk, Yue Shi Lai
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TPostScript
13\ingroup PS
14
15\brief Interface to PostScript.
16
17To generate a Postscript (or encapsulated ps) file corresponding to
18a single image in a canvas, you can:
19
20 - Select the <B>Print PostScript</B> item in the canvas <B>File</B> menu.
21 By default, a Postscript file with the name of the canvas.ps is generated.
22 - Click in the canvas area, near the edges, with the right mouse button
23 and select the <B>Print</B> item. You can select the name of the Postscript
24 file. If the file name is xxx.ps, you will generate a Postscript file named
25 xxx.ps. If the file name is xxx.eps, you generate an encapsulated Postscript
26 file instead.
27 - In your program (or macro), you can type:
28~~~ {.cpp}
29 c1->Print("xxx.ps");
30~~~
31or:
32~~~ {.cpp}
33 c1->Print("xxx.eps");
34~~~
35 This will generate a file corresponding to the picture in the canvas
36 pointed by `c1`.
37~~~ {.cpp}
38 pad1->Print("xxx.ps");
39~~~
40 prints only the picture in the pad pointed by `pad1`.
41
42The size of the Postscript picture, by default, is computed to keep the aspect
43ratio of the picture on the screen, where the size along x is always 20cm. You
44can set the size of the PostScript picture before generating the picture
45with a command such as:
46
47~~~ {.cpp}
48 TPostScript myps("myfile.ps",111)
49 myps.Range(xsize,ysize);
50 object->Draw();
51 myps.Close();
52~~~
53You can set the default paper size with:
54~~~ {.cpp}
55 gStyle->SetPaperSize(xsize,ysize);
56~~~
57You can resume writing again in this file with `myps.Open();`.
58Note that you may have several Postscript files opened simultaneously.
59
60 ## Output type
61
62The output type allows to define how the PostScript output will looks like.
63It allows to define the page format (A4, Legal etc..), the orientation
64(Portrait, Landscape) and the number of images (zones) per page.
65The output type has the following form:
66
67~~~ {.cpp}
68 [Format][Nx][Ny][Type]
69~~~
70
71Where:
72
73 - Format : Is an integer between 0 and 99 defining the page format:
74~~~ {.cpp}
75 Format = 3 the paper is in the standard A3 format.
76 Format = n (1<n<98) is an An format.
77 Format = 4 and Format=0 are the same and define an A4 page.
78 The A0 format is selected by Format=99.
79 The US format Letter is selected by Format = 100.
80 The US format Legal is selected by Format = 200.
81 The US format Ledger is selected by Format = 300.
82~~~
83 - Nx, Ny : Specify respectively the number of zones on the x and y axis.
84 Nx and Ny are integers between 1 and 9.
85 - Type : Can be equal to:
86 - 1 : Portrait mode with a small margin at the bottom of the page.
87 - 2 : Landscape mode with a small margin at the bottom of the page.
88 - 4 : Portrait mode with a large margin at the bottom of the page.
89 - 5 : Landscape mode with a large margin at the bottom of the page.
90 The large margin is useful for some PostScript printers (very often
91 for the colour printers) as they need more space to grip the paper
92 for mechanical reasons. Note that some PostScript colour printers
93 can also use the so called special A4 format permitting the full
94 usage of the A4 area; in this case larger margins are not necessary
95 and Type=1 or 2 can be used.
96 - 3 : Encapsulated PostScript. This Type permits the generation of files
97 which can be included in other documents, for example in LaTeX files.
98
99## Making several pictures in the same Postscript file: case 1
100
101The following macro is an example illustrating how to open a Postscript
102file and draw several pictures. The generation of a new Postscript page
103is automatic when `TCanvas::Clear` is called by `object->Draw()`.
104
105~~~ {.cpp}
106 {
107 TFile f("hsimple.root");
108 TCanvas c1("c1","canvas",800,600);
109
110 // select postscript output type
111 // type = 111 portrait ps
112 // type = 112 landscape ps
113 // type = 113 eps
114 Int_t type = 111;
115
116 // create a postscript file and set the paper size
117 TPostScript ps("test.ps",type);
118 ps.Range(16,24); //set x,y of printed page
119
120 // draw 3 histograms from file hsimple.root on separate pages
121 hpx->Draw();
122 c1.Update(); //force drawing in a macro
123 hprof->Draw();
124 c1.Update();
125 hpx->Draw("lego1");
126 c1.Update();
127 ps.Close();
128 }
129~~~
130
131## Making several pictures in the same Postscript file: case 2
132
133This example shows 2 pages. The canvas is divided.
134`TPostScript::NewPage` must be called before starting a new
135picture.`object->Draw` does not clear the canvas in this case
136because we clear only the pads and not the main canvas.
137Note that `c1->Update` must be called at the end of the first picture.
138
139~~~ {.cpp}
140 {
141 TFile *f1 = new TFile("hsimple.root");
142 TCanvas *c1 = new TCanvas("c1");
143 TPostScript *ps = new TPostScript("file.ps",112);
144 c1->Divide(2,1);
145 // picture 1
146 ps->NewPage();
147 c1->cd(1);
148 hpx->Draw();
149 c1->cd(2);
150 hprof->Draw();
151 c1->Update();
152
153 // picture 2
154 ps->NewPage();
155 c1->cd(1);
156 hpxpy->Draw();
157 c1->cd(2);
158 ntuple->Draw("px");
159 c1->Update();
160 ps->Close();
161
162 // invoke Postscript viewer
163 gSystem->Exec("gs file.ps");
164 }
165~~~
166
167## Making several pictures in the same Postscript file: case 3
168This is the recommended way. If the Postscript file name finishes with
169"(", the file remains opened (it is not closed). If the Postscript file name
170finishes with ")" and the file has been opened with "(", the file is closed.
171
172Example:
173~~~ {.cpp}
174 {
175 TCanvas c1("c1");
176 h1.Draw();
177 c1.Print("c1.ps("); // write canvas and keep the ps file open
178 h2.Draw();
179 c1.Print("c1.ps"); // canvas is added to "c1.ps"
180 h3.Draw();
181 c1.Print("c1.ps)"); // canvas is added to "c1.ps" and ps file is closed
182 }
183~~~
184The `TCanvas::Print("file.ps(")` mechanism is very useful, but it can
185be a little inconvenient to have the action of opening/closing a file being
186atomic with printing a page. Particularly if pages are being generated in some
187loop one needs to detect the special cases of first and last page and then
188munge the argument to Print() accordingly.
189The "[" and "]" can be used instead of "(" and ")" as shown below.
190
191Example:
192~~~ {.cpp}
193 c1.Print("file.ps["); // No actual print, just open file.ps
194
195 for (int i=0; i<10; ++i) {
196 // fill canvas for context i
197 // ...
198
199 c1.Print("file.ps"); // Actually print canvas to the file
200 }
201
202 c1.Print("file.ps]"); // No actual print, just close the file
203~~~
204
205 ## Color Model
206
207TPostScript support two color model RGB and CMYK. CMY and CMYK models are
208subtractive color models unlike RGB which is an additive. They are mainly
209used for printing purposes. CMY means Cyan Magenta Yellow to convert RGB
210to CMY it is enough to do: C=1-R, M=1-G and Y=1-B. CMYK has one more
211component K (black). The conversion from RGB to CMYK is:
212
213~~~ {.cpp}
214 Double_t Black = TMath::Min(TMath::Min(1-Red,1-Green),1-Blue);
215 Double_t Cyan = (1-Red-Black)/(1-Black);
216 Double_t Magenta = (1-Green-Black)/(1-Black);
217 Double_t Yellow = (1-Blue-Black)/(1-Black);
218~~~
219CMYK add the black component which allows to have a better quality for black
220printing. PostScript support the CMYK model.
221
222To change the color model use `gStyle->SetColorModelPS(c)`.
223
224 - c = 0 means TPostScript will use RGB color model (default)
225 - c = 1 means TPostScript will use CMYK color model
226*/
227
228#ifdef WIN32
229#pragma optimize("",off)
230#endif
231
232#include <cstdlib>
233#include <cstring>
234#include <cctype>
235#include <cwchar>
236#include <fstream>
237
238#include "strlcpy.h"
239#include "snprintf.h"
240#include "Byteswap.h"
241#include "TROOT.h"
242#include "TDatime.h"
243#include "TColor.h"
244#include "TVirtualPad.h"
245#include "TPoints.h"
246#include "TPoint.h"
247#include "TPostScript.h"
248#include "TStyle.h"
249#include "TMath.h"
250#include "TText.h"
251#include "TSystem.h"
252#include "TEnv.h"
253
254#include "../../../builtins/mathtext/inc/fontembed.h"
255
256// to scale fonts to the same size as the old TT version
257const Float_t kScale = 0.93376068;
258
259// Array defining if a font must be embedded or not.
262
263
264////////////////////////////////////////////////////////////////////////////////
265/// Default PostScript constructor
266
268{
269 for (Int_t i = 0; i < 32; i++)
270 fPatterns[i] = 0;
271 for (Int_t i = 0; i < 29; i++)
272 fMustEmbed[i] = kFALSE;
273 SetTitle("PS");
274
275 gVirtualPS = this;
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Initialize the PostScript interface
280///
281/// - fname : PostScript file name
282/// - wtype : PostScript workstation type
283///
284///
285/// The possible workstation types are:
286/// - 111 ps Portrait
287/// - 112 ps Landscape
288/// - 113 eps
289
291{
292 for (Int_t i = 0; i < 32; i++)
293 fPatterns[i] = 0;
294 for (Int_t i = 0; i < 29; i++)
295 fMustEmbed[i] = kFALSE;
296
297 SetTitle("PS");
298 Open(fname, wtype);
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Open a PostScript file
303
305{
306 if (fStream) {
307 Warning("Open", "postscript file already open");
308 return;
309 }
310
311 fMarkerSizeCur = 0;
312 fRed = -1;
313 fGreen = -1;
314 fBlue = -1;
315 fLenBuffer = 0;
316 fClip = 0;
317 fType = std::abs(wtype);
318 fClear = kTRUE;
319 fZone = kFALSE;
320 fSave = 0;
326 fMode = fType%10;
328 if (gPad) {
329 Double_t ww = gPad->GetWw();
330 Double_t wh = gPad->GetWh();
331 if (fType == 113) {
332 ww *= gPad->GetWNDC();
333 wh *= gPad->GetHNDC();
334 }
335 Double_t ratio = wh/ww;
336 if (fType == 112) {
337 xrange = fYsize;
338 yrange = xrange*ratio;
339 if (yrange > fXsize) { yrange = fXsize; xrange = yrange/ratio;}
340 } else {
341 xrange = fXsize;
342 yrange = fXsize*ratio;
343 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
344 }
346 }
347
348 // Open OS file
351 Error("Open", "Cannot open file: %s", fFileName.Data());
352 return;
353 }
354 gVirtualPS = this;
355
356 ClearBuffer();
357
358 if( fType == 113) {
360 PrintStr("%!PS-Adobe-2.0 EPSF-2.0@");
361 } else {
363 PrintStr("%!PS-Adobe-2.0@");
364 Initialize();
365 }
366
368 fRange = kFALSE;
369
370 // Set a default range
372
374 if (fType == 113)
375 NewPage();
376}
377
378////////////////////////////////////////////////////////////////////////////////
379/// Default PostScript destructor
380
385
386////////////////////////////////////////////////////////////////////////////////
387/// Close a PostScript file
388
390{
391 if (!gVirtualPS ||!fStream)
392 return;
393 if (gPad)
394 gPad->Update();
395 if(fMode != 3) {
396 SaveRestore(-1);
397 if( fPrinted ) { PrintStr("showpage@"); SaveRestore(-1);}
398 PrintStr("@");
399 PrintStr("%%Trailer@");
400 PrintStr("%%Pages: ");
402 PrintStr("@");
403 while (fSave > 0) { SaveRestore(-1); }
404 } else {
405 PrintStr("@");
406 while (fSave > 0) { SaveRestore(-1); }
407 PrintStr("showpage@");
408 PrintStr("end@");
409 }
410 PrintStr("@");
411 PrintStr("%%EOF@");
412
413 // Embed the fonts previously used by TMathText
414 if (!fFontEmbed) {
415 // Close the file fFileName
416 if (fStream) {
417 PrintStr("@");
418 CloseStream();
419 }
420
421 // Rename the file fFileName
423 if (gSystem->Rename(fFileName.Data(), tmpname.Data())) {
424 Error("Close", "Cannot open temporary file: %s", tmpname.Data());
425 return;
426 }
427
429 Error("Close", "Cannot open file: %s", fFileName.Data());
430 return;
431 }
432
433 // Embed the fonts at the right place
434 FILE *sg = fopen(tmpname.Data(),"r");
435 if (!sg) {
436 Error("Close", "Cannot open file: %s", tmpname.Data());
437 return;
438 }
439 char line[255];
440 while (fgets(line, 255, sg)) {
441 if (strstr(line,"EndComments")) PrintStr("%%DocumentNeededResources: ProcSet (FontSetInit)@");
442 fStream->write(line,strlen(line));
443 // insert font after end of generic defines
444 if (!fFontEmbed && strstr(line,"/ita")) {
445 FontEmbed();
446 PrintStr("@");
447 }
448 }
449 fclose(sg);
450 if (gSystem->Unlink(tmpname.Data())) return;
451 }
452
454
455 // Close file stream
456
457 CloseStream();
458
459 gVirtualPS = nullptr;
460}
461
462////////////////////////////////////////////////////////////////////////////////
463/// Activate an already open PostScript file
464
466{
467 if (!fType) {
468 Error("On", "no postscript file open");
469 Off();
470 return;
471 }
472 gVirtualPS = this;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Deactivate an already open PostScript file
477
479{
480 gVirtualPS = nullptr;
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Draw a Cell Array
485///
486/// Drawing a PostScript Cell Array is in fact done thanks to three
487/// procedures: CellArrayBegin, CellArrayFill, and CellArrayEnd.
488///
489/// - CellArrayBegin: Initiate the Cell Array by writing the necessary
490/// PostScript procedures and the initial values of the
491/// required parameters. The input parameters are:
492/// - W: number of boxes along the width.
493/// - H: number of boxes along the height
494/// - x1,x2,y1,y2: First box coordinates.
495/// - CellArrayFill: Is called for each box of the Cell Array. The first
496/// box is the top left one and the last box is the
497/// bottom right one. The input parameters are the Red,
498/// Green, and Blue components of the box colour. These
499/// Levels are between 0 and 255.
500/// - CellArrayEnd: Finishes the Cell Array.
501///
502/// PostScript cannot handle arrays larger than 65535. So the Cell Array
503/// is drawn in several pieces.
504
507{
508 Int_t ix1 = XtoPS(x1);
509 Int_t iy1 = YtoPS(y1);
510
511 Float_t wt = (288/2.54)*gPad->GetAbsWNDC()*
512 fXsize*((x2 - x1)/(gPad->GetX2()-gPad->GetX1()));
513 Float_t ht = (288/2.54)*gPad->GetAbsHNDC()*
514 fYsize*((y2 - y1)/(gPad->GetY2()-gPad->GetY1()));
515
516 fLastCellRed = 300;
517 fLastCellGreen = 300;
518 fLastCellBlue = 300;
520
521 fNbinCT = 0;
522 fNbCellW = W;
523 fNbCellLine = 0;
524 fMaxLines = 40000/(3*fNbCellW);
525
526 // Define some parameters
527 PrintStr("@/WT"); WriteReal(wt) ; PrintStr(" def"); // Cells width
528 PrintStr(" /HT"); WriteReal(ht) ; PrintStr(" def"); // Cells height
529 PrintStr(" /XS"); WriteInteger(ix1) ; PrintStr(" def"); // X start
530 PrintStr(" /YY"); WriteInteger(iy1) ; PrintStr(" def"); // Y start
531 PrintStr(" /NX"); WriteInteger(W) ; PrintStr(" def"); // Number of columns
532 PrintStr(" /NY"); WriteInteger(fMaxLines); PrintStr(" def"); // Number of lines
533
534 // This PS procedure draws one cell.
535 PrintStr(" /DrawCell ");
536 PrintStr( "{WT HT XX YY bf");
537 PrintStr( " /NBBD NBBD 1 add def");
538 PrintStr( " NBBD NBB eq {exit} if");
539 PrintStr( " /XX WT XX add def");
540 PrintStr( " IX NX eq ");
541 PrintStr( "{/YY YY HT sub def");
542 PrintStr( " /XX XS def");
543 PrintStr( " /IX 0 def} if");
544 PrintStr( " /IX IX 1 add def} def");
545
546 // This PS procedure draws fMaxLines line. It takes care of duplicated
547 // colors. Values "n" greater than 300 mean than the previous color
548 // should be duplicated n-300 times.
549 PrintStr(" /DrawCT ");
550 PrintStr( "{/NBB NX NY mul def");
551 PrintStr( " /XX XS def");
552 PrintStr( " /IX 1 def");
553 PrintStr( " /NBBD 0 def");
554 PrintStr( " /RC 0 def /GC 1 def /BC 2 def");
555 PrintStr( " 1 1 NBB ");
556 PrintStr( "{/NB CT RC get def");
557 PrintStr( " NB 301 ge ");
558 PrintStr( "{/NBL NB 300 sub def");
559 PrintStr( " 1 1 NBL ");
560 PrintStr( "{DrawCell}");
561 PrintStr( " for");
562 PrintStr( " /RC RC 1 add def");
563 PrintStr( " /GC RC 1 add def");
564 PrintStr( " /BC RC 2 add def}");
565 PrintStr( "{CT RC get 255 div CT GC get 255 div CT BC get 255 div setrgbcolor");
566 PrintStr( " DrawCell");
567 PrintStr( " /RC RC 3 add def");
568 PrintStr( " /GC GC 3 add def");
569 PrintStr( " /BC BC 3 add def} ifelse NBBD NBB eq {exit} if} for");
570 PrintStr( " /YY YY HT sub def clear} def");
571
572 PrintStr(" /CT [");
573}
574
575////////////////////////////////////////////////////////////////////////////////
576/// Paint the Cell Array
577
579{
580 if (fLastCellRed == r && fLastCellGreen == g && fLastCellBlue == b) {
582 } else {
583 if (fNBSameColorCell != 0 ) {
586 }
590 fLastCellRed = r;
593 }
594
595 fNbinCT++;
596 if (fNbinCT == fNbCellW) {
597 fNbCellLine++;
598 fNbinCT = 0;
599 }
600
601 if (fNbCellLine == fMaxLines) {
603 PrintStr("] def DrawCT /CT [");
604 fNbCellLine = 0;
605 fLastCellRed = 300;
606 fLastCellGreen = 300;
607 fLastCellBlue = 300;
609 fNbinCT = 0;
610 }
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// End the Cell Array painting
615
617{
619 PrintStr("] def /NY");
621 PrintStr(" def DrawCT ");
622}
623
624
625////////////////////////////////////////////////////////////////////////////////
626/// Draw a Box
627
629{
630 Double_t x[4], y[4];
631 Int_t ix1 = XtoPS(x1);
632 Int_t ix2 = XtoPS(x2);
633 Int_t iy1 = YtoPS(y1);
634 Int_t iy2 = YtoPS(y2);
635 Int_t fillis = fFillStyle/1000;
636 Int_t fillsi = fFillStyle%1000;
637
638 if (fillis == 3 || fillis == 2) {
639 if (fillsi > 99) {
640 x[0] = x1; y[0] = y1;
641 x[1] = x2; y[1] = y1;
642 x[2] = x2; y[2] = y2;
643 x[3] = x1; y[3] = y2;
644 return;
645 }
646 if (fillsi > 0 && fillsi < 26) {
647 x[0] = x1; y[0] = y1;
648 x[1] = x2; y[1] = y1;
649 x[2] = x2; y[2] = y2;
650 x[3] = x1; y[3] = y2;
651 DrawPS(-4, &x[0], &y[0]);
652 }
653 if (fillsi == -3) {
654 SetColor(5);
659 PrintFast(3," bf");
660 }
661 }
662 if (fillis == 1) {
668 PrintFast(3," bf");
669 }
670 if (fillis == 0) {
671 if (fLineWidth<=0) return;
677 PrintFast(3," bl");
678 }
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Draw a Frame around a box
683///
684/// - mode = -1 box looks as it is behind the screen
685/// - mode = 1 box looks as it is in front of the screen
686/// - border is the border size in already precomputed PostScript units
687/// - dark is the color for the dark part of the frame
688/// - light is the color for the light part of the frame
689
691 Int_t mode, Int_t border, Int_t dark, Int_t light)
692{
693 Int_t xps[7], yps[7];
694 Int_t i, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
695
696 // Draw top&left part of the box
697 if (mode == -1) SetColor(dark);
698 else SetColor(light);
699 Int_t bordPS = 4*border;
700 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
701 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
702 xps[2] = xps[1]; yps[2] = YtoPS(yt) - bordPS;
703 xps[3] = XtoPS(xt) - bordPS; yps[3] = yps[2];
704 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
705 xps[5] = xps[0]; yps[5] = yps[4];
706 xps[6] = xps[0]; yps[6] = yps[0];
707
708 ixd0 = xps[0];
709 iyd0 = yps[0];
712
713 PrintFast(2," m");
714 idx = 0;
715 idy = 0;
716 for (i=1;i<7;i++) {
717 ixdi = xps[i];
718 iydi = yps[i];
719 ix = ixdi - ixd0;
720 iy = iydi - iyd0;
721 ixd0 = ixdi;
722 iyd0 = iydi;
723 if( ix && iy) {
724 if( idx ) { MovePS(idx,0); idx = 0; }
725 if( idy ) { MovePS(0,idy); idy = 0; }
726 MovePS(ix,iy);
727 continue;
728 }
729 if ( ix ) {
730 if( idy ) { MovePS(0,idy); idy = 0; }
731 if( !idx ) { idx = ix; continue;}
732 if( ix*idx > 0 ) idx += ix;
733 else { MovePS(idx,0); idx = ix; }
734 continue;
735 }
736 if( iy ) {
737 if( idx ) { MovePS(idx,0); idx = 0; }
738 if( !idy) { idy = iy; continue;}
739 if( iy*idy > 0 ) idy += iy;
740 else { MovePS(0,idy); idy = iy; }
741 }
742 }
743 if( idx ) MovePS(idx,0);
744 if( idy ) MovePS(0,idy);
745 PrintFast(2," f");
746
747 // Draw bottom&right part of the box
748 if (mode == -1) SetColor(light);
749 else SetColor(dark);
750 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
751 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
752 xps[2] = XtoPS(xt) - bordPS; yps[2] = yps[1];
753 xps[3] = xps[2]; yps[3] = YtoPS(yt) - bordPS;
754 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
755 xps[5] = xps[4]; yps[5] = yps[0];
756 xps[6] = xps[0]; yps[6] = yps[0];
757
758 ixd0 = xps[0];
759 iyd0 = yps[0];
762
763 PrintFast(2," m");
764 idx = 0;
765 idy = 0;
766 for (i=1;i<7;i++) {
767 ixdi = xps[i];
768 iydi = yps[i];
769 ix = ixdi - ixd0;
770 iy = iydi - iyd0;
771 ixd0 = ixdi;
772 iyd0 = iydi;
773 if( ix && iy) {
774 if( idx ) { MovePS(idx,0); idx = 0; }
775 if( idy ) { MovePS(0,idy); idy = 0; }
776 MovePS(ix,iy);
777 continue;
778 }
779 if ( ix ) {
780 if( idy ) { MovePS(0,idy); idy = 0; }
781 if( !idx ) { idx = ix; continue;}
782 if( ix*idx > 0 ) idx += ix;
783 else { MovePS(idx,0); idx = ix; }
784 continue;
785 }
786 if( iy ) {
787 if( idx ) { MovePS(idx,0); idx = 0; }
788 if( !idy) { idy = iy; continue;}
789 if( iy*idy > 0 ) idy += iy;
790 else { MovePS(0,idy); idy = iy; }
791 }
792 }
793 if( idx ) MovePS(idx,0);
794 if( idy ) MovePS(0,idy);
795 PrintFast(2," f");
796}
797
798////////////////////////////////////////////////////////////////////////////////
799/// Draw a PolyLine
800///
801/// Draw a polyline through the points xy.
802/// - If nn=1 moves only to point x,y.
803/// - If nn=0 the x,y are written in the PostScript file
804/// according to the current transformation.
805/// - If nn>0 the line is clipped as a line.
806/// - If nn<0 the line is clipped as a fill area.
807
809{
810 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
813 if (nn > 0) {
814 if (fLineWidth<=0) return;
815 n = nn;
819 } else {
820 n = -nn;
821 SetStyle(1);
822 SetWidth(1);
824 }
825
826 ixd0 = XtoPS(xy[0].GetX());
827 iyd0 = YtoPS(xy[0].GetY());
830 if( n <= 1) {
831 if( n == 0) goto END;
832 PrintFast(2," m");
833 goto END;
834 }
835
836 PrintFast(2," m");
837 idx = 0;
838 idy = 0;
839 for (i=1;i<n;i++) {
840 ixdi = XtoPS(xy[i].GetX());
841 iydi = YtoPS(xy[i].GetY());
842 ix = ixdi - ixd0;
843 iy = iydi - iyd0;
844 ixd0 = ixdi;
845 iyd0 = iydi;
846 if( ix && iy) {
847 if( idx ) { MovePS(idx,0); idx = 0; }
848 if( idy ) { MovePS(0,idy); idy = 0; }
849 MovePS(ix,iy);
850 continue;
851 }
852 if ( ix ) {
853 if( idy ) { MovePS(0,idy); idy = 0; }
854 if( !idx ) { idx = ix; continue;}
855 if( ix*idx > 0 ) idx += ix;
856 else { MovePS(idx,0); idx = ix; }
857 continue;
858 }
859 if( iy ) {
860 if( idx ) { MovePS(idx,0); idx = 0; }
861 if( !idy) { idy = iy; continue;}
862 if( iy*idy > 0 ) idy += iy;
863 else { MovePS(0,idy); idy = iy; }
864 }
865 }
866 if( idx ) MovePS(idx,0);
867 if( idy ) MovePS(0,idy);
868
869 if (nn > 0 ) {
870 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
871 PrintFast(2," s");
872 } else {
873 PrintFast(2," f");
874 }
875END:
876 if (nn < 0) {
879 }
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Draw a PolyLine in NDC space
884///
885/// Draw a polyline through the points xy.
886/// - If nn=1 moves only to point x,y.
887/// - If nn=0 the x,y are written in the PostScript file
888/// according to the current transformation.
889/// - If nn>0 the line is clipped as a line.
890/// - If nn<0 the line is clipped as a fill area.
891
893{
894 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
897 if (nn > 0) {
898 if (fLineWidth<=0) return;
899 n = nn;
903 } else {
904 n = -nn;
905 SetStyle(1);
906 SetWidth(1);
908 }
909
910 ixd0 = UtoPS(xy[0].GetX());
911 iyd0 = VtoPS(xy[0].GetY());
914 if( n <= 1) {
915 if( n == 0) goto END;
916 PrintFast(2," m");
917 goto END;
918 }
919
920 PrintFast(2," m");
921 idx = 0;
922 idy = 0;
923 for (i=1;i<n;i++) {
924 ixdi = UtoPS(xy[i].GetX());
925 iydi = VtoPS(xy[i].GetY());
926 ix = ixdi - ixd0;
927 iy = iydi - iyd0;
928 ixd0 = ixdi;
929 iyd0 = iydi;
930 if( ix && iy) {
931 if( idx ) { MovePS(idx,0); idx = 0; }
932 if( idy ) { MovePS(0,idy); idy = 0; }
933 MovePS(ix,iy);
934 continue;
935 }
936 if ( ix ) {
937 if( idy ) { MovePS(0,idy); idy = 0; }
938 if( !idx ) { idx = ix; continue;}
939 if( ix*idx > 0 ) idx += ix;
940 else { MovePS(idx,0); idx = ix; }
941 continue;
942 }
943 if( iy ) {
944 if( idx ) { MovePS(idx,0); idx = 0; }
945 if( !idy) { idy = iy; continue;}
946 if( iy*idy > 0 ) idy += iy;
947 else { MovePS(0,idy); idy = iy; }
948 }
949 }
950 if( idx ) MovePS(idx,0);
951 if( idy ) MovePS(0,idy);
952
953 if (nn > 0 ) {
954 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
955 PrintFast(2," s");
956 } else {
957 PrintFast(2," f");
958 }
959END:
960 if (nn < 0) {
963 }
964}
965
966////////////////////////////////////////////////////////////////////////////////
967/// Draw markers at the n WC points x, y
968template<typename T>
970{
971 if (GetMarkerSize() <= 0)
972 return;
973
974 auto linestylesav = GetLineStyle();
975 auto linewidthsav = GetLineWidth();
976
977 Float_t s2x = 1. / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
978 // Rescale size of marker on PS coordinates
979 Float_t scale = UtoPS(s2x) - UtoPS(0);
980
981 Int_t markerSize = 0;
982 std::vector<TPoint> points;
983
984 auto shape = GetMarkerShape(markerSize, points, scale, kUsePSWidthScale);
985 auto markerLineWidth = GetMarkerLineWidth(GetMarkerStyle());
986
987 Int_t szindx = (Int_t) (GetMarkerSize()*100.);
988
990 : TString::Format("m%d_sz%d", (Int_t) GetMarkerStyle(), szindx);
991
992 if (!fMarkers[name.Data()]) {
993 // create marker definition only once
994 PrintStr("@/");
995 PrintStr(name.Data());
996 PrintStr(" { gsave translate newpath");
997 switch(shape) {
999 markerSize = TMath::Max(4, markerSize*4); // circe diameter
1000 // no break, handle as filled circle
1003 PrintStr(" 0 0");
1004 WriteInteger(markerSize/2);
1005 PrintStr(" 0 360 arc");
1006 if (shape != TAttMarker::kShapeCircle)
1007 PrintStr(" fill");
1008 else
1009 PrintStr(" stroke");
1010 break;
1013 for (std::size_t i = 0; i < points.size(); ++i) {
1014 WriteInteger(points[i].fX);
1015 WriteInteger(-points[i].fY);
1016 PrintStr(i == 0 ? " moveto" : " lineto");
1017 }
1018 if (points.front() == points.back())
1019 PrintStr(" closepath");
1020 if (shape == TAttMarker::kShapeFilledArea)
1021 PrintStr(" fill");
1022 else
1023 PrintStr(" stroke");
1024 break;
1026 for (std::size_t i = 0; i < points.size(); ++i) {
1027 WriteInteger(points[i].fX);
1028 WriteInteger(-points[i].fY);
1029 PrintStr(i % 2 == 0 ? " moveto" : " lineto stroke");
1030 }
1031 break;
1033 for (std::size_t i = 0; i < points.size(); ++i) {
1034 WriteInteger(points[i].fX);
1035 WriteInteger(-points[i].fY);
1036 PrintStr(i % 3 == 0 ? " moveto" : " lineto");
1037 if (i % 3 == 2)
1038 PrintStr(" closepath fill");
1039 }
1040 break;
1041 }
1042 PrintStr(" grestore } def@");
1043 fMarkers[name.Data()] = true;
1044 }
1045
1046 SetStyle(1);
1047 SetWidth((markerLineWidth > 1) ? markerLineWidth : 1);
1049
1050 for (Int_t k = 0; k < n; ++k) {
1051 WriteInteger(XtoPS(x[k]));
1052 WriteInteger(YtoPS(y[k]));
1053 PrintStr(" ");
1054 PrintStr(name.Data());
1055 }
1056 PrintStr("@");
1057
1060}
1061
1062
1063////////////////////////////////////////////////////////////////////////////////
1064/// Draw markers at the n WC points x, y
1065
1070
1071////////////////////////////////////////////////////////////////////////////////
1072/// Draw markers at the n WC points x, y
1073
1078
1079////////////////////////////////////////////////////////////////////////////////
1080/// Draw a PolyLine
1081///
1082/// Draw a polyline through the points xw,yw.
1083/// - If nn=1 moves only to point xw,yw.
1084/// - If nn=0 the XW(1) and YW(1) are written in the PostScript file
1085/// according to the current NT.
1086/// - If nn>0 the line is clipped as a line.
1087/// - If nn<0 the line is clipped as a fill area.
1088
1090{
1091 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1092 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1093 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1094 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1095 180, 90,135, 45,150, 30,120, 60,
1096 180, 90,135, 45,150, 30,120, 60};
1097 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1098 fais = fasi = n = 0;
1099 Int_t jxd0 = XtoPS(xw[0]);
1100 Int_t jyd0 = YtoPS(yw[0]);
1103
1104 if (nn > 0) {
1105 if (fLineWidth<=0) return;
1106 n = nn;
1110 }
1111 if (nn < 0) {
1112 n = -nn;
1113 SetStyle(1);
1114 SetWidth(1);
1116 fais = fFillStyle/1000;
1117 fasi = fFillStyle%1000;
1118 if (fais == 3 || fais == 2) {
1119 if (fasi > 100 && fasi <125) {
1120 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1121 goto END;
1122 }
1123 if (fasi > 0 && fasi < 26) {
1125 }
1126 }
1127 }
1128
1129 ixd0 = jxd0;
1130 iyd0 = jyd0;
1133 if( n <= 1) {
1134 if( n == 0) goto END;
1135 PrintFast(2," m");
1136 goto END;
1137 }
1138
1139 PrintFast(2," m");
1140 idx = idy = 0;
1141 for (i=1;i<n;i++) {
1142 ixdi = XtoPS(xw[i]);
1143 iydi = YtoPS(yw[i]);
1144 ix = ixdi - ixd0;
1145 iy = iydi - iyd0;
1146 ixd0 = ixdi;
1147 iyd0 = iydi;
1148 if( ix && iy) {
1149 if( idx ) { MovePS(idx,0); idx = 0; }
1150 if( idy ) { MovePS(0,idy); idy = 0; }
1151 MovePS(ix,iy);
1152 } else if ( ix ) {
1153 if( idy ) { MovePS(0,idy); idy = 0;}
1154 if( !idx ) { idx = ix;}
1155 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1156 else { MovePS(idx,0); idx = ix;}
1157 } else if( iy ) {
1158 if( idx ) { MovePS(idx,0); idx = 0;}
1159 if( !idy) { idy = iy;}
1160 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1161 else { MovePS(0,idy); idy = iy;}
1162 }
1163 }
1164 if (idx) MovePS(idx,0);
1165 if (idy) MovePS(0,idy);
1166
1167 if (nn > 0 ) {
1168 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3," cl");
1169 PrintFast(2," s");
1170 } else {
1171 if (fais == 0) {PrintFast(5," cl s"); goto END;}
1172 if (fais == 3 || fais == 2) {
1173 if (fasi > 0 && fasi < 26) {
1174 PrintFast(3," FA");
1175 fRed = -1;
1176 fGreen = -1;
1177 fBlue = -1;
1178 }
1179 goto END;
1180 }
1181 PrintFast(2," f");
1182 }
1183END:
1184 if (nn < 0) {
1187 }
1188}
1189
1190////////////////////////////////////////////////////////////////////////////////
1191/// Draw a PolyLine
1192///
1193/// Draw a polyline through the points xw,yw.
1194/// - If nn=1 moves only to point xw,yw.
1195/// - If nn=0 the xw(1) and YW(1) are written in the PostScript file
1196/// --- according to the current NT.
1197/// - If nn>0 the line is clipped as a line.
1198/// - If nn<0 the line is clipped as a fill area.
1199
1201{
1202 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1203 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1204 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1205 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1206 180, 90,135, 45,150, 30,120, 60,
1207 180, 90,135, 45,150, 30,120, 60};
1208 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1209 fais = fasi = n = 0;
1210 Int_t jxd0 = XtoPS(xw[0]);
1211 Int_t jyd0 = YtoPS(yw[0]);
1214
1215 if (nn > 0) {
1216 if (fLineWidth<=0) return;
1217 n = nn;
1221 }
1222 if (nn < 0) {
1223 n = -nn;
1224 SetStyle(1);
1225 SetWidth(1);
1227 fais = fFillStyle/1000;
1228 fasi = fFillStyle%1000;
1229 if (fais == 3 || fais == 2) {
1230 if (fasi > 100 && fasi <125) {
1231 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1232 goto END;
1233 }
1234 if (fasi > 0 && fasi < 26) {
1236 }
1237 }
1238 }
1239
1240 ixd0 = jxd0;
1241 iyd0 = jyd0;
1244 if( n <= 1) {
1245 if( n == 0) goto END;
1246 PrintFast(2," m");
1247 goto END;
1248 }
1249
1250 PrintFast(2," m");
1251 idx = idy = 0;
1252 for (i=1;i<n;i++) {
1253 ixdi = XtoPS(xw[i]);
1254 iydi = YtoPS(yw[i]);
1255 ix = ixdi - ixd0;
1256 iy = iydi - iyd0;
1257 ixd0 = ixdi;
1258 iyd0 = iydi;
1259 if( ix && iy) {
1260 if( idx ) { MovePS(idx,0); idx = 0; }
1261 if( idy ) { MovePS(0,idy); idy = 0; }
1262 MovePS(ix,iy);
1263 } else if ( ix ) {
1264 if( idy ) { MovePS(0,idy); idy = 0;}
1265 if( !idx ) { idx = ix;}
1266 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1267 else { MovePS(idx,0); idx = ix;}
1268 } else if( iy ) {
1269 if( idx ) { MovePS(idx,0); idx = 0;}
1270 if( !idy) { idy = iy;}
1271 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1272 else { MovePS(0,idy); idy = iy;}
1273 }
1274 }
1275 if (idx) MovePS(idx,0);
1276 if (idy) MovePS(0,idy);
1277
1278 if (nn > 0 ) {
1279 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3," cl");
1280 PrintFast(2," s");
1281 } else {
1282 if (fais == 0) {PrintFast(5," cl s"); goto END;}
1283 if (fais == 3 || fais == 2) {
1284 if (fasi > 0 && fasi < 26) {
1285 PrintFast(3," FA");
1286 fRed = -1;
1287 fGreen = -1;
1288 fBlue = -1;
1289 }
1290 goto END;
1291 }
1292 PrintFast(2," f");
1293 }
1294END:
1295 if (nn < 0) {
1298 }
1299}
1300
1301////////////////////////////////////////////////////////////////////////////////
1302/// Draw Fill area with hatch styles
1303
1305{
1306 Warning("DrawHatch", "hatch fill style not yet implemented");
1307}
1308
1309////////////////////////////////////////////////////////////////////////////////
1310/// Draw Fill area with hatch styles
1311
1313{
1314 Warning("DrawHatch", "hatch fill style not yet implemented");
1315}
1316
1317////////////////////////////////////////////////////////////////////////////////
1318
1320{
1321 std::ifstream font_file(filename, std::ios::binary);
1322
1323 // We cannot read directly using iostream iterators due to
1324 // signedness
1325 font_file.seekg(0, std::ios::end);
1326
1327 const size_t font_file_length = font_file.tellg();
1328
1329 font_file.seekg(0, std::ios::beg);
1330
1331 std::vector<unsigned char> font_data(font_file_length, '\0');
1332
1333 font_file.read(reinterpret_cast<char *>(&font_data[0]),
1335
1336 std::string font_name;
1337 std::string postscript_string =
1338 mathtext::font_embed_postscript_t::font_embed_type_1(
1339 font_name, font_data);
1340
1341 if (!postscript_string.empty()) {
1343 PrintStr("@");
1344
1345 return true;
1346 }
1347
1348 return false;
1349}
1350
1351////////////////////////////////////////////////////////////////////////////////
1352
1354{
1355 std::ifstream font_file(filename, std::ios::binary);
1356
1357 // We cannot read directly using iostream iterators due to
1358 // signedness
1359 font_file.seekg(0, std::ios::end);
1360
1361 const size_t font_file_length = font_file.tellg();
1362
1363 font_file.seekg(0, std::ios::beg);
1364
1365 std::vector<unsigned char> font_data(font_file_length, '\0');
1366
1367 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1368
1369 std::string font_name;
1370 std::string postscript_string =
1371 mathtext::font_embed_postscript_t::font_embed_type_2(font_name, font_data);
1372
1373 if (!postscript_string.empty()) {
1375 PrintStr("@");
1376
1377 return true;
1378 }
1379
1380 return false;
1381}
1382
1383////////////////////////////////////////////////////////////////////////////////
1384
1386{
1387 std::ifstream font_file(filename, std::ios::binary);
1388
1389 // We cannot read directly using iostream iterators due to signedness
1390
1391 font_file.seekg(0, std::ios::end);
1392
1393 const size_t font_file_length = font_file.tellg();
1394
1395 font_file.seekg(0, std::ios::beg);
1396
1397 std::vector<unsigned char> font_data(font_file_length, '\0');
1398
1399 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1400
1401 std::string font_name;
1402 std::string postscript_string =
1403 mathtext::font_embed_postscript_t::font_embed_type_42(font_name, font_data);
1404
1405 if (!postscript_string.empty()) {
1407 PrintStr("@");
1408
1409 return true;
1410 }
1411 fprintf(stderr, "%s:%d:\n", __FILE__, __LINE__);
1412
1413 return false;
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Embed font in PS file.
1418
1420{
1421 static const char *fonttable[32][2] = {
1422 { "Root.TTFont.0", "FreeSansBold.otf" },
1423 { "Root.TTFont.1", "FreeSerifItalic.otf" },
1424 { "Root.TTFont.2", "FreeSerifBold.otf" },
1425 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
1426 { "Root.TTFont.4", "FreeSans.otf" },
1427 { "Root.TTFont.5", "FreeSansOblique.otf" },
1428 { "Root.TTFont.6", "FreeSansBold.otf" },
1429 { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
1430 { "Root.TTFont.8", "FreeMono.otf" },
1431 { "Root.TTFont.9", "FreeMonoOblique.otf" },
1432 { "Root.TTFont.10", "FreeMonoBold.otf" },
1433 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
1434 { "Root.TTFont.12", "symbol.ttf" },
1435 { "Root.TTFont.13", "FreeSerif.otf" },
1436 { "Root.TTFont.14", "wingding.ttf" },
1437 { "Root.TTFont.15", "symbol.ttf" },
1438 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
1439 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
1440 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
1441 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
1442 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
1443 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
1444 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
1445 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
1446 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
1447 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
1448 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
1449 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
1450 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
1451 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
1452 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
1453 { "Root.TTFont.CJKCothic", "DroidSansFallback.ttf" }
1454 };
1455
1456 PrintStr("%%IncludeResource: ProcSet (FontSetInit)@");
1457
1458 // try to load font (font must be in Root.TTFontPath resource)
1459 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
1461
1462 for (Int_t fontid = 1; fontid < 30; fontid++) {
1463 if (fontid != 15 && fMustEmbed[fontid-1]) {
1466 if (!ttfont) {
1467 Error("FontEmbed",
1468 "font %d (filename '%s') not found in path",
1469 fontid, filename.Data());
1470 } else if (FontEmbedType2(ttfont)) {
1471 // nothing
1472 } else if(FontEmbedType1(ttfont)) {
1473 // nothing
1474 } else if(FontEmbedType42(ttfont)) {
1475 // nothing
1476 } else {
1477 Error("FontEmbed",
1478 "failed to embed font %d (filename '%s')",
1479 fontid, filename.Data());
1480 }
1481 }
1482 }
1483 PrintStr("%%IncludeResource: font Times-Roman@");
1484 PrintStr("%%IncludeResource: font Times-Italic@");
1485 PrintStr("%%IncludeResource: font Times-Bold@");
1486 PrintStr("%%IncludeResource: font Times-BoldItalic@");
1487 PrintStr("%%IncludeResource: font Helvetica@");
1488 PrintStr("%%IncludeResource: font Helvetica-Oblique@");
1489 PrintStr("%%IncludeResource: font Helvetica-Bold@");
1490 PrintStr("%%IncludeResource: font Helvetica-BoldOblique@");
1491 PrintStr("%%IncludeResource: font Courier@");
1492 PrintStr("%%IncludeResource: font Courier-Oblique@");
1493 PrintStr("%%IncludeResource: font Courier-Bold@");
1494 PrintStr("%%IncludeResource: font Courier-BoldOblique@");
1495 PrintStr("%%IncludeResource: font Symbol@");
1496 PrintStr("%%IncludeResource: font ZapfDingbats@");
1497
1498 fFontEmbed = kTRUE;
1499}
1500
1501////////////////////////////////////////////////////////////////////////////////
1502/// Font Re-encoding
1503
1505{
1506 PrintStr("/reEncode ");
1507 PrintStr("{exch findfont");
1508 PrintStr(" dup length dict begin");
1509 PrintStr(" {1 index /FID eq ");
1510 PrintStr(" {pop pop}");
1511 PrintStr(" {def} ifelse");
1512 PrintStr(" } forall");
1513 PrintStr(" /Encoding exch def");
1514 PrintStr(" currentdict end");
1515 PrintStr(" dup /FontName get exch");
1516 PrintStr(" definefont pop");
1517 PrintStr(" } def");
1518 PrintStr(" [/Times-Bold /Times-Italic /Times-BoldItalic /Helvetica");
1519 PrintStr(" /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique");
1520 PrintStr(" /Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique");
1521 PrintStr(" /Times-Roman /AvantGarde-Book /AvantGarde-BookOblique");
1522 PrintStr(" /AvantGarde-Demi /AvantGarde-DemiOblique /Bookman-Demi");
1523 PrintStr(" /Bookman-DemiItalic /Bookman-Light /Bookman-LightItalic");
1524 PrintStr(" /Helvetica-Narrow /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique");
1525 PrintStr(" /Helvetica-Narrow-Oblique /NewCenturySchlbk-Roman /NewCenturySchlbk-Bold");
1526 PrintStr(" /NewCenturySchlbk-BoldItalic /NewCenturySchlbk-Italic");
1527 PrintStr(" /Palatino-Bold /Palatino-BoldItalic /Palatino-Italic /Palatino-Roman");
1528 PrintStr(" ] {ISOLatin1Encoding reEncode } forall");
1529}
1530
1531////////////////////////////////////////////////////////////////////////////////
1532/// PostScript Initialisation
1533///
1534/// This method initialize the following PostScript procedures:
1535///
1536/// | Macro Name | Input parameters | Explanation |
1537/// |------------|------------------|-----------------------------------|
1538/// | l | x y | Draw a line to the x y position |
1539/// | m | x y | Move to the position x y |
1540/// | box | dx dy x y | Define a box |
1541/// | bl | dx dy x y | Draw a line box |
1542/// | bf | dx dy x y | Draw a filled box |
1543/// | t | x y | Translate |
1544/// | r | angle | Rotate |
1545/// | rl | i j | Roll the stack |
1546/// | d | x y | Draw a relative line to x y |
1547/// | X | x | Draw a relative line to x (y=0) |
1548/// | Y | y | Draw a relative line to y (x=0) |
1549/// | rm | x y | Move relatively to x y |
1550/// | gr | | Restore the graphic context |
1551/// | lw | lwidth | Set line width to lwidth |
1552/// | sd | [] 0 | Set dash line define by [] |
1553/// | s | | Stroke mode |
1554/// | c | r g b | Set rgb color to r g b |
1555/// | cl | | Close path |
1556/// | f | | Fill the last describe path |
1557/// | mXX | x y | Draw the marker type XX at (x,y) |
1558/// | Zone | ix iy | Define the current zone |
1559/// | black | | The color is black |
1560/// | C | dx dy x y | Clipping on |
1561/// | NC | | Clipping off |
1562/// | R | | repeat |
1563/// | ita | | Used to make the symbols italic |
1564/// | K | | kshow |
1565
1567{
1569 rpxmin = rpymin = width = heigth = 0;
1570 Int_t format;
1571 fNpages=1;
1572 for (Int_t i=0;i<32;i++) fPatterns[i]=0;
1573
1574 // Mode is last digit of PostScript Workstation type
1575 // mode=1,2 for portrait/landscape black and white
1576 // mode=3 for Encapsulated PostScript File
1577 // mode=4 for portrait colour
1578 // mode=5 for lanscape colour
1579 Int_t atype = abs(fType);
1580 fMode = atype%10;
1581 if( fMode <= 0 || fMode > 5) {
1582 Error("Initialize", "invalid file type %d", fMode);
1583 return;
1584 }
1585
1586 // fNXzone (fNYzone) is the total number of windows in x (y)
1587 fNXzone = (atype%1000)/100;
1588 fNYzone = (atype%100)/10;
1589 if( fNXzone <= 0 ) fNXzone = 1;
1590 if( fNYzone <= 0 ) fNYzone = 1;
1591 fIXzone = 1;
1592 fIYzone = 1;
1593
1594 // format = 0-99 is the European page format (A4,A3 ...)
1595 // format = 100 is the US format 8.5x11.0 inch
1596 // format = 200 is the US format 8.5x14.0 inch
1597 // format = 300 is the US format 11.0x17.0 inch
1598 format = atype/1000;
1599 if( format == 0 ) format = 4;
1600 if( format == 99 ) format = 0;
1601
1602 PrintStr("%%Title: ");
1603 const char *pstitle = gStyle->GetTitlePS();
1604 if (gPad && !pstitle[0]) pstitle = gPad->GetMother()->GetTitle();
1605 if (strlen(GetName())<=80) PrintStr(GetName());
1606 if(!pstitle[0] && fMode != 3) {;
1607 PrintFast(2," (");
1608 if ( format <= 99 ) {;
1609 PrintFast(2," A");
1611 PrintFast(1,")");
1612 }
1613 else {
1614 if ( format == 100 ) PrintFast(8," Letter)");
1615 if ( format == 200 ) PrintFast(7," Legal)");
1616 if ( format == 300 ) PrintFast(8," Ledger)");
1617 }
1618 PrintStr("@");
1619 PrintStr("%%Pages: (atend)@");
1620 }
1621 else {
1622 if (!strchr(pstitle,'\n')) {
1623 PrintFast(2,": ");
1625 }
1626 PrintStr("@");
1627 }
1628
1629 PrintFast(24,"%%Creator: ROOT Version ");
1630 PrintStr(gROOT->GetVersion());
1631 PrintStr("@");
1632 PrintFast(16,"%%CreationDate: ");
1633 TDatime t;
1634 PrintStr(t.AsString());
1635 PrintStr("@");
1636
1637 if (fMode == 1 || fMode == 4)
1638 PrintStr("%%Orientation: Portrait@");
1639 if (fMode == 2 || fMode == 5)
1640 PrintStr("%%Orientation: Landscape@");
1641
1642 PrintStr("%%EndComments@");
1643 PrintStr("%%BeginProlog@");
1644
1645 if(fMode == 3)
1646 PrintStr("80 dict begin@");
1647
1648 // Initialisation of PostScript procedures
1649 PrintStr("/s {stroke} def /l {lineto} def /m {moveto} def /t {translate} def@");
1650 PrintStr("/r {rotate} def /rl {roll} def /R {repeat} def@");
1651 PrintStr("/d {rlineto} def /rm {rmoveto} def /gr {grestore} def /f {eofill} def@");
1652 if (gStyle->GetColorModelPS()) {
1653 PrintStr("/c {setcmykcolor} def /black {0 0 0 1 setcmykcolor} def /sd {setdash} def@");
1654 } else {
1655 PrintStr("/c {setrgbcolor} def /black {0 setgray} def /sd {setdash} def@");
1656 }
1657 PrintStr("/cl {closepath} def /sf {scalefont setfont} def /lw {setlinewidth} def@");
1658 PrintStr("/box {m dup 0 exch d exch 0 d 0 exch neg d cl} def@");
1659 PrintStr("/NC{systemdict begin initclip end}def/C{NC box clip newpath}def@");
1660 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@");
1661 PrintStr("/K {{pop pop 0 moveto} exch kshow} bind def@");
1662 PrintStr("/ita {/ang 15 def gsave [1 0 ang dup sin exch cos div 1 0 0] concat} def@");
1663
1664 FontEncode();
1665
1666 // mode=1 for portrait black/white
1667 if (fMode == 1) {
1668 rpxmin = 0.7;
1670 switch (format) {
1671 case 100 :
1672 width = (8.5*2.54)-2.*rpxmin;
1673 heigth = (11.*2.54)-2.*rpymin;
1674 break;
1675 case 200 :
1676 width = (8.5*2.54)-2.*rpxmin;
1677 heigth = (14.*2.54)-2.*rpymin;
1678 break;
1679 case 300 :
1680 width = (11.*2.54)-2.*rpxmin;
1681 heigth = (17.*2.54)-2.*rpymin;
1682 break;
1683 default :
1684 width = 21.0-2.*rpxmin;
1685 heigth = 29.7-2.*rpymin;
1686 };
1687 }
1688
1689 // mode=2 for landscape black/white
1690 if (fMode == 2) {
1691 rpymin = 0.7;
1693 switch (format) {
1694 case 100 :
1695 width = (11.*2.54)-2.*rpxmin;
1696 heigth = (8.5*2.54)-2.*rpymin;
1697 break;
1698 case 200 :
1699 width = (14.*2.54)-2.*rpxmin;
1700 heigth = (8.5*2.54)-2.*rpymin;
1701 break;
1702 case 300 :
1703 width = (17.*2.54)-2.*rpxmin;
1704 heigth = (11.*2.54)-2.*rpymin;
1705 break;
1706 default :
1707 width = 29.7-2.*rpxmin;
1708 heigth = 21-2.*rpymin;
1709 };
1710 }
1711
1712 // mode=3 encapsulated PostScript
1713 if (fMode == 3) {
1714 width = 20;
1715 heigth = 20;
1716 format = 4;
1717 fNXzone = 1;
1718 fNYzone = 1;
1719 }
1720
1721 // mode=4 for portrait colour
1722 if (fMode == 4) {
1723 rpxmin = 0.7;
1724 rpymin = 3.4;
1725 switch (format) {
1726 case 100 :
1727 width = (8.5*2.54)-2.*rpxmin;
1728 heigth = (11.*2.54)-2.*rpymin;
1729 break;
1730 case 200 :
1731 width = (8.5*2.54)-2.*rpxmin;
1732 heigth = (14.*2.54)-2.*rpymin;
1733 break;
1734 case 300 :
1735 width = (11.*2.54)-2.*rpxmin;
1736 heigth = (17.*2.54)-2.*rpymin;
1737 break;
1738 default :
1739 width = (21.0-2*rpxmin);
1740 heigth = (29.7-2.*rpymin);
1741 };
1742 }
1743
1744 // mode=5 for lanscape colour
1745 if (fMode == 5) {
1746 rpxmin = 3.4;
1747 rpymin = 0.7;
1748 switch (format) {
1749 case 100 :
1750 width = (11.*2.54)-2.*rpxmin;
1751 heigth = (8.5*2.54)-2.*rpymin;
1752 break;
1753 case 200 :
1754 width = (14.*2.54)-2.*rpxmin;
1755 heigth = (8.5*2.54)-2.*rpymin;
1756 break;
1757 case 300 :
1758 width = (17.*2.54)-2.*rpxmin;
1759 heigth = (11.*2.54)-2.*rpymin;
1760 break;
1761 default :
1762 width = (29.7-2*rpxmin);
1763 heigth = (21-2.*rpymin);
1764 };
1765 }
1766
1767 Double_t value = 0;
1768 if (format < 100) value = 21*TMath::Power(TMath::Sqrt(2.), 4-format);
1769 else if (format == 100) value = 8.5*2.54;
1770 else if (format == 200) value = 8.5*2.54;
1771 else if (format == 300) value = 11.*2.54;
1772 if (format >= 100) format = 4;
1773
1774 // Compute size (in points) of the window for each picture = f(fNXzone,fNYzone)
1777 Int_t npx = 4*CMtoPS(sizex);
1778 Int_t npy = 4*CMtoPS(sizey);
1779 if (sizex > sizey) fMaxsize = CMtoPS(sizex);
1780 else fMaxsize = CMtoPS(sizey);
1781
1782 // Procedure Zone
1783 if (fMode != 3) {
1784 PrintFast(33,"/Zone {/iy exch def /ix exch def ");
1785 PrintFast(10," ix 1 sub ");
1787 PrintFast(5," mul ");
1789 PrintFast(8," iy sub ");
1791 PrintStr(" mul t} def@");
1792 } else {
1793 PrintStr("@");
1794 }
1795
1796 PrintStr("%%EndProlog@");
1797 PrintStr("%%BeginSetup@");
1798 PrintStr("%%EndSetup@");
1799 PrintFast(8,"newpath ");
1800 SaveRestore(1);
1801 if (fMode == 1 || fMode == 4) {
1804 PrintFast(2," t");
1805 }
1806 if (fMode == 2 || fMode == 5) {
1807 PrintFast(7," 90 r 0");
1809 PrintFast(3," t ");
1812 PrintFast(2," t");
1813 }
1814
1815 PrintFast(15," .25 .25 scale ");
1816 if (fMode != 3) {
1817 SaveRestore(1);
1818 PrintStr("@");
1819 PrintStr("%%Page: 1 1@");
1820 SaveRestore(1);
1821 }
1822
1823 //Check is user has defined a special header in the current style
1825 if (nh) {
1827 if (fMode != 3) SaveRestore(1);
1828 }
1829}
1830
1831////////////////////////////////////////////////////////////////////////////////
1832/// Move to a new position
1833
1835{
1836 if (ix != 0 && iy != 0) {
1837 WriteInteger(ix);
1838 WriteInteger(iy);
1839 PrintFast(2," d");
1840 } else if (ix != 0) {
1841 WriteInteger(ix);
1842 PrintFast(2," X");
1843 } else if (iy != 0) {
1844 WriteInteger(iy);
1845 PrintFast(2," Y");
1846 }
1847}
1848
1849////////////////////////////////////////////////////////////////////////////////
1850/// Move to a new PostScript page
1851
1853{
1854 // Compute pad conversion coefficients
1855 if (gPad) {
1856 // if (!gPad->GetPadPaint()) gPad->Update();
1857 Double_t ww = gPad->GetWw();
1858 Double_t wh = gPad->GetWh();
1859 fYsize = fXsize*wh/ww;
1860 } else fYsize = 27;
1861
1862 if(fType == 113 && !fBoundingBox) {
1864 PrintStr("@%%BoundingBox: ");
1865 Double_t xlow=0, ylow=0, xup=1, yup=1;
1866 if (gPad) {
1867 xlow = gPad->GetAbsXlowNDC();
1868 xup = xlow + gPad->GetAbsWNDC();
1869 ylow = gPad->GetAbsYlowNDC();
1870 yup = ylow + gPad->GetAbsHNDC();
1871 }
1872 WriteInteger(CMtoPS(fXsize*xlow));
1873 WriteInteger(CMtoPS(fYsize*ylow));
1876 PrintStr("@");
1877 Initialize();
1879 fPrinted = psave;
1880 }
1881 if (fPrinted) {
1882 if (fSave) SaveRestore(-1);
1883 fClear = kTRUE;
1884 fPrinted = kFALSE;
1885 }
1886 Zone();
1887}
1888
1889////////////////////////////////////////////////////////////////////////////////
1890/// Set the range for the paper in centimeters
1891
1893{
1894 Float_t xps=0, yps=0, xncm=0, yncm=0, dxwn=0, dywn=0, xwkwn=0, ywkwn=0, xymax=0;
1895
1896 fXsize = xsize;
1897 fYsize = ysize;
1898 if( fType != 113) { xps = fXsize; yps = fYsize; }
1899 else { xps = xsize; yps = ysize; }
1900
1901 if( xsize <= xps && ysize < yps) {
1902 if ( xps > yps ) xymax = xps;
1903 else xymax = yps;
1904 xncm = xsize/xymax;
1905 yncm = ysize/xymax;
1906 dxwn = ((xps/xymax)-xncm)/2;
1907 dywn = ((yps/xymax)-yncm)/2;
1908 } else {
1909 if (xps/yps < 1) xwkwn = xps/yps;
1910 else xwkwn = 1;
1911 if (yps/xps < 1) ywkwn = yps/xps;
1912 else ywkwn = 1;
1913
1914 if (xsize < ysize) {
1916 yncm = ywkwn;
1917 dxwn = (xwkwn-xncm)/2;
1918 dywn = 0;
1919 if( dxwn < 0) {
1920 xncm = xwkwn;
1921 dxwn = 0;
1923 dywn = (ywkwn-yncm)/2;
1924 }
1925 } else {
1926 xncm = xwkwn;
1928 dxwn = 0;
1929 dywn = (ywkwn-yncm)/2;
1930 if( dywn < 0) {
1931 yncm = ywkwn;
1932 dywn = 0;
1934 dxwn = (xwkwn-xncm)/2;
1935 }
1936 }
1937 }
1938 fXVP1 = dxwn;
1939 fXVP2 = xncm+dxwn;
1940 fYVP1 = dywn;
1941 fYVP2 = yncm+dywn;
1942 fRange = kTRUE;
1943}
1944
1945////////////////////////////////////////////////////////////////////////////////
1946/// Compute number of gsaves for restore
1947/// This allows to write the correct number of grestore at the
1948/// end of the PS file.
1949
1951{
1952 if (flag == 1) { PrintFast(7," gsave "); fSave++; }
1953 else { PrintFast(4," gr "); fSave--; }
1954}
1955
1956////////////////////////////////////////////////////////////////////////////////
1957/// Set color index for fill areas
1958
1960{
1962 if (gStyle->GetFillColor() <= 0) cindex = 0;
1963}
1964
1965////////////////////////////////////////////////////////////////////////////////
1966/// Patterns definition
1967///
1968/// Define the pattern ipat in the current PS file. ipat can vary from
1969/// 1 to 25. Together with the pattern, the color (color) in which the
1970/// pattern has to be drawn is also required. A pattern is defined in the
1971/// current PS file only the first time it is used. Some level 2
1972/// Postscript functions are used, so on level 1 printers, patterns will
1973/// not work. This is not a big problem because patterns are
1974/// defined only if they are used, so if they are not used a PS level 1
1975/// file will not be polluted by level 2 features, and in any case the old
1976/// patterns used a lot of memory which made them almost unusable on old
1977/// level 1 printers. Finally we should say that level 1 devices are
1978/// becoming very rare. The official PostScript is now level 3 !
1979
1981{
1982 char cdef[28];
1983 char cpat[5];
1984 snprintf(cpat,5," P%2.2d", ipat);
1985
1986 // fPatterns is used as an array of chars. If fPatterns[ipat] != 0 the
1987 // pattern number ipat as already be defined is this file and it
1988 // is not necessary to redefine it. fPatterns is set to zero in Initialize.
1989 // The pattern number 26 allows to know if the macro "cs" has already
1990 // been defined in the current file (see label 200).
1991 if (fPatterns[ipat] == 0) {
1992
1993 // Define the Patterns. Line width must be 1
1994 // Setting fLineWidth to -1 will force the line width definition next time
1995 // TPostScript::SetLineWidth will be called.
1996 fLineWidth = -1;
1997 PrintFast(5," 1 lw");
1998 PrintStr(" << /PatternType 1 /PaintType 2 /TilingType 1");
1999 switch (ipat) {
2000 case 1 :
2001 PrintStr(" /BBox [ 0 0 98 4 ]");
2002 PrintStr(" /XStep 98 /YStep 4");
2003 PrintStr(" /PaintProc { begin gsave");
2004 PrintStr(" [1] 0 sd 2 4 m 99 4 l s 1 3 m 98 3 l s");
2005 PrintStr(" 2 2 m 99 2 l s 1 1 m 98 1 l s");
2006 PrintStr(" gr end } >> [ 4.0 0 0 4.0 0 0 ]");
2007 break;
2008 case 2 :
2009 PrintStr(" /BBox [ 0 0 96 4 ]");
2010 PrintStr(" /XStep 96 /YStep 4");
2011 PrintStr(" /PaintProc { begin gsave");
2012 PrintStr(" [1 3] 0 sd 2 4 m 98 4 l s 0 3 m 96 3 l s");
2013 PrintStr(" 2 2 m 98 2 l s 0 1 m 96 1 l s");
2014 PrintStr(" gr end } >> [ 3.0 0 0 3.0 0 0 ]");
2015 break;
2016 case 3 :
2017 PrintStr(" /BBox [ 0 0 96 16 ]");
2018 PrintStr(" /XStep 96 /YStep 16");
2019 PrintStr(" /PaintProc { begin gsave");
2020 PrintStr(" [1 3] 0 sd 2 13 m 98 13 l s 0 9 m 96 9 l s");
2021 PrintStr(" 2 5 m 98 5 l s 0 1 m 96 1 l s");
2022 PrintStr(" gr end } >> [ 2.0 0 0 2.0 0 0 ]");
2023 break;
2024 case 4 :
2025 PrintStr(" /BBox [ 0 0 100 100 ]");
2026 PrintStr(" /XStep 100 /YStep 100");
2027 PrintStr(" /PaintProc { begin gsave");
2028 PrintStr(" 0 0 m 100 100 l s");
2029 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2030 break;
2031 case 5 :
2032 PrintStr(" /BBox [ 0 0 100 100 ]");
2033 PrintStr(" /XStep 100 /YStep 100");
2034 PrintStr(" /PaintProc { begin gsave");
2035 PrintStr(" 0 100 m 100 0 l s");
2036 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2037 break;
2038 case 6 :
2039 PrintStr(" /BBox [ 0 0 100 100 ]");
2040 PrintStr(" /XStep 100 /YStep 100");
2041 PrintStr(" /PaintProc { begin gsave");
2042 PrintStr(" 50 0 m 50 100 l s");
2043 PrintStr(" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2044 break;
2045 case 7 :
2046 PrintStr(" /BBox [ 0 0 100 100 ]");
2047 PrintStr(" /XStep 100 /YStep 100");
2048 PrintStr(" /PaintProc { begin gsave");
2049 PrintStr(" 0 50 m 100 50 l s");
2050 PrintStr(" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2051 break;
2052 case 8 :
2053 PrintStr(" /BBox [ 0 0 101 101 ]");
2054 PrintStr(" /XStep 100 /YStep 100");
2055 PrintStr(" /PaintProc { begin gsave");
2056 PrintStr(" 0 0 m 0 30 l 30 0 l f 0 70 m 0 100 l 30 100 l f");
2057 PrintStr(" 70 100 m 100 100 l 100 70 l f 70 0 m 100 0 l");
2058 PrintStr(" 100 30 l f 50 20 m 20 50 l 50 80 l 80 50 l f");
2059 PrintStr(" 50 80 m 30 100 l s 20 50 m 0 30 l s 50 20 m");
2060 PrintStr(" 70 0 l s 80 50 m 100 70 l s");
2061 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2062 break;
2063 case 9 :
2064 PrintStr(" /BBox [ 0 0 100 100 ]");
2065 PrintStr(" /XStep 100 /YStep 100");
2066 PrintStr(" /PaintProc { begin gsave");
2067 PrintStr(" 0 50 m 50 50 50 180 360 arc");
2068 PrintStr(" 0 50 m 0 100 50 270 360 arc");
2069 PrintStr(" 50 100 m 100 100 50 180 270 arc s");
2070 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2071 break;
2072 case 10 :
2073 PrintStr(" /BBox [ 0 0 100 100 ]");
2074 PrintStr(" /XStep 100 /YStep 100");
2075 PrintStr(" /PaintProc { begin gsave");
2076 PrintStr(" 0 50 m 100 50 l 1 1 m 100 1 l");
2077 PrintStr(" 0 0 m 0 50 l 100 0 m 100 50 l");
2078 PrintStr(" 50 50 m 50 100 l s");
2079 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2080 break;
2081 case 11 :
2082 PrintStr(" /BBox [ 0 0 100 100 ]");
2083 PrintStr(" /XStep 100 /YStep 100");
2084 PrintStr(" /PaintProc { begin gsave");
2085 PrintStr(" 0 0 m 0 20 l 50 0 m 50 20 l");
2086 PrintStr(" 100 0 m 100 20 l 0 80 m 0 100 l");
2087 PrintStr(" 50 80 m 50 100 l 100 80 m 100 100 l");
2088 PrintStr(" 25 30 m 25 70 l 75 30 m 75 70 l");
2089 PrintStr(" 0 100 m 20 85 l 50 100 m 30 85 l");
2090 PrintStr(" 50 100 m 70 85 l 100 100 m 80 85 l");
2091 PrintStr(" 0 0 m 20 15 l 50 0 m 30 15 l");
2092 PrintStr(" 50 0 m 70 15 l 100 0 m 80 15 l");
2093 PrintStr(" 5 35 m 45 65 l 5 65 m 45 35 l");
2094 PrintStr(" 55 35 m 95 65 l 55 65 m 95 35 l s");
2095 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2096 break;
2097 case 12 :
2098 PrintStr(" /BBox [ 0 0 100 100 ]");
2099 PrintStr(" /XStep 100 /YStep 100");
2100 PrintStr(" /PaintProc { begin gsave");
2101 PrintStr(" 0 80 m 0 100 20 270 360 arc");
2102 PrintStr(" 30 100 m 50 100 20 180 360 arc");
2103 PrintStr(" 80 100 m 100 100 20 180 270 arc");
2104 PrintStr(" 20 0 m 0 0 20 0 90 arc");
2105 PrintStr(" 70 0 m 50 0 20 0 180 arc");
2106 PrintStr(" 100 20 m 100 0 20 90 180 arc");
2107 PrintStr(" 45 50 m 25 50 20 0 360 arc");
2108 PrintStr(" 95 50 m 75 50 20 0 360 arc s");
2109 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2110 break;
2111 case 13 :
2112 PrintStr(" /BBox [ 0 0 100 100 ]");
2113 PrintStr(" /XStep 100 /YStep 100");
2114 PrintStr(" /PaintProc { begin gsave");
2115 PrintStr(" 0 0 m 100 100 l 0 100 m 100 0 l s");
2116 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2117 break;
2118 case 14 :
2119 PrintStr(" /BBox [ 0 0 100 100 ]");
2120 PrintStr(" /XStep 80 /YStep 80");
2121 PrintStr(" /PaintProc { begin gsave");
2122 PrintStr(" 0 20 m 100 20 l 20 0 m 20 100 l");
2123 PrintStr(" 0 80 m 100 80 l 80 0 m 80 100 l");
2124 PrintStr(" 20 40 m 60 40 l 60 20 m 60 60 l");
2125 PrintStr(" 40 40 m 40 80 l 40 60 m 80 60 l s");
2126 PrintStr(" gr end } >> [ 0.60 0 0 0.60 0 0 ]");
2127 break;
2128 case 15 :
2129 PrintStr(" /BBox [ 0 0 60 60 ]");
2130 PrintStr(" /XStep 60 /YStep 60");
2131 PrintStr(" /PaintProc { begin gsave");
2132 PrintStr(" 0 55 m 0 60 5 270 360 arc");
2133 PrintStr(" 25 60 m 30 60 5 180 360 arc");
2134 PrintStr(" 55 60 m 60 60 5 180 270 arc");
2135 PrintStr(" 20 30 m 15 30 5 0 360 arc");
2136 PrintStr(" 50 30 m 45 30 5 0 360");
2137 PrintStr(" arc 5 0 m 0 0 5 0 90 arc");
2138 PrintStr(" 35 0 m 30 0 5 0 180 arc");
2139 PrintStr(" 60 5 m 60 0 5 90 180 arc s");
2140 PrintStr(" gr end } >> [ 0.41 0 0 0.41 0 0 ]");
2141 break;
2142 case 16 :
2143 PrintStr(" /BBox [ 0 0 100 100 ]");
2144 PrintStr(" /XStep 100 /YStep 100");
2145 PrintStr(" /PaintProc { begin gsave");
2146 PrintStr(" 50 50 m 25 50 25 0 180 arc s");
2147 PrintStr(" 50 50 m 75 50 25 180 360 arc s");
2148 PrintStr(" gr end } >> [ 0.4 0 0 0.2 0 0 ]");
2149 break;
2150 case 17 :
2151 PrintStr(" /BBox [ 0 0 100 100 ]");
2152 PrintStr(" /XStep 100 /YStep 100");
2153 PrintStr(" /PaintProc { begin gsave");
2154 PrintStr(" [24] 0 setdash 0 0 m 100 100 l s");
2155 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2156 break;
2157 case 18 :
2158 PrintStr(" /BBox [ 0 0 100 100 ]");
2159 PrintStr(" /XStep 100 /YStep 100");
2160 PrintStr(" /PaintProc { begin gsave");
2161 PrintStr(" [24] 0 setdash 0 100 m 100 0 l s");
2162 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2163 break;
2164 case 19 :
2165 PrintStr(" /BBox [ 0 0 100 100 ]");
2166 PrintStr(" /XStep 100 /YStep 100");
2167 PrintStr(" /PaintProc { begin gsave");
2168 PrintStr(" 90 50 m 50 50 40 0 360 arc");
2169 PrintStr(" 0 50 m 0 100 50 270 360 arc");
2170 PrintStr(" 50 0 m 0 0 50 0 90 arc");
2171 PrintStr(" 100 50 m 100 0 50 90 180 arc");
2172 PrintStr(" 50 100 m 100 100 50 180 270 arc s");
2173 PrintStr(" gr end } >> [ 0.47 0 0 0.47 0 0 ]");
2174 break;
2175 case 20 :
2176 PrintStr(" /BBox [ 0 0 100 100 ]");
2177 PrintStr(" /XStep 100 /YStep 100");
2178 PrintStr(" /PaintProc { begin gsave");
2179 PrintStr(" 50 50 m 50 75 25 270 450 arc s");
2180 PrintStr(" 50 50 m 50 25 25 90 270 arc s");
2181 PrintStr(" gr end } >> [ 0.2 0 0 0.4 0 0 ]");
2182 break;
2183 case 21 :
2184 PrintStr(" /BBox [ 0 0 101 101 ]");
2185 PrintStr(" /XStep 100 /YStep 100");
2186 PrintStr(" /PaintProc { begin gsave");
2187 PrintStr(" 1 1 m 25 1 l 25 25 l 50 25 l 50 50 l");
2188 PrintStr(" 75 50 l 75 75 l 100 75 l 100 100 l");
2189 PrintStr(" 50 1 m 75 1 l 75 25 l 100 25 l 100 50 l");
2190 PrintStr(" 0 50 m 25 50 l 25 75 l 50 75 l 50 100 l s");
2191 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2192 break;
2193 case 22 :
2194 PrintStr(" /BBox [ 0 0 101 101 ]");
2195 PrintStr(" /XStep 100 /YStep 100");
2196 PrintStr(" /PaintProc { begin gsave");
2197 PrintStr(" 1 100 m 25 100 l 25 75 l 50 75 l 50 50 l");
2198 PrintStr(" 75 50 l 75 25 l 100 25 l 100 1 l");
2199 PrintStr(" 50 100 m 75 100 l 75 75 l 100 75 l 100 50 l");
2200 PrintStr(" 0 50 m 25 50 l 25 25 l 50 25 l 50 1 l s");
2201 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2202 break;
2203 case 23 :
2204 PrintStr(" /BBox [ 0 0 100 100 ]");
2205 PrintStr(" /XStep 100 /YStep 100");
2206 PrintStr(" /PaintProc { begin gsave");
2207 PrintStr(" [1 7] 0 sd 0 8 50 { dup dup m 2 mul 0 l s } for");
2208 PrintStr(" 0 8 50 { dup dup 2 mul 100 m 50 add exch 50");
2209 PrintStr(" add l s } for 100 0 m 100 100 l 50 50 l f");
2210 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2211 break;
2212 case 24 :
2213 PrintStr(" /BBox [ 0 0 100 100 ]");
2214 PrintStr(" /XStep 100 /YStep 100");
2215 PrintStr(" /PaintProc { begin gsave");
2216 PrintStr(" 100 100 m 100 36 l 88 36 l 88 88 l f");
2217 PrintStr(" 100 0 m 100 12 l 56 12 l 50 0 l f");
2218 PrintStr(" 0 0 m 48 0 l 48 48 l 50 48 l 56 60 l");
2219 PrintStr(" 36 60 l 36 12 l 0 12 l f [1 7] 0 sd");
2220 PrintStr(" 61 8 87 { dup dup dup 12 exch m 88 exch l s");
2221 PrintStr(" 16 exch 4 sub m 88 exch 4 sub l s } for");
2222 PrintStr(" 13 8 35 { dup dup dup 0 exch m 36 exch l s");
2223 PrintStr(" 4 exch 4 sub m 36 exch 4 sub l s } for");
2224 PrintStr(" 37 8 59 { dup dup dup 12 exch m 36 exch l s");
2225 PrintStr(" 16 exch 4 sub m 36 exch 4 sub l s } for");
2226 PrintStr(" 13 8 60 { dup dup dup 56 exch m 100 exch l s");
2227 PrintStr(" 60 exch 4 sub m 100 exch 4 sub l s } for");
2228 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2229 break;
2230 case 25 :
2231 PrintStr(" /BBox [ 0 0 101 101 ]");
2232 PrintStr(" /XStep 100 /YStep 100");
2233 PrintStr(" /PaintProc { begin gsave");
2234 PrintStr(" 0 0 m 30 30 l 70 30 l 70 70 l 100 100 l 100 0 l");
2235 PrintStr(" f 30 30 m 30 70 l 70 70 l f");
2236 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2237 };
2238 snprintf(cdef,28," makepattern /%s exch def",&cpat[1]);
2239 PrintStr(cdef);
2240 fPatterns[ipat] = 1;
2241 }
2242
2243 // Define the macro cs and FA if they are not yet defined.
2244 if (fPatterns[26] == 0) {
2245 if (gStyle->GetColorModelPS()) {
2246 PrintStr(" /cs {[/Pattern /DeviceCMYK] setcolorspace} def");
2247 PrintStr(" /FA {f [/DeviceCMYK] setcolorspace} def");
2248 } else {
2249 PrintStr(" /cs {[/Pattern /DeviceRGB] setcolorspace} def");
2250 PrintStr(" /FA {f [/DeviceRGB] setcolorspace} def");
2251 }
2252 fPatterns[26] = 1;
2253 }
2254
2255 // Activate the pattern.
2256 PrintFast(3," cs");
2257 TColor *col = gROOT->GetColor(color);
2258 if (col) {
2259 Double_t colRed = col->GetRed();
2260 Double_t colGreen = col->GetGreen();
2261 Double_t colBlue = col->GetBlue();
2262 if (gStyle->GetColorModelPS()) {
2264 if (colBlack==1) {
2265 WriteReal(0);
2266 WriteReal(0);
2267 WriteReal(0);
2269 } else {
2277 }
2278 } else {
2282 }
2283 }
2284 PrintFast(4,cpat);
2285 PrintFast(9," setcolor");
2286}
2287
2288////////////////////////////////////////////////////////////////////////////////
2289/// Set color index for lines
2290
2295
2296////////////////////////////////////////////////////////////////////////////////
2297/// Set the value of the global parameter TPostScript::fgLineJoin.
2298/// This parameter determines the appearance of joining lines in a PostScript
2299/// output.
2300/// It takes one argument which may be:
2301/// - 0 (miter join)
2302/// - 1 (round join)
2303/// - 2 (bevel join)
2304/// The default value is 0 (miter join).
2305///
2306/// \image html postscript_1.png
2307///
2308/// To change the line join behaviour just do:
2309/// ~~~ {.cpp}
2310/// gStyle->SetJoinLinePS(2); // Set the PS line join to bevel.
2311/// ~~~
2312
2314{
2316 if (fgLineJoin<0) fgLineJoin=0;
2317 if (fgLineJoin>2) fgLineJoin=2;
2318}
2319
2320////////////////////////////////////////////////////////////////////////////////
2321/// Set the value of the global parameter TPostScript::fgLineCap.
2322/// This parameter determines the appearance of line caps in a PostScript
2323/// output.
2324/// It takes one argument which may be:
2325/// - 0 (butt caps)
2326/// - 1 (round caps)
2327/// - 2 (projecting caps)
2328/// The default value is 0 (butt caps).
2329///
2330/// \image html postscript_2.png
2331///
2332/// To change the line cap behaviour just do:
2333/// ~~~ {.cpp}
2334/// gStyle->SetCapLinePS(2); // Set the PS line cap to projecting.
2335/// ~~~
2336
2338{
2340 if (fgLineCap<0) fgLineCap=0;
2341 if (fgLineCap>2) fgLineCap=2;
2342}
2343
2344////////////////////////////////////////////////////////////////////////////////
2345/// Change the line style
2346///
2347/// - linestyle = 2 dashed
2348/// - linestyle = 3 dotted
2349/// - linestyle = 4 dash-dotted
2350/// - linestyle = else = solid
2351///
2352/// See TStyle::SetLineStyleString for style definition
2353
2359
2360////////////////////////////////////////////////////////////////////////////////
2361/// Change the line style in the output file
2362
2364{
2365 if (linestyle == fStyle) return;
2366
2367 fStyle = linestyle;
2368
2369 const char *st = gStyle->GetLineStyleString(fStyle);
2370 PrintFast(1,"[");
2371 Int_t nch = strlen(st);
2372 PrintFast(nch,st);
2373 PrintFast(6,"] 0 sd");
2374}
2375
2376////////////////////////////////////////////////////////////////////////////////
2377/// Change the line width
2378
2384
2385////////////////////////////////////////////////////////////////////////////////
2386/// Change the line width in the output file
2387
2389{
2390 if (linewidth == fWidth) return;
2391
2392 fWidth = linewidth;
2393
2394 if (fWidth!=0) {
2396 PrintFast(3," lw");
2397 }
2398}
2399
2400////////////////////////////////////////////////////////////////////////////////
2401/// Set color index for markers
2402
2407
2408////////////////////////////////////////////////////////////////////////////////
2409/// Set the current color.
2410
2412{
2413 if (color < 0) color = 0;
2414 TColor *col = gROOT->GetColor(color);
2415 if (col)
2416 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
2417 else
2418 SetColor(1., 1., 1.);
2419}
2420
2421////////////////////////////////////////////////////////////////////////////////
2422/// Set directly current color (don't go via TColor).
2423
2425{
2426 if (r == fRed && g == fGreen && b == fBlue) return;
2427
2428 fRed = r;
2429 fGreen = g;
2430 fBlue = b;
2431
2432 if (fRed <= 0 && fGreen <= 0 && fBlue <= 0 ) {
2433 PrintFast(6," black");
2434 } else {
2435 if (gStyle->GetColorModelPS()) {
2444 } else {
2445 WriteReal(fRed);
2448 }
2449 PrintFast(2," c");
2450 }
2451}
2452
2453////////////////////////////////////////////////////////////////////////////////
2454/// Set color index for text
2455
2460
2461////////////////////////////////////////////////////////////////////////////////
2462/// Write a string of characters
2463///
2464/// This method writes the string chars into a PostScript file
2465/// at position xx,yy in world coordinates.
2466
2468{
2469 static const char *psfont[31][2] = {
2470 { "Root.PSFont.1", "/Times-Italic" },
2471 { "Root.PSFont.2", "/Times-Bold" },
2472 { "Root.PSFont.3", "/Times-BoldItalic" },
2473 { "Root.PSFont.4", "/Helvetica" },
2474 { "Root.PSFont.5", "/Helvetica-Oblique" },
2475 { "Root.PSFont.6", "/Helvetica-Bold" },
2476 { "Root.PSFont.7", "/Helvetica-BoldOblique" },
2477 { "Root.PSFont.8", "/Courier" },
2478 { "Root.PSFont.9", "/Courier-Oblique" },
2479 { "Root.PSFont.10", "/Courier-Bold" },
2480 { "Root.PSFont.11", "/Courier-BoldOblique" },
2481 { "Root.PSFont.12", "/Symbol" },
2482 { "Root.PSFont.13", "/Times-Roman" },
2483 { "Root.PSFont.14", "/ZapfDingbats" },
2484 { "Root.PSFont.15", "/Symbol" },
2485 { "Root.PSFont.STIXGen", "/STIXGeneral" },
2486 { "Root.PSFont.STIXGenIt", "/STIXGeneral-Italic" },
2487 { "Root.PSFont.STIXGenBd", "/STIXGeneral-Bold" },
2488 { "Root.PSFont.STIXGenBdIt", "/STIXGeneral-BoldItalic" },
2489 { "Root.PSFont.STIXSiz1Sym", "/STIXSize1Symbols" },
2490 { "Root.PSFont.STIXSiz1SymBd", "/STIXSize1Symbols-Bold" },
2491 { "Root.PSFont.STIXSiz2Sym", "/STIXSize2Symbols" },
2492 { "Root.PSFont.STIXSiz2SymBd", "/STIXSize2Symbols-Bold" },
2493 { "Root.PSFont.STIXSiz3Sym", "/STIXSize3Symbols" },
2494 { "Root.PSFont.STIXSiz3SymBd", "/STIXSize3Symbols-Bold" },
2495 { "Root.PSFont.STIXSiz4Sym", "/STIXSize4Symbols" },
2496 { "Root.PSFont.STIXSiz4SymBd", "/STIXSize4Symbols-Bold" },
2497 { "Root.PSFont.STIXSiz5Sym", "/STIXSize5Symbols" },
2498 { "Root.PSFont.ME", "/DroidSansFallback" },
2499 { "Root.PSFont.CJKMing", "/DroidSansFallback" },
2500 { "Root.PSFont.CJKGothic", "/DroidSansFallback" }
2501 };
2502
2503 const Double_t kDEGRAD = TMath::Pi()/180.;
2504 Double_t x = xx;
2505 Double_t y = yy;
2506 if (!gPad) return;
2507
2508 // Compute the font size. Exit if it is 0
2509 // The font size is computed from the TTF size to get exactly the same
2510 // size on the screen and in the PostScript file.
2511 Double_t wh = (Double_t) gPad->GetPadWidth();
2512 Double_t hh = (Double_t) gPad->GetPadHeight();
2513 if (wh <= 0 || hh <= 0)
2514 return;
2516
2517 if (wh < hh) {
2518 tsize = fTextSize*wh;
2519 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2520 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2521 } else {
2522 tsize = fTextSize*hh;
2523 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2524 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2525 }
2526 Double_t fontsize = 4*(72*(ftsize)/2.54);
2527 if( fontsize <= 0) return;
2528
2529 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2530 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2531
2532 Int_t font = abs(fTextFont)/10;
2533 if( font > 31 || font < 1) font = 1;
2534
2535 // Text color.
2537
2538 // Text alignment.
2539 Int_t txalh = fTextAlign/10;
2540 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
2541 Int_t txalv = fTextAlign%10;
2542 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
2543 if (txalv == 3) {
2546 } else if (txalv == 2) {
2549 }
2550
2551 UInt_t w = 0, w0 = 0;
2553 // In order to measure the precise character positions we need to trick
2554 // FreeType into rendering high-resolution characters otherwise it will
2555 // stick to the screen pixel grid, which is far worse than we can achieve
2556 // on print.
2557 const Float_t scale = 16.0;
2558 // Save current text attributes.
2560 saveAttText.TAttText::operator=(*this);
2561 const Int_t len=strlen(chars);
2562 Int_t *charWidthsCumul = nullptr;
2563 TText t;
2568 t.TAttText::Modify();
2569 if (w0-w != 0) kerning = kTRUE;
2570 else kerning = kFALSE;
2571 if (kerning) {
2572 // Calculate the individual character placements.
2573 charWidthsCumul = new Int_t[len];
2574 for (Int_t i = len - 1;i >= 0;i--) {
2575 UInt_t ww = 0;
2576 t.GetTextAdvance(ww, chars + i);
2577 Double_t wwl = (gPad->AbsPixeltoX(ww)-gPad->AbsPixeltoX(0));
2578 charWidthsCumul[i] = (Int_t)((XtoPS(wwl) - XtoPS(0)) / scale);
2579 }
2580 }
2581 // Restore text attributes.
2582 saveAttText.TAttText::Modify();
2583
2584 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2586
2587 // Text angle.
2588 Int_t psangle = Int_t(0.5 + fTextAngle);
2589
2590 // Save context.
2591 PrintStr("@");
2592 SaveRestore(1);
2593
2594 // Clipping
2595 Int_t xc1 = XtoPS(gPad->GetX1());
2596 Int_t xc2 = XtoPS(gPad->GetX2());
2597 Int_t yc1 = YtoPS(gPad->GetY1());
2598 Int_t yc2 = YtoPS(gPad->GetY2());
2599 WriteInteger(xc2 - xc1);
2600 WriteInteger(yc2 - yc1);
2603 PrintStr(" C");
2604
2605 // Output text position and angle. The text position is computed
2606 // using Double_t to avoid precision problems.
2607 Double_t vx = (x - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
2608 Double_t cmx = fXsize*(gPad->GetAbsXlowNDC()+vx*gPad->GetAbsWNDC());
2609 WriteReal((288.*cmx)/2.54);
2610 Double_t vy = (y - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
2611 Double_t cmy = fYsize*(gPad->GetAbsYlowNDC()+vy*gPad->GetAbsHNDC());
2612 WriteReal((288.*cmy)/2.54);
2613 PrintStr(TString::Format(" t %d r ", psangle));
2614 if(txalh == 2) PrintStr(TString::Format(" %d 0 t ", -psCharsLength/2));
2615 if(txalh == 3) PrintStr(TString::Format(" %d 0 t ", -psCharsLength));
2616 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2617 if (font != 15) {
2618 PrintStr(TString::Format(" findfont %g sf 0 0 m ",fontsize));
2619 } else {
2620 PrintStr(TString::Format(" findfont %g sf 0 0 m ita ",fontsize));
2621 }
2622
2623 if (kerning) {
2624 PrintStr("@");
2625 // Output individual character placements
2626 for (Int_t i = len-1; i >= 1; i--) {
2628 }
2629 delete [] charWidthsCumul;
2630 PrintStr("@");
2631 }
2632
2633 // Output text.
2634 PrintStr("(");
2635
2636 // Inside a PostScript string, the new line (if needed to break up long lines) must be escaped by a backslash.
2637 const char *crsave = fImplicitCREsc;
2638 fImplicitCREsc = "\\";
2639
2640 char str[8];
2641 for (Int_t i=0; i<len;i++) {
2642 if (chars[i]!='\n') {
2643 if (chars[i]=='(' || chars[i]==')' || chars[i]=='\\') {
2644 snprintf(str,8,"\\%c",chars[i]);
2645 PrintStr(str);
2646 } else if ((chars[i]=='-') && (font != 12)) {
2647 PrintStr("\\255");
2648 } else {
2649 snprintf(str,8,"%c",chars[i]);
2650 PrintFast(1,str);
2651 }
2652 }
2653 }
2654 PrintStr(")");
2656
2657 if (kerning) {
2658 if (font != 15) PrintStr(" K NC");
2659 else PrintStr(" K gr NC");
2660 } else {
2661 if (font != 15) PrintStr(" show NC");
2662 else PrintStr(" show gr NC");
2663 }
2664
2665 SaveRestore(-1);
2666}
2667
2668////////////////////////////////////////////////////////////////////////////////
2669/// Write a string of characters
2670///
2671/// This method writes the string chars into a PostScript file
2672/// at position xx,yy in world coordinates.
2673
2675{
2676 static const char *psfont[31][2] = {
2677 { "Root.PSFont.1", "/FreeSerifItalic" },
2678 { "Root.PSFont.2", "/FreeSerifBold" },
2679 { "Root.PSFont.3", "/FreeSerifBoldItalic" },
2680 { "Root.PSFont.4", "/FreeSans" },
2681 { "Root.PSFont.5", "/FreeSansOblique" },
2682 { "Root.PSFont.6", "/FreeSansBold" },
2683 { "Root.PSFont.7", "/FreeSansBoldOblique" },
2684 { "Root.PSFont.8", "/FreeMono" },
2685 { "Root.PSFont.9", "/FreeMonoOblique" },
2686 { "Root.PSFont.10", "/FreeMonoBold" },
2687 { "Root.PSFont.11", "/FreeMonoBoldOblique" },
2688 { "Root.PSFont.12", "/SymbolMT" },
2689 { "Root.PSFont.13", "/FreeSerif" },
2690 { "Root.PSFont.14", "/Wingdings-Regular" },
2691 { "Root.PSFont.15", "/SymbolMT" },
2692 { "Root.PSFont.STIXGen", "/STIXGeneral" },
2693 { "Root.PSFont.STIXGenIt", "/STIXGeneral-Italic" },
2694 { "Root.PSFont.STIXGenBd", "/STIXGeneral-Bold" },
2695 { "Root.PSFont.STIXGenBdIt", "/STIXGeneral-BoldItalic" },
2696 { "Root.PSFont.STIXSiz1Sym", "/STIXSize1Symbols" },
2697 { "Root.PSFont.STIXSiz1SymBd", "/STIXSize1Symbols-Bold" },
2698 { "Root.PSFont.STIXSiz2Sym", "/STIXSize2Symbols" },
2699 { "Root.PSFont.STIXSiz2SymBd", "/STIXSize2Symbols-Bold" },
2700 { "Root.PSFont.STIXSiz3Sym", "/STIXSize3Symbols" },
2701 { "Root.PSFont.STIXSiz3SymBd", "/STIXSize3Symbols-Bold" },
2702 { "Root.PSFont.STIXSiz4Sym", "/STIXSize4Symbols" },
2703 { "Root.PSFont.STIXSiz4SymBd", "/STIXSize4Symbols-Bold" },
2704 { "Root.PSFont.STIXSiz5Sym", "/STIXSize5Symbols" },
2705 { "Root.PSFont.ME", "/DroidSansFallback" },
2706 { "Root.PSFont.CJKMing", "/DroidSansFallback" },
2707 { "Root.PSFont.CJKGothic", "/DroidSansFallback" }
2708 };
2709
2710 Int_t len = wcslen(chars);
2711 if (len<=0) return;
2712
2713 const Double_t kDEGRAD = TMath::Pi()/180.;
2714 Double_t x = xx;
2715 Double_t y = yy;
2716 if (!gPad) return;
2717
2718 // Compute the font size. Exit if it is 0
2719 // The font size is computed from the TTF size to get exactly the same
2720 // size on the screen and in the PostScript file.
2721 Double_t wh = (Double_t)gPad->GetPadWidth();
2722 Double_t hh = (Double_t)gPad->GetPadHeight();
2724
2725 if (wh < hh) {
2726 tsize = fTextSize*wh;
2727 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2728 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2729 } else {
2730 tsize = fTextSize*hh;
2731 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2732 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2733 }
2734 Double_t fontsize = 4*(72*(ftsize)/2.54);
2735 if(fontsize <= 0) return;
2736
2737 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2738 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2739
2740 Int_t font = abs(fTextFont)/10;
2741 if( font > 29 || font < 1) font = 1;
2742
2743 // Text color.
2745
2746 // Text alignment.
2747 Int_t txalh = fTextAlign/10;
2748 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
2749 Int_t txalv = fTextAlign%10;
2750 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
2751 if (txalv == 3) {
2754 } else if (txalv == 2) {
2757 }
2758 UInt_t w = 0, h = 0;
2759
2760 TText t;
2763 t.GetTextExtent(w, h, chars);
2764 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2766
2767 // Text angle.
2768 Int_t psangle = Int_t(0.5 + fTextAngle);
2769
2770 // Save context.
2771 PrintStr("@");
2772 SaveRestore(1);
2773
2774 // Clipping
2775 Int_t xc1 = XtoPS(gPad->GetX1());
2776 Int_t xc2 = XtoPS(gPad->GetX2());
2777 Int_t yc1 = YtoPS(gPad->GetY1());
2778 Int_t yc2 = YtoPS(gPad->GetY2());
2779 WriteInteger(xc2 - xc1);
2780 WriteInteger(yc2 - yc1);
2783 PrintStr(" C");
2784
2785 // Output text position and angle.
2788 PrintStr(TString::Format(" t %d r ", psangle));
2789 if(txalh == 2) PrintStr(TString::Format(" %d 0 t ", -psCharsLength/2));
2790 if(txalh == 3) PrintStr(TString::Format(" %d 0 t ", -psCharsLength));
2791 fMustEmbed[font-1] = kTRUE; // This font will be embedded in the file at EOF time.
2792 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2793 PrintStr(TString::Format(" findfont %g sf 0 0 m ",fontsize));
2794
2795 // Output text.
2796 if (len > 1) PrintStr(TString::Format("%d ", len));
2797 for(Int_t i = 0; i < len; i++) {
2798 // Adobe Glyph Naming Convention
2799 // http://www.adobe.com/devnet/opentype/archives/glyph.html
2800#include "AdobeGlyphList.h"
2801 const wchar_t *lower = std::lower_bound(
2803 chars[i]);
2805 *lower == chars[i]) {
2806 // Named glyph from AGL 1.2
2807 const unsigned long index =
2810 }
2811 else if((unsigned int)chars[i] < 0xffff) {
2812 // Unicode BMP
2813 PrintStr(TString::Format("/uni%04X ",
2814 (unsigned int)chars[i]));
2815 }
2816 else {
2817 // Unicode supplemental planes
2818 PrintStr(TString::Format("/u%04X ",
2819 (unsigned int)chars[i]));
2820 }
2821 }
2822 if(len > 1) {
2823 PrintStr("{glyphshow} repeat ");
2824 }
2825 else {
2826 PrintStr("glyphshow ");
2827 }
2828
2829 PrintStr("NC");
2830
2831 SaveRestore(-1);
2832}
2833
2834////////////////////////////////////////////////////////////////////////////////
2835/// Draw text with URL. Same as Text.
2836///
2837
2838void TPostScript::TextUrl(Double_t x, Double_t y, const char *chars, const char *)
2839{
2840 Text(x, y, chars);
2841}
2842
2843////////////////////////////////////////////////////////////////////////////////
2844/// Write a string of characters in NDC
2845
2847{
2848 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2849 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2850 Text(x, y, chars);
2851}
2852
2853////////////////////////////////////////////////////////////////////////////////
2854/// Write a string of characters in NDC
2855
2857{
2858 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2859 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2860 Text(x, y, chars);
2861}
2862
2863////////////////////////////////////////////////////////////////////////////////
2864/// Convert U from NDC coordinate to PostScript
2865
2867{
2868 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
2869 return Int_t(0.5 + 288*cm/2.54);
2870}
2871
2872////////////////////////////////////////////////////////////////////////////////
2873/// Convert V from NDC coordinate to PostScript
2874
2876{
2877 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
2878 return Int_t(0.5 + 288*cm/2.54);
2879}
2880
2881////////////////////////////////////////////////////////////////////////////////
2882/// Convert X from world coordinate to PostScript
2883
2885{
2886 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
2887 return UtoPS(u);
2888}
2889
2890////////////////////////////////////////////////////////////////////////////////
2891/// Convert Y from world coordinate to PostScript
2892
2894{
2895 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
2896 return VtoPS(v);
2897}
2898
2899////////////////////////////////////////////////////////////////////////////////
2900/// Initialize the PostScript page in zones
2901
2903{
2904 if( !fClear )return;
2905 fClear = kFALSE;
2906
2907 // When Zone has been called, fZone is TRUE
2908 fZone = kTRUE;
2909
2910 if( fIYzone > fNYzone) {
2911 fIYzone=1;
2912 if( fMode != 3) {
2913 PrintStr("@showpage");
2914 SaveRestore(-1);
2915 fNpages++;
2916 PrintStr("@%%Page:");
2919 PrintStr("@");
2920 } else {
2921 PrintFast(9," showpage");
2922 SaveRestore(-1);
2923 }
2924 }
2925
2926 // No grestore the first time
2927 if( fMode != 3) {
2928 if( fIXzone != 1 || fIYzone != 1) SaveRestore(-1);
2929 SaveRestore(1);
2930 PrintStr("@");
2933 PrintFast(5," Zone");
2934 PrintStr("@");
2935 fIXzone++;
2936 if( fIXzone > fNXzone) { fIXzone=1; fIYzone++; }
2937 }
2938
2939 // Picture Initialisation
2940 SaveRestore(1);
2941 if (fgLineJoin) {
2943 PrintFast(12," setlinejoin");
2944 }
2945 if (fgLineCap) {
2947 PrintFast(11," setlinecap");
2948 }
2949 PrintFast(6," 0 0 t");
2950 fRed = -1;
2951 fGreen = -1;
2952 fBlue = -1;
2953 fPrinted = kFALSE;
2954 fLineColor = -1;
2955 fLineStyle = -1;
2956 fLineWidth = -1;
2957 fFillColor = -1;
2958 fFillStyle = -1;
2959 fMarkerSizeCur = -1;
2960}
static const wchar_t adobe_glyph_ucs[nadobe_glyph]
static const unsigned long nadobe_glyph
static const char * adobe_glyph_name[nadobe_glyph]
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
short Style_t
Style number (short)
Definition RtypesCore.h:97
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
const Float_t kScale
Definition TASImage.cxx:135
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
Option_t Option_t cindex
Option_t Option_t SetLineWidth
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t width
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
const Float_t kScale
#define gROOT
Definition TROOT.h:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
@ kReadPermission
Definition TSystem.h:55
@ kWritePermission
Definition TSystem.h:54
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:88
#define gPad
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
Style_t fFillStyle
Fill area style.
Definition TAttFill.h:25
Color_t fFillColor
Fill area color.
Definition TAttFill.h:24
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
Width_t fLineWidth
Line width.
Definition TAttLine.h:26
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
Style_t fLineStyle
Line style.
Definition TAttLine.h:25
Color_t fLineColor
Line color.
Definition TAttLine.h:24
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:35
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:34
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:25
@ kUsePSWidthScale
Definition TAttMarker.h:53
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:36
EMarkerShape GetMarkerShape(Int_t &sz, std::vector< TPoint > &points, Float_t scale=1., UInt_t flags=0) const
Return marker shape.
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
Color_t fTextColor
Text color.
Definition TAttText.h:27
Float_t fTextAngle
Text angle.
Definition TAttText.h:24
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
Font_t fTextFont
Text font.
Definition TAttText.h:28
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
Short_t fTextAlign
Text alignment.
Definition TAttText.h:26
Float_t fTextSize
Text size.
Definition TAttText.h:25
The color creation and management class.
Definition TColor.h:22
Float_t GetRed() const
Definition TColor.h:61
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
Float_t GetBlue() const
Definition TColor.h:63
Float_t GetGreen() const
Definition TColor.h:62
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:101
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
2-D graphics point (world coordinates).
Definition TPoints.h:19
Float_t fXsize
Page size along X.
Definition TPostScript.h:48
Int_t fIYzone
Current zone along Y.
Definition TPostScript.h:61
Int_t fType
PostScript workstation type.
Definition TPostScript.h:64
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Draw markers at the n WC points x, y.
TPostScript()
Default PostScript constructor.
Int_t VtoPS(Double_t v)
Convert V from NDC coordinate to PostScript.
void CellArrayEnd() override
End the Cell Array painting.
static Int_t fgLineCap
Appearance of line caps.
Definition TPostScript.h:87
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Int_t fNBSameColorCell
Number of boxes with the same color.
Definition TPostScript.h:80
void DrawPolyMarkerShape(Int_t n, T *x, T *y)
Draw markers at the n WC points x, y.
void SetColor(Int_t color=1)
Set the current color.
Int_t fMode
PostScript mode.
Definition TPostScript.h:65
Int_t fIXzone
Current zone along X.
Definition TPostScript.h:60
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
void FontEncode()
Font Re-encoding.
Float_t fXVP2
Definition TPostScript.h:41
Int_t fLastCellBlue
Last blue value.
Definition TPostScript.h:79
Int_t fNbCellW
Number of boxes per line.
Definition TPostScript.h:74
Float_t fWidth
Current line width.
Definition TPostScript.h:54
Float_t fRed
Per cent of red.
Definition TPostScript.h:51
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Draw a PolyLine.
Bool_t fClipStatus
Clipping Indicator.
Definition TPostScript.h:69
Float_t fLineScale
Line width scale factor.
Definition TPostScript.h:56
Float_t fMarkerSizeCur
current transformed value of marker size
Definition TPostScript.h:62
Bool_t fZone
Zone indicator.
Definition TPostScript.h:71
void Open(const char *filename, Int_t type=-111) override
Open a PostScript file.
void SetFillPatterns(Int_t ipat, Int_t color)
Patterns definition.
Int_t fLastCellRed
Last red value.
Definition TPostScript.h:77
void SetLineWidth(Width_t linewidth=1) override
Change the line width.
void Off()
Deactivate an already open PostScript file.
Int_t YtoPS(Double_t y)
Convert Y from world coordinate to PostScript.
Bool_t fRange
True when a range has been defined.
Definition TPostScript.h:70
Float_t fBlue
Per cent of blue.
Definition TPostScript.h:53
void Text(Double_t x, Double_t y, const char *string) override
Write a string of characters.
void MovePS(Int_t x, Int_t y)
Move to a new position.
void Initialize()
PostScript Initialisation.
bool FontEmbedType2(const char *filename)
Int_t fNbCellLine
Number of boxes in the current line.
Definition TPostScript.h:75
Float_t fMaxsize
Largest dimension of X and Y.
Definition TPostScript.h:50
void SetStyle(Style_t linestyle=1)
Change the line style in the output file.
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
Int_t fClip
Clipping mode.
Definition TPostScript.h:66
TString fFileName
PS file name.
Definition TPostScript.h:81
Int_t fNYzone
Number of zones along Y.
Definition TPostScript.h:59
bool FontEmbedType1(const char *filename)
Float_t fGreen
Per cent of green.
Definition TPostScript.h:52
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
void SetLineCap(Int_t linecap=0)
Set the value of the global parameter TPostScript::fgLineCap.
Float_t fYVP2
Definition TPostScript.h:43
void NewPage() override
Move to a new PostScript page.
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Float_t *x, Float_t *y)
Draw Fill area with hatch styles.
Int_t UtoPS(Double_t u)
Convert U from NDC coordinate to PostScript.
Bool_t fFontEmbed
True is FontEmbed has been called.
Definition TPostScript.h:82
void SetWidth(Width_t linewidth=1)
Change the line width in the output file.
void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark, Int_t light) override
Draw a Frame around a box.
Float_t fYVP1
Definition TPostScript.h:42
Int_t fSave
Number of gsave for restore.
Definition TPostScript.h:57
Int_t fStyle
Current line style.
Definition TPostScript.h:55
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array.
void SetTextColor(Color_t cindex=1) override
Set color index for text.
void On()
Activate an already open PostScript file.
Int_t CMtoPS(Double_t u)
bool FontEmbedType42(const char *filename)
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Int_t fNXzone
Number of zones along X.
Definition TPostScript.h:58
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
void SetLineScale(Float_t scale=3)
Bool_t fBoundingBox
True for Encapsulated PostScript.
Definition TPostScript.h:67
Int_t XtoPS(Double_t x)
Convert X from world coordinate to PostScript.
~TPostScript() override
Default PostScript destructor.
char fPatterns[32]
Indicate if pattern n is defined.
Definition TPostScript.h:72
Int_t fNbinCT
Number of entries in the current Cell Array.
Definition TPostScript.h:73
static Int_t fgLineJoin
Appearance of joining lines.
Definition TPostScript.h:86
std::map< std::string, bool > fMarkers
! array of already defined markers
Definition TPostScript.h:84
Int_t fLastCellGreen
Last green value.
Definition TPostScript.h:78
void SaveRestore(Int_t flag)
Compute number of gsaves for restore This allows to write the correct number of grestore at the end o...
Bool_t fClear
True when page must be cleared.
Definition TPostScript.h:68
Int_t fMaxLines
Maximum number of lines in a PS array.
Definition TPostScript.h:76
void Zone()
Initialize the PostScript page in zones.
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TPostScript::fgLineJoin.
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimeters.
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2) override
Draw a Cell Array.
void FontEmbed()
Embed font in PS file.
void Close(Option_t *opt="") override
Close a PostScript file.
Bool_t fMustEmbed[29]
flag to embed font
Definition TPostScript.h:83
Float_t fXVP1
Definition TPostScript.h:40
Int_t fNpages
number of pages
Definition TPostScript.h:63
Float_t fYsize
Page size along Y.
Definition TPostScript.h:49
static const TString & GetTTFFontDir()
Get the fonts directory in the installation. Static utility function.
Definition TROOT.cxx:3522
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:386
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2459
Int_t GetJoinLinePS() const
Returns the line join method used for PostScript, PDF and SVG output. See TPostScript::SetLineJoin fo...
Definition TStyle.h:289
Int_t GetColorModelPS() const
Definition TStyle.h:198
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition TStyle.cxx:1167
const char * GetTitlePS() const
Definition TStyle.h:287
Int_t GetCapLinePS() const
Returns the line cap method used for PostScript, PDF and SVG output. See TPostScript::SetLineCap for ...
Definition TStyle.h:290
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
Definition TStyle.cxx:1184
const char * GetHeaderPS() const
Definition TStyle.h:286
Float_t GetLineScalePS() const
Definition TStyle.h:291
virtual int GetPid()
Get process id.
Definition TSystem.cxx:720
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1553
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1311
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1365
virtual int Unlink(const char *name)
Unlink, i.e.
Definition TSystem.cxx:1396
Base class for several text objects.
Definition TText.h:22
virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const
Return text extent for string text.
Definition TText.cxx:545
virtual void GetTextAdvance(UInt_t &a, const char *text, const Bool_t kern=kTRUE) const
Return text advance for string text if kern is true (default) kerning is taken into account.
Definition TText.cxx:562
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:30
Int_t fLenBuffer
Definition TVirtualPS.h:38
virtual void WriteInteger(Int_t i, Bool_t space=kTRUE)
Write one Integer to the file.
virtual void PrintRaw(Int_t len, const char *str)
Print a raw.
void CloseStream()
Close existing stream.
virtual void PrintStr(const char *string="")
Output the string str in the output buffer.
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
std::ofstream * fStream
Definition TVirtualPS.h:41
Bool_t OpenStream(const char *fname, Bool_t binary=kFALSE)
Open output stream.
void ClearBuffer()
Clear content of internal buffer.
const char * fImplicitCREsc
Definition TVirtualPS.h:43
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
Bool_t fPrinted
Definition TVirtualPS.h:40
TLine * line
TCanvas * kerning()
Definition kerning.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Definition TMathBase.h:174
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:734
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:607
constexpr Double_t Pi()
Definition TMath.h:40
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:601