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 "strlcpy.h"
233#include "Byteswap.h"
234#include "TROOT.h"
235#include "TDatime.h"
236#include "TColor.h"
237#include "TVirtualPad.h"
238#include "TPoints.h"
239#include "TPoint.h"
240#include "TImage.h"
241#include "TPostScript.h"
242#include "TStyle.h"
243#include "TMath.h"
244#include "TText.h"
245#include "TSystem.h"
246#include "TEnv.h"
247
248#include <cstdio>
249#include <cstdlib>
250#include <cstring>
251#include <cctype>
252#include <cwchar>
253#include <fstream>
254
255#include "mathtext/fontembed.h"
256
257// to scale fonts to the same size as the old TT version
258const Float_t kScale = 0.93376068;
259
260// Array defining if a font must be embedded or not.
263
264
265////////////////////////////////////////////////////////////////////////////////
266/// Default PostScript constructor
267
269{
270 for (Int_t i = 0; i < 32; i++)
271 fPatterns[i] = 0;
272 for (Int_t i = 0; i < 29; i++)
273 fMustEmbed[i] = kFALSE;
274 SetTitle("PS");
275
276 gVirtualPS = this;
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Initialize the PostScript interface
281///
282/// - fname : PostScript file name
283/// - wtype : PostScript workstation type
284///
285///
286/// The possible workstation types are:
287/// - 111 ps Portrait
288/// - 112 ps Landscape
289/// - 113 eps
290
292{
293 for (Int_t i = 0; i < 32; i++)
294 fPatterns[i] = 0;
295 for (Int_t i = 0; i < 29; i++)
296 fMustEmbed[i] = kFALSE;
297
298 SetTitle("PS");
299 Open(fname, wtype);
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Open a PostScript file
304
306{
307 if (fStream) {
308 Warning("Open", "postscript file already open");
309 return;
310 }
311
312 fMarkerSizeCur = 0;
313 fRed = -1;
314 fGreen = -1;
315 fBlue = -1;
316 fLenBuffer = 0;
317 fClip = 0;
318 fType = std::abs(wtype);
319 fClear = kTRUE;
320 fZone = kFALSE;
321 fSave = 0;
327 fMode = fType%10;
329 if (gPad) {
330 Double_t ww = gPad->GetWw();
331 Double_t wh = gPad->GetWh();
332 if (fType == 113) {
333 ww *= gPad->GetWNDC();
334 wh *= gPad->GetHNDC();
335 }
336 Double_t ratio = wh/ww;
337 if (fType == 112) {
338 xrange = fYsize;
339 yrange = xrange*ratio;
340 if (yrange > fXsize) { yrange = fXsize; xrange = yrange/ratio;}
341 } else {
342 xrange = fXsize;
343 yrange = fXsize*ratio;
344 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
345 }
347 }
348
349 // Open OS file
352 Error("Open", "Cannot open file: %s", fFileName.Data());
353 return;
354 }
355 gVirtualPS = this;
356
357 ClearBuffer();
358
359 if( fType == 113) {
361 PrintStr("%!PS-Adobe-2.0 EPSF-2.0@");
362 } else {
364 PrintStr("%!PS-Adobe-2.0@");
365 Initialize();
366 }
367
369 fRange = kFALSE;
370
371 // Set a default range
373
375 if (fType == 113)
376 NewPage();
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Default PostScript destructor
381
386
387////////////////////////////////////////////////////////////////////////////////
388/// Close a PostScript file
389
391{
392 if (!gVirtualPS ||!fStream)
393 return;
394 if (gPad)
395 gPad->Update();
396 if(fMode != 3) {
397 SaveRestore(-1);
398 if( fPrinted ) { PrintStr("showpage@"); SaveRestore(-1);}
399 PrintStr("@");
400 PrintStr("%%Trailer@");
401 PrintStr("%%Pages: ");
403 PrintStr("@");
404 while (fSave > 0) { SaveRestore(-1); }
405 } else {
406 PrintStr("@");
407 while (fSave > 0) { SaveRestore(-1); }
408 PrintStr("showpage@");
409 PrintStr("end@");
410 }
411 PrintStr("@");
412 PrintStr("%%EOF@");
413
414 // Embed the fonts previously used by TMathText
415 if (!fFontEmbed) {
416 // Close the file fFileName
417 if (fStream) {
418 PrintStr("@");
419 CloseStream();
420 }
421
422 // Rename the file fFileName
424 if (gSystem->Rename(fFileName.Data(), tmpname.Data())) {
425 Error("Close", "Cannot open temporary file: %s", tmpname.Data());
426 return;
427 }
428
430 Error("Close", "Cannot open file: %s", fFileName.Data());
431 return;
432 }
433
434 // Embed the fonts at the right place
435 FILE *sg = fopen(tmpname.Data(),"r");
436 if (!sg) {
437 Error("Close", "Cannot open file: %s", tmpname.Data());
438 return;
439 }
440 char line[255];
441 while (fgets(line, 255, sg)) {
442 if (strstr(line,"EndComments")) PrintStr("%%DocumentNeededResources: ProcSet (FontSetInit)@");
443 fStream->write(line,strlen(line));
444 // insert font after end of generic defines
445 if (!fFontEmbed && strstr(line,"/ita")) {
446 FontEmbed();
447 PrintStr("@");
448 }
449 }
450 fclose(sg);
451 if (gSystem->Unlink(tmpname.Data())) return;
452 }
453
455
456 // Close file stream
457
458 CloseStream();
459
460 gVirtualPS = nullptr;
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Activate an already open PostScript file
465
467{
468 if (!fType) {
469 Error("On", "no postscript file open");
470 Off();
471 return;
472 }
473 gVirtualPS = this;
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Deactivate an already open PostScript file
478
480{
481 gVirtualPS = nullptr;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Draw a Cell Array
486///
487/// Drawing a PostScript Cell Array is in fact done thanks to three
488/// procedures: CellArrayBegin, CellArrayFill, and CellArrayEnd.
489///
490/// - CellArrayBegin: Initiate the Cell Array by writing the necessary
491/// PostScript procedures and the initial values of the
492/// required parameters. The input parameters are:
493/// - W: number of boxes along the width.
494/// - H: number of boxes along the height
495/// - x1,x2,y1,y2: First box coordinates.
496/// - CellArrayFill: Is called for each box of the Cell Array. The first
497/// box is the top left one and the last box is the
498/// bottom right one. The input parameters are the Red,
499/// Green, and Blue components of the box colour. These
500/// Levels are between 0 and 255.
501/// - CellArrayEnd: Finishes the Cell Array.
502///
503/// PostScript cannot handle arrays larger than 65535. So the Cell Array
504/// is drawn in several pieces.
505
508{
509 Int_t ix1 = XtoPS(x1);
510 Int_t iy1 = YtoPS(y1);
511
512 Float_t wt = (288/2.54)*gPad->GetAbsWNDC()*
513 fXsize*((x2 - x1)/(gPad->GetX2()-gPad->GetX1()));
514 Float_t ht = (288/2.54)*gPad->GetAbsHNDC()*
515 fYsize*((y2 - y1)/(gPad->GetY2()-gPad->GetY1()));
516
517 fLastCellRed = 300;
518 fLastCellGreen = 300;
519 fLastCellBlue = 300;
521
522 fNbinCT = 0;
523 fNbCellW = W;
524 fNbCellLine = 0;
525 fMaxLines = 40000/(3*fNbCellW);
526
527 // Define some parameters
528 PrintStr("@/WT"); WriteReal(wt) ; PrintStr(" def"); // Cells width
529 PrintStr(" /HT"); WriteReal(ht) ; PrintStr(" def"); // Cells height
530 PrintStr(" /XS"); WriteInteger(ix1) ; PrintStr(" def"); // X start
531 PrintStr(" /YY"); WriteInteger(iy1) ; PrintStr(" def"); // Y start
532 PrintStr(" /NX"); WriteInteger(W) ; PrintStr(" def"); // Number of columns
533 PrintStr(" /NY"); WriteInteger(fMaxLines); PrintStr(" def"); // Number of lines
534
535 // This PS procedure draws one cell.
536 PrintStr(" /DrawCell ");
537 PrintStr( "{WT HT XX YY bf");
538 PrintStr( " /NBBD NBBD 1 add def");
539 PrintStr( " NBBD NBB eq {exit} if");
540 PrintStr( " /XX WT XX add def");
541 PrintStr( " IX NX eq ");
542 PrintStr( "{/YY YY HT sub def");
543 PrintStr( " /XX XS def");
544 PrintStr( " /IX 0 def} if");
545 PrintStr( " /IX IX 1 add def} def");
546
547 // This PS procedure draws fMaxLines line. It takes care of duplicated
548 // colors. Values "n" greater than 300 mean than the previous color
549 // should be duplicated n-300 times.
550 PrintStr(" /DrawCT ");
551 PrintStr( "{/NBB NX NY mul def");
552 PrintStr( " /XX XS def");
553 PrintStr( " /IX 1 def");
554 PrintStr( " /NBBD 0 def");
555 PrintStr( " /RC 0 def /GC 1 def /BC 2 def");
556 PrintStr( " 1 1 NBB ");
557 PrintStr( "{/NB CT RC get def");
558 PrintStr( " NB 301 ge ");
559 PrintStr( "{/NBL NB 300 sub def");
560 PrintStr( " 1 1 NBL ");
561 PrintStr( "{DrawCell}");
562 PrintStr( " for");
563 PrintStr( " /RC RC 1 add def");
564 PrintStr( " /GC RC 1 add def");
565 PrintStr( " /BC RC 2 add def}");
566 PrintStr( "{CT RC get 255 div CT GC get 255 div CT BC get 255 div setrgbcolor");
567 PrintStr( " DrawCell");
568 PrintStr( " /RC RC 3 add def");
569 PrintStr( " /GC GC 3 add def");
570 PrintStr( " /BC BC 3 add def} ifelse NBBD NBB eq {exit} if} for");
571 PrintStr( " /YY YY HT sub def clear} def");
572
573 PrintStr(" /CT [");
574}
575
576////////////////////////////////////////////////////////////////////////////////
577/// Paint the Cell Array
578
580{
581 if (fLastCellRed == r && fLastCellGreen == g && fLastCellBlue == b) {
583 } else {
584 if (fNBSameColorCell != 0 ) {
587 }
591 fLastCellRed = r;
594 }
595
596 fNbinCT++;
597 if (fNbinCT == fNbCellW) {
598 fNbCellLine++;
599 fNbinCT = 0;
600 }
601
602 if (fNbCellLine == fMaxLines) {
604 PrintStr("] def DrawCT /CT [");
605 fNbCellLine = 0;
606 fLastCellRed = 300;
607 fLastCellGreen = 300;
608 fLastCellBlue = 300;
610 fNbinCT = 0;
611 }
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// End the Cell Array painting
616
618{
620 PrintStr("] def /NY");
622 PrintStr(" def DrawCT ");
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Draw image in postscript
627
629{
630 auto argb = img->GetArgbArray();
631 if (!argb) {
632 Error("DrawImage", "Fail to access ARGB values");
633 return;
634 }
635
636 Int_t width = img->GetWidth();
637 Int_t height = img->GetHeight();
638
639 auto x1 = gPad->AbsPixeltoX(x);
640 auto x2 = gPad->AbsPixeltoX(x + width);
641 auto y1 = gPad->AbsPixeltoY(y);
642 auto y2 = gPad->AbsPixeltoY(y - height);
643
644 Int_t ix1 = XtoPS(x1);
645 Int_t iy1 = YtoPS(y1);
646 Int_t ix2 = XtoPS(x2);
647 Int_t iy2 = YtoPS(y2);
648
649 Float_t wt = (0. + ix2 - ix1) / width;
650 Float_t ht = (0. + iy2 - iy1) / height;
651
652 fLastCellRed = 300;
653 fLastCellGreen = 300;
654 fLastCellBlue = 300;
656
657 fNbinCT = 0;
658 fNbCellW = width;
659 fNbCellLine = 0;
660 fMaxLines = 40000/(3*fNbCellW);
661
662 // Define some parameters
663 PrintStr("@/WT"); WriteReal(wt) ; PrintStr(" def"); // Cells width
664 PrintStr(" /HT"); WriteReal(ht) ; PrintStr(" def"); // Cells height
665 PrintStr(" /XS"); WriteInteger(ix1) ; PrintStr(" def"); // X start
666 PrintStr(" /YY"); WriteInteger(iy1) ; PrintStr(" def"); // Y start
667 PrintStr(" /NX"); WriteInteger(width) ; PrintStr(" def"); // Number of columns
668 PrintStr(" /NY"); WriteInteger(fMaxLines); PrintStr(" def"); // Number of lines
669
670 // This PS procedure draws one cell.
671 PrintStr(" /DrawCell ");
672 PrintStr( "{WT HT XX YY bf");
673 PrintStr( " /NBBD NBBD 1 add def");
674 PrintStr( " NBBD NBB eq {exit} if");
675 PrintStr( " /XX WT XX add def");
676 PrintStr( " IX NX eq ");
677 PrintStr( "{/YY YY HT sub def");
678 PrintStr( " /XX XS def");
679 PrintStr( " /IX 0 def} if");
680 PrintStr( " /IX IX 1 add def} def");
681
682 // This PS procedure draws fMaxLines line. It takes care of duplicated
683 // colors. Values "n" greater than 300 mean than the previous color
684 // should be duplicated n-300 times.
685 PrintStr(" /DrawCT ");
686 PrintStr( "{/NBB NX NY mul def");
687 PrintStr( " /XX XS def");
688 PrintStr( " /IX 1 def");
689 PrintStr( " /NBBD 0 def");
690 PrintStr( " /RC 0 def /GC 1 def /BC 2 def");
691 PrintStr( " 1 1 NBB ");
692 PrintStr( "{/NB CT RC get def");
693 PrintStr( " NB 301 ge ");
694 PrintStr( "{/NBL NB 300 sub def");
695 PrintStr( " 1 1 NBL ");
696 PrintStr( "{DrawCell}");
697 PrintStr( " for");
698 PrintStr( " /RC RC 1 add def");
699 PrintStr( " /GC RC 1 add def");
700 PrintStr( " /BC RC 2 add def}");
701 PrintStr( "{CT RC get 255 div CT GC get 255 div CT BC get 255 div setrgbcolor");
702 PrintStr( " DrawCell");
703 PrintStr( " /RC RC 3 add def");
704 PrintStr( " /GC GC 3 add def");
705 PrintStr( " /BC BC 3 add def} ifelse NBBD NBB eq {exit} if} for");
706 PrintStr( " /YY YY HT sub def clear} def");
707
708 PrintStr(" /CT [");
709
710 // use old API, move here once old is deprecated
711 for (Int_t i = 0; i < width * height; ++i) {
712 UInt_t p = argb[i];
713 auto r = static_cast<unsigned char>((p >> 16) & 0xFF);
714 auto g = static_cast<unsigned char>((p >> 8) & 0xFF);
715 auto b = static_cast<unsigned char>(p & 0xFF);
716 CellArrayFill(r, g, b);
717 }
718
719 CellArrayEnd();
720}
721
722////////////////////////////////////////////////////////////////////////////////
723/// Draw a Box
724
726{
727 Double_t x[4], y[4];
728 Int_t ix1 = XtoPS(x1);
729 Int_t ix2 = XtoPS(x2);
730 Int_t iy1 = YtoPS(y1);
731 Int_t iy2 = YtoPS(y2);
732 Int_t fillis = fFillStyle/1000;
733 Int_t fillsi = fFillStyle%1000;
734
735 if (fillis == 3 || fillis == 2) {
736 if (fillsi > 99) {
737 x[0] = x1; y[0] = y1;
738 x[1] = x2; y[1] = y1;
739 x[2] = x2; y[2] = y2;
740 x[3] = x1; y[3] = y2;
741 return;
742 }
743 if (fillsi > 0 && fillsi < 26) {
744 x[0] = x1; y[0] = y1;
745 x[1] = x2; y[1] = y1;
746 x[2] = x2; y[2] = y2;
747 x[3] = x1; y[3] = y2;
748 DrawPS(-4, &x[0], &y[0]);
749 }
750 if (fillsi == -3) {
751 SetColor(5);
756 PrintFast(3," bf");
757 }
758 }
759 if (fillis == 1) {
765 PrintFast(3," bf");
766 }
767 if (fillis == 0) {
768 if (fLineWidth<=0) return;
774 PrintFast(3," bl");
775 }
776}
777
778////////////////////////////////////////////////////////////////////////////////
779/// Draw a Frame around a box
780///
781/// - mode = -1 box looks as it is behind the screen
782/// - mode = 1 box looks as it is in front of the screen
783/// - border is the border size in already precomputed PostScript units
784/// - dark is the color for the dark part of the frame
785/// - light is the color for the light part of the frame
786
788 Int_t mode, Int_t border, Int_t dark, Int_t light)
789{
790 Int_t xps[7], yps[7];
791 Int_t i, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
792
793 // Draw top&left part of the box
794 if (mode == -1) SetColor(dark);
795 else SetColor(light);
796 Int_t bordPS = 4*border;
797 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
798 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
799 xps[2] = xps[1]; yps[2] = YtoPS(yt) - bordPS;
800 xps[3] = XtoPS(xt) - bordPS; yps[3] = yps[2];
801 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
802 xps[5] = xps[0]; yps[5] = yps[4];
803 xps[6] = xps[0]; yps[6] = yps[0];
804
805 ixd0 = xps[0];
806 iyd0 = yps[0];
809
810 PrintFast(2," m");
811 idx = 0;
812 idy = 0;
813 for (i=1;i<7;i++) {
814 ixdi = xps[i];
815 iydi = yps[i];
816 ix = ixdi - ixd0;
817 iy = iydi - iyd0;
818 ixd0 = ixdi;
819 iyd0 = iydi;
820 if( ix && iy) {
821 if( idx ) { MovePS(idx,0); idx = 0; }
822 if( idy ) { MovePS(0,idy); idy = 0; }
823 MovePS(ix,iy);
824 continue;
825 }
826 if ( ix ) {
827 if( idy ) { MovePS(0,idy); idy = 0; }
828 if( !idx ) { idx = ix; continue;}
829 if( ix*idx > 0 ) idx += ix;
830 else { MovePS(idx,0); idx = ix; }
831 continue;
832 }
833 if( iy ) {
834 if( idx ) { MovePS(idx,0); idx = 0; }
835 if( !idy) { idy = iy; continue;}
836 if( iy*idy > 0 ) idy += iy;
837 else { MovePS(0,idy); idy = iy; }
838 }
839 }
840 if( idx ) MovePS(idx,0);
841 if( idy ) MovePS(0,idy);
842 PrintFast(2," f");
843
844 // Draw bottom&right part of the box
845 if (mode == -1) SetColor(light);
846 else SetColor(dark);
847 xps[0] = XtoPS(xl); yps[0] = YtoPS(yl);
848 xps[1] = xps[0] + bordPS; yps[1] = yps[0] + bordPS;
849 xps[2] = XtoPS(xt) - bordPS; yps[2] = yps[1];
850 xps[3] = xps[2]; yps[3] = YtoPS(yt) - bordPS;
851 xps[4] = XtoPS(xt); yps[4] = YtoPS(yt);
852 xps[5] = xps[4]; yps[5] = yps[0];
853 xps[6] = xps[0]; yps[6] = yps[0];
854
855 ixd0 = xps[0];
856 iyd0 = yps[0];
859
860 PrintFast(2," m");
861 idx = 0;
862 idy = 0;
863 for (i=1;i<7;i++) {
864 ixdi = xps[i];
865 iydi = yps[i];
866 ix = ixdi - ixd0;
867 iy = iydi - iyd0;
868 ixd0 = ixdi;
869 iyd0 = iydi;
870 if( ix && iy) {
871 if( idx ) { MovePS(idx,0); idx = 0; }
872 if( idy ) { MovePS(0,idy); idy = 0; }
873 MovePS(ix,iy);
874 continue;
875 }
876 if ( ix ) {
877 if( idy ) { MovePS(0,idy); idy = 0; }
878 if( !idx ) { idx = ix; continue;}
879 if( ix*idx > 0 ) idx += ix;
880 else { MovePS(idx,0); idx = ix; }
881 continue;
882 }
883 if( iy ) {
884 if( idx ) { MovePS(idx,0); idx = 0; }
885 if( !idy) { idy = iy; continue;}
886 if( iy*idy > 0 ) idy += iy;
887 else { MovePS(0,idy); idy = iy; }
888 }
889 }
890 if( idx ) MovePS(idx,0);
891 if( idy ) MovePS(0,idy);
892 PrintFast(2," f");
893}
894
895////////////////////////////////////////////////////////////////////////////////
896/// Draw a PolyLine
897///
898/// Draw a polyline through the points xy.
899/// - If nn=1 moves only to point x,y.
900/// - If nn=0 the x,y are written in the PostScript file
901/// according to the current transformation.
902/// - If nn>0 the line is clipped as a line.
903/// - If nn<0 the line is clipped as a fill area.
904
906{
907 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
910 if (nn > 0) {
911 if (fLineWidth<=0) return;
912 n = nn;
916 } else {
917 n = -nn;
918 SetStyle(1);
919 SetWidth(1);
921 }
922
923 ixd0 = XtoPS(xy[0].GetX());
924 iyd0 = YtoPS(xy[0].GetY());
927 if( n <= 1) {
928 if( n == 0) goto END;
929 PrintFast(2," m");
930 goto END;
931 }
932
933 PrintFast(2," m");
934 idx = 0;
935 idy = 0;
936 for (i=1;i<n;i++) {
937 ixdi = XtoPS(xy[i].GetX());
938 iydi = YtoPS(xy[i].GetY());
939 ix = ixdi - ixd0;
940 iy = iydi - iyd0;
941 ixd0 = ixdi;
942 iyd0 = iydi;
943 if( ix && iy) {
944 if( idx ) { MovePS(idx,0); idx = 0; }
945 if( idy ) { MovePS(0,idy); idy = 0; }
946 MovePS(ix,iy);
947 continue;
948 }
949 if ( ix ) {
950 if( idy ) { MovePS(0,idy); idy = 0; }
951 if( !idx ) { idx = ix; continue;}
952 if( ix*idx > 0 ) idx += ix;
953 else { MovePS(idx,0); idx = ix; }
954 continue;
955 }
956 if( iy ) {
957 if( idx ) { MovePS(idx,0); idx = 0; }
958 if( !idy) { idy = iy; continue;}
959 if( iy*idy > 0 ) idy += iy;
960 else { MovePS(0,idy); idy = iy; }
961 }
962 }
963 if( idx ) MovePS(idx,0);
964 if( idy ) MovePS(0,idy);
965
966 if (nn > 0 ) {
967 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
968 PrintFast(2," s");
969 } else {
970 PrintFast(2," f");
971 }
972END:
973 if (nn < 0) {
976 }
977}
978
979////////////////////////////////////////////////////////////////////////////////
980/// Draw a PolyLine in NDC space
981///
982/// Draw a polyline through the points xy.
983/// - If nn=1 moves only to point x,y.
984/// - If nn=0 the x,y are written in the PostScript file
985/// according to the current transformation.
986/// - If nn>0 the line is clipped as a line.
987/// - If nn<0 the line is clipped as a fill area.
988
990{
991 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy;
994 if (nn > 0) {
995 if (fLineWidth<=0) return;
996 n = nn;
1000 } else {
1001 n = -nn;
1002 SetStyle(1);
1003 SetWidth(1);
1005 }
1006
1007 ixd0 = UtoPS(xy[0].GetX());
1008 iyd0 = VtoPS(xy[0].GetY());
1011 if( n <= 1) {
1012 if( n == 0) goto END;
1013 PrintFast(2," m");
1014 goto END;
1015 }
1016
1017 PrintFast(2," m");
1018 idx = 0;
1019 idy = 0;
1020 for (i=1;i<n;i++) {
1021 ixdi = UtoPS(xy[i].GetX());
1022 iydi = VtoPS(xy[i].GetY());
1023 ix = ixdi - ixd0;
1024 iy = iydi - iyd0;
1025 ixd0 = ixdi;
1026 iyd0 = iydi;
1027 if( ix && iy) {
1028 if( idx ) { MovePS(idx,0); idx = 0; }
1029 if( idy ) { MovePS(0,idy); idy = 0; }
1030 MovePS(ix,iy);
1031 continue;
1032 }
1033 if ( ix ) {
1034 if( idy ) { MovePS(0,idy); idy = 0; }
1035 if( !idx ) { idx = ix; continue;}
1036 if( ix*idx > 0 ) idx += ix;
1037 else { MovePS(idx,0); idx = ix; }
1038 continue;
1039 }
1040 if( iy ) {
1041 if( idx ) { MovePS(idx,0); idx = 0; }
1042 if( !idy) { idy = iy; continue;}
1043 if( iy*idy > 0 ) idy += iy;
1044 else { MovePS(0,idy); idy = iy; }
1045 }
1046 }
1047 if( idx ) MovePS(idx,0);
1048 if( idy ) MovePS(0,idy);
1049
1050 if (nn > 0 ) {
1051 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
1052 PrintFast(2," s");
1053 } else {
1054 PrintFast(2," f");
1055 }
1056END:
1057 if (nn < 0) {
1060 }
1061}
1062
1063////////////////////////////////////////////////////////////////////////////////
1064/// Draw markers at the n WC points x, y
1065template<typename T>
1067{
1068 if (GetMarkerSize() <= 0)
1069 return;
1070
1071 auto linestylesav = GetLineStyle();
1072 auto linewidthsav = GetLineWidth();
1073
1074 Float_t s2x = 1. / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
1075 // Rescale size of marker on PS coordinates
1076 Float_t scale = UtoPS(s2x) - UtoPS(0);
1077
1078 Int_t markerSize = 0;
1079 std::vector<TPoint> points;
1080
1081 auto shape = GetMarkerShape(markerSize, points, scale, kUsePSWidthScale);
1082 auto markerLineWidth = GetMarkerLineWidth(GetMarkerStyle());
1083
1084 Int_t szindx = (Int_t) (GetMarkerSize()*100.);
1085
1086 TString name = szindx == 100 ? TString::Format("m%d", (Int_t) GetMarkerStyle())
1087 : TString::Format("m%d_sz%d", (Int_t) GetMarkerStyle(), szindx);
1088
1089 if (!fMarkers[name.Data()]) {
1090 // create marker definition only once
1091 PrintStr("@/");
1092 PrintStr(name.Data());
1093 PrintStr(" { gsave translate newpath");
1094 switch(shape) {
1096 markerSize = TMath::Max(4, markerSize*4); // circe diameter
1097 // no break, handle as filled circle
1100 PrintStr(" 0 0");
1101 WriteInteger(markerSize/2);
1102 PrintStr(" 0 360 arc");
1103 if (shape != TAttMarker::kShapeCircle)
1104 PrintStr(" fill");
1105 else
1106 PrintStr(" stroke");
1107 break;
1110 for (std::size_t i = 0; i < points.size(); ++i) {
1111 WriteInteger(points[i].fX);
1112 WriteInteger(-points[i].fY);
1113 PrintStr(i == 0 ? " moveto" : " lineto");
1114 }
1115 if (points.front() == points.back())
1116 PrintStr(" closepath");
1117 if (shape == TAttMarker::kShapeFilledArea)
1118 PrintStr(" fill");
1119 else
1120 PrintStr(" stroke");
1121 break;
1123 for (std::size_t i = 0; i < points.size(); ++i) {
1124 WriteInteger(points[i].fX);
1125 WriteInteger(-points[i].fY);
1126 PrintStr(i % 2 == 0 ? " moveto" : " lineto stroke");
1127 }
1128 break;
1130 for (std::size_t i = 0; i < points.size(); ++i) {
1131 WriteInteger(points[i].fX);
1132 WriteInteger(-points[i].fY);
1133 PrintStr(i % 3 == 0 ? " moveto" : " lineto");
1134 if (i % 3 == 2)
1135 PrintStr(" closepath fill");
1136 }
1137 break;
1138 }
1139 PrintStr(" grestore } def@");
1140 fMarkers[name.Data()] = true;
1141 }
1142
1143 SetStyle(1);
1144 SetWidth((markerLineWidth > 1) ? markerLineWidth : 1);
1146
1147 for (Int_t k = 0; k < n; ++k) {
1148 WriteInteger(XtoPS(x[k]));
1149 WriteInteger(YtoPS(y[k]));
1150 PrintStr(" ");
1151 PrintStr(name.Data());
1152 }
1153 PrintStr("@");
1154
1157}
1158
1159
1160////////////////////////////////////////////////////////////////////////////////
1161/// Draw markers at the n WC points x, y
1162
1167
1168////////////////////////////////////////////////////////////////////////////////
1169/// Draw markers at the n WC points x, y
1170
1175
1176////////////////////////////////////////////////////////////////////////////////
1177/// Draw a PolyLine
1178///
1179/// Draw a polyline through the points xw,yw.
1180/// - If nn=1 moves only to point xw,yw.
1181/// - If nn=0 the XW(1) and YW(1) are written in the PostScript file
1182/// according to the current NT.
1183/// - If nn>0 the line is clipped as a line.
1184/// - If nn<0 the line is clipped as a fill area.
1185
1187{
1188 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1189 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1190 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1191 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1192 180, 90,135, 45,150, 30,120, 60,
1193 180, 90,135, 45,150, 30,120, 60};
1194 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1195 fais = fasi = n = 0;
1196 Int_t jxd0 = XtoPS(xw[0]);
1197 Int_t jyd0 = YtoPS(yw[0]);
1200
1201 if (nn > 0) {
1202 if (fLineWidth<=0) return;
1203 n = nn;
1207 }
1208 if (nn < 0) {
1209 n = -nn;
1210 SetStyle(1);
1211 SetWidth(1);
1213 fais = fFillStyle/1000;
1214 fasi = fFillStyle%1000;
1215 if (fais == 3 || fais == 2) {
1216 if (fasi > 100 && fasi <125) {
1217 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1218 goto END;
1219 }
1220 if (fasi > 0 && fasi < 26) {
1222 }
1223 }
1224 }
1225
1226 ixd0 = jxd0;
1227 iyd0 = jyd0;
1230 if( n <= 1) {
1231 if( n == 0) goto END;
1232 PrintFast(2," m");
1233 goto END;
1234 }
1235
1236 PrintFast(2," m");
1237 idx = idy = 0;
1238 for (i=1;i<n;i++) {
1239 ixdi = XtoPS(xw[i]);
1240 iydi = YtoPS(yw[i]);
1241 ix = ixdi - ixd0;
1242 iy = iydi - iyd0;
1243 ixd0 = ixdi;
1244 iyd0 = iydi;
1245 if( ix && iy) {
1246 if( idx ) { MovePS(idx,0); idx = 0; }
1247 if( idy ) { MovePS(0,idy); idy = 0; }
1248 MovePS(ix,iy);
1249 } else if ( ix ) {
1250 if( idy ) { MovePS(0,idy); idy = 0;}
1251 if( !idx ) { idx = ix;}
1252 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1253 else { MovePS(idx,0); idx = ix;}
1254 } else if( iy ) {
1255 if( idx ) { MovePS(idx,0); idx = 0;}
1256 if( !idy) { idy = iy;}
1257 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1258 else { MovePS(0,idy); idy = iy;}
1259 }
1260 }
1261 if (idx) MovePS(idx,0);
1262 if (idy) MovePS(0,idy);
1263
1264 if (nn > 0 ) {
1265 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3," cl");
1266 PrintFast(2," s");
1267 } else {
1268 if (fais == 0) {PrintFast(5," cl s"); goto END;}
1269 if (fais == 3 || fais == 2) {
1270 if (fasi > 0 && fasi < 26) {
1271 PrintFast(3," FA");
1272 fRed = -1;
1273 fGreen = -1;
1274 fBlue = -1;
1275 }
1276 goto END;
1277 }
1278 PrintFast(2," f");
1279 }
1280END:
1281 if (nn < 0) {
1284 }
1285}
1286
1287////////////////////////////////////////////////////////////////////////////////
1288/// Draw a PolyLine
1289///
1290/// Draw a polyline through the points xw,yw.
1291/// - If nn=1 moves only to point xw,yw.
1292/// - If nn=0 the xw(1) and YW(1) are written in the PostScript file
1293/// --- according to the current NT.
1294/// - If nn>0 the line is clipped as a line.
1295/// - If nn<0 the line is clipped as a fill area.
1296
1298{
1299 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1300 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1301 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1302 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1303 180, 90,135, 45,150, 30,120, 60,
1304 180, 90,135, 45,150, 30,120, 60};
1305 Int_t i, n, ixd0, iyd0, idx, idy, ixdi, iydi, ix, iy, fais, fasi;
1306 fais = fasi = n = 0;
1307 Int_t jxd0 = XtoPS(xw[0]);
1308 Int_t jyd0 = YtoPS(yw[0]);
1311
1312 if (nn > 0) {
1313 if (fLineWidth<=0) return;
1314 n = nn;
1318 }
1319 if (nn < 0) {
1320 n = -nn;
1321 SetStyle(1);
1322 SetWidth(1);
1324 fais = fFillStyle/1000;
1325 fasi = fFillStyle%1000;
1326 if (fais == 3 || fais == 2) {
1327 if (fasi > 100 && fasi <125) {
1328 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1329 goto END;
1330 }
1331 if (fasi > 0 && fasi < 26) {
1333 }
1334 }
1335 }
1336
1337 ixd0 = jxd0;
1338 iyd0 = jyd0;
1341 if( n <= 1) {
1342 if( n == 0) goto END;
1343 PrintFast(2," m");
1344 goto END;
1345 }
1346
1347 PrintFast(2," m");
1348 idx = idy = 0;
1349 for (i=1;i<n;i++) {
1350 ixdi = XtoPS(xw[i]);
1351 iydi = YtoPS(yw[i]);
1352 ix = ixdi - ixd0;
1353 iy = iydi - iyd0;
1354 ixd0 = ixdi;
1355 iyd0 = iydi;
1356 if( ix && iy) {
1357 if( idx ) { MovePS(idx,0); idx = 0; }
1358 if( idy ) { MovePS(0,idy); idy = 0; }
1359 MovePS(ix,iy);
1360 } else if ( ix ) {
1361 if( idy ) { MovePS(0,idy); idy = 0;}
1362 if( !idx ) { idx = ix;}
1363 else if( TMath::Sign(ix,idx) == ix ) idx += ix;
1364 else { MovePS(idx,0); idx = ix;}
1365 } else if( iy ) {
1366 if( idx ) { MovePS(idx,0); idx = 0;}
1367 if( !idy) { idy = iy;}
1368 else if( TMath::Sign(iy,idy) == iy) idy += iy;
1369 else { MovePS(0,idy); idy = iy;}
1370 }
1371 }
1372 if (idx) MovePS(idx,0);
1373 if (idy) MovePS(0,idy);
1374
1375 if (nn > 0 ) {
1376 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(3," cl");
1377 PrintFast(2," s");
1378 } else {
1379 if (fais == 0) {PrintFast(5," cl s"); goto END;}
1380 if (fais == 3 || fais == 2) {
1381 if (fasi > 0 && fasi < 26) {
1382 PrintFast(3," FA");
1383 fRed = -1;
1384 fGreen = -1;
1385 fBlue = -1;
1386 }
1387 goto END;
1388 }
1389 PrintFast(2," f");
1390 }
1391END:
1392 if (nn < 0) {
1395 }
1396}
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Draw Fill area with hatch styles
1400
1402{
1403 Warning("DrawHatch", "hatch fill style not yet implemented");
1404}
1405
1406////////////////////////////////////////////////////////////////////////////////
1407/// Draw Fill area with hatch styles
1408
1410{
1411 Warning("DrawHatch", "hatch fill style not yet implemented");
1412}
1413
1414////////////////////////////////////////////////////////////////////////////////
1415
1417{
1418 std::ifstream font_file(filename, std::ios::binary);
1419
1420 // We cannot read directly using iostream iterators due to
1421 // signedness
1422 font_file.seekg(0, std::ios::end);
1423
1424 const size_t font_file_length = font_file.tellg();
1425
1426 font_file.seekg(0, std::ios::beg);
1427
1428 std::vector<unsigned char> font_data(font_file_length, '\0');
1429
1430 font_file.read(reinterpret_cast<char *>(&font_data[0]),
1432
1433 std::string font_name;
1434 std::string postscript_string =
1435 mathtext::font_embed_postscript_t::font_embed_type_1(
1437
1438 if (!postscript_string.empty()) {
1440 PrintStr("@");
1441
1442 return true;
1443 }
1444
1445 return false;
1446}
1447
1448////////////////////////////////////////////////////////////////////////////////
1449
1451{
1452 std::ifstream font_file(filename, std::ios::binary);
1453
1454 // We cannot read directly using iostream iterators due to
1455 // signedness
1456 font_file.seekg(0, std::ios::end);
1457
1458 const size_t font_file_length = font_file.tellg();
1459
1460 font_file.seekg(0, std::ios::beg);
1461
1462 std::vector<unsigned char> font_data(font_file_length, '\0');
1463
1464 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1465
1466 std::string font_name;
1467 std::string postscript_string =
1468 mathtext::font_embed_postscript_t::font_embed_type_2(font_name, font_data);
1469
1470 if (!postscript_string.empty()) {
1472 PrintStr("@");
1473
1474 return true;
1475 }
1476
1477 return false;
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481
1483{
1484 std::ifstream font_file(filename, std::ios::binary);
1485
1486 // We cannot read directly using iostream iterators due to signedness
1487
1488 font_file.seekg(0, std::ios::end);
1489
1490 const size_t font_file_length = font_file.tellg();
1491
1492 font_file.seekg(0, std::ios::beg);
1493
1494 std::vector<unsigned char> font_data(font_file_length, '\0');
1495
1496 font_file.read(reinterpret_cast<char *>(&font_data[0]), font_file_length);
1497
1498 std::string font_name;
1499 std::string postscript_string =
1500 mathtext::font_embed_postscript_t::font_embed_type_42(font_name, font_data);
1501
1502 if (!postscript_string.empty()) {
1504 PrintStr("@");
1505
1506 return true;
1507 }
1508 fprintf(stderr, "%s:%d:\n", __FILE__, __LINE__);
1509
1510 return false;
1511}
1512
1513////////////////////////////////////////////////////////////////////////////////
1514/// Embed font in PS file.
1515
1517{
1518 static const char *fonttable[32][2] = {
1519 { "Root.TTFont.0", "FreeSansBold.otf" },
1520 { "Root.TTFont.1", "FreeSerifItalic.otf" },
1521 { "Root.TTFont.2", "FreeSerifBold.otf" },
1522 { "Root.TTFont.3", "FreeSerifBoldItalic.otf" },
1523 { "Root.TTFont.4", "FreeSans.otf" },
1524 { "Root.TTFont.5", "FreeSansOblique.otf" },
1525 { "Root.TTFont.6", "FreeSansBold.otf" },
1526 { "Root.TTFont.7", "FreeSansBoldOblique.otf" },
1527 { "Root.TTFont.8", "FreeMono.otf" },
1528 { "Root.TTFont.9", "FreeMonoOblique.otf" },
1529 { "Root.TTFont.10", "FreeMonoBold.otf" },
1530 { "Root.TTFont.11", "FreeMonoBoldOblique.otf" },
1531 { "Root.TTFont.12", "symbol.ttf" },
1532 { "Root.TTFont.13", "FreeSerif.otf" },
1533 { "Root.TTFont.14", "wingding.ttf" },
1534 { "Root.TTFont.15", "symbol.ttf" },
1535 { "Root.TTFont.STIXGen", "STIXGeneral.otf" },
1536 { "Root.TTFont.STIXGenIt", "STIXGeneralItalic.otf" },
1537 { "Root.TTFont.STIXGenBd", "STIXGeneralBol.otf" },
1538 { "Root.TTFont.STIXGenBdIt", "STIXGeneralBolIta.otf" },
1539 { "Root.TTFont.STIXSiz1Sym", "STIXSiz1Sym.otf" },
1540 { "Root.TTFont.STIXSiz1SymBd", "STIXSiz1SymBol.otf" },
1541 { "Root.TTFont.STIXSiz2Sym", "STIXSiz2Sym.otf" },
1542 { "Root.TTFont.STIXSiz2SymBd", "STIXSiz2SymBol.otf" },
1543 { "Root.TTFont.STIXSiz3Sym", "STIXSiz3Sym.otf" },
1544 { "Root.TTFont.STIXSiz3SymBd", "STIXSiz3SymBol.otf" },
1545 { "Root.TTFont.STIXSiz4Sym", "STIXSiz4Sym.otf" },
1546 { "Root.TTFont.STIXSiz4SymBd", "STIXSiz4SymBol.otf" },
1547 { "Root.TTFont.STIXSiz5Sym", "STIXSiz5Sym.otf" },
1548 { "Root.TTFont.ME", "DroidSansFallback.ttf" },
1549 { "Root.TTFont.CJKMing", "DroidSansFallback.ttf" },
1550 { "Root.TTFont.CJKCothic", "DroidSansFallback.ttf" }
1551 };
1552
1553 PrintStr("%%IncludeResource: ProcSet (FontSetInit)@");
1554
1555 // try to load font (font must be in Root.TTFontPath resource)
1556 const char *ttpath = gEnv->GetValue("Root.TTFontPath",
1558
1559 for (Int_t fontid = 1; fontid < 30; fontid++) {
1560 if (fontid != 15 && fMustEmbed[fontid-1]) {
1563 if (!ttfont) {
1564 Error("FontEmbed",
1565 "font %d (filename '%s') not found in path",
1566 fontid, filename.Data());
1567 } else if (FontEmbedType2(ttfont)) {
1568 // nothing
1569 } else if(FontEmbedType1(ttfont)) {
1570 // nothing
1571 } else if(FontEmbedType42(ttfont)) {
1572 // nothing
1573 } else {
1574 Error("FontEmbed",
1575 "failed to embed font %d (filename '%s')",
1576 fontid, filename.Data());
1577 }
1578 }
1579 }
1580 PrintStr("%%IncludeResource: font Times-Roman@");
1581 PrintStr("%%IncludeResource: font Times-Italic@");
1582 PrintStr("%%IncludeResource: font Times-Bold@");
1583 PrintStr("%%IncludeResource: font Times-BoldItalic@");
1584 PrintStr("%%IncludeResource: font Helvetica@");
1585 PrintStr("%%IncludeResource: font Helvetica-Oblique@");
1586 PrintStr("%%IncludeResource: font Helvetica-Bold@");
1587 PrintStr("%%IncludeResource: font Helvetica-BoldOblique@");
1588 PrintStr("%%IncludeResource: font Courier@");
1589 PrintStr("%%IncludeResource: font Courier-Oblique@");
1590 PrintStr("%%IncludeResource: font Courier-Bold@");
1591 PrintStr("%%IncludeResource: font Courier-BoldOblique@");
1592 PrintStr("%%IncludeResource: font Symbol@");
1593 PrintStr("%%IncludeResource: font ZapfDingbats@");
1594
1595 fFontEmbed = kTRUE;
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Font Re-encoding
1600
1602{
1603 PrintStr("/reEncode ");
1604 PrintStr("{exch findfont");
1605 PrintStr(" dup length dict begin");
1606 PrintStr(" {1 index /FID eq ");
1607 PrintStr(" {pop pop}");
1608 PrintStr(" {def} ifelse");
1609 PrintStr(" } forall");
1610 PrintStr(" /Encoding exch def");
1611 PrintStr(" currentdict end");
1612 PrintStr(" dup /FontName get exch");
1613 PrintStr(" definefont pop");
1614 PrintStr(" } def");
1615 PrintStr(" [/Times-Bold /Times-Italic /Times-BoldItalic /Helvetica");
1616 PrintStr(" /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique");
1617 PrintStr(" /Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique");
1618 PrintStr(" /Times-Roman /AvantGarde-Book /AvantGarde-BookOblique");
1619 PrintStr(" /AvantGarde-Demi /AvantGarde-DemiOblique /Bookman-Demi");
1620 PrintStr(" /Bookman-DemiItalic /Bookman-Light /Bookman-LightItalic");
1621 PrintStr(" /Helvetica-Narrow /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique");
1622 PrintStr(" /Helvetica-Narrow-Oblique /NewCenturySchlbk-Roman /NewCenturySchlbk-Bold");
1623 PrintStr(" /NewCenturySchlbk-BoldItalic /NewCenturySchlbk-Italic");
1624 PrintStr(" /Palatino-Bold /Palatino-BoldItalic /Palatino-Italic /Palatino-Roman");
1625 PrintStr(" ] {ISOLatin1Encoding reEncode } forall");
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// PostScript Initialisation
1630///
1631/// This method initialize the following PostScript procedures:
1632///
1633/// | Macro Name | Input parameters | Explanation |
1634/// |------------|------------------|-----------------------------------|
1635/// | l | x y | Draw a line to the x y position |
1636/// | m | x y | Move to the position x y |
1637/// | box | dx dy x y | Define a box |
1638/// | bl | dx dy x y | Draw a line box |
1639/// | bf | dx dy x y | Draw a filled box |
1640/// | t | x y | Translate |
1641/// | r | angle | Rotate |
1642/// | rl | i j | Roll the stack |
1643/// | d | x y | Draw a relative line to x y |
1644/// | X | x | Draw a relative line to x (y=0) |
1645/// | Y | y | Draw a relative line to y (x=0) |
1646/// | rm | x y | Move relatively to x y |
1647/// | gr | | Restore the graphic context |
1648/// | lw | lwidth | Set line width to lwidth |
1649/// | sd | [] 0 | Set dash line define by [] |
1650/// | s | | Stroke mode |
1651/// | c | r g b | Set rgb color to r g b |
1652/// | cl | | Close path |
1653/// | f | | Fill the last describe path |
1654/// | mXX | x y | Draw the marker type XX at (x,y) |
1655/// | Zone | ix iy | Define the current zone |
1656/// | black | | The color is black |
1657/// | C | dx dy x y | Clipping on |
1658/// | NC | | Clipping off |
1659/// | R | | repeat |
1660/// | ita | | Used to make the symbols italic |
1661/// | K | | kshow |
1662
1664{
1666 rpxmin = rpymin = width = heigth = 0;
1667 Int_t format;
1668 fNpages=1;
1669 for (Int_t i=0;i<32;i++) fPatterns[i]=0;
1670
1671 // Mode is last digit of PostScript Workstation type
1672 // mode=1,2 for portrait/landscape black and white
1673 // mode=3 for Encapsulated PostScript File
1674 // mode=4 for portrait colour
1675 // mode=5 for lanscape colour
1676 Int_t atype = abs(fType);
1677 fMode = atype%10;
1678 if( fMode <= 0 || fMode > 5) {
1679 Error("Initialize", "invalid file type %d", fMode);
1680 return;
1681 }
1682
1683 // fNXzone (fNYzone) is the total number of windows in x (y)
1684 fNXzone = (atype%1000)/100;
1685 fNYzone = (atype%100)/10;
1686 if( fNXzone <= 0 ) fNXzone = 1;
1687 if( fNYzone <= 0 ) fNYzone = 1;
1688 fIXzone = 1;
1689 fIYzone = 1;
1690
1691 // format = 0-99 is the European page format (A4,A3 ...)
1692 // format = 100 is the US format 8.5x11.0 inch
1693 // format = 200 is the US format 8.5x14.0 inch
1694 // format = 300 is the US format 11.0x17.0 inch
1695 format = atype/1000;
1696 if( format == 0 ) format = 4;
1697 if( format == 99 ) format = 0;
1698
1699 PrintStr("%%Title: ");
1700 const char *pstitle = gStyle->GetTitlePS();
1701 if (gPad && !pstitle[0]) pstitle = gPad->GetMother()->GetTitle();
1702 if (strlen(GetName())<=80) PrintStr(GetName());
1703 if(!pstitle[0] && fMode != 3) {;
1704 PrintFast(2," (");
1705 if ( format <= 99 ) {;
1706 PrintFast(2," A");
1708 PrintFast(1,")");
1709 }
1710 else {
1711 if ( format == 100 ) PrintFast(8," Letter)");
1712 if ( format == 200 ) PrintFast(7," Legal)");
1713 if ( format == 300 ) PrintFast(8," Ledger)");
1714 }
1715 PrintStr("@");
1716 PrintStr("%%Pages: (atend)@");
1717 }
1718 else {
1719 if (!strchr(pstitle,'\n')) {
1720 PrintFast(2,": ");
1722 }
1723 PrintStr("@");
1724 }
1725
1726 PrintFast(24,"%%Creator: ROOT Version ");
1727 PrintStr(gROOT->GetVersion());
1728 PrintStr("@");
1729 PrintFast(16,"%%CreationDate: ");
1730 TDatime t;
1731 PrintStr(t.AsString());
1732 PrintStr("@");
1733
1734 if (fMode == 1 || fMode == 4)
1735 PrintStr("%%Orientation: Portrait@");
1736 if (fMode == 2 || fMode == 5)
1737 PrintStr("%%Orientation: Landscape@");
1738
1739 PrintStr("%%EndComments@");
1740 PrintStr("%%BeginProlog@");
1741
1742 if(fMode == 3)
1743 PrintStr("80 dict begin@");
1744
1745 // Initialisation of PostScript procedures
1746 PrintStr("/s {stroke} def /l {lineto} def /m {moveto} def /t {translate} def@");
1747 PrintStr("/r {rotate} def /rl {roll} def /R {repeat} def@");
1748 PrintStr("/d {rlineto} def /rm {rmoveto} def /gr {grestore} def /f {eofill} def@");
1749 if (gStyle->GetColorModelPS()) {
1750 PrintStr("/c {setcmykcolor} def /black {0 0 0 1 setcmykcolor} def /sd {setdash} def@");
1751 } else {
1752 PrintStr("/c {setrgbcolor} def /black {0 setgray} def /sd {setdash} def@");
1753 }
1754 PrintStr("/cl {closepath} def /sf {scalefont setfont} def /lw {setlinewidth} def@");
1755 PrintStr("/box {m dup 0 exch d exch 0 d 0 exch neg d cl} def@");
1756 PrintStr("/NC{systemdict begin initclip end}def/C{NC box clip newpath}def@");
1757 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@");
1758 PrintStr("/K {{pop pop 0 moveto} exch kshow} bind def@");
1759 PrintStr("/ita {/ang 15 def gsave [1 0 ang dup sin exch cos div 1 0 0] concat} def@");
1760
1761 FontEncode();
1762
1763 // mode=1 for portrait black/white
1764 if (fMode == 1) {
1765 rpxmin = 0.7;
1767 switch (format) {
1768 case 100 :
1769 width = (8.5*2.54)-2.*rpxmin;
1770 heigth = (11.*2.54)-2.*rpymin;
1771 break;
1772 case 200 :
1773 width = (8.5*2.54)-2.*rpxmin;
1774 heigth = (14.*2.54)-2.*rpymin;
1775 break;
1776 case 300 :
1777 width = (11.*2.54)-2.*rpxmin;
1778 heigth = (17.*2.54)-2.*rpymin;
1779 break;
1780 default :
1781 width = 21.0-2.*rpxmin;
1782 heigth = 29.7-2.*rpymin;
1783 };
1784 }
1785
1786 // mode=2 for landscape black/white
1787 if (fMode == 2) {
1788 rpymin = 0.7;
1790 switch (format) {
1791 case 100 :
1792 width = (11.*2.54)-2.*rpxmin;
1793 heigth = (8.5*2.54)-2.*rpymin;
1794 break;
1795 case 200 :
1796 width = (14.*2.54)-2.*rpxmin;
1797 heigth = (8.5*2.54)-2.*rpymin;
1798 break;
1799 case 300 :
1800 width = (17.*2.54)-2.*rpxmin;
1801 heigth = (11.*2.54)-2.*rpymin;
1802 break;
1803 default :
1804 width = 29.7-2.*rpxmin;
1805 heigth = 21-2.*rpymin;
1806 };
1807 }
1808
1809 // mode=3 encapsulated PostScript
1810 if (fMode == 3) {
1811 width = 20;
1812 heigth = 20;
1813 format = 4;
1814 fNXzone = 1;
1815 fNYzone = 1;
1816 }
1817
1818 // mode=4 for portrait colour
1819 if (fMode == 4) {
1820 rpxmin = 0.7;
1821 rpymin = 3.4;
1822 switch (format) {
1823 case 100 :
1824 width = (8.5*2.54)-2.*rpxmin;
1825 heigth = (11.*2.54)-2.*rpymin;
1826 break;
1827 case 200 :
1828 width = (8.5*2.54)-2.*rpxmin;
1829 heigth = (14.*2.54)-2.*rpymin;
1830 break;
1831 case 300 :
1832 width = (11.*2.54)-2.*rpxmin;
1833 heigth = (17.*2.54)-2.*rpymin;
1834 break;
1835 default :
1836 width = (21.0-2*rpxmin);
1837 heigth = (29.7-2.*rpymin);
1838 };
1839 }
1840
1841 // mode=5 for lanscape colour
1842 if (fMode == 5) {
1843 rpxmin = 3.4;
1844 rpymin = 0.7;
1845 switch (format) {
1846 case 100 :
1847 width = (11.*2.54)-2.*rpxmin;
1848 heigth = (8.5*2.54)-2.*rpymin;
1849 break;
1850 case 200 :
1851 width = (14.*2.54)-2.*rpxmin;
1852 heigth = (8.5*2.54)-2.*rpymin;
1853 break;
1854 case 300 :
1855 width = (17.*2.54)-2.*rpxmin;
1856 heigth = (11.*2.54)-2.*rpymin;
1857 break;
1858 default :
1859 width = (29.7-2*rpxmin);
1860 heigth = (21-2.*rpymin);
1861 };
1862 }
1863
1864 Double_t value = 0;
1865 if (format < 100) value = 21*TMath::Power(TMath::Sqrt(2.), 4-format);
1866 else if (format == 100) value = 8.5*2.54;
1867 else if (format == 200) value = 8.5*2.54;
1868 else if (format == 300) value = 11.*2.54;
1869 if (format >= 100) format = 4;
1870
1871 // Compute size (in points) of the window for each picture = f(fNXzone,fNYzone)
1874 Int_t npx = 4*CMtoPS(sizex);
1875 Int_t npy = 4*CMtoPS(sizey);
1876 if (sizex > sizey) fMaxsize = CMtoPS(sizex);
1877 else fMaxsize = CMtoPS(sizey);
1878
1879 // Procedure Zone
1880 if (fMode != 3) {
1881 PrintFast(33,"/Zone {/iy exch def /ix exch def ");
1882 PrintFast(10," ix 1 sub ");
1884 PrintFast(5," mul ");
1886 PrintFast(8," iy sub ");
1888 PrintStr(" mul t} def@");
1889 } else {
1890 PrintStr("@");
1891 }
1892
1893 PrintStr("%%EndProlog@");
1894 PrintStr("%%BeginSetup@");
1895 PrintStr("%%EndSetup@");
1896 PrintFast(8,"newpath ");
1897 SaveRestore(1);
1898 if (fMode == 1 || fMode == 4) {
1901 PrintFast(2," t");
1902 }
1903 if (fMode == 2 || fMode == 5) {
1904 PrintFast(7," 90 r 0");
1906 PrintFast(3," t ");
1909 PrintFast(2," t");
1910 }
1911
1912 PrintFast(15," .25 .25 scale ");
1913 if (fMode != 3) {
1914 SaveRestore(1);
1915 PrintStr("@");
1916 PrintStr("%%Page: 1 1@");
1917 SaveRestore(1);
1918 }
1919
1920 //Check is user has defined a special header in the current style
1922 if (nh) {
1924 if (fMode != 3) SaveRestore(1);
1925 }
1926}
1927
1928////////////////////////////////////////////////////////////////////////////////
1929/// Move to a new position
1930
1932{
1933 if (ix != 0 && iy != 0) {
1934 WriteInteger(ix);
1935 WriteInteger(iy);
1936 PrintFast(2," d");
1937 } else if (ix != 0) {
1938 WriteInteger(ix);
1939 PrintFast(2," X");
1940 } else if (iy != 0) {
1941 WriteInteger(iy);
1942 PrintFast(2," Y");
1943 }
1944}
1945
1946////////////////////////////////////////////////////////////////////////////////
1947/// Move to a new PostScript page
1948
1950{
1951 // Compute pad conversion coefficients
1952 if (gPad) {
1953 // if (!gPad->GetPadPaint()) gPad->Update();
1954 Double_t ww = gPad->GetWw();
1955 Double_t wh = gPad->GetWh();
1956 fYsize = fXsize*wh/ww;
1957 } else fYsize = 27;
1958
1959 if(fType == 113 && !fBoundingBox) {
1961 PrintStr("@%%BoundingBox: ");
1962 Double_t xlow=0, ylow=0, xup=1, yup=1;
1963 if (gPad) {
1964 xlow = gPad->GetAbsXlowNDC();
1965 xup = xlow + gPad->GetAbsWNDC();
1966 ylow = gPad->GetAbsYlowNDC();
1967 yup = ylow + gPad->GetAbsHNDC();
1968 }
1969 WriteInteger(CMtoPS(fXsize*xlow));
1970 WriteInteger(CMtoPS(fYsize*ylow));
1973 PrintStr("@");
1974 Initialize();
1976 fPrinted = psave;
1977 }
1978 if (fPrinted) {
1979 if (fSave) SaveRestore(-1);
1980 fClear = kTRUE;
1981 fPrinted = kFALSE;
1982 }
1983 Zone();
1984}
1985
1986////////////////////////////////////////////////////////////////////////////////
1987/// Set the range for the paper in centimeters
1988
1990{
1991 Float_t xps=0, yps=0, xncm=0, yncm=0, dxwn=0, dywn=0, xwkwn=0, ywkwn=0, xymax=0;
1992
1993 fXsize = xsize;
1994 fYsize = ysize;
1995 if( fType != 113) { xps = fXsize; yps = fYsize; }
1996 else { xps = xsize; yps = ysize; }
1997
1998 if( xsize <= xps && ysize < yps) {
1999 if ( xps > yps ) xymax = xps;
2000 else xymax = yps;
2001 xncm = xsize/xymax;
2002 yncm = ysize/xymax;
2003 dxwn = ((xps/xymax)-xncm)/2;
2004 dywn = ((yps/xymax)-yncm)/2;
2005 } else {
2006 if (xps/yps < 1) xwkwn = xps/yps;
2007 else xwkwn = 1;
2008 if (yps/xps < 1) ywkwn = yps/xps;
2009 else ywkwn = 1;
2010
2011 if (xsize < ysize) {
2013 yncm = ywkwn;
2014 dxwn = (xwkwn-xncm)/2;
2015 dywn = 0;
2016 if( dxwn < 0) {
2017 xncm = xwkwn;
2018 dxwn = 0;
2020 dywn = (ywkwn-yncm)/2;
2021 }
2022 } else {
2023 xncm = xwkwn;
2025 dxwn = 0;
2026 dywn = (ywkwn-yncm)/2;
2027 if( dywn < 0) {
2028 yncm = ywkwn;
2029 dywn = 0;
2031 dxwn = (xwkwn-xncm)/2;
2032 }
2033 }
2034 }
2035 fXVP1 = dxwn;
2036 fXVP2 = xncm+dxwn;
2037 fYVP1 = dywn;
2038 fYVP2 = yncm+dywn;
2039 fRange = kTRUE;
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Compute number of gsaves for restore
2044/// This allows to write the correct number of grestore at the
2045/// end of the PS file.
2046
2048{
2049 if (flag == 1) { PrintFast(7," gsave "); fSave++; }
2050 else { PrintFast(4," gr "); fSave--; }
2051}
2052
2053////////////////////////////////////////////////////////////////////////////////
2054/// Set color index for fill areas
2055
2057{
2059 if (gStyle->GetFillColor() <= 0) cindex = 0;
2060}
2061
2062////////////////////////////////////////////////////////////////////////////////
2063/// Patterns definition
2064///
2065/// Define the pattern ipat in the current PS file. ipat can vary from
2066/// 1 to 25. Together with the pattern, the color (color) in which the
2067/// pattern has to be drawn is also required. A pattern is defined in the
2068/// current PS file only the first time it is used. Some level 2
2069/// Postscript functions are used, so on level 1 printers, patterns will
2070/// not work. This is not a big problem because patterns are
2071/// defined only if they are used, so if they are not used a PS level 1
2072/// file will not be polluted by level 2 features, and in any case the old
2073/// patterns used a lot of memory which made them almost unusable on old
2074/// level 1 printers. Finally we should say that level 1 devices are
2075/// becoming very rare. The official PostScript is now level 3 !
2076
2078{
2079 char cdef[28];
2080 char cpat[5];
2081 snprintf(cpat,5," P%2.2d", ipat);
2082
2083 // fPatterns is used as an array of chars. If fPatterns[ipat] != 0 the
2084 // pattern number ipat as already be defined is this file and it
2085 // is not necessary to redefine it. fPatterns is set to zero in Initialize.
2086 // The pattern number 26 allows to know if the macro "cs" has already
2087 // been defined in the current file (see label 200).
2088 if (fPatterns[ipat] == 0) {
2089
2090 // Define the Patterns. Line width must be 1
2091 // Setting fLineWidth to -1 will force the line width definition next time
2092 // TPostScript::SetLineWidth will be called.
2093 fLineWidth = -1;
2094 PrintFast(5," 1 lw");
2095 PrintStr(" << /PatternType 1 /PaintType 2 /TilingType 1");
2096 switch (ipat) {
2097 case 1 :
2098 PrintStr(" /BBox [ 0 0 98 4 ]");
2099 PrintStr(" /XStep 98 /YStep 4");
2100 PrintStr(" /PaintProc { begin gsave");
2101 PrintStr(" [1] 0 sd 2 4 m 99 4 l s 1 3 m 98 3 l s");
2102 PrintStr(" 2 2 m 99 2 l s 1 1 m 98 1 l s");
2103 PrintStr(" gr end } >> [ 4.0 0 0 4.0 0 0 ]");
2104 break;
2105 case 2 :
2106 PrintStr(" /BBox [ 0 0 96 4 ]");
2107 PrintStr(" /XStep 96 /YStep 4");
2108 PrintStr(" /PaintProc { begin gsave");
2109 PrintStr(" [1 3] 0 sd 2 4 m 98 4 l s 0 3 m 96 3 l s");
2110 PrintStr(" 2 2 m 98 2 l s 0 1 m 96 1 l s");
2111 PrintStr(" gr end } >> [ 3.0 0 0 3.0 0 0 ]");
2112 break;
2113 case 3 :
2114 PrintStr(" /BBox [ 0 0 96 16 ]");
2115 PrintStr(" /XStep 96 /YStep 16");
2116 PrintStr(" /PaintProc { begin gsave");
2117 PrintStr(" [1 3] 0 sd 2 13 m 98 13 l s 0 9 m 96 9 l s");
2118 PrintStr(" 2 5 m 98 5 l s 0 1 m 96 1 l s");
2119 PrintStr(" gr end } >> [ 2.0 0 0 2.0 0 0 ]");
2120 break;
2121 case 4 :
2122 PrintStr(" /BBox [ 0 0 100 100 ]");
2123 PrintStr(" /XStep 100 /YStep 100");
2124 PrintStr(" /PaintProc { begin gsave");
2125 PrintStr(" 0 0 m 100 100 l s");
2126 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2127 break;
2128 case 5 :
2129 PrintStr(" /BBox [ 0 0 100 100 ]");
2130 PrintStr(" /XStep 100 /YStep 100");
2131 PrintStr(" /PaintProc { begin gsave");
2132 PrintStr(" 0 100 m 100 0 l s");
2133 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2134 break;
2135 case 6 :
2136 PrintStr(" /BBox [ 0 0 100 100 ]");
2137 PrintStr(" /XStep 100 /YStep 100");
2138 PrintStr(" /PaintProc { begin gsave");
2139 PrintStr(" 50 0 m 50 100 l s");
2140 PrintStr(" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2141 break;
2142 case 7 :
2143 PrintStr(" /BBox [ 0 0 100 100 ]");
2144 PrintStr(" /XStep 100 /YStep 100");
2145 PrintStr(" /PaintProc { begin gsave");
2146 PrintStr(" 0 50 m 100 50 l s");
2147 PrintStr(" gr end } >> [ 0.12 0 0 0.12 0 0 ]");
2148 break;
2149 case 8 :
2150 PrintStr(" /BBox [ 0 0 101 101 ]");
2151 PrintStr(" /XStep 100 /YStep 100");
2152 PrintStr(" /PaintProc { begin gsave");
2153 PrintStr(" 0 0 m 0 30 l 30 0 l f 0 70 m 0 100 l 30 100 l f");
2154 PrintStr(" 70 100 m 100 100 l 100 70 l f 70 0 m 100 0 l");
2155 PrintStr(" 100 30 l f 50 20 m 20 50 l 50 80 l 80 50 l f");
2156 PrintStr(" 50 80 m 30 100 l s 20 50 m 0 30 l s 50 20 m");
2157 PrintStr(" 70 0 l s 80 50 m 100 70 l s");
2158 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2159 break;
2160 case 9 :
2161 PrintStr(" /BBox [ 0 0 100 100 ]");
2162 PrintStr(" /XStep 100 /YStep 100");
2163 PrintStr(" /PaintProc { begin gsave");
2164 PrintStr(" 0 50 m 50 50 50 180 360 arc");
2165 PrintStr(" 0 50 m 0 100 50 270 360 arc");
2166 PrintStr(" 50 100 m 100 100 50 180 270 arc s");
2167 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2168 break;
2169 case 10 :
2170 PrintStr(" /BBox [ 0 0 100 100 ]");
2171 PrintStr(" /XStep 100 /YStep 100");
2172 PrintStr(" /PaintProc { begin gsave");
2173 PrintStr(" 0 50 m 100 50 l 1 1 m 100 1 l");
2174 PrintStr(" 0 0 m 0 50 l 100 0 m 100 50 l");
2175 PrintStr(" 50 50 m 50 100 l s");
2176 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2177 break;
2178 case 11 :
2179 PrintStr(" /BBox [ 0 0 100 100 ]");
2180 PrintStr(" /XStep 100 /YStep 100");
2181 PrintStr(" /PaintProc { begin gsave");
2182 PrintStr(" 0 0 m 0 20 l 50 0 m 50 20 l");
2183 PrintStr(" 100 0 m 100 20 l 0 80 m 0 100 l");
2184 PrintStr(" 50 80 m 50 100 l 100 80 m 100 100 l");
2185 PrintStr(" 25 30 m 25 70 l 75 30 m 75 70 l");
2186 PrintStr(" 0 100 m 20 85 l 50 100 m 30 85 l");
2187 PrintStr(" 50 100 m 70 85 l 100 100 m 80 85 l");
2188 PrintStr(" 0 0 m 20 15 l 50 0 m 30 15 l");
2189 PrintStr(" 50 0 m 70 15 l 100 0 m 80 15 l");
2190 PrintStr(" 5 35 m 45 65 l 5 65 m 45 35 l");
2191 PrintStr(" 55 35 m 95 65 l 55 65 m 95 35 l s");
2192 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2193 break;
2194 case 12 :
2195 PrintStr(" /BBox [ 0 0 100 100 ]");
2196 PrintStr(" /XStep 100 /YStep 100");
2197 PrintStr(" /PaintProc { begin gsave");
2198 PrintStr(" 0 80 m 0 100 20 270 360 arc");
2199 PrintStr(" 30 100 m 50 100 20 180 360 arc");
2200 PrintStr(" 80 100 m 100 100 20 180 270 arc");
2201 PrintStr(" 20 0 m 0 0 20 0 90 arc");
2202 PrintStr(" 70 0 m 50 0 20 0 180 arc");
2203 PrintStr(" 100 20 m 100 0 20 90 180 arc");
2204 PrintStr(" 45 50 m 25 50 20 0 360 arc");
2205 PrintStr(" 95 50 m 75 50 20 0 360 arc s");
2206 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2207 break;
2208 case 13 :
2209 PrintStr(" /BBox [ 0 0 100 100 ]");
2210 PrintStr(" /XStep 100 /YStep 100");
2211 PrintStr(" /PaintProc { begin gsave");
2212 PrintStr(" 0 0 m 100 100 l 0 100 m 100 0 l s");
2213 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2214 break;
2215 case 14 :
2216 PrintStr(" /BBox [ 0 0 100 100 ]");
2217 PrintStr(" /XStep 80 /YStep 80");
2218 PrintStr(" /PaintProc { begin gsave");
2219 PrintStr(" 0 20 m 100 20 l 20 0 m 20 100 l");
2220 PrintStr(" 0 80 m 100 80 l 80 0 m 80 100 l");
2221 PrintStr(" 20 40 m 60 40 l 60 20 m 60 60 l");
2222 PrintStr(" 40 40 m 40 80 l 40 60 m 80 60 l s");
2223 PrintStr(" gr end } >> [ 0.60 0 0 0.60 0 0 ]");
2224 break;
2225 case 15 :
2226 PrintStr(" /BBox [ 0 0 60 60 ]");
2227 PrintStr(" /XStep 60 /YStep 60");
2228 PrintStr(" /PaintProc { begin gsave");
2229 PrintStr(" 0 55 m 0 60 5 270 360 arc");
2230 PrintStr(" 25 60 m 30 60 5 180 360 arc");
2231 PrintStr(" 55 60 m 60 60 5 180 270 arc");
2232 PrintStr(" 20 30 m 15 30 5 0 360 arc");
2233 PrintStr(" 50 30 m 45 30 5 0 360");
2234 PrintStr(" arc 5 0 m 0 0 5 0 90 arc");
2235 PrintStr(" 35 0 m 30 0 5 0 180 arc");
2236 PrintStr(" 60 5 m 60 0 5 90 180 arc s");
2237 PrintStr(" gr end } >> [ 0.41 0 0 0.41 0 0 ]");
2238 break;
2239 case 16 :
2240 PrintStr(" /BBox [ 0 0 100 100 ]");
2241 PrintStr(" /XStep 100 /YStep 100");
2242 PrintStr(" /PaintProc { begin gsave");
2243 PrintStr(" 50 50 m 25 50 25 0 180 arc s");
2244 PrintStr(" 50 50 m 75 50 25 180 360 arc s");
2245 PrintStr(" gr end } >> [ 0.4 0 0 0.2 0 0 ]");
2246 break;
2247 case 17 :
2248 PrintStr(" /BBox [ 0 0 100 100 ]");
2249 PrintStr(" /XStep 100 /YStep 100");
2250 PrintStr(" /PaintProc { begin gsave");
2251 PrintStr(" [24] 0 setdash 0 0 m 100 100 l s");
2252 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2253 break;
2254 case 18 :
2255 PrintStr(" /BBox [ 0 0 100 100 ]");
2256 PrintStr(" /XStep 100 /YStep 100");
2257 PrintStr(" /PaintProc { begin gsave");
2258 PrintStr(" [24] 0 setdash 0 100 m 100 0 l s");
2259 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2260 break;
2261 case 19 :
2262 PrintStr(" /BBox [ 0 0 100 100 ]");
2263 PrintStr(" /XStep 100 /YStep 100");
2264 PrintStr(" /PaintProc { begin gsave");
2265 PrintStr(" 90 50 m 50 50 40 0 360 arc");
2266 PrintStr(" 0 50 m 0 100 50 270 360 arc");
2267 PrintStr(" 50 0 m 0 0 50 0 90 arc");
2268 PrintStr(" 100 50 m 100 0 50 90 180 arc");
2269 PrintStr(" 50 100 m 100 100 50 180 270 arc s");
2270 PrintStr(" gr end } >> [ 0.47 0 0 0.47 0 0 ]");
2271 break;
2272 case 20 :
2273 PrintStr(" /BBox [ 0 0 100 100 ]");
2274 PrintStr(" /XStep 100 /YStep 100");
2275 PrintStr(" /PaintProc { begin gsave");
2276 PrintStr(" 50 50 m 50 75 25 270 450 arc s");
2277 PrintStr(" 50 50 m 50 25 25 90 270 arc s");
2278 PrintStr(" gr end } >> [ 0.2 0 0 0.4 0 0 ]");
2279 break;
2280 case 21 :
2281 PrintStr(" /BBox [ 0 0 101 101 ]");
2282 PrintStr(" /XStep 100 /YStep 100");
2283 PrintStr(" /PaintProc { begin gsave");
2284 PrintStr(" 1 1 m 25 1 l 25 25 l 50 25 l 50 50 l");
2285 PrintStr(" 75 50 l 75 75 l 100 75 l 100 100 l");
2286 PrintStr(" 50 1 m 75 1 l 75 25 l 100 25 l 100 50 l");
2287 PrintStr(" 0 50 m 25 50 l 25 75 l 50 75 l 50 100 l s");
2288 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2289 break;
2290 case 22 :
2291 PrintStr(" /BBox [ 0 0 101 101 ]");
2292 PrintStr(" /XStep 100 /YStep 100");
2293 PrintStr(" /PaintProc { begin gsave");
2294 PrintStr(" 1 100 m 25 100 l 25 75 l 50 75 l 50 50 l");
2295 PrintStr(" 75 50 l 75 25 l 100 25 l 100 1 l");
2296 PrintStr(" 50 100 m 75 100 l 75 75 l 100 75 l 100 50 l");
2297 PrintStr(" 0 50 m 25 50 l 25 25 l 50 25 l 50 1 l s");
2298 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2299 break;
2300 case 23 :
2301 PrintStr(" /BBox [ 0 0 100 100 ]");
2302 PrintStr(" /XStep 100 /YStep 100");
2303 PrintStr(" /PaintProc { begin gsave");
2304 PrintStr(" [1 7] 0 sd 0 8 50 { dup dup m 2 mul 0 l s } for");
2305 PrintStr(" 0 8 50 { dup dup 2 mul 100 m 50 add exch 50");
2306 PrintStr(" add l s } for 100 0 m 100 100 l 50 50 l f");
2307 PrintStr(" gr end } >> [ 0.24 0 0 0.24 0 0 ]");
2308 break;
2309 case 24 :
2310 PrintStr(" /BBox [ 0 0 100 100 ]");
2311 PrintStr(" /XStep 100 /YStep 100");
2312 PrintStr(" /PaintProc { begin gsave");
2313 PrintStr(" 100 100 m 100 36 l 88 36 l 88 88 l f");
2314 PrintStr(" 100 0 m 100 12 l 56 12 l 50 0 l f");
2315 PrintStr(" 0 0 m 48 0 l 48 48 l 50 48 l 56 60 l");
2316 PrintStr(" 36 60 l 36 12 l 0 12 l f [1 7] 0 sd");
2317 PrintStr(" 61 8 87 { dup dup dup 12 exch m 88 exch l s");
2318 PrintStr(" 16 exch 4 sub m 88 exch 4 sub l s } for");
2319 PrintStr(" 13 8 35 { dup dup dup 0 exch m 36 exch l s");
2320 PrintStr(" 4 exch 4 sub m 36 exch 4 sub l s } for");
2321 PrintStr(" 37 8 59 { dup dup dup 12 exch m 36 exch l s");
2322 PrintStr(" 16 exch 4 sub m 36 exch 4 sub l s } for");
2323 PrintStr(" 13 8 60 { dup dup dup 56 exch m 100 exch l s");
2324 PrintStr(" 60 exch 4 sub m 100 exch 4 sub l s } for");
2325 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2326 break;
2327 case 25 :
2328 PrintStr(" /BBox [ 0 0 101 101 ]");
2329 PrintStr(" /XStep 100 /YStep 100");
2330 PrintStr(" /PaintProc { begin gsave");
2331 PrintStr(" 0 0 m 30 30 l 70 30 l 70 70 l 100 100 l 100 0 l");
2332 PrintStr(" f 30 30 m 30 70 l 70 70 l f");
2333 PrintStr(" gr end } >> [ 0.5 0 0 0.5 0 0 ]");
2334 };
2335 snprintf(cdef,28," makepattern /%s exch def",&cpat[1]);
2336 PrintStr(cdef);
2337 fPatterns[ipat] = 1;
2338 }
2339
2340 // Define the macro cs and FA if they are not yet defined.
2341 if (fPatterns[26] == 0) {
2342 if (gStyle->GetColorModelPS()) {
2343 PrintStr(" /cs {[/Pattern /DeviceCMYK] setcolorspace} def");
2344 PrintStr(" /FA {f [/DeviceCMYK] setcolorspace} def");
2345 } else {
2346 PrintStr(" /cs {[/Pattern /DeviceRGB] setcolorspace} def");
2347 PrintStr(" /FA {f [/DeviceRGB] setcolorspace} def");
2348 }
2349 fPatterns[26] = 1;
2350 }
2351
2352 // Activate the pattern.
2353 PrintFast(3," cs");
2354 TColor *col = gROOT->GetColor(color);
2355 if (col) {
2356 Double_t colRed = col->GetRed();
2357 Double_t colGreen = col->GetGreen();
2358 Double_t colBlue = col->GetBlue();
2359 if (gStyle->GetColorModelPS()) {
2361 if (colBlack==1) {
2362 WriteReal(0);
2363 WriteReal(0);
2364 WriteReal(0);
2366 } else {
2374 }
2375 } else {
2379 }
2380 }
2381 PrintFast(4,cpat);
2382 PrintFast(9," setcolor");
2383}
2384
2385////////////////////////////////////////////////////////////////////////////////
2386/// Set color index for lines
2387
2392
2393////////////////////////////////////////////////////////////////////////////////
2394/// Set the value of the global parameter TPostScript::fgLineJoin.
2395/// This parameter determines the appearance of joining lines in a PostScript
2396/// output.
2397/// It takes one argument which may be:
2398/// - 0 (miter join)
2399/// - 1 (round join)
2400/// - 2 (bevel join)
2401/// The default value is 0 (miter join).
2402///
2403/// \image html postscript_1.png
2404///
2405/// To change the line join behaviour just do:
2406/// ~~~ {.cpp}
2407/// gStyle->SetJoinLinePS(2); // Set the PS line join to bevel.
2408/// ~~~
2409
2411{
2413 if (fgLineJoin<0) fgLineJoin=0;
2414 if (fgLineJoin>2) fgLineJoin=2;
2415}
2416
2417////////////////////////////////////////////////////////////////////////////////
2418/// Set the value of the global parameter TPostScript::fgLineCap.
2419/// This parameter determines the appearance of line caps in a PostScript
2420/// output.
2421/// It takes one argument which may be:
2422/// - 0 (butt caps)
2423/// - 1 (round caps)
2424/// - 2 (projecting caps)
2425/// The default value is 0 (butt caps).
2426///
2427/// \image html postscript_2.png
2428///
2429/// To change the line cap behaviour just do:
2430/// ~~~ {.cpp}
2431/// gStyle->SetCapLinePS(2); // Set the PS line cap to projecting.
2432/// ~~~
2433
2435{
2437 if (fgLineCap<0) fgLineCap=0;
2438 if (fgLineCap>2) fgLineCap=2;
2439}
2440
2441////////////////////////////////////////////////////////////////////////////////
2442/// Change the line style
2443///
2444/// - linestyle = 2 dashed
2445/// - linestyle = 3 dotted
2446/// - linestyle = 4 dash-dotted
2447/// - linestyle = else = solid
2448///
2449/// See TStyle::SetLineStyleString for style definition
2450
2456
2457////////////////////////////////////////////////////////////////////////////////
2458/// Change the line style in the output file
2459
2461{
2462 if (linestyle == fStyle) return;
2463
2464 fStyle = linestyle;
2465
2466 const char *st = gStyle->GetLineStyleString(fStyle);
2467 PrintFast(1,"[");
2468 Int_t nch = strlen(st);
2469 PrintFast(nch,st);
2470 PrintFast(6,"] 0 sd");
2471}
2472
2473////////////////////////////////////////////////////////////////////////////////
2474/// Change the line width
2475
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Change the line width in the output file
2484
2486{
2487 if (linewidth == fWidth) return;
2488
2489 fWidth = linewidth;
2490
2491 if (fWidth!=0) {
2493 PrintFast(3," lw");
2494 }
2495}
2496
2497////////////////////////////////////////////////////////////////////////////////
2498/// Set color index for markers
2499
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Set the current color.
2507
2509{
2510 if (color < 0) color = 0;
2511 TColor *col = gROOT->GetColor(color);
2512 if (col)
2513 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
2514 else
2515 SetColor(1., 1., 1.);
2516}
2517
2518////////////////////////////////////////////////////////////////////////////////
2519/// Set directly current color (don't go via TColor).
2520
2522{
2523 if (r == fRed && g == fGreen && b == fBlue) return;
2524
2525 fRed = r;
2526 fGreen = g;
2527 fBlue = b;
2528
2529 if (fRed <= 0 && fGreen <= 0 && fBlue <= 0 ) {
2530 PrintFast(6," black");
2531 } else {
2532 if (gStyle->GetColorModelPS()) {
2541 } else {
2542 WriteReal(fRed);
2545 }
2546 PrintFast(2," c");
2547 }
2548}
2549
2550////////////////////////////////////////////////////////////////////////////////
2551/// Set color index for text
2552
2557
2558////////////////////////////////////////////////////////////////////////////////
2559/// Write a string of characters
2560///
2561/// This method writes the string chars into a PostScript file
2562/// at position xx,yy in world coordinates.
2563
2565{
2566 static const char *psfont[31][2] = {
2567 { "Root.PSFont.1", "/Times-Italic" },
2568 { "Root.PSFont.2", "/Times-Bold" },
2569 { "Root.PSFont.3", "/Times-BoldItalic" },
2570 { "Root.PSFont.4", "/Helvetica" },
2571 { "Root.PSFont.5", "/Helvetica-Oblique" },
2572 { "Root.PSFont.6", "/Helvetica-Bold" },
2573 { "Root.PSFont.7", "/Helvetica-BoldOblique" },
2574 { "Root.PSFont.8", "/Courier" },
2575 { "Root.PSFont.9", "/Courier-Oblique" },
2576 { "Root.PSFont.10", "/Courier-Bold" },
2577 { "Root.PSFont.11", "/Courier-BoldOblique" },
2578 { "Root.PSFont.12", "/Symbol" },
2579 { "Root.PSFont.13", "/Times-Roman" },
2580 { "Root.PSFont.14", "/ZapfDingbats" },
2581 { "Root.PSFont.15", "/Symbol" },
2582 { "Root.PSFont.STIXGen", "/STIXGeneral" },
2583 { "Root.PSFont.STIXGenIt", "/STIXGeneral-Italic" },
2584 { "Root.PSFont.STIXGenBd", "/STIXGeneral-Bold" },
2585 { "Root.PSFont.STIXGenBdIt", "/STIXGeneral-BoldItalic" },
2586 { "Root.PSFont.STIXSiz1Sym", "/STIXSize1Symbols" },
2587 { "Root.PSFont.STIXSiz1SymBd", "/STIXSize1Symbols-Bold" },
2588 { "Root.PSFont.STIXSiz2Sym", "/STIXSize2Symbols" },
2589 { "Root.PSFont.STIXSiz2SymBd", "/STIXSize2Symbols-Bold" },
2590 { "Root.PSFont.STIXSiz3Sym", "/STIXSize3Symbols" },
2591 { "Root.PSFont.STIXSiz3SymBd", "/STIXSize3Symbols-Bold" },
2592 { "Root.PSFont.STIXSiz4Sym", "/STIXSize4Symbols" },
2593 { "Root.PSFont.STIXSiz4SymBd", "/STIXSize4Symbols-Bold" },
2594 { "Root.PSFont.STIXSiz5Sym", "/STIXSize5Symbols" },
2595 { "Root.PSFont.ME", "/DroidSansFallback" },
2596 { "Root.PSFont.CJKMing", "/DroidSansFallback" },
2597 { "Root.PSFont.CJKGothic", "/DroidSansFallback" }
2598 };
2599
2600 const Double_t kDEGRAD = TMath::Pi()/180.;
2601 Double_t x = xx;
2602 Double_t y = yy;
2603 if (!gPad) return;
2604
2605 // Compute the font size. Exit if it is 0
2606 // The font size is computed from the TTF size to get exactly the same
2607 // size on the screen and in the PostScript file.
2608 Double_t wh = (Double_t) gPad->GetPadWidth();
2609 Double_t hh = (Double_t) gPad->GetPadHeight();
2610 if (wh <= 0 || hh <= 0)
2611 return;
2613
2614 if (wh < hh) {
2615 tsize = fTextSize*wh;
2616 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2617 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2618 } else {
2619 tsize = fTextSize*hh;
2620 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2621 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2622 }
2623 Double_t fontsize = 4*(72*(ftsize)/2.54);
2624 if( fontsize <= 0) return;
2625
2626 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2627 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2628
2629 Int_t font = abs(fTextFont)/10;
2630 if( font > 31 || font < 1) font = 1;
2631
2632 // Text color.
2634
2635 // Text alignment.
2636 Int_t txalh = fTextAlign/10;
2637 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
2638 Int_t txalv = fTextAlign%10;
2639 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
2640 if (txalv == 3) {
2643 } else if (txalv == 2) {
2646 }
2647
2648 UInt_t w = 0, w0 = 0;
2650 // In order to measure the precise character positions we need to trick
2651 // FreeType into rendering high-resolution characters otherwise it will
2652 // stick to the screen pixel grid, which is far worse than we can achieve
2653 // on print.
2654 const Float_t scale = 16.0;
2655 // Save current text attributes.
2657 saveAttText.TAttText::operator=(*this);
2658 const Int_t len=strlen(chars);
2659 Int_t *charWidthsCumul = nullptr;
2660 TText t;
2665 t.TAttText::Modify();
2666 if (w0-w != 0) kerning = kTRUE;
2667 else kerning = kFALSE;
2668 if (kerning) {
2669 // Calculate the individual character placements.
2670 charWidthsCumul = new Int_t[len];
2671 for (Int_t i = len - 1;i >= 0;i--) {
2672 UInt_t ww = 0;
2673 t.GetTextAdvance(ww, chars + i);
2674 Double_t wwl = (gPad->AbsPixeltoX(ww)-gPad->AbsPixeltoX(0));
2675 charWidthsCumul[i] = (Int_t)((XtoPS(wwl) - XtoPS(0)) / scale);
2676 }
2677 }
2678 // Restore text attributes.
2679 saveAttText.TAttText::Modify();
2680
2681 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2683
2684 // Text angle.
2685 Int_t psangle = Int_t(0.5 + fTextAngle);
2686
2687 // Save context.
2688 PrintStr("@");
2689 SaveRestore(1);
2690
2691 // Clipping
2692 Int_t xc1 = XtoPS(gPad->GetX1());
2693 Int_t xc2 = XtoPS(gPad->GetX2());
2694 Int_t yc1 = YtoPS(gPad->GetY1());
2695 Int_t yc2 = YtoPS(gPad->GetY2());
2696 WriteInteger(xc2 - xc1);
2697 WriteInteger(yc2 - yc1);
2700 PrintStr(" C");
2701
2702 // Output text position and angle. The text position is computed
2703 // using Double_t to avoid precision problems.
2704 Double_t vx = (x - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
2705 Double_t cmx = fXsize*(gPad->GetAbsXlowNDC()+vx*gPad->GetAbsWNDC());
2706 WriteReal((288.*cmx)/2.54);
2707 Double_t vy = (y - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
2708 Double_t cmy = fYsize*(gPad->GetAbsYlowNDC()+vy*gPad->GetAbsHNDC());
2709 WriteReal((288.*cmy)/2.54);
2710 PrintStr(TString::Format(" t %d r ", psangle));
2711 if(txalh == 2) PrintStr(TString::Format(" %d 0 t ", -psCharsLength/2));
2712 if(txalh == 3) PrintStr(TString::Format(" %d 0 t ", -psCharsLength));
2713 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2714 if (font != 15) {
2715 PrintStr(TString::Format(" findfont %g sf 0 0 m ",fontsize));
2716 } else {
2717 PrintStr(TString::Format(" findfont %g sf 0 0 m ita ",fontsize));
2718 }
2719
2720 if (kerning) {
2721 PrintStr("@");
2722 // Output individual character placements
2723 for (Int_t i = len-1; i >= 1; i--) {
2725 }
2726 delete [] charWidthsCumul;
2727 PrintStr("@");
2728 }
2729
2730 // Output text.
2731 PrintStr("(");
2732
2733 // Inside a PostScript string, the new line (if needed to break up long lines) must be escaped by a backslash.
2734 const char *crsave = fImplicitCREsc;
2735 fImplicitCREsc = "\\";
2736
2737 char str[8];
2738 for (Int_t i=0; i<len;i++) {
2739 if (chars[i]!='\n') {
2740 if (chars[i]=='(' || chars[i]==')' || chars[i]=='\\') {
2741 snprintf(str,8,"\\%c",chars[i]);
2742 PrintStr(str);
2743 } else if ((chars[i]=='-') && (font != 12)) {
2744 PrintStr("\\255");
2745 } else {
2746 snprintf(str,8,"%c",chars[i]);
2747 PrintFast(1,str);
2748 }
2749 }
2750 }
2751 PrintStr(")");
2753
2754 if (kerning) {
2755 if (font != 15) PrintStr(" K NC");
2756 else PrintStr(" K gr NC");
2757 } else {
2758 if (font != 15) PrintStr(" show NC");
2759 else PrintStr(" show gr NC");
2760 }
2761
2762 SaveRestore(-1);
2763}
2764
2765////////////////////////////////////////////////////////////////////////////////
2766/// Write a string of characters
2767///
2768/// This method writes the string chars into a PostScript file
2769/// at position xx,yy in world coordinates.
2770
2772{
2773 static const char *psfont[31][2] = {
2774 { "Root.PSFont.1", "/FreeSerifItalic" },
2775 { "Root.PSFont.2", "/FreeSerifBold" },
2776 { "Root.PSFont.3", "/FreeSerifBoldItalic" },
2777 { "Root.PSFont.4", "/FreeSans" },
2778 { "Root.PSFont.5", "/FreeSansOblique" },
2779 { "Root.PSFont.6", "/FreeSansBold" },
2780 { "Root.PSFont.7", "/FreeSansBoldOblique" },
2781 { "Root.PSFont.8", "/FreeMono" },
2782 { "Root.PSFont.9", "/FreeMonoOblique" },
2783 { "Root.PSFont.10", "/FreeMonoBold" },
2784 { "Root.PSFont.11", "/FreeMonoBoldOblique" },
2785 { "Root.PSFont.12", "/SymbolMT" },
2786 { "Root.PSFont.13", "/FreeSerif" },
2787 { "Root.PSFont.14", "/Wingdings-Regular" },
2788 { "Root.PSFont.15", "/SymbolMT" },
2789 { "Root.PSFont.STIXGen", "/STIXGeneral" },
2790 { "Root.PSFont.STIXGenIt", "/STIXGeneral-Italic" },
2791 { "Root.PSFont.STIXGenBd", "/STIXGeneral-Bold" },
2792 { "Root.PSFont.STIXGenBdIt", "/STIXGeneral-BoldItalic" },
2793 { "Root.PSFont.STIXSiz1Sym", "/STIXSize1Symbols" },
2794 { "Root.PSFont.STIXSiz1SymBd", "/STIXSize1Symbols-Bold" },
2795 { "Root.PSFont.STIXSiz2Sym", "/STIXSize2Symbols" },
2796 { "Root.PSFont.STIXSiz2SymBd", "/STIXSize2Symbols-Bold" },
2797 { "Root.PSFont.STIXSiz3Sym", "/STIXSize3Symbols" },
2798 { "Root.PSFont.STIXSiz3SymBd", "/STIXSize3Symbols-Bold" },
2799 { "Root.PSFont.STIXSiz4Sym", "/STIXSize4Symbols" },
2800 { "Root.PSFont.STIXSiz4SymBd", "/STIXSize4Symbols-Bold" },
2801 { "Root.PSFont.STIXSiz5Sym", "/STIXSize5Symbols" },
2802 { "Root.PSFont.ME", "/DroidSansFallback" },
2803 { "Root.PSFont.CJKMing", "/DroidSansFallback" },
2804 { "Root.PSFont.CJKGothic", "/DroidSansFallback" }
2805 };
2806
2807 Int_t len = wcslen(chars);
2808 if (len<=0) return;
2809
2810 const Double_t kDEGRAD = TMath::Pi()/180.;
2811 Double_t x = xx;
2812 Double_t y = yy;
2813 if (!gPad) return;
2814
2815 // Compute the font size. Exit if it is 0
2816 // The font size is computed from the TTF size to get exactly the same
2817 // size on the screen and in the PostScript file.
2818 Double_t wh = (Double_t)gPad->GetPadWidth();
2819 Double_t hh = (Double_t)gPad->GetPadHeight();
2821
2822 if (wh < hh) {
2823 tsize = fTextSize*wh;
2824 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2825 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2826 } else {
2827 tsize = fTextSize*hh;
2828 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2829 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2830 }
2831 Double_t fontsize = 4*(72*(ftsize)/2.54);
2832 if(fontsize <= 0) return;
2833
2834 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2835 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2836
2837 Int_t font = abs(fTextFont)/10;
2838 if( font > 29 || font < 1) font = 1;
2839
2840 // Text color.
2842
2843 // Text alignment.
2844 Int_t txalh = fTextAlign/10;
2845 if (txalh <1) txalh = 1; else if (txalh > 3) txalh = 3;
2846 Int_t txalv = fTextAlign%10;
2847 if (txalv <1) txalv = 1; else if (txalv > 3) txalv = 3;
2848 if (txalv == 3) {
2851 } else if (txalv == 2) {
2854 }
2855 UInt_t w = 0, h = 0;
2856
2857 TText t;
2860 t.GetTextExtent(w, h, chars);
2861 Double_t charsLength = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2863
2864 // Text angle.
2865 Int_t psangle = Int_t(0.5 + fTextAngle);
2866
2867 // Save context.
2868 PrintStr("@");
2869 SaveRestore(1);
2870
2871 // Clipping
2872 Int_t xc1 = XtoPS(gPad->GetX1());
2873 Int_t xc2 = XtoPS(gPad->GetX2());
2874 Int_t yc1 = YtoPS(gPad->GetY1());
2875 Int_t yc2 = YtoPS(gPad->GetY2());
2876 WriteInteger(xc2 - xc1);
2877 WriteInteger(yc2 - yc1);
2880 PrintStr(" C");
2881
2882 // Output text position and angle.
2885 PrintStr(TString::Format(" t %d r ", psangle));
2886 if(txalh == 2) PrintStr(TString::Format(" %d 0 t ", -psCharsLength/2));
2887 if(txalh == 3) PrintStr(TString::Format(" %d 0 t ", -psCharsLength));
2888 fMustEmbed[font-1] = kTRUE; // This font will be embedded in the file at EOF time.
2889 PrintStr(gEnv->GetValue(psfont[font-1][0], psfont[font-1][1]));
2890 PrintStr(TString::Format(" findfont %g sf 0 0 m ",fontsize));
2891
2892 // Output text.
2893 if (len > 1) PrintStr(TString::Format("%d ", len));
2894 for(Int_t i = 0; i < len; i++) {
2895 // Adobe Glyph Naming Convention
2896 // http://www.adobe.com/devnet/opentype/archives/glyph.html
2897#include "AdobeGlyphList.h"
2898 const wchar_t *lower = std::lower_bound(
2900 chars[i]);
2902 *lower == chars[i]) {
2903 // Named glyph from AGL 1.2
2904 const unsigned long index =
2907 }
2908 else if((unsigned int)chars[i] < 0xffff) {
2909 // Unicode BMP
2910 PrintStr(TString::Format("/uni%04X ",
2911 (unsigned int)chars[i]));
2912 }
2913 else {
2914 // Unicode supplemental planes
2915 PrintStr(TString::Format("/u%04X ",
2916 (unsigned int)chars[i]));
2917 }
2918 }
2919 if(len > 1) {
2920 PrintStr("{glyphshow} repeat ");
2921 }
2922 else {
2923 PrintStr("glyphshow ");
2924 }
2925
2926 PrintStr("NC");
2927
2928 SaveRestore(-1);
2929}
2930
2931////////////////////////////////////////////////////////////////////////////////
2932/// Draw text with URL. Same as Text.
2933///
2934
2935void TPostScript::TextUrl(Double_t x, Double_t y, const char *chars, const char *)
2936{
2937 Text(x, y, chars);
2938}
2939
2940////////////////////////////////////////////////////////////////////////////////
2941/// Write a string of characters in NDC
2942
2944{
2945 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2946 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2947 Text(x, y, chars);
2948}
2949
2950////////////////////////////////////////////////////////////////////////////////
2951/// Write a string of characters in NDC
2952
2954{
2955 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2956 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2957 Text(x, y, chars);
2958}
2959
2960////////////////////////////////////////////////////////////////////////////////
2961/// Convert U from NDC coordinate to PostScript
2962
2964{
2965 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
2966 return Int_t(0.5 + 288*cm/2.54);
2967}
2968
2969////////////////////////////////////////////////////////////////////////////////
2970/// Convert V from NDC coordinate to PostScript
2971
2973{
2974 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
2975 return Int_t(0.5 + 288*cm/2.54);
2976}
2977
2978////////////////////////////////////////////////////////////////////////////////
2979/// Convert X from world coordinate to PostScript
2980
2982{
2983 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
2984 return UtoPS(u);
2985}
2986
2987////////////////////////////////////////////////////////////////////////////////
2988/// Convert Y from world coordinate to PostScript
2989
2991{
2992 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
2993 return VtoPS(v);
2994}
2995
2996////////////////////////////////////////////////////////////////////////////////
2997/// Initialize the PostScript page in zones
2998
3000{
3001 if( !fClear )return;
3002 fClear = kFALSE;
3003
3004 // When Zone has been called, fZone is TRUE
3005 fZone = kTRUE;
3006
3007 if( fIYzone > fNYzone) {
3008 fIYzone=1;
3009 if( fMode != 3) {
3010 PrintStr("@showpage");
3011 SaveRestore(-1);
3012 fNpages++;
3013 PrintStr("@%%Page:");
3016 PrintStr("@");
3017 } else {
3018 PrintFast(9," showpage");
3019 SaveRestore(-1);
3020 }
3021 }
3022
3023 // No grestore the first time
3024 if( fMode != 3) {
3025 if( fIXzone != 1 || fIYzone != 1) SaveRestore(-1);
3026 SaveRestore(1);
3027 PrintStr("@");
3030 PrintFast(5," Zone");
3031 PrintStr("@");
3032 fIXzone++;
3033 if( fIXzone > fNXzone) { fIXzone=1; fIYzone++; }
3034 }
3035
3036 // Picture Initialisation
3037 SaveRestore(1);
3038 if (fgLineJoin) {
3040 PrintFast(12," setlinejoin");
3041 }
3042 if (fgLineCap) {
3044 PrintFast(11," setlinecap");
3045 }
3046 PrintFast(6," 0 0 t");
3047 fRed = -1;
3048 fGreen = -1;
3049 fBlue = -1;
3050 fPrinted = kFALSE;
3051 fLineColor = -1;
3052 fLineStyle = -1;
3053 fLineWidth = -1;
3054 fFillColor = -1;
3055 fFillStyle = -1;
3056 fMarkerSizeCur = -1;
3057}
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:131
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
winID h TVirtualViewer3D TVirtualGLPainter p
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:142
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:93
#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
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:98
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
An abstract interface to image processing library.
Definition TImage.h:29
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 DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags=0) override
Draw image in postscript.
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:137
const char * Data() const
Definition TString.h:385
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:2460
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:539
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:556
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:32
Int_t fLenBuffer
Definition TVirtualPS.h:40
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:43
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:45
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
Bool_t fPrinted
Definition TVirtualPS.h:42
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