Logo ROOT   6.08/07
Reference Guide
TPDF.cxx
Go to the documentation of this file.
1 // @(#)root/postscript:$Id: TPDF.cxx,v 1.0
2 // Author: Olivier Couet
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 TPDF
13 \ingroup PS
14 
15 Interface to PDF.
16 
17 Like PostScript, PDF is a vector graphics output format allowing a very high
18 graphics output quality. The functionalities provided by this class are very
19 similar to those provided by `TPostScript`.
20 
21 Compare to PostScript output, the PDF files are usually smaller because some
22 parts of them can be compressed.
23 
24 PDF also allows to define table of contents. This facility can be used in ROOT.
25 The following example shows how to proceed:
26 ~~~ {.cpp}
27 {
28  TCanvas* canvas = new TCanvas("canvas");
29  TH1F* histo = new TH1F("histo","test 1",10,0.,10.);
30  histo->SetFillColor(2);
31  histo->Fill(2.);
32  histo->Draw();
33  canvas->Print("plots.pdf(","Title:One bin filled");
34  histo->Fill(4.);
35  histo->Draw();
36  canvas->Print("plots.pdf","Title:Two bins filled");
37  histo->Fill(6.);
38  histo->Draw();
39  canvas->Print("plots.pdf","Title:Three bins filled");
40  histo->Fill(8.);
41  histo->Draw();
42  canvas->Print("plots.pdf","Title:Four bins filled");
43  histo->Fill(8.);
44  histo->Draw();
45  canvas->Print("plots.pdf)","Title:The fourth bin content is 2");
46 }
47 ~~~
48 Each character string following the keyword "Title:" makes a new entry in
49 the table of contents.
50 */
51 
52 #ifdef WIN32
53 #pragma optimize("",off)
54 #endif
55 
56 #include <stdlib.h>
57 #include <string.h>
58 #include <ctype.h>
59 
60 #include "Riostream.h"
61 #include "TROOT.h"
62 #include "TColor.h"
63 #include "TVirtualPad.h"
64 #include "TPoints.h"
65 #include "TPDF.h"
66 #include "TStyle.h"
67 #include "TMath.h"
68 #include "TStorage.h"
69 #include "TText.h"
70 #include "zlib.h"
71 #include "TObjString.h"
72 #include "TClass.h"
73 #include "TObjArray.h"
74 
75 // To scale fonts to the same size as the old TT version
76 const Float_t kScale = 0.93376068;
77 
78 // Objects numbers
79 const Int_t kObjRoot = 1; // Root object
80 const Int_t kObjInfo = 2; // Info object
81 const Int_t kObjOutlines = 3; // Outlines object
82 const Int_t kObjPages = 4; // Pages object (pages index)
83 const Int_t kObjPageResources = 5; // Pages Resources object
84 const Int_t kObjContents = 6; // Table of content
85 const Int_t kObjFont = 7; // First Font object (14 in total)
86 const Int_t kObjColorSpace = 22; // ColorSpace object
87 const Int_t kObjPatternResourses = 23; // Pattern Resources object
88 const Int_t kObjPatternList = 24; // Pattern list object
89 const Int_t kObjTransList = 25; // List of transparencies
90 const Int_t kObjPattern = 26; // First pattern object (25 in total)
91 const Int_t kObjFirstPage = 51; // First page object
92 
93 // Number of fonts
94 const Int_t kNumberOfFonts = 15;
95 
97 
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Default PDF constructor
102 
104 {
105  fStream = 0;
106  fCompress = kFALSE;
107  fPageNotEmpty = kFALSE;
108  gVirtualPS = this;
109  fRed = 0.;
110  fGreen = 0.;
111  fBlue = 0.;
112  fAlpha = 1.;
113  fXsize = 0.;
114  fYsize = 0.;
115  fType = 0;
116  fPageFormat = 0;
117  fPageOrientation = 0;
118  fStartStream = 0;
119  fLineScale = 0.;
120  fObjPosSize = 0;
121  fObjPos = 0;
122  fNbObj = 0;
123  fNbPage = 0;
124  fRange = kFALSE;
125  SetTitle("PDF");
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Initialize the PDF interface
130 ///
131 /// - fname : PDF file name
132 /// - wtype : PDF workstation type. Not used in the PDF driver. But as TPDF
133 /// inherits from TVirtualPS it should be kept. Anyway it is not
134 /// necessary to specify this parameter at creation time because it
135 /// has a default value (which is ignore in the PDF case).
136 
137 TPDF::TPDF(const char *fname, Int_t wtype) : TVirtualPS(fname, wtype)
138 {
139  fStream = 0;
140  fCompress = kFALSE;
142  fRed = 0.;
143  fGreen = 0.;
144  fBlue = 0.;
145  fAlpha = 1.;
146  fXsize = 0.;
147  fYsize = 0.;
148  fType = 0;
149  fPageFormat = 0;
150  fPageOrientation = 0;
151  fStartStream = 0;
152  fLineScale = 0.;
153  fObjPosSize = 0;
154  fNbObj = 0;
155  fNbPage = 0;
156  fRange = kFALSE;
157  SetTitle("PDF");
158  Open(fname, wtype);
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Default PDF destructor
163 
165 {
166  Close();
167 
168  if (fObjPos) delete [] fObjPos;
169 }
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 /// Begin the Cell Array painting
173 
175  Double_t)
176 {
177  Warning("TPDF::CellArrayBegin", "not yet implemented");
178 }
179 
180 ////////////////////////////////////////////////////////////////////////////////
181 /// Paint the Cell Array
182 
184 {
185  Warning("TPDF::CellArrayFill", "not yet implemented");
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// End the Cell Array painting
190 
192 {
193  Warning("TPDF::CellArrayEnd", "not yet implemented");
194 }
195 
196 ////////////////////////////////////////////////////////////////////////////////
197 /// Close a PDF file
198 
200 {
201  Int_t i;
202 
203  if (!gVirtualPS) return;
204  if (!fStream) return;
205  if (gPad) gPad->Update();
206 
207  // Close the currently opened page
209  PrintStr("endstream@");
210  Int_t streamLength = fNByte-fStartStream-10;
211  PrintStr("endobj@");
213  WriteInteger(streamLength, 0);
214  PrintStr("@");
215  PrintStr("endobj@");
217  PrintStr("<<@");
218  if (!strstr(GetTitle(),"PDF")) {
219  PrintStr("/Title (");
220  PrintStr(GetTitle());
221  PrintStr(")@");
222  } else {
223  PrintStr("/Title (Page");
225  PrintStr(")@");
226  }
227  PrintStr("/Dest [");
229  PrintStr(" 0 R /XYZ null null 0]@");
230  PrintStr("/Parent");
232  PrintStr(" 0 R");
233  PrintStr("@");
234  if (fNbPage > 1) {
235  PrintStr("/Prev");
237  PrintStr(" 0 R");
238  PrintStr("@");
239  }
240  PrintStr(">>@");
241 
243  PrintStr("<<@");
244  PrintStr("/Type /Outlines@");
245  PrintStr("/Count");
247  PrintStr("@");
248  PrintStr("/First");
250  PrintStr(" 0 R");
251  PrintStr("@");
252  PrintStr("/Last");
254  PrintStr(" 0 R");
255  PrintStr("@");
256  PrintStr(">>@");
257  PrintStr("endobj@");
258 
260  PrintStr("<<@");
261  PrintStr("/Title (Contents)@");
262  PrintStr("/Dest [");
264  PrintStr(" 0 R /XYZ null null 0]@");
265  PrintStr("/Count");
267  PrintStr("@");
268  PrintStr("/Parent");
270  PrintStr(" 0 R");
271  PrintStr("@");
272  PrintStr("/First");
274  PrintStr(" 0 R");
275  PrintStr("@");
276  PrintStr("/Last");
278  PrintStr(" 0 R");
279  PrintStr("@");
280  PrintStr(">>@");
281 
282  // List of all the pages
284  PrintStr("<<@");
285  PrintStr("/Type /Pages@");
286  PrintStr("/Count");
288  PrintStr("@");
289  PrintStr("/Kids [");
290  for (i=1; i<=fNbPage; i++) {
291  WriteInteger(4*(i-1)+kObjFirstPage);
292  PrintStr(" 0 R");
293  }
294  PrintStr(" ]");
295  PrintStr("@");
296  PrintStr(">>@");
297  PrintStr("endobj@");
298 
300  PrintStr("<<@");
301  for (i=0; i<(int)fAlphas.size(); i++) {
302  PrintStr(
303  Form("/ca%3.2f << /Type /ExtGState /ca %3.2f >> /CA%3.2f << /Type /ExtGState /CA %3.2f >>@",
304  fAlphas[i],fAlphas[i],fAlphas[i],fAlphas[i]));
305  }
306  PrintStr(">>@");
307  PrintStr("endobj@");
308  if (fAlphas.size()) fAlphas.clear();
309 
310  // Cross-Reference Table
311  Int_t refInd = fNByte;
312  PrintStr("xref@");
313  PrintStr("0");
314  WriteInteger(fNbObj+1);
315  PrintStr("@");
316  PrintStr("0000000000 65535 f @");
317  char str[21];
318  for (i=0; i<fNbObj; i++) {
319  snprintf(str,21,"%10.10d 00000 n @",fObjPos[i]);
320  PrintStr(str);
321  }
322 
323  // Trailer
324  PrintStr("trailer@");
325  PrintStr("<<@");
326  PrintStr("/Size");
327  WriteInteger(fNbObj+1);
328  PrintStr("@");
329  PrintStr("/Root");
331  PrintStr(" 0 R");
332  PrintStr("@");
333  PrintStr("/Info");
335  PrintStr(" 0 R@");
336  PrintStr(">>@");
337  PrintStr("startxref@");
338  WriteInteger(refInd, 0);
339  PrintStr("@");
340  PrintStr("%%EOF@");
341 
342  // Close file stream
343  if (fStream) { fStream->close(); delete fStream; fStream = 0;}
344 
345  gVirtualPS = 0;
346 }
347 
348 ////////////////////////////////////////////////////////////////////////////////
349 /// Draw a Box
350 
352 {
353  static Double_t x[4], y[4];
354  Double_t ix1 = XtoPDF(x1);
355  Double_t ix2 = XtoPDF(x2);
356  Double_t iy1 = YtoPDF(y1);
357  Double_t iy2 = YtoPDF(y2);
358  Int_t fillis = fFillStyle/1000;
359  Int_t fillsi = fFillStyle%1000;
360 
361  if (fillis == 3 || fillis == 2) {
362  if (fillsi > 99) {
363  x[0] = x1; y[0] = y1;
364  x[1] = x2; y[1] = y1;
365  x[2] = x2; y[2] = y2;
366  x[3] = x1; y[3] = y2;
367  return;
368  }
369  if (fillsi > 0 && fillsi < 26) {
370  x[0] = x1; y[0] = y1;
371  x[1] = x2; y[1] = y1;
372  x[2] = x2; y[2] = y2;
373  x[3] = x1; y[3] = y2;
374  DrawPS(-4, &x[0], &y[0]);
375  }
376  if (fillsi == -3) {
377  SetColor(5);
378  if (fAlpha == 1) PrintFast(17," q 0.002 w [] 0 d");
379  WriteReal(ix1);
380  WriteReal(iy1);
381  WriteReal(ix2 - ix1);
382  WriteReal(iy2 - iy1);
383  if (fAlpha == 1) PrintFast(8," re b* Q");
384  else PrintFast(6," re f*");
385  }
386  }
387  if (fillis == 1) {
389  if (fAlpha == 1) PrintFast(17," q 0.002 w [] 0 d");
390  WriteReal(ix1);
391  WriteReal(iy1);
392  WriteReal(ix2 - ix1);
393  WriteReal(iy2 - iy1);
394  if (fAlpha == 1) PrintFast(8," re b* Q");
395  else PrintFast(6," re f*");
396  }
397  if (fillis == 0) {
398  if (fLineWidth<=0) return;
400  WriteReal(ix1);
401  WriteReal(iy1);
402  WriteReal(ix2 - ix1);
403  WriteReal(iy2 - iy1);
404  PrintFast(5," re S");
405  }
406 }
407 
408 ////////////////////////////////////////////////////////////////////////////////
409 /// Draw a Frame around a box
410 ///
411 /// - mode = -1 box looks as it is behind the screen
412 /// - mode = 1 box looks as it is in front of the screen
413 /// - border is the border size in already precomputed PDF units
414 /// - dark is the color for the dark part of the frame
415 /// - light is the color for the light part of the frame
416 
418  Int_t mode, Int_t border, Int_t dark, Int_t light)
419 {
420  static Double_t xps[7], yps[7];
421  Int_t i;
422 
423  // Draw top&left part of the box
424  if (mode == -1) SetColor(dark);
425  else SetColor(light);
426  xps[0] = XtoPDF(xl); yps[0] = YtoPDF(yl);
427  xps[1] = xps[0] + border; yps[1] = yps[0] + border;
428  xps[2] = xps[1]; yps[2] = YtoPDF(yt) - border;
429  xps[3] = XtoPDF(xt) - border; yps[3] = yps[2];
430  xps[4] = XtoPDF(xt); yps[4] = YtoPDF(yt);
431  xps[5] = xps[0]; yps[5] = yps[4];
432  xps[6] = xps[0]; yps[6] = yps[0];
433 
434  MoveTo(xps[0], yps[0]);
435  for (i=1;i<7;i++) LineTo(xps[i], yps[i]);
436  PrintFast(3," f*");
437 
438  // Draw bottom&right part of the box
439  if (mode == -1) SetColor(light);
440  else SetColor(dark);
441  xps[0] = XtoPDF(xl); yps[0] = YtoPDF(yl);
442  xps[1] = xps[0] + border; yps[1] = yps[0] + border;
443  xps[2] = XtoPDF(xt) - border; yps[2] = yps[1];
444  xps[3] = xps[2]; yps[3] = YtoPDF(yt) - border;
445  xps[4] = XtoPDF(xt); yps[4] = YtoPDF(yt);
446  xps[5] = xps[4]; yps[5] = yps[0];
447  xps[6] = xps[0]; yps[6] = yps[0];
448 
449  MoveTo(xps[0], yps[0]);
450  for (i=1;i<7;i++) LineTo(xps[i], yps[i]);
451  PrintFast(3," f*");
452 }
453 
454 ////////////////////////////////////////////////////////////////////////////////
455 /// Draw Fill area with hatch styles
456 
458 {
459  Warning("DrawHatch", "hatch fill style not yet implemented");
460 }
461 
462 ////////////////////////////////////////////////////////////////////////////////
463 /// Draw Fill area with hatch styles
464 
466 {
467  Warning("DrawHatch", "hatch fill style not yet implemented");
468 }
469 
470 ////////////////////////////////////////////////////////////////////////////////
471 /// Draw a PolyLine
472 ///
473 /// Draw a polyline through the points xy.
474 ///
475 /// - If NN=1 moves only to point x,y.
476 /// - If NN=0 the x,y are written in the PDF file
477 /// according to the current transformation.
478 /// - If NN>0 the line is clipped as a line.
479 /// - If NN<0 the line is clipped as a fill area.
480 
482 {
483  Int_t n;
484 
485  Style_t linestylesav = fLineStyle;
486  Width_t linewidthsav = fLineWidth;
487 
488  if (nn > 0) {
489  if (fLineWidth<=0) return;
490  n = nn;
494  } else {
495  n = -nn;
496  SetLineStyle(1);
497  SetLineWidth(1);
499  }
500 
501  WriteReal(XtoPDF(xy[0].GetX()));
502  WriteReal(YtoPDF(xy[0].GetY()));
503  if (n <= 1) {
504  if (n == 0) return;
505  PrintFast(2," m");
506  return;
507  }
508 
509  PrintFast(2," m");
510 
511  for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xy[i].GetX()), YtoPDF(xy[i].GetY()));
512 
513  if (nn > 0) {
514  if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
515  PrintFast(2," S");
516  } else {
517  PrintFast(3," f*");
518  }
519 
520  SetLineStyle(linestylesav);
521  SetLineWidth(linewidthsav);
522 }
523 
524 ////////////////////////////////////////////////////////////////////////////////
525 /// Draw a PolyLine in NDC space
526 ///
527 /// Draw a polyline through the points xy.
528 ///
529 /// - If NN=1 moves only to point x,y.
530 /// - If NN=0 the x,y are written in the PDF file
531 /// according to the current transformation.
532 /// - If NN>0 the line is clipped as a line.
533 /// - If NN<0 the line is clipped as a fill area.
534 
536 {
537  Int_t n;
538 
539  Style_t linestylesav = fLineStyle;
540  Width_t linewidthsav = fLineWidth;
541 
542  if (nn > 0) {
543  if (fLineWidth<=0) return;
544  n = nn;
548  } else {
549  n = -nn;
550  SetLineStyle(1);
551  SetLineWidth(1);
553  }
554 
555  WriteReal(UtoPDF(xy[0].GetX()));
556  WriteReal(VtoPDF(xy[0].GetY()));
557  if (n <= 1) {
558  if (n == 0) return;
559  PrintFast(2," m");
560  return;
561  }
562 
563  PrintFast(2," m");
564 
565  for (Int_t i=1;i<n;i++) LineTo(UtoPDF(xy[i].GetX()), VtoPDF(xy[i].GetY()));
566 
567  if (nn > 0) {
568  if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
569  PrintFast(2," S");
570  } else {
571  PrintFast(3," f*");
572  }
573 
574  SetLineStyle(linestylesav);
575  SetLineWidth(linewidthsav);
576 }
577 
578 ////////////////////////////////////////////////////////////////////////////////
579 /// Draw markers at the n WC points xw, yw
580 
582 {
583  Style_t linestylesav = fLineStyle;
584  Width_t linewidthsav = fLineWidth;
585  SetLineStyle(1);
586  SetLineWidth(1);
588  Int_t ms = abs(fMarkerStyle);
589 
590  if (ms >= 6 && ms <= 19) ms = 20;
591  if (ms == 4) ms = 24;
592 
593  // Define the marker size
594  Float_t msize = fMarkerSize;
595  if (fMarkerStyle == 1) {
596  msize = 1.;
597  } else if (fMarkerStyle == 6) {
598  msize = 1.;
599  } else if (fMarkerStyle == 7) {
600  msize = 1.5;
601  } else {
602  const Int_t kBASEMARKER = 8;
603  Float_t sbase = msize*kBASEMARKER;
604  Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
605  msize = this->UtoPDF(s2x) - this->UtoPDF(0);
606  }
607 
608  Double_t m = msize;
609  Double_t m2 = m/2;
610  Double_t m3 = m/3;
611  Double_t m4 = m2*1.333333333333;
612  Double_t m6 = m/6;
613 
614  // Draw the marker according to the type
615  Double_t ix,iy;
616  for (Int_t i=0;i<n;i++) {
617  ix = XtoPDF(xw[i]);
618  iy = YtoPDF(yw[i]);
619  // Dot (.)
620  if (ms == 1) {
621  MoveTo(ix-1, iy);
622  LineTo(ix , iy);
623  // Plus (+)
624  } else if (ms == 2) {
625  MoveTo(ix-m2, iy);
626  LineTo(ix+m2, iy);
627  MoveTo(ix , iy-m2);
628  LineTo(ix , iy+m2);
629  // X shape (X)
630  } else if (ms == 5) {
631  MoveTo(ix-m2, iy-m2);
632  LineTo(ix+m2, iy+m2);
633  MoveTo(ix-m2, iy+m2);
634  LineTo(ix+m2, iy-m2);
635  // Asterisk shape (*)
636  } else if (ms == 3 || ms == 31) {
637  MoveTo(ix-m2, iy);
638  LineTo(ix+m2, iy);
639  MoveTo(ix , iy-m2);
640  LineTo(ix , iy+m2);
641  MoveTo(ix-m2, iy-m2);
642  LineTo(ix+m2, iy+m2);
643  MoveTo(ix-m2, iy+m2);
644  LineTo(ix+m2, iy-m2);
645  // Circle
646  } else if (ms == 24 || ms == 20) {
647  MoveTo(ix-m2, iy);
648  WriteReal(ix-m2); WriteReal(iy+m4);
649  WriteReal(ix+m2); WriteReal(iy+m4);
650  WriteReal(ix+m2); WriteReal(iy) ; PrintFast(2," c");
651  WriteReal(ix+m2); WriteReal(iy-m4);
652  WriteReal(ix-m2); WriteReal(iy-m4);
653  WriteReal(ix-m2); WriteReal(iy) ; PrintFast(4," c h");
654  // Square
655  } else if (ms == 25 || ms == 21) {
656  WriteReal(ix-m2); WriteReal(iy-m2);
657  WriteReal(m) ; WriteReal(m) ; PrintFast(3," re");
658  // Down triangle
659  } else if (ms == 23 || ms == 32) {
660  MoveTo(ix , iy-m2);
661  LineTo(ix+m2, iy+m2);
662  LineTo(ix-m2, iy+m2);
663  PrintFast(2," h");
664  // Up triangle
665  } else if (ms == 26 || ms == 22) {
666  MoveTo(ix-m2, iy-m2);
667  LineTo(ix+m2, iy-m2);
668  LineTo(ix , iy+m2);
669  PrintFast(2," h");
670  } else if (ms == 27 || ms == 33) {
671  MoveTo(ix , iy-m2);
672  LineTo(ix+m3, iy);
673  LineTo(ix , iy+m2);
674  LineTo(ix-m3, iy) ;
675  PrintFast(2," h");
676  } else if (ms == 28 || ms == 34) {
677  MoveTo(ix-m6, iy-m6);
678  LineTo(ix-m6, iy-m2);
679  LineTo(ix+m6, iy-m2);
680  LineTo(ix+m6, iy-m6);
681  LineTo(ix+m2, iy-m6);
682  LineTo(ix+m2, iy+m6);
683  LineTo(ix+m6, iy+m6);
684  LineTo(ix+m6, iy+m2);
685  LineTo(ix-m6, iy+m2);
686  LineTo(ix-m6, iy+m6);
687  LineTo(ix-m2, iy+m6);
688  LineTo(ix-m2, iy-m6);
689  PrintFast(2," h");
690  } else if (ms == 29 || ms == 30) {
691  MoveTo(ix , iy+m2);
692  LineTo(ix+0.112255*m, iy+0.15451*m);
693  LineTo(ix+0.47552*m , iy+0.15451*m);
694  LineTo(ix+0.181635*m, iy-0.05902*m);
695  LineTo(ix+0.29389*m , iy-0.40451*m);
696  LineTo(ix , iy-0.19098*m);
697  LineTo(ix-0.29389*m , iy-0.40451*m);
698  LineTo(ix-0.181635*m, iy-0.05902*m);
699  LineTo(ix-0.47552*m , iy+0.15451*m);
700  LineTo(ix-0.112255*m, iy+0.15451*m);
701  PrintFast(2," h");
702  } else {
703  MoveTo(ix-1, iy);
704  LineTo(ix , iy);
705  }
706  }
707 
708  if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34) {
709  PrintFast(2," f");
710  } else {
711  PrintFast(2," S");
712  }
713 
714  SetLineStyle(linestylesav);
715  SetLineWidth(linewidthsav);
716 }
717 
718 ////////////////////////////////////////////////////////////////////////////////
719 /// Draw markers at the n WC points xw, yw
720 
722 {
723  Style_t linestylesav = fLineStyle;
724  Width_t linewidthsav = fLineWidth;
725  SetLineStyle(1);
726  SetLineWidth(1);
728  Int_t ms = abs(fMarkerStyle);
729 
730  if (ms >= 6 && ms <= 19) ms = 20;
731  if (ms == 4) ms = 24;
732 
733  // Define the marker size
734  Float_t msize = fMarkerSize;
735  if (fMarkerStyle == 1) {
736  msize = 1.;
737  } else if (fMarkerStyle == 6) {
738  msize = 1.5;
739  } else if (fMarkerStyle == 7) {
740  msize = 3.;
741  } else {
742  const Int_t kBASEMARKER = 8;
743  Float_t sbase = msize*kBASEMARKER;
744  Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
745  msize = this->UtoPDF(s2x) - this->UtoPDF(0);
746  }
747 
748  Double_t m = msize;
749  Double_t m2 = m/2;
750  Double_t m3 = m/3;
751  Double_t m4 = m2*1.333333333333;
752  Double_t m6 = m/6;
753 
754  // Draw the marker according to the type
755  Double_t ix,iy;
756  for (Int_t i=0;i<n;i++) {
757  ix = XtoPDF(xw[i]);
758  iy = YtoPDF(yw[i]);
759  // Dot (.)
760  if (ms == 1) {
761  MoveTo(ix-1, iy);
762  LineTo(ix , iy);
763  // Plus (+)
764  } else if (ms == 2) {
765  MoveTo(ix-m2, iy);
766  LineTo(ix+m2, iy);
767  MoveTo(ix , iy-m2);
768  LineTo(ix , iy+m2);
769  // X shape (X)
770  } else if (ms == 5) {
771  MoveTo(ix-m2, iy-m2);
772  LineTo(ix+m2, iy+m2);
773  MoveTo(ix-m2, iy+m2);
774  LineTo(ix+m2, iy-m2);
775  // Asterisk shape (*)
776  } else if (ms == 3 || ms == 31) {
777  MoveTo(ix-m2, iy);
778  LineTo(ix+m2, iy);
779  MoveTo(ix , iy-m2);
780  LineTo(ix , iy+m2);
781  MoveTo(ix-m2, iy-m2);
782  LineTo(ix+m2, iy+m2);
783  MoveTo(ix-m2, iy+m2);
784  LineTo(ix+m2, iy-m2);
785  // Circle
786  } else if (ms == 24 || ms == 20) {
787  MoveTo(ix-m2, iy);
788  WriteReal(ix-m2); WriteReal(iy+m4);
789  WriteReal(ix+m2); WriteReal(iy+m4);
790  WriteReal(ix+m2); WriteReal(iy) ; PrintFast(2," c");
791  WriteReal(ix+m2); WriteReal(iy-m4);
792  WriteReal(ix-m2); WriteReal(iy-m4);
793  WriteReal(ix-m2); WriteReal(iy) ; PrintFast(4," c h");
794  // Square
795  } else if (ms == 25 || ms == 21) {
796  WriteReal(ix-m2); WriteReal(iy-m2);
797  WriteReal(m) ; WriteReal(m) ; PrintFast(3," re");
798  // Down triangle
799  } else if (ms == 23 || ms == 32) {
800  MoveTo(ix , iy-m2);
801  LineTo(ix+m2, iy+m2);
802  LineTo(ix-m2, iy+m2);
803  PrintFast(2," h");
804  // Up triangle
805  } else if (ms == 26 || ms == 22) {
806  MoveTo(ix-m2, iy-m2);
807  LineTo(ix+m2, iy-m2);
808  LineTo(ix , iy+m2);
809  PrintFast(2," h");
810  } else if (ms == 27 || ms == 33) {
811  MoveTo(ix , iy-m2);
812  LineTo(ix+m3, iy);
813  LineTo(ix , iy+m2);
814  LineTo(ix-m3, iy) ;
815  PrintFast(2," h");
816  } else if (ms == 28 || ms == 34) {
817  MoveTo(ix-m6, iy-m6);
818  LineTo(ix-m6, iy-m2);
819  LineTo(ix+m6, iy-m2);
820  LineTo(ix+m6, iy-m6);
821  LineTo(ix+m2, iy-m6);
822  LineTo(ix+m2, iy+m6);
823  LineTo(ix+m6, iy+m6);
824  LineTo(ix+m6, iy+m2);
825  LineTo(ix-m6, iy+m2);
826  LineTo(ix-m6, iy+m6);
827  LineTo(ix-m2, iy+m6);
828  LineTo(ix-m2, iy-m6);
829  PrintFast(2," h");
830  } else if (ms == 29 || ms == 30) {
831  MoveTo(ix , iy+m2);
832  LineTo(ix+0.112255*m, iy+0.15451*m);
833  LineTo(ix+0.47552*m , iy+0.15451*m);
834  LineTo(ix+0.181635*m, iy-0.05902*m);
835  LineTo(ix+0.29389*m , iy-0.40451*m);
836  LineTo(ix , iy-0.19098*m);
837  LineTo(ix-0.29389*m , iy-0.40451*m);
838  LineTo(ix-0.181635*m, iy-0.05902*m);
839  LineTo(ix-0.47552*m , iy+0.15451*m);
840  LineTo(ix-0.112255*m, iy+0.15451*m);
841  PrintFast(2," h");
842  } else {
843  MoveTo(ix-1, iy);
844  LineTo(ix , iy);
845  }
846  }
847 
848  if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34) {
849  PrintFast(2," f");
850  } else {
851  PrintFast(2," S");
852  }
853 
854  SetLineStyle(linestylesav);
855  SetLineWidth(linewidthsav);
856 }
857 
858 ////////////////////////////////////////////////////////////////////////////////
859 /// Draw a PolyLine
860 ///
861 /// Draw a polyline through the points xw,yw.
862 ///
863 /// - If nn=1 moves only to point xw,yw.
864 /// - If nn=0 the XW(1) and YW(1) are written in the PDF file
865 /// according to the current NT.
866 /// - If nn>0 the line is clipped as a line.
867 /// - If nn<0 the line is clipped as a fill area.
868 
870 {
871  static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
872  .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
873  .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
874  static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
875  180, 90,135, 45,150, 30,120, 60,
876  180, 90,135, 45,150, 30,120, 60};
877  Int_t n = 0, fais = 0 , fasi = 0;
878 
879  Style_t linestylesav = fLineStyle;
880  Width_t linewidthsav = fLineWidth;
881 
882  if (nn > 0) {
883  if (fLineWidth<=0) return;
884  n = nn;
888  }
889  if (nn < 0) {
890  n = -nn;
891  SetLineStyle(1);
892  SetLineWidth(1);
894  fais = fFillStyle/1000;
895  fasi = fFillStyle%1000;
896  if (fais == 3 || fais == 2) {
897  if (fasi > 100 && fasi <125) {
898  DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
899  SetLineStyle(linestylesav);
900  SetLineWidth(linewidthsav);
901  return;
902  }
903  if (fasi > 0 && fasi < 26) {
905  }
906  }
907  }
908 
909  WriteReal(XtoPDF(xw[0]));
910  WriteReal(YtoPDF(yw[0]));
911  if (n <= 1) {
912  if (n == 0) return;
913  PrintFast(2," m");
914  return;
915  }
916 
917  PrintFast(2," m");
918 
919  for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xw[i]), YtoPDF(yw[i]));
920 
921  if (nn > 0) {
922  if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(2," h");
923  PrintFast(2," S");
924  } else {
925  if (fais == 0) {PrintFast(2," s"); return;}
926  if (fais == 3 || fais == 2) {
927  if (fasi > 0 && fasi < 26) {
928  PrintFast(3," f*");
929  fRed = -1;
930  fGreen = -1;
931  fBlue = -1;
932  fAlpha = -1.;
933  }
934  SetLineStyle(linestylesav);
935  SetLineWidth(linewidthsav);
936  return;
937  }
938  PrintFast(3," f*");
939  }
940 
941  SetLineStyle(linestylesav);
942  SetLineWidth(linewidthsav);
943 }
944 
945 ////////////////////////////////////////////////////////////////////////////////
946 /// Draw a PolyLine
947 ///
948 /// Draw a polyline through the points xw,yw.
949 ///
950 /// - If nn=1 moves only to point xw,yw.
951 /// - If nn=0 the xw(1) and YW(1) are written in the PDF file
952 /// according to the current NT.
953 /// - If nn>0 the line is clipped as a line.
954 /// - If nn<0 the line is clipped as a fill area.
955 
957 {
958  static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
959  .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
960  .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
961  static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
962  180, 90,135, 45,150, 30,120, 60,
963  180, 90,135, 45,150, 30,120, 60};
964  Int_t n = 0, fais = 0, fasi = 0;
965 
966  Style_t linestylesav = fLineStyle;
967  Width_t linewidthsav = fLineWidth;
968 
969  if (nn > 0) {
970  if (fLineWidth<=0) return;
971  n = nn;
975  }
976  if (nn < 0) {
977  n = -nn;
978  SetLineStyle(1);
979  SetLineWidth(1);
981  fais = fFillStyle/1000;
982  fasi = fFillStyle%1000;
983  if (fais == 3 || fais == 2) {
984  if (fasi > 100 && fasi <125) {
985  DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
986  SetLineStyle(linestylesav);
987  SetLineWidth(linewidthsav);
988  return;
989  }
990  if (fasi > 0 && fasi < 26) {
992  }
993  }
994  }
995 
996  WriteReal(XtoPDF(xw[0]));
997  WriteReal(YtoPDF(yw[0]));
998  if (n <= 1) {
999  if (n == 0) return;
1000  PrintFast(2," m");
1001  return;
1002  }
1003 
1004  PrintFast(2," m");
1005 
1006  for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xw[i]), YtoPDF(yw[i]));
1007 
1008  if (nn > 0) {
1009  if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(2," h");
1010  PrintFast(2," S");
1011  } else {
1012  if (fais == 0) {PrintFast(2," s"); return;}
1013  if (fais == 3 || fais == 2) {
1014  if (fasi > 0 && fasi < 26) {
1015  PrintFast(3," f*");
1016  fRed = -1;
1017  fGreen = -1;
1018  fBlue = -1;
1019  fAlpha = -1.;
1020  }
1021  SetLineStyle(linestylesav);
1022  SetLineWidth(linewidthsav);
1023  return;
1024  }
1025  PrintFast(3," f*");
1026  }
1027 
1028  SetLineStyle(linestylesav);
1029  SetLineWidth(linewidthsav);
1030 }
1031 
1032 ////////////////////////////////////////////////////////////////////////////////
1033 /// Font encoding
1034 
1036 {
1037  static const char *sdtfonts[] = {
1038  "/Times-Italic" , "/Times-Bold" , "/Times-BoldItalic",
1039  "/Helvetica" , "/Helvetica-Oblique" , "/Helvetica-Bold" ,
1040  "/Helvetica-BoldOblique", "/Courier" , "/Courier-Oblique" ,
1041  "/Courier-Bold" , "/Courier-BoldOblique", "/Symbol" ,
1042  "/Times-Roman" , "/ZapfDingbats" , "/Symbol"};
1043 
1044  for (Int_t i=0; i<kNumberOfFonts; i++) {
1045  NewObject(kObjFont+i);
1046  PrintStr("<<@");
1047  PrintStr("/Type /Font@");
1048  PrintStr("/Subtype /Type1@");
1049  PrintStr("/Name /F");
1050  WriteInteger(i+1,0);
1051  PrintStr("@");
1052  PrintStr("/BaseFont ");
1053  PrintStr(sdtfonts[i]);
1054  PrintStr("@");
1055  if (i!=11 && i!=13 && i!=14) {
1056  PrintStr("/Encoding /WinAnsiEncoding");
1057  PrintStr("@");
1058  }
1059  PrintStr(">>@");
1060  PrintStr("endobj@");
1061  }
1062 }
1063 
1064 ////////////////////////////////////////////////////////////////////////////////
1065 /// Draw a line to a new position
1066 
1068 {
1069  WriteReal(x);
1070  WriteReal(y);
1071  PrintFast(2," l");
1072 }
1073 
1074 ////////////////////////////////////////////////////////////////////////////////
1075 /// Move to a new position
1076 
1078 {
1079  WriteReal(x);
1080  WriteReal(y);
1081  PrintFast(2," m");
1082 }
1083 
1084 ////////////////////////////////////////////////////////////////////////////////
1085 /// Create a new object in the PDF file
1086 
1088 {
1089  if (!fObjPos || n >= fObjPosSize) {
1090  Int_t newN = TMath::Max(2*fObjPosSize,n+1);
1091  Int_t *saveo = new Int_t [newN];
1092  if (fObjPos && fObjPosSize) {
1093  memcpy(saveo,fObjPos,fObjPosSize*sizeof(Int_t));
1094  memset(&saveo[fObjPosSize],0,(newN-fObjPosSize)*sizeof(Int_t));
1095  delete [] fObjPos;
1096  }
1097  fObjPos = saveo;
1098  fObjPosSize = newN;
1099  }
1100  fObjPos[n-1] = fNByte;
1101  fNbObj = TMath::Max(fNbObj,n);
1102  WriteInteger(n, 0);
1103  PrintStr(" 0 obj");
1104  PrintStr("@");
1105 }
1106 
1107 ////////////////////////////////////////////////////////////////////////////////
1108 /// Start a new PDF page.
1109 
1111 {
1112  if (!fPageNotEmpty) return;
1113 
1114  // Compute pad conversion coefficients
1115  if (gPad) {
1116  Double_t ww = gPad->GetWw();
1117  Double_t wh = gPad->GetWh();
1118  fYsize = fXsize*wh/ww;
1119  } else {
1120  fYsize = 27;
1121  }
1122 
1123  fNbPage++;
1124 
1125  if (fNbPage>1) {
1126  // Close the currently opened page
1128  PrintStr("endstream@");
1129  Int_t streamLength = fNByte-fStartStream-10;
1130  PrintStr("endobj@");
1131  NewObject(4*(fNbPage-2)+kObjFirstPage+2);
1132  WriteInteger(streamLength, 0);
1133  PrintStr("@");
1134  PrintStr("endobj@");
1135  NewObject(4*(fNbPage-2)+kObjFirstPage+3);
1136  PrintStr("<<@");
1137  if (!strstr(GetTitle(),"PDF")) {
1138  PrintStr("/Title (");
1139  PrintStr(GetTitle());
1140  PrintStr(")@");
1141  } else {
1142  PrintStr("/Title (Page");
1143  WriteInteger(fNbPage-1);
1144  PrintStr(")@");
1145  }
1146  PrintStr("/Dest [");
1148  PrintStr(" 0 R /XYZ null null 0]@");
1149  PrintStr("/Parent");
1151  PrintStr(" 0 R");
1152  PrintStr("@");
1153  PrintStr("/Next");
1155  PrintStr(" 0 R");
1156  PrintStr("@");
1157  if (fNbPage>2) {
1158  PrintStr("/Prev");
1160  PrintStr(" 0 R");
1161  PrintStr("@");
1162  }
1163  PrintStr(">>@");
1164  }
1165 
1166  // Start a new page
1168  PrintStr("<<@");
1169  PrintStr("/Type /Page@");
1170  PrintStr("@");
1171  PrintStr("/Parent");
1173  PrintStr(" 0 R");
1174  PrintStr("@");
1175 
1176  Double_t xlow=0, ylow=0, xup=1, yup=1;
1177  if (gPad) {
1178  xlow = gPad->GetAbsXlowNDC();
1179  xup = xlow + gPad->GetAbsWNDC();
1180  ylow = gPad->GetAbsYlowNDC();
1181  yup = ylow + gPad->GetAbsHNDC();
1182  }
1183 
1184  PrintStr("/MediaBox [");
1185  Double_t width, height;
1186  switch (fPageFormat) {
1187  case 100 :
1188  width = 8.5*2.54;
1189  height = 11.*2.54;
1190  break;
1191  case 200 :
1192  width = 8.5*2.54;
1193  height = 14.*2.54;
1194  break;
1195  case 300 :
1196  width = 11.*2.54;
1197  height = 17.*2.54;
1198  break;
1199  default :
1200  width = 21.0*TMath::Power(TMath::Sqrt(2.), 4-fPageFormat);
1201  height = 29.7*TMath::Power(TMath::Sqrt(2.), 4-fPageFormat);
1202  };
1203  WriteReal(CMtoPDF(fXsize*xlow));
1204  WriteReal(CMtoPDF(fYsize*ylow));
1205  WriteReal(CMtoPDF(width));
1206  WriteReal(CMtoPDF(height));
1207  PrintStr("]");
1208  PrintStr("@");
1209 
1210  Double_t xmargin = CMtoPDF(0.7);
1211  Double_t ymargin = 0;
1212  if (fPageOrientation == 1) ymargin = CMtoPDF(TMath::Sqrt(2.)*0.7);
1213  if (fPageOrientation == 2) ymargin = CMtoPDF(height)-CMtoPDF(0.7);
1214 
1215  PrintStr("/CropBox [");
1216  if (fPageOrientation == 1) {
1217  WriteReal(xmargin);
1218  WriteReal(ymargin);
1219  WriteReal(xmargin+CMtoPDF(fXsize*xup));
1220  WriteReal(ymargin+CMtoPDF(fYsize*yup));
1221  }
1222  if (fPageOrientation == 2) {
1223  WriteReal(xmargin);
1224  WriteReal(CMtoPDF(height)-CMtoPDF(fXsize*xup)-xmargin);
1225  WriteReal(xmargin+CMtoPDF(fYsize*yup));
1226  WriteReal(CMtoPDF(height)-xmargin);
1227  }
1228  PrintStr("]");
1229  PrintStr("@");
1230 
1231  if (fPageOrientation == 1) PrintStr("/Rotate 0@");
1232  if (fPageOrientation == 2) PrintStr("/Rotate 90@");
1233 
1234  PrintStr("/Resources");
1236  PrintStr(" 0 R");
1237  PrintStr("@");
1238 
1239  PrintStr("/Contents");
1241  PrintStr(" 0 R@");
1242  PrintStr(">>@");
1243  PrintStr("endobj@");
1244 
1245  NewObject(4*(fNbPage-1)+kObjFirstPage+1);
1246  PrintStr("<<@");
1247  PrintStr("/Length");
1249  PrintStr(" 0 R@");
1250  PrintStr("/Filter [/FlateDecode]@");
1251  PrintStr(">>@");
1252  PrintStr("stream@");
1253  fStartStream = fNByte;
1254  fCompress = kTRUE;
1255 
1256  // Force the line width definition next time TPDF::SetLineWidth will be called.
1257  fLineWidth = -1;
1258 
1259  // Force the color definition next time TPDF::SetColor will be called.
1260  fRed = -1;
1261  fGreen = -1;
1262  fBlue = -1;
1263  fAlpha = -1.;
1264 
1265  PrintStr("1 0 0 1");
1266  if (fPageOrientation == 2) {
1267  ymargin = CMtoPDF(height)-CMtoPDF(fXsize*xup)-xmargin;
1268  xmargin = xmargin+CMtoPDF(fYsize*yup);
1269  }
1270  WriteReal(xmargin);
1271  WriteReal(ymargin);
1272  PrintStr(" cm");
1273  if (fPageOrientation == 2) PrintStr(" 0 1 -1 0 0 0 cm");
1274  if (fgLineJoin) {
1276  PrintFast(2," j");
1277  }
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Deactivate an already open PDF file
1282 
1284 {
1285  gVirtualPS = 0;
1286 }
1287 
1288 ////////////////////////////////////////////////////////////////////////////////
1289 /// Activate an already open PDF file
1290 
1291 void TPDF::On()
1292 {
1293  // fType is used to know if the PDF file is open. Unlike TPostScript, TPDF
1294  // has no "workstation type".
1295 
1296  if (!fType) {
1297  Error("On", "no PDF file open");
1298  Off();
1299  return;
1300  }
1301  gVirtualPS = this;
1302 }
1303 
1304 ////////////////////////////////////////////////////////////////////////////////
1305 /// Open a PDF file
1306 
1307 void TPDF::Open(const char *fname, Int_t wtype)
1308 {
1309  Int_t i;
1310 
1311  if (fStream) {
1312  Warning("Open", "PDF file already open");
1313  return;
1314  }
1315 
1316  fLenBuffer = 0;
1317  fRed = -1;
1318  fGreen = -1;
1319  fBlue = -1;
1320  fAlpha = -1.;
1321  fType = abs(wtype);
1325  Float_t xrange, yrange;
1326  if (gPad) {
1327  Double_t ww = gPad->GetWw();
1328  Double_t wh = gPad->GetWh();
1329  if (fType == 113) {
1330  ww *= gPad->GetWNDC();
1331  wh *= gPad->GetHNDC();
1332  }
1333  Double_t ratio = wh/ww;
1334  xrange = fXsize;
1335  yrange = fXsize*ratio;
1336  if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
1337  fXsize = xrange; fYsize = yrange;
1338  }
1339 
1340  // Open OS file
1341  fStream = new std::ofstream();
1342 #ifdef R__WIN32
1343  fStream->open(fname, std::ofstream::out | std::ofstream::binary);
1344 #else
1345  fStream->open(fname, std::ofstream::out);
1346 #endif
1347  if (fStream == 0 || !fStream->good()) {
1348  printf("ERROR in TPDF::Open: Cannot open file:%s\n",fname);
1349  if (fStream == 0) return;
1350  }
1351 
1352  gVirtualPS = this;
1353 
1354  for (i=0; i<fSizBuffer; i++) fBuffer[i] = ' ';
1355 
1356  // The page orientation is last digit of PDF workstation type
1357  // orientation = 1 for portrait
1358  // orientation = 2 for landscape
1359  fPageOrientation = fType%10;
1360  if (fPageOrientation < 1 || fPageOrientation > 2) {
1361  Error("Open", "Invalid page orientation %d", fPageOrientation);
1362  return;
1363  }
1364 
1365  // format = 0-99 is the European page format (A4,A3 ...)
1366  // format = 100 is the US format 8.5x11.0 inch
1367  // format = 200 is the US format 8.5x14.0 inch
1368  // format = 300 is the US format 11.0x17.0 inch
1369  fPageFormat = fType/1000;
1370  if (fPageFormat == 0) fPageFormat = 4;
1371  if (fPageFormat == 99) fPageFormat = 0;
1372 
1373  fRange = kFALSE;
1374 
1375  // Set a default range
1376  Range(fXsize, fYsize);
1377 
1378  fObjPos = 0;
1379  fObjPosSize = 0;
1380  fNbObj = 0;
1381  fNbPage = 0;
1382 
1383  PrintStr("%PDF-1.4@");
1384  PrintStr("%\342\343\317\323");
1385  PrintStr("@");
1386 
1388  PrintStr("<<@");
1389  PrintStr("/Type /Catalog@");
1390  PrintStr("/Pages");
1392  PrintStr(" 0 R@");
1393  PrintStr("/Outlines");
1395  PrintStr(" 0 R@");
1396  PrintStr("/PageMode /UseOutlines@");
1397  PrintStr(">>@");
1398  PrintStr("endobj@");
1399 
1401  PrintStr("<<@");
1402  PrintStr("/Creator (ROOT Version ");
1403  PrintStr(gROOT->GetVersion());
1404  PrintStr(")");
1405  PrintStr("@");
1406  PrintStr("/CreationDate (");
1407  TDatime t;
1408  char str[17];
1409  snprintf(str,17,"D:%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d",
1410  t.GetYear() , t.GetMonth(),
1411  t.GetDay() , t.GetHour(),
1412  t.GetMinute(), t.GetSecond());
1413  PrintStr(str);
1414  PrintStr(")");
1415  PrintStr("@");
1416  PrintStr("/Title (");
1417  if (strlen(GetName())<=80) PrintStr(GetName());
1418  PrintStr(")");
1419  PrintStr("@");
1420  PrintStr("/Keywords (ROOT)@");
1421  PrintStr(">>@");
1422  PrintStr("endobj@");
1423 
1425  PrintStr("<<@");
1426  PrintStr("/ProcSet [/PDF /Text]@");
1427 
1428  PrintStr("/Font@");
1429  PrintStr("<<@");
1430  for (i=0; i<kNumberOfFonts; i++) {
1431  PrintStr(" /F");
1432  WriteInteger(i+1,0);
1434  PrintStr(" 0 R");
1435  }
1436  PrintStr("@");
1437  PrintStr(">>@");
1438 
1439  PrintStr("/ExtGState");
1441  PrintStr(" 0 R @");
1442  if (fAlphas.size()) fAlphas.clear();
1443 
1444  PrintStr("/ColorSpace << /Cs8");
1446  PrintStr(" 0 R >>");
1447  PrintStr("@");
1448  PrintStr("/Pattern");
1450  PrintStr(" 0 R");
1451  PrintStr("@");
1452  PrintStr(">>@");
1453  PrintStr("endobj@");
1454 
1455  FontEncode();
1456  PatternEncode();
1457 
1458  NewPage();
1460 }
1461 
1462 ////////////////////////////////////////////////////////////////////////////////
1463 /// Patterns encoding
1464 
1466 {
1467  Int_t patternNb = kObjPattern;
1468 
1470  if (gStyle->GetColorModelPS()) {
1471  PrintStr("[/Pattern /DeviceCMYK]@");
1472  } else {
1473  PrintStr("[/Pattern /DeviceRGB]@");
1474  }
1475  PrintStr("endobj@");
1477  PrintStr("<</ProcSet[/PDF]>>@");
1478  PrintStr("endobj@");
1479 
1481  PrintStr("<<@");
1482  PrintStr(" /P01");
1483  WriteInteger(patternNb++);
1484  PrintStr(" 0 R");
1485  PrintStr(" /P02");
1486  WriteInteger(patternNb++);
1487  PrintStr(" 0 R");
1488  PrintStr(" /P03");
1489  WriteInteger(patternNb++);
1490  PrintStr(" 0 R");
1491  PrintStr(" /P04");
1492  WriteInteger(patternNb++);
1493  PrintStr(" 0 R");
1494  PrintStr(" /P05");
1495  WriteInteger(patternNb++);
1496  PrintStr(" 0 R");
1497  PrintStr(" /P06");
1498  WriteInteger(patternNb++);
1499  PrintStr(" 0 R");
1500  PrintStr(" /P07");
1501  WriteInteger(patternNb++);
1502  PrintStr(" 0 R");
1503  PrintStr(" /P08");
1504  WriteInteger(patternNb++);
1505  PrintStr(" 0 R");
1506  PrintStr(" /P09");
1507  WriteInteger(patternNb++);
1508  PrintStr(" 0 R");
1509  PrintStr(" /P10");
1510  WriteInteger(patternNb++);
1511  PrintStr(" 0 R");
1512  PrintStr(" /P11");
1513  WriteInteger(patternNb++);
1514  PrintStr(" 0 R");
1515  PrintStr(" /P12");
1516  WriteInteger(patternNb++);
1517  PrintStr(" 0 R");
1518  PrintStr(" /P13");
1519  WriteInteger(patternNb++);
1520  PrintStr(" 0 R");
1521  PrintStr(" /P14");
1522  WriteInteger(patternNb++);
1523  PrintStr(" 0 R");
1524  PrintStr(" /P15");
1525  WriteInteger(patternNb++);
1526  PrintStr(" 0 R");
1527  PrintStr(" /P16");
1528  WriteInteger(patternNb++);
1529  PrintStr(" 0 R");
1530  PrintStr(" /P17");
1531  WriteInteger(patternNb++);
1532  PrintStr(" 0 R");
1533  PrintStr(" /P18");
1534  WriteInteger(patternNb++);
1535  PrintStr(" 0 R");
1536  PrintStr(" /P19");
1537  WriteInteger(patternNb++);
1538  PrintStr(" 0 R");
1539  PrintStr(" /P20");
1540  WriteInteger(patternNb++);
1541  PrintStr(" 0 R");
1542  PrintStr(" /P21");
1543  WriteInteger(patternNb++);
1544  PrintStr(" 0 R");
1545  PrintStr(" /P22");
1546  WriteInteger(patternNb++);
1547  PrintStr(" 0 R");
1548  PrintStr(" /P23");
1549  WriteInteger(patternNb++);
1550  PrintStr(" 0 R");
1551  PrintStr(" /P24");
1552  WriteInteger(patternNb++);
1553  PrintStr(" 0 R");
1554  PrintStr(" /P25");
1555  WriteInteger(patternNb++);
1556  PrintStr(" 0 R@");
1557  PrintStr(">>@");
1558  PrintStr("endobj@");
1559 
1560  patternNb = kObjPattern;
1561 
1562  // P01
1563  NewObject(patternNb++);
1564  PrintStr("<</Type/Pattern/Matrix[1 0 0 1 20 28]/PatternType 1/Resources");
1566  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 98 4]/XStep 98/YStep 4/Length 91/Filter/FlateDecode>>");
1567  PrintStr("@");
1568  fStream->write("stream",6); fNByte += 6;
1569  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301P\241\034(\254\340\253\020m\250\020k\240\220\302e\244`\242\220\313ei\t\244r\200\272\215A\034\v \225\003\2241\202\310\030\201e\f!2\206@N0W \027@\200\001\0|c\024\357\n", 93);
1570  fNByte += 93;
1571  PrintStr("endstream@");
1572  PrintStr("endobj@");
1573 
1574  // P02
1575  NewObject(patternNb++);
1576  PrintStr("<</Type/Pattern/Matrix[0.75 0 0 0.75 20 28]/PatternType 1/Resources");
1578  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 96 4]/XStep 96/YStep 4/Length 92/Filter/FlateDecode>>@");
1579  PrintStr("@");
1580  fStream->write("stream",6); fNByte += 6;
1581  fStream->write("\r\nH\211$\2121\n\2000\024C\367\234\"G\370\277\025\321+\b\016\342\340P\334tP\252\240\213\3277\332!\204\274\227\v\316\2150\032\335J\356\025\023O\241Np\247\363\021f\317\344\214\234\215\v\002+\036h\033U\326/~\243Ve\231PL\370\215\027\343\032#\006\274\002\f\0\242`\025:\n", 94);
1582  fNByte += 94;
1583  PrintStr("endstream@");
1584  PrintStr("endobj@");
1585 
1586  // P03
1587  NewObject(patternNb++);
1588  PrintStr("<</Type/Pattern/Matrix[0.5 0 0 0.5 20 28]/PatternType 1/Resources");
1590  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 96 16]/XStep 96/YStep 16/Length 93/Filter/FlateDecode>>@");
1591  PrintStr("@");
1592  fStream->write("stream",6); fNByte += 6;
1593  fStream->write("\r\nH\211$\2121\n\2000\024C\367\234\"G\370\261(\366\n\202\20388\210\233\016J\025t\361\372\376\332!\204\274\227\033\342N\030\215\262\222g\303\304\313Q\347\360\240\370:f\317Y\f\\\214+**\360Dls'\177\306\274\032\257\344\256.\252\376\215\212\221\217\021\003>\001\006\0\317\243\025\254\n", 95);
1594  fNByte += 95;
1595  PrintStr("endstream@");
1596  PrintStr("endobj@");
1597 
1598  // P04
1599  NewObject(patternNb++);
1600  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1602  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 63/Filter/FlateDecode>>");
1603  PrintStr("@");
1604  fStream->write("stream",6); fNByte += 6;
1605  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\002V\231\313\005S\233\303\025\314\025\310\005\020`\0\344\270\r\274\n", 65);
1606  fNByte += 65;
1607  PrintStr("endstream@");
1608  PrintStr("endobj@");
1609 
1610  // P05
1611  NewObject(patternNb++);
1612  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1614  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
1615  PrintStr("@");
1616  fStream->write("stream",6); fNByte += 6;
1617  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\302\005Q\223\313\005\"\r\024r\270\202\271\002\271\0\002\f\0\344\320\r\274\n", 68);
1618  fNByte += 68;
1619  PrintStr("endstream@");
1620  PrintStr("endobj@");
1621 
1622  // P06
1623  NewObject(patternNb++);
1624  PrintStr("<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources");
1626  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
1627  PrintStr("@");
1628  fStream->write("stream",6); fNByte += 6;
1629  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\302e\nR\232\v\242@js\270\202\271\002\271\0\002\f\0\345X\r\305\n", 68);
1630  fNByte += 68;
1631  PrintStr("endstream@");
1632  PrintStr("endobj@");
1633 
1634  // P07
1635  NewObject(patternNb++);
1636  PrintStr("<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources");
1638  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 68/Filter/FlateDecode>>");
1639  PrintStr("@");
1640  fStream->write("stream",6); fNByte += 6;
1641  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\002\02465P\310\345\002)\0042r\270\202\271\002\271\0\002\f\0\345=\r\305\n", 70);
1642  fNByte += 70;
1643  PrintStr("endstream@");
1644  PrintStr("endobj@");
1645 
1646  // P08
1647  NewObject(patternNb++);
1648  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1650  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 139/Filter/FlateDecode>>");
1651  PrintStr("@");
1652  fStream->write("stream",6); fNByte += 6;
1653  fStream->write("\r\nH\211D\217\261\016\3020\fDw\177\305\315L6Q\225|\003\022C\305\300Puk+\201\032$\272\360\373\330\265\323\016\271\330\367\234\344\"x\201\030\214\252\232\030+%\353VZ.jd\367\205\003x\241({]\311\324]\323|\342\006\033J\201:\306\325\230Jg\226J\261\275D\257#\337=\220\260\354k\233\351\211\217Z75\337\020\374\324\306\035\303\310\230\342x=\303\371\275\307o\332s\331\223\224\240G\330\a\365\364\027`\0\nX1}\n",141);
1654  fNByte += 141;
1655  PrintStr("endstream@");
1656  PrintStr("endobj@");
1657 
1658  // P09
1659  NewObject(patternNb++);
1660  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1662  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 108/Filter/FlateDecode>>");
1663  PrintStr("@");
1664  fStream->write("stream",6); fNByte += 6;
1665  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\002\02465P\310\005RFFz&\020\002,d\240\220\314en\256g\0065\b,\001b\230\202$\240\232\214@\362\246`\2169H\336\024\2426\231\v&\200,\n\326\030\314\025\310\005\020`\0\f@\036\227\n", 110);
1666  fNByte += 110;
1667  PrintStr("endstream@");
1668  PrintStr("endobj@");
1669 
1670  // P10
1671  NewObject(patternNb++);
1672  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1674  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 93/Filter/FlateDecode>>");
1675  PrintStr("@");
1676  fStream->write("stream",6); fNByte += 6;
1677  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\002\02465P\310\345\002)\0042r\200\332\r\241\\C \017dN.\027L\312\0\302\205\2535\205j6\205X\224\303\025\314\025\310\005\020`\0\2127\031\t\n", 95);
1678  fNByte += 95;
1679  PrintStr("endstream@");
1680  PrintStr("endobj@");
1681 
1682  // P11
1683  NewObject(patternNb++);
1684  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1686  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 164/Filter/FlateDecode>>");
1687  PrintStr("@");
1688  fStream->write("stream",6); fNByte += 6;
1689  fStream->write("\r\nH\211\\\2171\016\3020\fEw\237\342\037\301ip\223^\001\211\001u`@l0\200(\022,\\\037;v\204\332\241\211\336\373\337V\363\246\204;\210\301H\354\337\347F'\274T\355U>\220\360U\215\003\316\027\306\2655\027=\a\306\223\304I\002m\332\330\356&\030\325\333fZ\275F\337\205\235\265O\270\032\004\331\214\336\305\270\004\227`\357i\256\223\342;]\344\255(!\372\356\205j\030\377K\335\220\344\377\210\274\306\022\330\337T{\214,\212;\301\3508\006\346\206\021O=\216|\212|\246#\375\004\030\0\216FF\207\n", 166);
1690  fNByte += 166;
1691  PrintStr("endstream@");
1692  PrintStr("endobj@");
1693 
1694  // P12
1695  NewObject(patternNb++);
1696  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1698  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 226/Filter/FlateDecode>>");
1699  PrintStr("@");
1700  fStream->write("stream",6); fNByte += 6;
1701  fStream->write("\r\nH\211<P;n\3030\f\335y\n\236 \220DK\242\256P\240C\321\241C\221\311\311\220\242\016\220.\275~D\221/\203I\342}\370(?(\363\215)q\342\234\374\373\273\322\027\337'\3646\301\037\316\374?a~\347\357s\342\313\2045\361A9\237\322fc\231\200\236F\263\301\334;\211\017\207\rN\311\252S\\\227{\247\006w\207\244\303\255p+(\205\333\360e/v\356a\315\317\360\272\320b|w\276\203o\340k\b\004\027\v$b\226\235,\242\254t(\024\nu\305Vm\313\021\375\327\272\257\227fuf\226ju\356\222x\030\024\313\261S\215\377\341\274,\203\254\253Z\\\262A\262\205eD\350\210\320\201\225\212\320\036\241\355\025\372JE,\2266\344\366\310U\344\016HFx>\351\203\236\002\f\0d}e\216\n", 228);
1702  fNByte += 228;
1703  PrintStr("endstream@");
1704  PrintStr("endobj@");
1705 
1706  // P13
1707  NewObject(patternNb++);
1708  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1710  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>");
1711  PrintStr("@");
1712  fStream->write("stream",6); fNByte += 6;
1713  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\002V\231\313\005S\233\303\005\241!\" ~0W \027@\200\001\0\331\227\020\253\n", 71);
1714  fNByte += 71;
1715  PrintStr("endstream@");
1716  PrintStr("endobj@");
1717 
1718  // P14
1719  NewObject(patternNb++);
1720  PrintStr("<</Type/Pattern/Matrix[0.15 0 0 0.15 20 28]/PatternType 1/Resources");
1722  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 80/YStep 80/Length 114/Filter/FlateDecode>>");
1723  PrintStr("@");
1724  fStream->write("stream",6); fNByte += 6;
1725  fStream->write("\r\nH\2114\214=\n\2000\f\205\367\234\342\035!-\241\364\f\202\20388\210\233\016J+\350\342\365M\3723\224\327\367}I\036r8A\f\206\343\372\336\203\026\334\212\006\205\027\004\237b\214X7\306\256\33032\331\240~\022y[\315\026\206\222\372\330}\264\036\253\217\335\353\240\030\b%\223\245o=X\227\346\245\355K\341\345@\3613M\364\v0\0\207o\"\261\n", 116);
1726  fNByte += 116;
1727  PrintStr("endstream@");
1728  PrintStr("endobj@");
1729 
1730  // P15
1731  NewObject(patternNb++);
1732  PrintStr("<</Type/Pattern/Matrix[0.102 0 0 0.102 20 28]/PatternType 1/Resources");
1734  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 60 60]/XStep 60/YStep 60/Length 218/Filter/FlateDecode>>");
1735  PrintStr("@");
1736  fStream->write("stream",6); fNByte += 6;
1737  fStream->write("\r\nH\211<\2211\016\3020\fEw\237\302'@\211c\267w@b@\f\f\210\2510\200(\022,\\\037\347\307\256Z\325\221\375\337\377\225\363\241\312\017\246\302\205'\274\337;\235\371\355\215\275\267\236\\\371\307\265\360\201/\327\3027o\233\361J\262\233\247~\362g\336\211zur!A]{\035}\031S\343\006p\241\226dKI\v\326\202\265\3153\331)X)\335fE\205M\235\373\327\r*\374\026\252\022\216u\223\200\361I\211\177\031\022\001#``\342GI\211\004c\221gi\246\231\247\221\247\231\247\233$XM3\315<\215<\315<K\211e\036#\215a4\366\344\035lm\214Z\314b\211Xj\337K\\\201$\332\325\v\365\2659\204\362\242\274'\v\221\r\321\211\216\364\027`\0\212'_\215\n", 220);
1738  fNByte += 220;
1739  PrintStr("endstream@");
1740  PrintStr("endobj@");
1741 
1742  // P16
1743  NewObject(patternNb++);
1744  PrintStr("<</Type/Pattern/Matrix[0.1 0 0 0.05 20 28]/PatternType 1/Resources");
1746  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 123/Filter/FlateDecode>>");
1747  PrintStr("@");
1748  fStream->write("stream",6); fNByte += 6;
1749  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020\035k\240\220\302ej\240\0D\271 \332\314X\317B\301\330\002H\230\233*\030\231\202\310d.CC=#\020\v*\rV\235\214\254\v\210r@\264\261\031P\241\031H5D\253\021H\267\005\3104 \v\344\016\260\002\020\003lB0W \027@\200\001\0hU \305\n", 125);
1750  fNByte += 125;
1751  PrintStr("endstream@");
1752  PrintStr("endobj@");
1753 
1754  // P17
1755  NewObject(patternNb++);
1756  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1758  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
1759  PrintStr("@");
1760  fStream->write("stream",6); fNByte += 6;
1761  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020md\242\020k\240\220\002V\234\313\005S\236\303\025\314\025\310\005\020`\0\r\351\016B\n", 68);
1762  fNByte += 68;
1763  PrintStr("endstream@");
1764  PrintStr("endobj@");
1765 
1766  // P18
1767  NewObject(patternNb++);
1768  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1770  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>");
1771  PrintStr("@");
1772  fStream->write("stream",6); fNByte += 6;
1773  fStream->write("\r\nH\211*\3442T\310T\3402P0P04\200\340\242T\256p\205<\240\220\027P0K\301D\241\034(\254\340\253\020md\242\020k\240\220\302\005Q\226\313\005\"\r\024r\270\202\271\002\271\0\002\f\0\016\001\016B\n", 71);
1774  fNByte += 71;
1775  PrintStr("endstream@");
1776  PrintStr("endobj@");
1777 
1778  // P19
1779  NewObject(patternNb++);
1780  PrintStr("<</Type/Pattern/Matrix[0.117 0 0 0.117 20 28]/PatternType 1/Resources");
1782  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 149/Filter/FlateDecode>>");
1783  PrintStr("@");
1784  fStream->write("stream",6); fNByte += 6;
1785  fStream->write("\r\nH\211L\216;\016\302@\fD{\237bN\020\331+6a\257\200D\201((P\252@\001R\220\240\341\372\370\263\216(\326\266f\336\330\373&\301\003\304`\b\307\373\334\351\202\227J\a\025\237\020|U\306\021\327\231q\243\306\250\214\325\372T\006\336\367\032\262\326\205\3124\264b\243$\"n.\244=\314\250!\2139\033\327\022i=\323\317\2518\332T}\347.\202\346W\373\372j\315\221\344\266\213=\237\241\344\034\361\264!\236w\344\177\271o8\323\211~\002\f\0\366\3026\233\n", 151);
1786  fNByte += 151;
1787  PrintStr("endstream@");
1788  PrintStr("endobj@");
1789 
1790  // P20
1791  NewObject(patternNb++);
1792  PrintStr("<</Type/Pattern/Matrix[0.05 0 0 0.1 20 28]/PatternType 1/Resources");
1794  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 122/Filter/FlateDecode>>");
1795  PrintStr("@");
1796  fStream->write("stream",6); fNByte += 6;
1797  fStream->write("\r\nH\211<L;\016\2030\f\335}\212w\002\344$M\2323 1 \006\006\304\224vhU\220`\341\372<\aT\311\366\263\336o\023\207\017D\241pz\355\376\226\021+\251\226\344\027\017\034\244\321a\232\025/\211\n\316r\343ORh\262}\317\210\344\032o\310)\302\2233\245\252[m\274\332\313\277!$\332\371\371\210`N\242\267$\217\263\246\252W\257\245\006\351\345\024`\0o\347 \305\n", 124);
1798  fNByte += 124;
1799  PrintStr("endstream@");
1800  PrintStr("endobj@");
1801 
1802  // P21
1803  NewObject(patternNb++);
1804  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1806  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 117/Filter/FlateDecode>>");
1807  PrintStr("@");
1808  fStream->write("stream",6); fNByte += 6;
1809  fStream->write("\r\nH\211D\2151\n\2000\fE\367\234\342\037!)\224\336Ap\020\a\aq\323A\251\202.^\337$-\025\022^\372\033^n\022\354 \006CX\274\237\215&\\\032u\032\036\020\274\032\243\307\2740V]\027\234\024\242\"\033\2642En\324\312\224bc\262\\\230\377\301\332WM\224\212(U\221\375\265\301\025\016?\350\317P\215\221\033\213o\244\201>\001\006\0\031I'f\n", 119);
1810  fNByte += 119;
1811  PrintStr("endstream@");
1812  PrintStr("endobj@");
1813 
1814  // P22
1815  NewObject(patternNb++);
1816  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1818  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 118/Filter/FlateDecode>>");
1819  PrintStr("@");
1820  fStream->write("stream",6); fNByte += 6;
1821  fStream->write("\r\nH\211<\215=\n\204P\f\204\373\234b\216\220<\b\357\016\302\026ba!vZ(\273\v\332x}\223\274\237\"|\223a\230\271Hp\200\030\fa\211\273w\232\3617k0\363\204\3401\033\037,+c#\3170~\2244\304\327EV\243r\247\272oOcr\337\323]H\t\226\252\334\252r\255\362\257\213(\t\304\250\326\315T\267\032\275q\242\221^\001\006\0\272\367(&\n", 120);
1822  fNByte += 120;
1823  PrintStr("endstream@");
1824  PrintStr("endobj@");
1825 
1826  // P23
1827  NewObject(patternNb++);
1828  PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
1830  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 169/Filter/FlateDecode>>");
1831  PrintStr("@");
1832  fStream->write("stream",6); fNByte += 6;
1833  fStream->write("\r\nH\211<\220\273\n\0021\020E\373\371\212[[M\326\331\354\344\027\004\v\261\260\020;\025\224D\320\306\337w\036\254p\363\230\223\341$\344M\005\017\020\203Q8\307\347F'\274\f\355\f>Q\3605\214=\316\005\v.\214kt\217\230;)\324\366\245Fa\213e\320v\212r\022X\006\211Fi\3242\250J\224\302\020\367h\212\254I\\\325R\225o\03143\346U\235@a\t[\202Za\tA\202E`\351~O\002\235`\351~S\202\306h.m\253\264)\232K\217t\310\017q\354\a\353\247\364\377C\356\033\372\t0\0\bm:\375\n", 171);
1834  fNByte += 171;
1835  PrintStr("endstream@");
1836  PrintStr("endobj@");
1837 
1838  // P24
1839  NewObject(patternNb++);
1840  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1842  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 280/Filter/FlateDecode>>");
1843  PrintStr("@");
1844  fStream->write("stream",6); fNByte += 6;
1845  fStream->write("\r\nH\211DQ9N\004A\f\314\373\025\216\211\326\343v\037_@\"@\004\004\210\f\220@\003\022$|\177\335\345j\220v\345\251\303\343*\215\312\273\024\275\\d\375?\361dM\3162\306\337\214\337Y\336n\240m\217\036\301y\343\\<,i\250\0038F\035)\347l\322\026o\377\023\353|[\254\177\343\005;\315\317ky\224\257\240n\203\374\020\225\337\240\345N\236T\272<_\344\245\304^\3238\030\tc\236E\233xO\034\363\204>\251\317\324\233\023{\352\235\376\336S\357Fl\251\017\372\207\247>xoh&_\366Ud\331\253\314D\023\332\241\211\016\205\246\235\326\236*\275\307\204z8!s\031\335\306\\\306C\306\\\225\376\312\\\225\307\252\246\356\364\273Q\347\271:\371\341l\177\311e\210\3571\211\251#\374\302H\037:\342c\241\323\2617\320 \034\250\0\302\323a{\005%\302a\373(Zx\313\026\213@\215p\324}\026=\274e\217E8s\326}\026M\036\312}\271\n0\0\215\263\207\016\n", 282);
1846  fNByte += 282;
1847  PrintStr("endstream@");
1848  PrintStr("endobj@");
1849 
1850  // P25
1851  NewObject(patternNb++);
1852  PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
1854  PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 54/Filter/FlateDecode>>");
1855  PrintStr("@");
1856  fStream->write("stream",6); fNByte += 6;
1857  fStream->write("\r\nH\2112T\310T\3402P0P\310\34526P\0\242\034.s\004m\016\242\r\r\f\024@\030\302\002\321iZP\305`M\346\310\212\201R\0\001\006\0\206\322\017\200\n", 56);
1858  fNByte += 56;
1859  PrintStr("endstream@");
1860  PrintStr("endobj@");
1861 }
1862 
1863 ////////////////////////////////////////////////////////////////////////////////
1864 /// Output the string str in the output buffer
1865 
1866 void TPDF::PrintStr(const char *str)
1867 {
1868  Int_t len = strlen(str);
1869  if (len == 0) return;
1870  fPageNotEmpty = kTRUE;
1871 
1872  if (fCompress) {
1873  if (fLenBuffer+len >= fSizBuffer) {
1875  fSizBuffer = 2*fSizBuffer;
1876  }
1877  strcpy(fBuffer + fLenBuffer, str);
1878  fLenBuffer += len;
1879  return;
1880  }
1881 
1882  TVirtualPS::PrintStr(str);
1883 }
1884 
1885 ////////////////////////////////////////////////////////////////////////////////
1886 /// Fast version of Print
1887 
1888 void TPDF::PrintFast(Int_t len, const char *str)
1889 {
1890  fPageNotEmpty = kTRUE;
1891  if (fCompress) {
1892  if (fLenBuffer+len >= fSizBuffer) {
1894  fSizBuffer = 2*fSizBuffer;
1895  }
1896  strcpy(fBuffer + fLenBuffer, str);
1897  fLenBuffer += len;
1898  return;
1899  }
1900 
1901  TVirtualPS::PrintFast(len, str);
1902 }
1903 
1904 ////////////////////////////////////////////////////////////////////////////////
1905 /// Set the range for the paper in centimetres
1906 
1907 void TPDF::Range(Float_t xsize, Float_t ysize)
1908 {
1909  Float_t xps, yps, xncm, yncm, dxwn, dywn, xwkwn, ywkwn, xymax;
1910 
1911  fXsize = xsize;
1912  fYsize = ysize;
1913 
1914  xps = xsize;
1915  yps = ysize;
1916 
1917  if (xsize <= xps && ysize < yps) {
1918  if ( xps > yps) xymax = xps;
1919  else xymax = yps;
1920  xncm = xsize/xymax;
1921  yncm = ysize/xymax;
1922  dxwn = ((xps/xymax)-xncm)/2;
1923  dywn = ((yps/xymax)-yncm)/2;
1924  } else {
1925  if (xps/yps < 1) xwkwn = xps/yps;
1926  else xwkwn = 1;
1927  if (yps/xps < 1) ywkwn = yps/xps;
1928  else ywkwn = 1;
1929 
1930  if (xsize < ysize) {
1931  xncm = ywkwn*xsize/ysize;
1932  yncm = ywkwn;
1933  dxwn = (xwkwn-xncm)/2;
1934  dywn = 0;
1935  if (dxwn < 0) {
1936  xncm = xwkwn;
1937  dxwn = 0;
1938  yncm = xwkwn*ysize/xsize;
1939  dywn = (ywkwn-yncm)/2;
1940  }
1941  } else {
1942  xncm = xwkwn;
1943  yncm = xwkwn*ysize/xsize;
1944  dxwn = 0;
1945  dywn = (ywkwn-yncm)/2;
1946  if (dywn < 0) {
1947  yncm = ywkwn;
1948  dywn = 0;
1949  xncm = ywkwn*xsize/ysize;
1950  dxwn = (xwkwn-xncm)/2;
1951  }
1952  }
1953  }
1954  fRange = kTRUE;
1955 }
1956 
1957 ////////////////////////////////////////////////////////////////////////////////
1958 /// Set the alpha channel value.
1959 
1961 {
1962  if (a == fAlpha) return;
1963  fAlpha = a;
1964  if (fAlpha <= 0.000001) fAlpha = 0;
1965 
1966  Bool_t known = kFALSE;
1967  for (int i=0; i<(int)fAlphas.size(); i++) {
1968  if (fAlpha == fAlphas[i]) {
1969  known = kTRUE;
1970  break;
1971  }
1972  }
1973  if (!known) fAlphas.push_back(fAlpha);
1974  PrintStr(Form(" /ca%3.2f gs /CA%3.2f gs",fAlpha,fAlpha));
1975 }
1976 
1977 ////////////////////////////////////////////////////////////////////////////////
1978 /// Set color with its color index.
1979 
1981 {
1982  if (color < 0) color = 0;
1983  TColor *col = gROOT->GetColor(color);
1984 
1985  if (col) {
1986  SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1987  SetAlpha(col->GetAlpha());
1988  } else {
1989  SetColor(1., 1., 1.);
1990  SetAlpha(1.);
1991  }
1992 }
1993 
1994 ////////////////////////////////////////////////////////////////////////////////
1995 /// Set color with its R G B components:
1996 ///
1997 /// - r: % of red in [0,1]
1998 /// - g: % of green in [0,1]
1999 /// - b: % of blue in [0,1]
2000 
2002 {
2003  if (r == fRed && g == fGreen && b == fBlue) return;
2004 
2005  fRed = r;
2006  fGreen = g;
2007  fBlue = b;
2008  if (fRed <= 0.000001) fRed = 0;
2009  if (fGreen <= 0.000001) fGreen = 0;
2010  if (fBlue <= 0.000001) fBlue = 0;
2011 
2012  if (gStyle->GetColorModelPS()) {
2013  Double_t colCyan, colMagenta, colYellow;
2014  Double_t colBlack = TMath::Min(TMath::Min(1-fRed,1-fGreen),1-fBlue);
2015  if (colBlack==1) {
2016  colCyan = 0;
2017  colMagenta = 0;
2018  colYellow = 0;
2019  } else {
2020  colCyan = (1-fRed-colBlack)/(1-colBlack);
2021  colMagenta = (1-fGreen-colBlack)/(1-colBlack);
2022  colYellow = (1-fBlue-colBlack)/(1-colBlack);
2023  }
2024  if (colCyan <= 0.000001) colCyan = 0;
2025  if (colMagenta <= 0.000001) colMagenta = 0;
2026  if (colYellow <= 0.000001) colYellow = 0;
2027  if (colBlack <= 0.000001) colBlack = 0;
2028  WriteReal(colCyan);
2029  WriteReal(colMagenta);
2030  WriteReal(colYellow);
2031  WriteReal(colBlack);
2032  PrintFast(2," K");
2033  WriteReal(colCyan);
2034  WriteReal(colMagenta);
2035  WriteReal(colYellow);
2036  WriteReal(colBlack);
2037  PrintFast(2," k");
2038  } else {
2039  WriteReal(fRed);
2040  WriteReal(fGreen);
2041  WriteReal(fBlue);
2042  PrintFast(3," RG");
2043  WriteReal(fRed);
2044  WriteReal(fGreen);
2045  WriteReal(fBlue);
2046  PrintFast(3," rg");
2047  }
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Set color index for fill areas
2052 
2054 {
2055  fFillColor = cindex;
2056  if (gStyle->GetFillColor() <= 0) cindex = 0;
2057 }
2058 
2059 ////////////////////////////////////////////////////////////////////////////////
2060 /// Set the fill patterns (1 to 25) for fill areas
2061 
2063 {
2064  char cpat[10];
2065  TColor *col = gROOT->GetColor(color);
2066  if (!col) return;
2067  PrintStr(" /Cs8 cs");
2068  Double_t colRed = col->GetRed();
2069  Double_t colGreen = col->GetGreen();
2070  Double_t colBlue = col->GetBlue();
2071  if (gStyle->GetColorModelPS()) {
2072  Double_t colBlack = TMath::Min(TMath::Min(1-colRed,1-colGreen),1-colBlue);
2073  if (colBlack==1) {
2074  WriteReal(0);
2075  WriteReal(0);
2076  WriteReal(0);
2077  WriteReal(colBlack);
2078  } else {
2079  Double_t colCyan = (1-colRed-colBlack)/(1-colBlack);
2080  Double_t colMagenta = (1-colGreen-colBlack)/(1-colBlack);
2081  Double_t colYellow = (1-colBlue-colBlack)/(1-colBlack);
2082  WriteReal(colCyan);
2083  WriteReal(colMagenta);
2084  WriteReal(colYellow);
2085  WriteReal(colBlack);
2086  }
2087  } else {
2088  WriteReal(colRed);
2089  WriteReal(colGreen);
2090  WriteReal(colBlue);
2091  }
2092  snprintf(cpat,10," /P%2.2d scn", ipat);
2093  PrintStr(cpat);
2094 }
2095 
2096 ////////////////////////////////////////////////////////////////////////////////
2097 /// Set color index for lines
2098 
2100 {
2101  fLineColor = cindex;
2102 }
2103 
2104 ////////////////////////////////////////////////////////////////////////////////
2105 /// Set the value of the global parameter TPDF::fgLineJoin.
2106 /// This parameter determines the appearance of joining lines in a PDF
2107 /// output.
2108 /// It takes one argument which may be:
2109 /// - 0 (miter join)
2110 /// - 1 (round join)
2111 /// - 2 (bevel join)
2112 /// The default value is 0 (miter join).
2113 ///
2114 /// \image html postscript_1.png
2115 ///
2116 /// To change the line join behaviour just do:
2117 /// ~~~ {.cpp}
2118 /// gStyle->SetLineJoinPS(2); // Set the PDF line join to bevel.
2119 /// ~~~
2120 
2121 void TPDF::SetLineJoin( Int_t linejoin )
2122 {
2123  fgLineJoin = linejoin;
2124 }
2125 
2126 ////////////////////////////////////////////////////////////////////////////////
2127 /// Change the line style
2128 ///
2129 /// - linestyle = 2 dashed
2130 /// - linestyle = 3 dotted
2131 /// - linestyle = 4 dash-dotted
2132 /// - linestyle = else solid (1 in is used most of the time)
2133 
2135 {
2136  if ( linestyle == fLineStyle) return;
2137  fLineStyle = linestyle;
2138  TString st = (TString)gStyle->GetLineStyleString(linestyle);
2139  PrintFast(2," [");
2140  TObjArray *tokens = st.Tokenize(" ");
2141  for (Int_t j = 0; j<tokens->GetEntries(); j++) {
2142  Int_t it;
2143  sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2144  WriteInteger((Int_t)(it/4));
2145  }
2146  delete tokens;
2147  PrintFast(5,"] 0 d");
2148 }
2149 
2150 ////////////////////////////////////////////////////////////////////////////////
2151 /// Change the line width
2152 
2154 {
2155  if (linewidth == fLineWidth) return;
2156  fLineWidth = linewidth;
2157  if (fLineWidth!=0) {
2159  PrintFast(2," w");
2160  }
2161 }
2162 
2163 ////////////////////////////////////////////////////////////////////////////////
2164 /// Set color index for markers.
2165 
2167 {
2168  fMarkerColor = cindex;
2169 }
2170 
2171 ////////////////////////////////////////////////////////////////////////////////
2172 /// Set color index for text
2173 
2175 {
2176  fTextColor = cindex;
2177 }
2178 
2179 ////////////////////////////////////////////////////////////////////////////////
2180 /// Draw text
2181 ///
2182 /// - xx: x position of the text
2183 /// - yy: y position of the text
2184 /// - chars: text to be drawn
2185 
2186 void TPDF::Text(Double_t xx, Double_t yy, const char *chars)
2187 {
2188  if (fTextSize <= 0) return;
2189 
2190  const Double_t kDEGRAD = TMath::Pi()/180.;
2191  char str[8];
2192  Double_t x = xx;
2193  Double_t y = yy;
2194 
2195  // Font and text size
2196  Int_t font = abs(fTextFont)/10;
2197  if (font > kNumberOfFonts || font < 1) font = 1;
2198 
2199  Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
2200  Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
2201  Float_t tsize, ftsize;
2202  if (wh < hh) {
2203  tsize = fTextSize*wh;
2204  Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2205  ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2206  } else {
2207  tsize = fTextSize*hh;
2208  Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2209  ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2210  }
2211  Double_t fontsize = 72*(ftsize)/2.54;
2212  if (fontsize <= 0) return;
2213 
2214  // Text color
2216 
2217  // Clipping
2218  PrintStr(" q");
2219  Double_t x1 = XtoPDF(gPad->GetX1());
2220  Double_t x2 = XtoPDF(gPad->GetX2());
2221  Double_t y1 = YtoPDF(gPad->GetY1());
2222  Double_t y2 = YtoPDF(gPad->GetY2());
2223  WriteReal(x1);
2224  WriteReal(y1);
2225  WriteReal(x2 - x1);
2226  WriteReal(y2 - y1);
2227  PrintStr(" re W n");
2228 
2229  // Start the text
2230  if (!fCompress) PrintStr("@");
2231 
2232  // Text alignment
2233  Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2234  Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2235  Int_t txalh = fTextAlign/10;
2236  if (txalh < 1) txalh = 1; else if (txalh > 3) txalh = 3;
2237  Int_t txalv = fTextAlign%10;
2238  if (txalv < 1) txalv = 1; else if (txalv > 3) txalv = 3;
2239  if (txalv == 3) {
2240  y -= 0.8*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2241  x += 0.8*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2242  } else if (txalv == 2) {
2243  y -= 0.4*tsizey*TMath::Cos(kDEGRAD*fTextAngle);
2244  x += 0.4*tsizex*TMath::Sin(kDEGRAD*fTextAngle);
2245  }
2246 
2247  if (txalh > 1) {
2248  TText t;
2249  UInt_t w=0, h;
2252  t.GetTextExtent(w, h, chars);
2253  Double_t twx = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2254  Double_t twy = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(w);
2255  if (txalh == 2) {
2256  x = x-(twx/2)*TMath::Cos(kDEGRAD*fTextAngle);
2257  y = y-(twy/2)*TMath::Sin(kDEGRAD*fTextAngle);
2258  }
2259  if (txalh == 3) {
2260  x = x-twx*TMath::Cos(kDEGRAD*fTextAngle);
2261  y = y-twy*TMath::Sin(kDEGRAD*fTextAngle);
2262  }
2263  }
2264 
2265  // Text angle
2266  if (fTextAngle == 0) {
2267  PrintStr(" 1 0 0 1");
2268  WriteReal(XtoPDF(x));
2269  WriteReal(YtoPDF(y));
2270  } else if (fTextAngle == 90) {
2271  PrintStr(" 0 1 -1 0");
2272  WriteReal(XtoPDF(x));
2273  WriteReal(YtoPDF(y));
2274  } else if (fTextAngle == 270) {
2275  PrintStr(" 0 -1 1 0");
2276  WriteReal(XtoPDF(x));
2277  WriteReal(YtoPDF(y));
2278  } else {
2279  WriteReal(TMath::Cos(kDEGRAD*fTextAngle));
2280  WriteReal(TMath::Sin(kDEGRAD*fTextAngle));
2281  WriteReal(-TMath::Sin(kDEGRAD*fTextAngle));
2282  WriteReal(TMath::Cos(kDEGRAD*fTextAngle));
2283  WriteReal(XtoPDF(x));
2284  WriteReal(YtoPDF(y));
2285  }
2286  PrintStr(" cm");
2287 
2288  // Symbol Italic tan(15) = .26794
2289  if (font == 15) PrintStr(" 1 0 0.26794 1 0 0 cm");
2290 
2291  PrintStr(" BT");
2292 
2293  snprintf(str,8," /F%d",font);
2294  PrintStr(str);
2295  WriteReal(fontsize);
2296  PrintStr(" Tf");
2297 
2298  const Int_t len=strlen(chars);
2299 
2300  // Calculate the individual character placements.
2301  // Otherwise, if a string is printed in one line the kerning is not
2302  // performed. In order to measure the precise character positions we need to
2303  // trick FreeType into rendering high-resolution characters otherwise it will
2304  // stick to the screen pixel grid which is far worse than we can achieve on
2305  // print.
2306  const Float_t scale = 16.0;
2307  // Save current text attributes.
2308  TText saveAttText;
2309  saveAttText.TAttText::operator=(*this);
2310  TText t;
2311  t.SetTextSize(fTextSize * scale);
2313  UInt_t wa1=0, wa0=0;
2314  t.GetTextAdvance(wa0, chars, kFALSE);
2315  t.GetTextAdvance(wa1, chars);
2316  t.TAttText::Modify();
2317  Bool_t kerning;
2318  if (wa0-wa1 != 0) kerning = kTRUE;
2319  else kerning = kFALSE;
2320  Int_t *charDeltas = 0;
2321  if (kerning) {
2322  charDeltas = new Int_t[len];
2323  for (Int_t i = 0;i < len;i++) {
2324  UInt_t ww=0;
2325  t.GetTextAdvance(ww, chars + i);
2326  charDeltas[i] = wa1 - ww;
2327  }
2328  for (Int_t i = len - 1;i > 0;i--) {
2329  charDeltas[i] -= charDeltas[i-1];
2330  }
2331  char tmp[2];
2332  tmp[1] = 0;
2333  for (Int_t i = 1;i < len;i++) {
2334  tmp[0] = chars[i-1];
2335  UInt_t width=0;
2336  t.GetTextAdvance(width, &tmp[0], kFALSE);
2337  Double_t wwl = gPad->AbsPixeltoX(width - charDeltas[i]) - gPad->AbsPixeltoX(0);
2338  wwl -= 0.5*(gPad->AbsPixeltoX(1) - gPad->AbsPixeltoX(0)); // half a pixel ~ rounding error
2339  charDeltas[i] = (Int_t)((1000.0/Float_t(fontsize))*(XtoPDF(wwl) - XtoPDF(0))/scale);
2340  }
2341  }
2342  // Restore text attributes.
2343  saveAttText.TAttText::Modify();
2344 
2345  // Output the text. Escape some characters if needed
2346  if (kerning) PrintStr(" [");
2347  else PrintStr(" (");
2348 
2349  for (Int_t i=0; i<len;i++) {
2350  if (chars[i]!='\n') {
2351  if (kerning) PrintStr("(");
2352  if (chars[i]=='(' || chars[i]==')') {
2353  snprintf(str,8,"\\%c",chars[i]);
2354  } else {
2355  snprintf(str,8,"%c",chars[i]);
2356  }
2357  PrintStr(str);
2358  if (kerning) {
2359  PrintStr(") ");
2360  if (i < len-1) {
2361  WriteInteger(charDeltas[i+1]);
2362  }
2363  }
2364  }
2365  }
2366 
2367  if (kerning) PrintStr("] TJ ET Q");
2368  else PrintStr(") Tj ET Q");
2369  if (!fCompress) PrintStr("@");
2370  if (kerning) delete [] charDeltas;
2371 }
2372 
2373 ////////////////////////////////////////////////////////////////////////////////
2374 /// Write a string of characters
2375 ///
2376 /// This method writes the string chars into a PDF file
2377 /// at position xx,yy in world coordinates.
2378 
2379 void TPDF::Text(Double_t, Double_t, const wchar_t *)
2380 {
2381 }
2382 
2383 ////////////////////////////////////////////////////////////////////////////////
2384 /// Write a string of characters in NDC
2385 
2386 void TPDF::TextNDC(Double_t u, Double_t v, const char *chars)
2387 {
2388  Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2389  Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2390  Text(x, y, chars);
2391 }
2392 
2393 ////////////////////////////////////////////////////////////////////////////////
2394 /// Write a string of characters in NDC
2395 
2396 void TPDF::TextNDC(Double_t u, Double_t v, const wchar_t *chars)
2397 {
2398  Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2399  Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2400  Text(x, y, chars);
2401 }
2402 
2403 ////////////////////////////////////////////////////////////////////////////////
2404 /// Convert U from NDC coordinate to PDF
2405 
2407 {
2408  Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
2409  return 72*cm/2.54;
2410 }
2411 
2412 ////////////////////////////////////////////////////////////////////////////////
2413 /// Convert V from NDC coordinate to PDF
2414 
2416 {
2417  Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
2418  return 72*cm/2.54;
2419 }
2420 
2421 ////////////////////////////////////////////////////////////////////////////////
2422 /// Convert X from world coordinate to PDF
2423 
2425 {
2426  Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
2427  return UtoPDF(u);
2428 }
2429 
2430 ////////////////////////////////////////////////////////////////////////////////
2431 /// Convert Y from world coordinate to PDF
2432 
2434 {
2435  Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
2436  return VtoPDF(v);
2437 }
2438 
2439 ////////////////////////////////////////////////////////////////////////////////
2440 /// Write the buffer in a compressed way
2441 
2443 {
2444  z_stream stream;
2445  int err;
2446  char *out = new char[2*fLenBuffer];
2447 
2448  stream.next_in = (Bytef*)fBuffer;
2449  stream.avail_in = (uInt)fLenBuffer;
2450  stream.next_out = (Bytef*)out;
2451  stream.avail_out = (uInt)2*fLenBuffer;
2452  stream.zalloc = (alloc_func)0;
2453  stream.zfree = (free_func)0;
2454  stream.opaque = (voidpf)0;
2455 
2456  err = deflateInit(&stream, Z_DEFAULT_COMPRESSION);
2457  if (err != Z_OK) {
2458  Error("WriteCompressedBuffer", "error in deflateInit (zlib)");
2459  return;
2460  }
2461 
2462  err = deflate(&stream, Z_FINISH);
2463  if (err != Z_STREAM_END) {
2464  deflateEnd(&stream);
2465  Error("WriteCompressedBuffer", "error in deflate (zlib)");
2466  return;
2467  }
2468 
2469  err = deflateEnd(&stream);
2470 
2471  fStream->write(out, stream.total_out);
2472 
2473  fNByte += stream.total_out;
2474  fStream->write("\n",1); fNByte++;
2475  fLenBuffer = 0;
2476  delete [] out;
2477  fCompress = kFALSE;
2478 }
2479 
2480 ////////////////////////////////////////////////////////////////////////////////
2481 /// Write a Real number to the file.
2482 /// This method overwrites TVirtualPS::WriteReal. Some PDF reader like
2483 /// Acrobat do not work when a PDF file contains reals with exponent. This
2484 /// method writes the real number "z" using the format "%f" instead of the
2485 /// format "%g" when writing it with "%g" generates a number with exponent.
2486 
2488 {
2489  char str[15];
2490  if (space) {
2491  snprintf(str,15," %g", z);
2492  if (strstr(str,"e") || strstr(str,"E")) snprintf(str,15," %10.8f", z);
2493  } else {
2494  snprintf(str,15,"%g", z);
2495  if (strstr(str,"e") || strstr(str,"E")) snprintf(str,15,"%10.8f", z);
2496  }
2497  PrintStr(str);
2498 }
Int_t GetColorModelPS() const
Definition: TStyle.h:198
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw a Box.
Definition: TPDF.cxx:351
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
void DrawPS(Int_t n, Float_t *xw, Float_t *yw)
Draw a PolyLine.
Definition: TPDF.cxx:869
Float_t GetLineScalePS() const
Definition: TStyle.h:288
const Int_t kObjPattern
Definition: TPDF.cxx:90
void MoveTo(Double_t x, Double_t y)
Move to a new position.
Definition: TPDF.cxx:1077
char * fBuffer
Definition: TVirtualPS.h:52
An array of TObjects.
Definition: TObjArray.h:39
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TPDF::fgLineJoin.
Definition: TPDF.cxx:2121
void On()
Activate an already open PDF file.
Definition: TPDF.cxx:1291
const Int_t kObjInfo
Definition: TPDF.cxx:80
Float_t GetRed() const
Definition: TColor.h:60
void WriteCompressedBuffer()
Write the buffer in a compressed way.
Definition: TPDF.cxx:2442
short Style_t
Definition: RtypesCore.h:76
TPDF()
Default PDF constructor.
Definition: TPDF.cxx:103
const Int_t kNumberOfFonts
Definition: TPDF.cxx:94
Float_t fXsize
Page size along X.
Definition: TPDF.h:40
Collectable string class.
Definition: TObjString.h:32
float Float_t
Definition: RtypesCore.h:53
void DrawHatch(Float_t dy, Float_t angle, Int_t n, Float_t *x, Float_t *y)
Draw Fill area with hatch styles.
Definition: TPDF.cxx:457
Float_t fYsize
Page size along Y.
Definition: TPDF.h:41
const Float_t kScale
Definition: TPDF.cxx:76
const char Option_t
Definition: RtypesCore.h:62
void SetColor(Int_t color=1)
Set color with its color index.
Definition: TPDF.cxx:1980
Float_t GetAlpha() const
Definition: TColor.h:66
R__EXTERN TStyle * gStyle
Definition: TStyle.h:418
void FontEncode()
Font encoding.
Definition: TPDF.cxx:1035
TH1 * h
Definition: legend2.C:5
void GetPaperSize(Float_t &xsize, Float_t &ysize) const
Set paper size for PostScript output.
Definition: TStyle.cxx:810
Bool_t fRange
True when a range has been defined.
Definition: TPDF.h:53
Size_t fMarkerSize
Marker size.
Definition: TAttMarker.h:29
#define gROOT
Definition: TROOT.h:364
Int_t fType
Workstation type used to know if the PDF is open.
Definition: TPDF.h:42
Int_t fStartStream
Definition: TPDF.h:45
Basic string class.
Definition: TString.h:137
virtual void WriteInteger(Int_t i, Bool_t space=kTRUE)
Write one Integer to the file.
Definition: TVirtualPS.cxx:170
void SetTextColor(Color_t cindex=1)
Set color index for text.
Definition: TPDF.cxx:2174
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:170
Int_t fObjPosSize
Real size of fObjPos.
Definition: TPDF.h:48
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Float_t fAlpha
Per cent of transparency.
Definition: TPDF.h:38
const Int_t kObjOutlines
Definition: TPDF.cxx:81
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
Bool_t fPageNotEmpty
True if the current page is not empty.
Definition: TPDF.h:51
Double_t CMtoPDF(Double_t u)
Definition: TPDF.h:66
Float_t GetBlue() const
Definition: TColor.h:62
const Int_t kObjColorSpace
Definition: TPDF.cxx:86
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:501
Int_t fNbObj
Number of objects.
Definition: TPDF.h:49
std::vector< float > fAlphas
List of alpha values used.
Definition: TPDF.h:39
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:51
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:615
Bool_t fCompress
True when fBuffer must be compressed.
Definition: TPDF.h:52
Int_t GetDay() const
Definition: TDatime.h:69
const Int_t kObjPatternList
Definition: TPDF.cxx:88
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
Float_t fBlue
Per cent of blue.
Definition: TPDF.h:37
virtual void PrintStr(const char *string="")
Output the string str in the output buffer.
Definition: TVirtualPS.cxx:72
Int_t fNbPage
Number of pages.
Definition: TPDF.h:50
Float_t GetGreen() const
Definition: TColor.h:61
static char * ReAllocChar(char *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition: TStorage.cxx:260
Int_t fPageFormat
Page format (A4, Letter etc ...)
Definition: TPDF.h:43
void Text(Double_t x, Double_t y, const char *string)
Draw text.
Definition: TPDF.cxx:2186
Double_t XtoPDF(Double_t x)
Convert X from world coordinate to PDF.
Definition: TPDF.cxx:2424
void Close(Option_t *opt="")
Close a PDF file.
Definition: TPDF.cxx:199
Int_t GetMonth() const
Definition: TDatime.h:68
const Int_t kObjRoot
Definition: TPDF.cxx:79
Base class for several text objects.
Definition: TText.h:33
void NewObject(Int_t n)
Create a new object in the PDF file.
Definition: TPDF.cxx:1087
void Off()
Deactivate an already open PDF file.
Definition: TPDF.cxx:1283
void SetAlpha(Float_t alpha=1.)
Set the alpha channel value.
Definition: TPDF.cxx:1960
void NewPage()
Start a new PDF page.
Definition: TPDF.cxx:1110
short Color_t
Definition: RtypesCore.h:79
void CellArrayFill(Int_t r, Int_t g, Int_t b)
Paint the Cell Array.
Definition: TPDF.cxx:183
void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
Definition: TPDF.cxx:1888
Style_t fMarkerStyle
Marker style.
Definition: TAttMarker.h:28
TCanvas * kerning()
Definition: kerning.C:1
void SetLineStyle(Style_t linestyle=1)
Change the line style.
Definition: TPDF.cxx:2134
Float_t fRed
Per cent of red.
Definition: TPDF.h:35
Int_t GetSecond() const
Definition: TDatime.h:73
Int_t GetMinute() const
Definition: TDatime.h:72
Double_t YtoPDF(Double_t y)
Convert Y from world coordinate to PDF.
Definition: TPDF.cxx:2433
Float_t fTextAngle
Text angle.
Definition: TAttText.h:27
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition: TPDF.cxx:1907
Style_t fLineStyle
Line style.
Definition: TAttLine.h:28
const Int_t kObjPatternResourses
Definition: TPDF.cxx:87
TRandom2 r(17)
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Definition: TPDF.cxx:481
SVector< double, 2 > v
Definition: Dict.h:5
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
Int_t GetHour() const
Definition: TDatime.h:71
const Int_t kObjContents
Definition: TPDF.cxx:84
Int_t fSizBuffer
Definition: TVirtualPS.h:49
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition: TStyle.cxx:792
Color_t fLineColor
Line color.
Definition: TAttLine.h:27
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition: TPDF.cxx:2386
unsigned int UInt_t
Definition: RtypesCore.h:42
Width_t fLineWidth
Line width.
Definition: TAttLine.h:29
TMarker * m
Definition: textangle.C:8
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
char * Form(const char *fmt,...)
Double_t VtoPDF(Double_t v)
Convert V from NDC coordinate to PDF.
Definition: TPDF.cxx:2415
void SetMarkerColor(Color_t cindex=1)
Set color index for markers.
Definition: TPDF.cxx:2166
std::ofstream * fStream
Definition: TVirtualPS.h:51
Font_t fTextFont
Text font.
Definition: TAttText.h:31
Double_t Cos(Double_t)
Definition: TMath.h:424
short Width_t
Definition: RtypesCore.h:78
Int_t GetJoinLinePS() const
Definition: TStyle.h:287
PyObject * fType
Double_t Pi()
Definition: TMath.h:44
2-D graphics point (world coordinates).
Definition: TPoints.h:21
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
Definition: TPDF.cxx:535
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2241
virtual void WriteReal(Float_t r, Bool_t space=kTRUE)
Write a Real number to the file.
Definition: TPDF.cxx:2487
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:279
const Int_t kObjPageResources
Definition: TPDF.cxx:83
void SetLineWidth(Width_t linewidth=1)
Change the line width.
Definition: TPDF.cxx:2153
double Double_t
Definition: RtypesCore.h:55
const Int_t kObjTransList
Definition: TPDF.cxx:89
const Int_t kObjPages
Definition: TPDF.cxx:82
static Int_t fgLineJoin
Appearance of joining lines.
Definition: TPDF.h:55
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
Definition: TVirtualPS.cxx:103
Double_t y[n]
Definition: legend1.C:17
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:35
Double_t UtoPDF(Double_t u)
Convert U from NDC coordinate to PDF.
Definition: TPDF.cxx:2406
Float_t fGreen
Per cent of green.
Definition: TPDF.h:36
The color creation and management class.
Definition: TColor.h:23
void SetLineScale(Float_t scale=1)
Definition: TPDF.h:97
Float_t fTextSize
Text size.
Definition: TAttText.h:28
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)
Draw a Frame around a box.
Definition: TPDF.cxx:417
void CellArrayEnd()
End the Cell Array painting.
Definition: TPDF.cxx:191
Float_t fLineScale
Line width scale factor.
Definition: TPDF.h:46
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y)
Draw markers at the n WC points xw, yw.
Definition: TPDF.cxx:581
Int_t * fObjPos
Objets position.
Definition: TPDF.h:47
void SetFillColor(Color_t cindex=1)
Set color index for fill areas.
Definition: TPDF.cxx:2053
virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const
Return text extent for string text.
Definition: TText.cxx:587
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
const Int_t kObjFont
Definition: TPDF.cxx:85
Int_t fLenBuffer
Definition: TVirtualPS.h:48
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2)
Begin the Cell Array painting.
Definition: TPDF.cxx:174
Int_t fPageOrientation
Page orientation (Portrait, Landscape)
Definition: TPDF.h:44
Color_t fFillColor
Fill area color.
Definition: TAttFill.h:27
void Open(const char *filename, Int_t type=-111)
Open a PDF file.
Definition: TPDF.cxx:1307
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:202
void PatternEncode()
Patterns encoding.
Definition: TPDF.cxx:1465
Double_t Sin(Double_t)
Definition: TMath.h:421
void SetLineColor(Color_t cindex=1)
Set color index for lines.
Definition: TPDF.cxx:2099
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define snprintf
Definition: civetweb.c:822
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:91
void LineTo(Double_t x, Double_t y)
Draw a line to a new position.
Definition: TPDF.cxx:1067
virtual ~TPDF()
Default PDF destructor.
Definition: TPDF.cxx:164
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:494
#define gPad
Definition: TVirtualPad.h:289
Interface to PDF.
Definition: TPDF.h:32
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition: TVirtualPS.h:40
const int nn
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:52
Int_t GetYear() const
Definition: TDatime.h:67
const Bool_t kTRUE
Definition: Rtypes.h:91
Color_t fMarkerColor
Marker color.
Definition: TAttMarker.h:27
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Int_t kObjFirstPage
Definition: TPDF.cxx:91
Color_t fTextColor
Text color.
Definition: TAttText.h:30
const Int_t n
Definition: legend1.C:16
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:911
void SetFillPatterns(Int_t ipat, Int_t color)
Set the fill patterns (1 to 25) for fill areas.
Definition: TPDF.cxx:2062
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39
Int_t fNByte
Definition: TVirtualPS.h:47
Style_t fFillStyle
Fill area style.
Definition: TAttFill.h:28
Short_t fTextAlign
Text alignment.
Definition: TAttText.h:29
void PrintStr(const char *string="")
Output the string str in the output buffer.
Definition: TPDF.cxx:1866