Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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\brief Interface to PDF.
16
17Like PostScript, PDF is a vector graphics output format allowing a very high
18graphics output quality. The functionalities provided by this class are very
19similar to those provided by `TPostScript`.
20
21Compare to PostScript output, the PDF files are usually smaller because some
22parts of them can be compressed.
23
24PDF also allows to define table of contents. This facility can be used in ROOT.
25The 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~~~
48Each character string following the keyword "Title:" makes a new entry in
49the table of contents.
50*/
51
52#ifdef WIN32
53#pragma optimize("",off)
54#endif
55
56#include <cstdlib>
57#include <cstring>
58#include <cctype>
59#include <fstream>
60
61#include "TROOT.h"
62#include "TDatime.h"
63#include "TColor.h"
64#include "TVirtualPad.h"
65#include "TPoints.h"
66#include "TPDF.h"
67#include "TStyle.h"
68#include "TMath.h"
69#include "TStorage.h"
70#include "TText.h"
71#include "zlib.h"
72#include "TObjString.h"
73#include "TObjArray.h"
74#include "snprintf.h"
75
76// To scale fonts to the same size as the old TT version
77const Float_t kScale = 0.93376068;
78
79// Objects numbers
80const Int_t kObjRoot = 1; // Root object
81const Int_t kObjInfo = 2; // Info object
82const Int_t kObjOutlines = 3; // Outlines object
83const Int_t kObjPages = 4; // Pages object (pages index)
84const Int_t kObjPageResources = 5; // Pages Resources object
85const Int_t kObjContents = 6; // Table of content
86const Int_t kObjFont = 7; // First Font object (14 in total)
87const Int_t kObjColorSpace = 22; // ColorSpace object
88const Int_t kObjPatternResourses = 23; // Pattern Resources object
89const Int_t kObjPatternList = 24; // Pattern list object
90const Int_t kObjTransList = 25; // List of transparencies
91const Int_t kObjPattern = 26; // First pattern object (25 in total)
92const Int_t kObjFirstPage = 51; // First page object
93
94// Number of fonts
96
99
100
101////////////////////////////////////////////////////////////////////////////////
102/// Default PDF constructor
103
105{
106 fStream = nullptr;
110 gVirtualPS = this;
111 fRed = 0.;
112 fGreen = 0.;
113 fBlue = 0.;
114 fAlpha = 1.;
115 fXsize = 0.;
116 fYsize = 0.;
117 fType = 0;
118 fPageFormat = 0;
120 fStartStream = 0;
121 fLineScale = 0.;
122 fNbPage = 0;
124 fRange = kFALSE;
125 fUrl = kFALSE;
126 fNbUrl = 1;
127 fA = 1.;
128 fB = 0.;
129 fC = 0.;
130 fD = 1.;
131 fE = 0.;
132 fF = 0.;
133 SetTitle("PDF");
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Initialize the PDF interface
138///
139/// - fname : PDF file name
140/// - wtype : PDF workstation type. Not used in the PDF driver. But as TPDF
141/// inherits from TVirtualPS it should be kept. Anyway it is not
142/// necessary to specify this parameter at creation time because it
143/// has a default value (which is ignore in the PDF case).
144
146{
147 fStream = nullptr;
151 fRed = 0.;
152 fGreen = 0.;
153 fBlue = 0.;
154 fAlpha = 1.;
155 fXsize = 0.;
156 fYsize = 0.;
157 fType = 0;
158 fPageFormat = 0;
160 fStartStream = 0;
161 fLineScale = 0.;
162 fNbPage = 0;
164 fRange = kFALSE;
165 fUrl = kFALSE;
166 fNbUrl = 1;
167 fA = 1.;
168 fB = 0.;
169 fC = 0.;
170 fD = 1.;
171 fE = 0.;
172 fF = 0.;
173 SetTitle("PDF");
174 Open(fname, wtype);
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Default PDF destructor
179
181{
182 Close();
183
184 if (fObjPos) delete [] fObjPos;
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Begin the Cell Array painting
189
191 Double_t)
192{
193 Warning("TPDF::CellArrayBegin", "not yet implemented");
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Paint the Cell Array
198
200{
201 Warning("TPDF::CellArrayFill", "not yet implemented");
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// End the Cell Array painting
206
208{
209 Warning("TPDF::CellArrayEnd", "not yet implemented");
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Close a PDF file
214
216{
217 Int_t i;
218
219 if (!gVirtualPS) return;
220 if (!fStream) return;
221 if (gPad) gPad->Update();
222
223 // Close the currently opened page
225 PrintStr("endstream@");
227 EndObject();
230 PrintStr("@");
231 EndObject();
233 PrintStr("<<@");
234 if (!strstr(GetTitle(),"PDF")) {
235 PrintStr("/Title (");
237 PrintStr(")@");
238 } else {
239 PrintStr("/Title (Page");
241 PrintStr(")@");
242 }
243 PrintStr("/Dest [");
245 PrintStr(" 0 R /XYZ null null 0]@");
246 PrintStr("/Parent");
248 PrintStr(" 0 R");
249 PrintStr("@");
250 if (fNbPage > 1) {
251 PrintStr("/Prev");
253 PrintStr(" 0 R");
254 PrintStr("@");
255 }
256 PrintStr(">>@");
257 EndObject();
259 PrintStr("@");
261 PrintStr("<<@");
262 PrintStr("/Type /Outlines@");
263 PrintStr("/Count");
265 PrintStr("@");
266 PrintStr("/First");
268 PrintStr(" 0 R");
269 PrintStr("@");
270 PrintStr("/Last");
272 PrintStr(" 0 R");
273 PrintStr("@");
274 PrintStr(">>@");
275 EndObject();
276
278 PrintStr("<<@");
279 PrintStr("/Title (Contents)@");
280 PrintStr("/Dest [");
282 PrintStr(" 0 R /XYZ null null 0]@");
283 PrintStr("/Count");
285 PrintStr("@");
286 PrintStr("/Parent");
288 PrintStr(" 0 R");
289 PrintStr("@");
290 PrintStr("/First");
292 PrintStr(" 0 R");
293 PrintStr("@");
294 PrintStr("/Last");
296 PrintStr(" 0 R");
297 PrintStr("@");
298 PrintStr(">>@");
299 EndObject();
300
301 // List of all the pages
303 PrintStr("<<@");
304 PrintStr("/Type /Pages@");
305 PrintStr("/Count");
307 PrintStr("@");
308 PrintStr("/Kids [");
309 for (i = 0; i < (int)fPageObjects.size(); i++) {
311 PrintStr(" 0 R");
312 }
313 PrintStr(" ]");
314 PrintStr("@");
315 PrintStr(">>@");
316 EndObject();
317
318 if (!fPageObjects.empty())
319 fPageObjects.clear();
320 if (!fUrls.empty())
321 fUrls.clear();
322 if (!fRectX1.empty())
323 fRectX1.clear();
324 if (!fRectY1.empty())
325 fRectY1.clear();
326 if (!fRectX2.empty())
327 fRectX2.clear();
328 if (!fRectY2.empty())
329 fRectY2.clear();
330
331 // List of transparencies
333 PrintStr("<<@");
334 for (i=0; i<(int)fAlphas.size(); i++) {
335 PrintStr(
336 Form("/ca%3.2f << /Type /ExtGState /ca %3.2f >> /CA%3.2f << /Type /ExtGState /CA %3.2f >>@",
337 fAlphas[i],fAlphas[i],fAlphas[i],fAlphas[i]));
338 }
339 PrintStr(">>@");
340 EndObject();
341 if (!fAlphas.empty()) fAlphas.clear();
342
343 // Cross-Reference Table
345 PrintStr("xref@");
346 PrintStr("0");
348 PrintStr("@");
349 PrintStr("0000000000 65535 f @");
350 char str[21];
351 for (i=0; i<fNbObj; i++) {
352 snprintf(str,21,"%10.10d 00000 n @",fObjPos[i]);
353 PrintStr(str);
354 }
355
356 // Trailer
357 PrintStr("trailer@");
358 PrintStr("<<@");
359 PrintStr("/Size");
361 PrintStr("@");
362 PrintStr("/Root");
364 PrintStr(" 0 R");
365 PrintStr("@");
366 PrintStr("/Info");
368 PrintStr(" 0 R@");
369 PrintStr(">>@");
370 PrintStr("startxref@");
371 WriteInteger(refInd, false);
372 PrintStr("@");
373 PrintStr("%%EOF@");
374
375 // Close file stream
376 if (fStream) { fStream->close(); delete fStream; fStream = nullptr;}
377
378 gVirtualPS = nullptr;
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Draw a Box
383
385{
386 static Double_t x[4], y[4];
391 Int_t fillis = fFillStyle/1000;
392 Int_t fillsi = fFillStyle%1000;
393
394 if (fillis == 3 || fillis == 2) {
395 if (fillsi > 99) {
396 x[0] = x1; y[0] = y1;
397 x[1] = x2; y[1] = y1;
398 x[2] = x2; y[2] = y2;
399 x[3] = x1; y[3] = y2;
400 return;
401 }
402 if (fillsi > 0 && fillsi < 26) {
403 x[0] = x1; y[0] = y1;
404 x[1] = x2; y[1] = y1;
405 x[2] = x2; y[2] = y2;
406 x[3] = x1; y[3] = y2;
407 DrawPS(-4, &x[0], &y[0]);
408 }
409 if (fillsi == -3) {
410 SetColor(5);
411 if (fAlpha == 1) PrintFast(15," q 0.4 w [] 0 d");
412 WriteReal(ix1);
413 WriteReal(iy1);
414 WriteReal(ix2 - ix1);
415 WriteReal(iy2 - iy1);
416 if (fAlpha == 1) PrintFast(8," re b* Q");
417 else PrintFast(6," re f*");
418 }
419 }
420 if (fillis == 1) {
422 if (fAlpha == 1) PrintFast(15," q 0.4 w [] 0 d");
423 WriteReal(ix1);
424 WriteReal(iy1);
425 WriteReal(ix2 - ix1);
426 WriteReal(iy2 - iy1);
427 if (fAlpha == 1) PrintFast(8," re b* Q");
428 else PrintFast(6," re f*");
429 }
430 if (fillis == 0) {
431 if (fLineWidth<=0) return;
433 WriteReal(ix1);
434 WriteReal(iy1);
435 WriteReal(ix2 - ix1);
436 WriteReal(iy2 - iy1);
437 PrintFast(5," re S");
438 }
439}
440
441////////////////////////////////////////////////////////////////////////////////
442/// Draw a Frame around a box
443///
444/// - mode = -1 box looks as it is behind the screen
445/// - mode = 1 box looks as it is in front of the screen
446/// - border is the border size in already precomputed PDF units
447/// - dark is the color for the dark part of the frame
448/// - light is the color for the light part of the frame
449
451 Int_t mode, Int_t border, Int_t dark, Int_t light)
452{
453 static Double_t xps[7], yps[7];
454 Int_t i;
455
456 // Draw top&left part of the box
457 if (mode == -1) SetColor(dark);
458 else SetColor(light);
459 xps[0] = XtoPDF(xl); yps[0] = YtoPDF(yl);
460 xps[1] = xps[0] + border; yps[1] = yps[0] + border;
461 xps[2] = xps[1]; yps[2] = YtoPDF(yt) - border;
462 xps[3] = XtoPDF(xt) - border; yps[3] = yps[2];
463 xps[4] = XtoPDF(xt); yps[4] = YtoPDF(yt);
464 xps[5] = xps[0]; yps[5] = yps[4];
465 xps[6] = xps[0]; yps[6] = yps[0];
466
467 MoveTo(xps[0], yps[0]);
468 for (i=1;i<7;i++) LineTo(xps[i], yps[i]);
469 PrintFast(3," f*");
470
471 // Draw bottom&right part of the box
472 if (mode == -1) SetColor(light);
473 else SetColor(dark);
474 xps[0] = XtoPDF(xl); yps[0] = YtoPDF(yl);
475 xps[1] = xps[0] + border; yps[1] = yps[0] + border;
476 xps[2] = XtoPDF(xt) - border; yps[2] = yps[1];
477 xps[3] = xps[2]; yps[3] = YtoPDF(yt) - border;
478 xps[4] = XtoPDF(xt); yps[4] = YtoPDF(yt);
479 xps[5] = xps[4]; yps[5] = yps[0];
480 xps[6] = xps[0]; yps[6] = yps[0];
481
482 MoveTo(xps[0], yps[0]);
483 for (i=1;i<7;i++) LineTo(xps[i], yps[i]);
484 PrintFast(3," f*");
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Draw Fill area with hatch styles
489
491{
492 Warning("DrawHatch", "hatch fill style not yet implemented");
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Draw Fill area with hatch styles
497
499{
500 Warning("DrawHatch", "hatch fill style not yet implemented");
501}
502
503////////////////////////////////////////////////////////////////////////////////
504/// Draw a PolyLine
505///
506/// Draw a polyline through the points xy.
507///
508/// - If NN=1 moves only to point x,y.
509/// - If NN=0 the x,y are written in the PDF file
510/// according to the current transformation.
511/// - If NN>0 the line is clipped as a line.
512/// - If NN<0 the line is clipped as a fill area.
513
515{
516 Int_t n;
517
520
521 if (nn > 0) {
522 if (fLineWidth<=0) return;
523 n = nn;
527 } else {
528 n = -nn;
529 SetLineStyle(1);
530 SetLineWidth(1);
532 }
533
534 WriteReal(XtoPDF(xy[0].GetX()));
535 WriteReal(YtoPDF(xy[0].GetY()));
536 if (n <= 1) {
537 if (n == 0) return;
538 PrintFast(2," m");
539 return;
540 }
541
542 PrintFast(2," m");
543
544 for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xy[i].GetX()), YtoPDF(xy[i].GetY()));
545
546 if (nn > 0) {
547 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
548 PrintFast(2," S");
549 } else {
550 PrintFast(3," f*");
551 }
552
555}
556
557////////////////////////////////////////////////////////////////////////////////
558/// Draw a PolyLine in NDC space
559///
560/// Draw a polyline through the points xy.
561///
562/// - If NN=1 moves only to point x,y.
563/// - If NN=0 the x,y are written in the PDF file
564/// according to the current transformation.
565/// - If NN>0 the line is clipped as a line.
566/// - If NN<0 the line is clipped as a fill area.
567
569{
570 Int_t n;
571
574
575 if (nn > 0) {
576 if (fLineWidth<=0) return;
577 n = nn;
581 } else {
582 n = -nn;
583 SetLineStyle(1);
584 SetLineWidth(1);
586 }
587
588 WriteReal(UtoPDF(xy[0].GetX()));
589 WriteReal(VtoPDF(xy[0].GetY()));
590 if (n <= 1) {
591 if (n == 0) return;
592 PrintFast(2," m");
593 return;
594 }
595
596 PrintFast(2," m");
597
598 for (Int_t i=1;i<n;i++) LineTo(UtoPDF(xy[i].GetX()), VtoPDF(xy[i].GetY()));
599
600 if (nn > 0) {
601 if (xy[0].GetX() == xy[n-1].GetX() && xy[0].GetY() == xy[n-1].GetY()) PrintFast(3," cl");
602 PrintFast(2," S");
603 } else {
604 PrintFast(3," f*");
605 }
606
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Draw markers at the n WC points xw, yw
613
615{
619 SetLineStyle(1);
623
624 if (ms == 4)
625 ms = 24;
626 else if (ms >= 6 && ms <= 8)
627 ms = 20;
628 else if (ms >= 9 && ms <= 19)
629 ms = 1;
630
631 // Define the marker size
633 if (fMarkerStyle == 1 || (fMarkerStyle >= 9 && fMarkerStyle <= 19)) {
634 msize = 1.;
635 } else if (fMarkerStyle == 6) {
636 msize = 1.;
637 } else if (fMarkerStyle == 7) {
638 msize = 1.5;
639 } else {
640 const Int_t kBASEMARKER = 8;
642 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
643 msize = this->UtoPDF(s2x) - this->UtoPDF(0);
644 }
645
646 Double_t m = msize;
647 Double_t m2 = m/2;
648 Double_t m3 = m/3;
649 Double_t m4 = m2*1.333333333333;
650 Double_t m6 = m/6;
651 Double_t m0 = m/10.;
652 Double_t m8 = m/4;
653 Double_t m9 = m/8;
654
655 // Draw the marker according to the type
656 Double_t ix,iy;
657 for (Int_t i=0;i<n;i++) {
658 ix = XtoPDF(xw[i]);
659 iy = YtoPDF(yw[i]);
660 // Dot (.)
661 if (ms == 1) {
662 MoveTo(ix-1, iy);
663 LineTo(ix , iy);
664 // Plus (+)
665 } else if (ms == 2) {
666 MoveTo(ix-m2, iy);
667 LineTo(ix+m2, iy);
668 MoveTo(ix , iy-m2);
669 LineTo(ix , iy+m2);
670 // X shape (X)
671 } else if (ms == 5) {
672 MoveTo(ix-m2*0.707, iy-m2*0.707);
673 LineTo(ix+m2*0.707, iy+m2*0.707);
674 MoveTo(ix-m2*0.707, iy+m2*0.707);
675 LineTo(ix+m2*0.707, iy-m2*0.707);
676 // Asterisk shape (*)
677 } else if (ms == 3 || ms == 31) {
678 MoveTo(ix-m2, iy);
679 LineTo(ix+m2, iy);
680 MoveTo(ix , iy-m2);
681 LineTo(ix , iy+m2);
682 MoveTo(ix-m2*0.707, iy-m2*0.707);
683 LineTo(ix+m2*0.707, iy+m2*0.707);
684 MoveTo(ix-m2*0.707, iy+m2*0.707);
685 LineTo(ix+m2*0.707, iy-m2*0.707);
686 // Circle
687 } else if (ms == 24 || ms == 20) {
688 MoveTo(ix-m2, iy);
689 WriteReal(ix-m2); WriteReal(iy+m4);
690 WriteReal(ix+m2); WriteReal(iy+m4);
691 WriteReal(ix+m2); WriteReal(iy) ; PrintFast(2," c");
692 WriteReal(ix+m2); WriteReal(iy-m4);
693 WriteReal(ix-m2); WriteReal(iy-m4);
694 WriteReal(ix-m2); WriteReal(iy) ; PrintFast(4," c h");
695 // Square
696 } else if (ms == 25 || ms == 21) {
697 WriteReal(ix-m2); WriteReal(iy-m2);
698 WriteReal(m) ; WriteReal(m) ; PrintFast(3," re");
699 // Down triangle
700 } else if (ms == 23 || ms == 32) {
701 MoveTo(ix , iy-m2);
702 LineTo(ix+m2, iy+m2);
703 LineTo(ix-m2, iy+m2);
704 PrintFast(2," h");
705 // Up triangle
706 } else if (ms == 26 || ms == 22) {
707 MoveTo(ix-m2, iy-m2);
708 LineTo(ix+m2, iy-m2);
709 LineTo(ix , iy+m2);
710 PrintFast(2," h");
711 } else if (ms == 27 || ms == 33) {
712 MoveTo(ix , iy-m2);
713 LineTo(ix+m3, iy);
714 LineTo(ix , iy+m2);
715 LineTo(ix-m3, iy) ;
716 PrintFast(2," h");
717 } else if (ms == 28 || ms == 34) {
718 MoveTo(ix-m6, iy-m6);
719 LineTo(ix-m6, iy-m2);
720 LineTo(ix+m6, iy-m2);
721 LineTo(ix+m6, iy-m6);
722 LineTo(ix+m2, iy-m6);
723 LineTo(ix+m2, iy+m6);
724 LineTo(ix+m6, iy+m6);
725 LineTo(ix+m6, iy+m2);
726 LineTo(ix-m6, iy+m2);
727 LineTo(ix-m6, iy+m6);
728 LineTo(ix-m2, iy+m6);
729 LineTo(ix-m2, iy-m6);
730 PrintFast(2," h");
731 } else if (ms == 29 || ms == 30) {
732 MoveTo(ix , iy+m2);
733 LineTo(ix+0.112255*m, iy+0.15451*m);
734 LineTo(ix+0.47552*m , iy+0.15451*m);
735 LineTo(ix+0.181635*m, iy-0.05902*m);
736 LineTo(ix+0.29389*m , iy-0.40451*m);
737 LineTo(ix , iy-0.19098*m);
738 LineTo(ix-0.29389*m , iy-0.40451*m);
739 LineTo(ix-0.181635*m, iy-0.05902*m);
740 LineTo(ix-0.47552*m , iy+0.15451*m);
741 LineTo(ix-0.112255*m, iy+0.15451*m);
742 PrintFast(2," h");
743 } else if (ms == 35 ) {
744 // diamond with cross
745 MoveTo(ix-m2, iy );
746 LineTo(ix , iy-m2);
747 LineTo(ix+m2, iy );
748 LineTo(ix , iy+m2);
749 LineTo(ix-m2, iy );
750 LineTo(ix+m2, iy );
751 LineTo(ix , iy+m2);
752 LineTo(ix , iy-m2);
753 PrintFast(2," h");
754 } else if (ms == 36 ) {
755 // square with diagonal cross
756 MoveTo(ix-m2, iy-m2);
757 LineTo(ix+m2, iy-m2);
758 LineTo(ix+m2, iy+m2);
759 LineTo(ix-m2, iy+m2);
760 LineTo(ix-m2, iy-m2);
761 LineTo(ix+m2, iy+m2);
762 LineTo(ix-m2, iy+m2);
763 LineTo(ix+m2, iy-m2);
764 PrintFast(2," h");
765 } else if (ms == 37 || ms == 39 ) {
766 // square with cross
767 MoveTo(ix , iy );
768 LineTo(ix-m8, iy+m2);
769 LineTo(ix-m2, iy );
770 LineTo(ix , iy );
771 LineTo(ix-m8, iy-m2);
772 LineTo(ix+m8, iy-m2);
773 LineTo(ix , iy );
774 LineTo(ix+m2, iy );
775 LineTo(ix+m8, iy+m2);
776 LineTo(ix , iy );
777 PrintFast(2," h");
778 } else if (ms == 38 ) {
779 // + shaped marker with octagon
780 MoveTo(ix-m2, iy );
781 LineTo(ix-m2, iy-m8);
782 LineTo(ix-m8, iy-m2);
783 LineTo(ix+m8, iy-m2);
784 LineTo(ix+m2, iy-m8);
785 LineTo(ix+m2, iy+m8);
786 LineTo(ix+m8, iy+m2);
787 LineTo(ix-m8, iy+m2);
788 LineTo(ix-m2, iy+m8);
789 LineTo(ix-m2, iy );
790 LineTo(ix+m2, iy );
791 LineTo(ix , iy );
792 LineTo(ix , iy-m2);
793 LineTo(ix , iy+m2);
794 LineTo(ix , iy);
795 PrintFast(2," h");
796 } else if (ms == 40 || ms == 41 ) {
797 // four triangles X
798 MoveTo(ix , iy );
799 LineTo(ix+m8, iy+m2);
800 LineTo(ix+m2, iy+m8);
801 LineTo(ix , iy );
802 LineTo(ix+m2, iy-m8);
803 LineTo(ix+m8, iy-m2);
804 LineTo(ix , iy );
805 LineTo(ix-m8, iy-m2);
806 LineTo(ix-m2, iy-m8);
807 LineTo(ix , iy );
808 LineTo(ix-m2, iy+m8);
809 LineTo(ix-m8, iy+m2);
810 LineTo(ix , iy );
811 PrintFast(2," h");
812 } else if (ms == 42 || ms == 43 ) {
813 // double diamonds
814 MoveTo(ix , iy+m2);
815 LineTo(ix-m9, iy+m9);
816 LineTo(ix-m2, iy );
817 LineTo(ix-m9, iy-m9);
818 LineTo(ix , iy-m2);
819 LineTo(ix+m9, iy-m9);
820 LineTo(ix+m2, iy );
821 LineTo(ix+m9, iy+m9);
822 LineTo(ix , iy+m2);
823 PrintFast(2," h");
824 } else if (ms == 44 ) {
825 // open four triangles plus
826 MoveTo(ix , iy );
827 LineTo(ix+m8, iy+m2);
828 LineTo(ix-m8, iy+m2);
829 LineTo(ix+m8, iy-m2);
830 LineTo(ix-m8, iy-m2);
831 LineTo(ix , iy );
832 LineTo(ix+m2, iy+m8);
833 LineTo(ix+m2, iy-m8);
834 LineTo(ix-m2, iy+m8);
835 LineTo(ix-m2, iy-m8);
836 LineTo(ix , iy );
837 PrintFast(2," h");
838 } else if (ms == 45 ) {
839 // filled four triangles plus
840 MoveTo(ix+m0, iy+m0);
841 LineTo(ix+m8, iy+m2);
842 LineTo(ix-m8, iy+m2);
843 LineTo(ix-m0, iy+m0);
844 LineTo(ix-m2, iy+m8);
845 LineTo(ix-m2, iy-m8);
846 LineTo(ix-m0, iy-m0);
847 LineTo(ix-m8, iy-m2);
848 LineTo(ix+m8, iy-m2);
849 LineTo(ix+m0, iy-m0);
850 LineTo(ix+m2, iy-m8);
851 LineTo(ix+m2, iy+m8);
852 LineTo(ix+m0, iy+m0);
853 PrintFast(2," h");
854 } else if (ms == 46 || ms == 47 ) {
855 // four triangles X
856 MoveTo(ix , iy+m8);
857 LineTo(ix-m8, iy+m2);
858 LineTo(ix-m2, iy+m8);
859 LineTo(ix-m8, iy );
860 LineTo(ix-m2, iy-m8);
861 LineTo(ix-m8, iy-m2);
862 LineTo(ix , iy-m8);
863 LineTo(ix+m8, iy-m2);
864 LineTo(ix+m2, iy-m8);
865 LineTo(ix+m8, iy );
866 LineTo(ix+m2, iy+m8);
867 LineTo(ix+m8, iy+m2);
868 LineTo(ix , iy+m8);
869 PrintFast(2," h");
870 } else if (ms == 48 ) {
871 // four filled squares X
872 MoveTo(ix , iy+m8*1.01);
873 LineTo(ix-m8, iy+m2);
874 LineTo(ix-m2, iy+m8);
875 LineTo(ix-m8, iy );
876 LineTo(ix-m2, iy-m8);
877 LineTo(ix-m8, iy-m2);
878 LineTo(ix , iy-m8);
879 LineTo(ix+m8, iy-m2);
880 LineTo(ix+m2, iy-m8);
881 LineTo(ix+m8, iy );
882 LineTo(ix+m2, iy+m8);
883 LineTo(ix+m8, iy+m2);
884 LineTo(ix , iy+m8*0.99);
885 LineTo(ix+m8*0.99, iy );
886 LineTo(ix , iy-m8*0.99);
887 LineTo(ix-m8*0.99, iy );
888 LineTo(ix , iy+m8*0.99);
889 PrintFast(2," h");
890 } else if (ms == 49 ) {
891 // four filled squares plus
892 MoveTo(ix-m6, iy-m6*1.01);
893 LineTo(ix-m6, iy-m2);
894 LineTo(ix+m6, iy-m2);
895 LineTo(ix+m6, iy-m6);
896 LineTo(ix+m2, iy-m6);
897 LineTo(ix+m2, iy+m6);
898 LineTo(ix+m6, iy+m6);
899 LineTo(ix+m6, iy+m2);
900 LineTo(ix-m6, iy+m2);
901 LineTo(ix-m6, iy+m6);
902 LineTo(ix-m2, iy+m6);
903 LineTo(ix-m2, iy-m6);
904 LineTo(ix-m6, iy-m6*0.99);
905 LineTo(ix-m6, iy+m6);
906 LineTo(ix+m6, iy+m6);
907 LineTo(ix+m6, iy-m6);
908 PrintFast(2," h");
909 } else {
910 MoveTo(ix-m6, iy-m6);
911 LineTo(ix-m6, iy-m2);
912 }
913
914 if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34 ||
915 ms == 39 || ms == 41 || ms == 43 || ms == 45 ||
916 ms == 47 || ms == 48 || ms == 49) {
917 PrintFast(2," f");
918 } else {
919 PrintFast(2," S");
920 }
921 }
922
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Draw markers at the n WC points xw, yw
929
931{
935 SetLineStyle(1);
939
940 if (ms == 4)
941 ms = 24;
942 else if (ms >= 6 && ms <= 8)
943 ms = 20;
944 else if (ms >= 9 && ms <= 19)
945 ms = 1;
946
947 // Define the marker size
949 if (fMarkerStyle == 1 || (fMarkerStyle >= 9 && fMarkerStyle <= 19)) {
950 msize = 1.;
951 } else if (fMarkerStyle == 6) {
952 msize = 1.5;
953 } else if (fMarkerStyle == 7) {
954 msize = 3.;
955 } else {
956 const Int_t kBASEMARKER = 8;
958 Float_t s2x = sbase / Float_t(gPad->GetWw() * gPad->GetAbsWNDC());
959 msize = this->UtoPDF(s2x) - this->UtoPDF(0);
960 }
961
962 Double_t m = msize;
963 Double_t m2 = m/2;
964 Double_t m3 = m/3;
965 Double_t m4 = m2*1.333333333333;
966 Double_t m6 = m/6;
967 Double_t m8 = m/4;
968 Double_t m9 = m/8;
969
970 // Draw the marker according to the type
971 Double_t ix,iy;
972 for (Int_t i=0;i<n;i++) {
973 ix = XtoPDF(xw[i]);
974 iy = YtoPDF(yw[i]);
975 // Dot (.)
976 if (ms == 1) {
977 MoveTo(ix-1, iy);
978 LineTo(ix , iy);
979 // Plus (+)
980 } else if (ms == 2) {
981 MoveTo(ix-m2, iy);
982 LineTo(ix+m2, iy);
983 MoveTo(ix , iy-m2);
984 LineTo(ix , iy+m2);
985 // X shape (X)
986 } else if (ms == 5) {
987 MoveTo(ix-m2*0.707, iy-m2*0.707);
988 LineTo(ix+m2*0.707, iy+m2*0.707);
989 MoveTo(ix-m2*0.707, iy+m2*0.707);
990 LineTo(ix+m2*0.707, iy-m2*0.707);
991 // Asterisk shape (*)
992 } else if (ms == 3 || ms == 31) {
993 MoveTo(ix-m2, iy);
994 LineTo(ix+m2, iy);
995 MoveTo(ix , iy-m2);
996 LineTo(ix , iy+m2);
997 MoveTo(ix-m2*0.707, iy-m2*0.707);
998 LineTo(ix+m2*0.707, iy+m2*0.707);
999 MoveTo(ix-m2*0.707, iy+m2*0.707);
1000 LineTo(ix+m2*0.707, iy-m2*0.707);
1001 // Circle
1002 } else if (ms == 24 || ms == 20) {
1003 MoveTo(ix-m2, iy);
1004 WriteReal(ix-m2); WriteReal(iy+m4);
1005 WriteReal(ix+m2); WriteReal(iy+m4);
1006 WriteReal(ix+m2); WriteReal(iy) ; PrintFast(2," c");
1007 WriteReal(ix+m2); WriteReal(iy-m4);
1008 WriteReal(ix-m2); WriteReal(iy-m4);
1009 WriteReal(ix-m2); WriteReal(iy) ; PrintFast(4," c h");
1010 // Square
1011 } else if (ms == 25 || ms == 21) {
1012 WriteReal(ix-m2); WriteReal(iy-m2);
1013 WriteReal(m) ; WriteReal(m) ; PrintFast(3," re");
1014 // Down triangle
1015 } else if (ms == 23 || ms == 32) {
1016 MoveTo(ix , iy-m2);
1017 LineTo(ix+m2, iy+m2);
1018 LineTo(ix-m2, iy+m2);
1019 PrintFast(2," h");
1020 // Up triangle
1021 } else if (ms == 26 || ms == 22) {
1022 MoveTo(ix-m2, iy-m2);
1023 LineTo(ix+m2, iy-m2);
1024 LineTo(ix , iy+m2);
1025 PrintFast(2," h");
1026 } else if (ms == 27 || ms == 33) {
1027 MoveTo(ix , iy-m2);
1028 LineTo(ix+m3, iy);
1029 LineTo(ix , iy+m2);
1030 LineTo(ix-m3, iy) ;
1031 PrintFast(2," h");
1032 } else if (ms == 28 || ms == 34) {
1033 MoveTo(ix-m6, iy-m6);
1034 LineTo(ix-m6, iy-m2);
1035 LineTo(ix+m6, iy-m2);
1036 LineTo(ix+m6, iy-m6);
1037 LineTo(ix+m2, iy-m6);
1038 LineTo(ix+m2, iy+m6);
1039 LineTo(ix+m6, iy+m6);
1040 LineTo(ix+m6, iy+m2);
1041 LineTo(ix-m6, iy+m2);
1042 LineTo(ix-m6, iy+m6);
1043 LineTo(ix-m2, iy+m6);
1044 LineTo(ix-m2, iy-m6);
1045 PrintFast(2," h");
1046 } else if (ms == 29 || ms == 30) {
1047 MoveTo(ix , iy-m2);
1048 LineTo(ix-0.112255*m, iy-0.15451*m);
1049 LineTo(ix-0.47552*m , iy-0.15451*m);
1050 LineTo(ix-0.181635*m, iy+0.05902*m);
1051 LineTo(ix-0.29389*m , iy+0.40451*m);
1052 LineTo(ix , iy+0.19098*m);
1053 LineTo(ix+0.29389*m , iy+0.40451*m);
1054 LineTo(ix+0.181635*m, iy+0.05902*m);
1055 LineTo(ix+0.47552*m , iy-0.15451*m);
1056 LineTo(ix+0.112255*m, iy-0.15451*m);
1057 PrintFast(2," h");
1058 } else if (ms == 35 ) {
1059 MoveTo(ix-m2, iy );
1060 LineTo(ix , iy-m2);
1061 LineTo(ix+m2, iy );
1062 LineTo(ix , iy+m2);
1063 LineTo(ix-m2, iy );
1064 LineTo(ix+m2, iy );
1065 LineTo(ix , iy+m2);
1066 LineTo(ix , iy-m2);
1067 PrintFast(2," h");
1068 } else if (ms == 36 ) {
1069 MoveTo(ix-m2, iy-m2);
1070 LineTo(ix+m2, iy-m2);
1071 LineTo(ix+m2, iy+m2);
1072 LineTo(ix-m2, iy+m2);
1073 LineTo(ix-m2, iy-m2);
1074 LineTo(ix+m2, iy+m2);
1075 LineTo(ix-m2, iy+m2);
1076 LineTo(ix+m2, iy-m2);
1077 PrintFast(2," h");
1078 } else if (ms == 37 || ms == 39 ) {
1079 MoveTo(ix , iy );
1080 LineTo(ix-m8, iy+m2);
1081 LineTo(ix-m2, iy );
1082 LineTo(ix , iy );
1083 LineTo(ix-m8, iy-m2);
1084 LineTo(ix+m8, iy-m2);
1085 LineTo(ix , iy );
1086 LineTo(ix+m2, iy );
1087 LineTo(ix+m8, iy+m2);
1088 LineTo(ix , iy );
1089 PrintFast(2," h");
1090 } else if (ms == 38 ) {
1091 MoveTo(ix-m2, iy );
1092 LineTo(ix-m2, iy-m8);
1093 LineTo(ix-m8, iy-m2);
1094 LineTo(ix+m8, iy-m2);
1095 LineTo(ix+m2, iy-m8);
1096 LineTo(ix+m2, iy+m8);
1097 LineTo(ix+m8, iy+m2);
1098 LineTo(ix-m8, iy+m2);
1099 LineTo(ix-m2, iy+m8);
1100 LineTo(ix-m2, iy );
1101 LineTo(ix+m2, iy );
1102 LineTo(ix , iy );
1103 LineTo(ix , iy-m2);
1104 LineTo(ix , iy+m2);
1105 LineTo(ix , iy );
1106 PrintFast(2," h");
1107 } else if (ms == 40 || ms == 41 ) {
1108 MoveTo(ix , iy );
1109 LineTo(ix+m8, iy+m2);
1110 LineTo(ix+m2, iy+m8);
1111 LineTo(ix , iy );
1112 LineTo(ix+m2, iy-m8);
1113 LineTo(ix+m8, iy-m2);
1114 LineTo(ix , iy );
1115 LineTo(ix-m8, iy-m2);
1116 LineTo(ix-m2, iy-m8);
1117 LineTo(ix , iy );
1118 LineTo(ix-m2, iy+m8);
1119 LineTo(ix-m8, iy+m2);
1120 LineTo(ix , iy );
1121 PrintFast(2," h");
1122 } else if (ms == 42 || ms == 43 ) {
1123 MoveTo(ix , iy+m2);
1124 LineTo(ix-m9, iy+m9);
1125 LineTo(ix-m2, iy );
1126 LineTo(ix-m9, iy-m9);
1127 LineTo(ix , iy-m2);
1128 LineTo(ix+m9, iy-m9);
1129 LineTo(ix+m2, iy );
1130 LineTo(ix+m9, iy+m9);
1131 LineTo(ix , iy+m2);
1132 PrintFast(2," h");
1133 } else if (ms == 44 ) {
1134 MoveTo(ix , iy );
1135 LineTo(ix+m8, iy+m2);
1136 LineTo(ix-m8, iy+m2);
1137 LineTo(ix+m8, iy-m2);
1138 LineTo(ix-m8, iy-m2);
1139 LineTo(ix , iy );
1140 LineTo(ix+m2, iy+m8);
1141 LineTo(ix+m2, iy-m8);
1142 LineTo(ix-m2, iy+m8);
1143 LineTo(ix-m2, iy-m8);
1144 LineTo(ix , iy );
1145 PrintFast(2," h");
1146 } else if (ms == 45 ) {
1147 MoveTo(ix+m6/2., iy+m6/2.);
1148 LineTo(ix+m8, iy+m2);
1149 LineTo(ix-m8, iy+m2);
1150 LineTo(ix-m6/2., iy+m6/2.);
1151 LineTo(ix-m2, iy+m8);
1152 LineTo(ix-m2, iy-m8);
1153 LineTo(ix-m6/2., iy-m6/2.);
1154 LineTo(ix-m8, iy-m2);
1155 LineTo(ix+m8, iy-m2);
1156 LineTo(ix+m6/2., iy-m6/2.);
1157 LineTo(ix+m2, iy-m8);
1158 LineTo(ix+m2, iy+m8);
1159 LineTo(ix+m6/2., iy+m6/2.);
1160 PrintFast(2," h");
1161 } else if (ms == 46 || ms == 47 ) {
1162 MoveTo(ix , iy+m8);
1163 LineTo(ix-m8, iy+m2);
1164 LineTo(ix-m2, iy+m8);
1165 LineTo(ix-m8, iy );
1166 LineTo(ix-m2, iy-m8);
1167 LineTo(ix-m8, iy-m2);
1168 LineTo(ix , iy-m8);
1169 LineTo(ix+m8, iy-m2);
1170 LineTo(ix+m2, iy-m8);
1171 LineTo(ix+m8, iy );
1172 LineTo(ix+m2, iy+m8);
1173 LineTo(ix+m8, iy+m2);
1174 LineTo(ix , iy+m8);
1175 PrintFast(2," h");
1176 } else if (ms == 48 ) {
1177 MoveTo(ix , iy+m8*1.005);
1178 LineTo(ix-m8, iy+m2);
1179 LineTo(ix-m2, iy+m8);
1180 LineTo(ix-m8, iy );
1181 LineTo(ix-m2, iy-m8);
1182 LineTo(ix-m8, iy-m2);
1183 LineTo(ix , iy-m8);
1184 LineTo(ix+m8, iy-m2);
1185 LineTo(ix+m2, iy-m8);
1186 LineTo(ix+m8, iy );
1187 LineTo(ix+m2, iy+m8);
1188 LineTo(ix+m8, iy+m2);
1189 LineTo(ix , iy+m8*0.995);
1190 LineTo(ix+m8*0.995, iy );
1191 LineTo(ix , iy-m8*0.995);
1192 LineTo(ix-m8*0.995, iy );
1193 LineTo(ix , iy+m8*0.995);
1194 PrintFast(2," h");
1195 } else if (ms == 49 ) {
1196 MoveTo(ix-m6, iy-m6*1.01);
1197 LineTo(ix-m6, iy-m2);
1198 LineTo(ix+m6, iy-m2);
1199 LineTo(ix+m6, iy-m6);
1200 LineTo(ix+m2, iy-m6);
1201 LineTo(ix+m2, iy+m6);
1202 LineTo(ix+m6, iy+m6);
1203 LineTo(ix+m6, iy+m2);
1204 LineTo(ix-m6, iy+m2);
1205 LineTo(ix-m6, iy+m6);
1206 LineTo(ix-m2, iy+m6);
1207 LineTo(ix-m2, iy-m6);
1208 LineTo(ix-m6, iy-m6*0.99);
1209 LineTo(ix-m6, iy+m6);
1210 LineTo(ix+m6, iy+m6);
1211 LineTo(ix+m6, iy-m6);
1212 MoveTo(ix-m6, iy-m6*1.01);
1213 PrintFast(2," h");
1214 } else {
1215 MoveTo(ix-1, iy);
1216 LineTo(ix , iy);
1217 }
1218 if ((ms > 19 && ms < 24) || ms == 29 || ms == 33 || ms == 34 ||
1219 ms == 39 || ms == 41 || ms == 43 || ms == 45 ||
1220 ms == 47 || ms == 48 || ms == 49) {
1221 PrintFast(2," f");
1222 } else {
1223 PrintFast(2," S");
1224 }
1225 }
1226
1229}
1230
1231////////////////////////////////////////////////////////////////////////////////
1232/// Draw a PolyLine
1233///
1234/// Draw a polyline through the points xw,yw.
1235///
1236/// - If nn=1 moves only to point xw,yw.
1237/// - If nn=0 the XW(1) and YW(1) are written in the PDF file
1238/// according to the current NT.
1239/// - If nn>0 the line is clipped as a line.
1240/// - If nn<0 the line is clipped as a fill area.
1241
1243{
1244 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1245 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1246 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1247 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1248 180, 90,135, 45,150, 30,120, 60,
1249 180, 90,135, 45,150, 30,120, 60};
1250 Int_t n = 0, fais = 0 , fasi = 0;
1251
1254
1255 if (nn > 0) {
1256 if (fLineWidth<=0) return;
1257 n = nn;
1261 }
1262 if (nn < 0) {
1263 n = -nn;
1264 SetLineStyle(1);
1265 SetLineWidth(1);
1267 fais = fFillStyle/1000;
1268 fasi = fFillStyle%1000;
1269 if (fais == 3 || fais == 2) {
1270 if (fasi > 100 && fasi <125) {
1271 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1274 return;
1275 }
1276 if (fasi > 0 && fasi < 26) {
1278 }
1279 }
1280 }
1281
1282 WriteReal(XtoPDF(xw[0]));
1283 WriteReal(YtoPDF(yw[0]));
1284 if (n <= 1) {
1285 if (n == 0) return;
1286 PrintFast(2," m");
1287 return;
1288 }
1289
1290 PrintFast(2," m");
1291
1292 for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xw[i]), YtoPDF(yw[i]));
1293
1294 if (nn > 0) {
1295 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(2," h");
1296 PrintFast(2," S");
1297 } else {
1298 if (fais == 0) {PrintFast(2," s"); return;}
1299 if (fais == 3 || fais == 2) {
1300 if (fasi > 0 && fasi < 26) {
1301 PrintFast(3," f*");
1302 fRed = -1;
1303 fGreen = -1;
1304 fBlue = -1;
1305 fAlpha = -1.;
1306 }
1309 return;
1310 }
1311 PrintFast(3," f*");
1312 }
1313
1316}
1317
1318////////////////////////////////////////////////////////////////////////////////
1319/// Draw a PolyLine
1320///
1321/// Draw a polyline through the points xw,yw.
1322///
1323/// - If nn=1 moves only to point xw,yw.
1324/// - If nn=0 the xw(1) and YW(1) are written in the PDF file
1325/// according to the current NT.
1326/// - If nn>0 the line is clipped as a line.
1327/// - If nn<0 the line is clipped as a fill area.
1328
1330{
1331 static Float_t dyhatch[24] = {.0075,.0075,.0075,.0075,.0075,.0075,.0075,.0075,
1332 .01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,.01 ,
1333 .015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015 ,.015};
1334 static Float_t anglehatch[24] = {180, 90,135, 45,150, 30,120, 60,
1335 180, 90,135, 45,150, 30,120, 60,
1336 180, 90,135, 45,150, 30,120, 60};
1337 Int_t n = 0, fais = 0, fasi = 0;
1338
1341
1342 if (nn > 0) {
1343 if (fLineWidth<=0) return;
1344 n = nn;
1348 }
1349 if (nn < 0) {
1350 n = -nn;
1351 SetLineStyle(1);
1352 SetLineWidth(1);
1354 fais = fFillStyle/1000;
1355 fasi = fFillStyle%1000;
1356 if (fais == 3 || fais == 2) {
1357 if (fasi > 100 && fasi <125) {
1358 DrawHatch(dyhatch[fasi-101],anglehatch[fasi-101], n, xw, yw);
1361 return;
1362 }
1363 if (fasi > 0 && fasi < 26) {
1365 }
1366 }
1367 }
1368
1369 WriteReal(XtoPDF(xw[0]));
1370 WriteReal(YtoPDF(yw[0]));
1371 if (n <= 1) {
1372 if (n == 0) return;
1373 PrintFast(2," m");
1374 return;
1375 }
1376
1377 PrintFast(2," m");
1378
1379 for (Int_t i=1;i<n;i++) LineTo(XtoPDF(xw[i]), YtoPDF(yw[i]));
1380
1381 if (nn > 0) {
1382 if (xw[0] == xw[n-1] && yw[0] == yw[n-1]) PrintFast(2," h");
1383 PrintFast(2," S");
1384 } else {
1385 if (fais == 0) {PrintFast(2," s"); return;}
1386 if (fais == 3 || fais == 2) {
1387 if (fasi > 0 && fasi < 26) {
1388 PrintFast(3," f*");
1389 fRed = -1;
1390 fGreen = -1;
1391 fBlue = -1;
1392 fAlpha = -1.;
1393 }
1396 return;
1397 }
1398 PrintFast(3," f*");
1399 }
1400
1403}
1404
1405////////////////////////////////////////////////////////////////////////////////
1406/// Close the current opened object
1407
1409{
1410 if (!fObjectIsOpen)
1411 Warning("TPDF::EndObject", "No Object currently opened.");
1413
1414 PrintStr("endobj@");
1415}
1416
1417////////////////////////////////////////////////////////////////////////////////
1418/// Font encoding
1419
1421{
1422 static const char *sdtfonts[] = {
1423 "/Times-Italic" , "/Times-Bold" , "/Times-BoldItalic",
1424 "/Helvetica" , "/Helvetica-Oblique" , "/Helvetica-Bold" ,
1425 "/Helvetica-BoldOblique", "/Courier" , "/Courier-Oblique" ,
1426 "/Courier-Bold" , "/Courier-BoldOblique", "/Symbol" ,
1427 "/Times-Roman" , "/ZapfDingbats" , "/Symbol"};
1428
1429 for (Int_t i=0; i<kNumberOfFonts; i++) {
1431 PrintStr("<<@");
1432 PrintStr("/Type /Font@");
1433 PrintStr("/Subtype /Type1@");
1434 PrintStr("/Name /F");
1435 WriteInteger(i+1,false);
1436 PrintStr("@");
1437 PrintStr("/BaseFont ");
1438 PrintStr(sdtfonts[i]);
1439 PrintStr("@");
1440 if (i!=11 && i!=13 && i!=14) {
1441 PrintStr("/Encoding /WinAnsiEncoding");
1442 PrintStr("@");
1443 }
1444 PrintStr(">>@");
1445 EndObject();
1446 }
1447}
1448
1449////////////////////////////////////////////////////////////////////////////////
1450/// Draw a line to a new position
1451
1453{
1454 WriteReal(x);
1455 WriteReal(y);
1456 PrintFast(2," l");
1457}
1458
1459////////////////////////////////////////////////////////////////////////////////
1460/// Move to a new position
1461
1463{
1464 WriteReal(x);
1465 WriteReal(y);
1466 PrintFast(2," m");
1467}
1468
1469////////////////////////////////////////////////////////////////////////////////
1470/// Create a new object in the PDF file
1471
1473{
1474 if (fObjectIsOpen)
1475 Warning("TPDF::NewObject", "An Object is already open.");
1477 if (!fObjPos || n >= fObjPosSize) {
1479 Int_t *saveo = new Int_t [newN];
1480 if (fObjPos && fObjPosSize) {
1483 delete [] fObjPos;
1484 }
1485 fObjPos = saveo;
1486 fObjPosSize = newN;
1487 }
1488 fObjPos[n-1] = fNByte;
1490 WriteInteger(n, false);
1491 PrintStr(" 0 obj");
1492 PrintStr("@");
1493}
1494
1495////////////////////////////////////////////////////////////////////////////////
1496/// Start a new PDF page.
1497
1499{
1500 if (!fPageNotEmpty) return;
1501
1502 // Compute pad conversion coefficients
1503 if (gPad) {
1504 Double_t ww = gPad->GetWw();
1505 Double_t wh = gPad->GetWh();
1506 fYsize = fXsize*wh/ww;
1507 } else {
1508 fYsize = 27;
1509 }
1510
1511 fNbPage++;
1512 fA = 1.;
1513 fB = 0.;
1514 fC = 0.;
1515 fD = 1.;
1516 fE = 0.;
1517 fF = 0.;
1518
1519 if (fNbPage>1) {
1520 // Close the currently opened page
1522 PrintStr("endstream@");
1524 EndObject();
1526 WriteInteger(streamLength, false);
1527 PrintStr("@");
1528 EndObject();
1530 PrintStr("<<@");
1531 if (!strstr(GetTitle(),"PDF")) {
1532 PrintStr("/Title (");
1533 PrintStr(GetTitle());
1534 PrintStr(")@");
1535 } else {
1536 PrintStr("/Title (Page");
1538 PrintStr(")@");
1539 }
1540 PrintStr("/Dest [");
1542 PrintStr(" 0 R /XYZ null null 0]@");
1543 PrintStr("/Parent");
1545 PrintStr(" 0 R");
1546 PrintStr("@");
1547 PrintStr("/Next");
1549 PrintStr(" 0 R");
1550 PrintStr("@");
1551 if (fNbPage>2) {
1552 PrintStr("/Prev");
1554 PrintStr(" 0 R");
1555 PrintStr("@");
1556 }
1557 PrintStr(">>@");
1558 EndObject();
1560 fCurrentPage = fCurrentPage + fNbUrl + 4; // object number of the next page
1561 fNbUrl = 1;
1562 }
1563
1564 // Start a new page
1565 PrintStr("@");
1567 fPageObjects.push_back(fCurrentPage);
1568 PrintStr("<<@");
1569 PrintStr("/Type /Page@");
1570 PrintStr("@");
1571 PrintStr("/Parent");
1573 PrintStr(" 0 R");
1574 PrintStr("@");
1575
1576 Double_t xlow=0, ylow=0, xup=1, yup=1;
1577 if (gPad) {
1578 xlow = gPad->GetAbsXlowNDC();
1579 xup = xlow + gPad->GetAbsWNDC();
1580 ylow = gPad->GetAbsYlowNDC();
1581 yup = ylow + gPad->GetAbsHNDC();
1582 }
1583
1584 PrintStr("/MediaBox [");
1586 switch (fPageFormat) {
1587 case 100 :
1588 width = 8.5*2.54;
1589 height = 11.*2.54;
1590 break;
1591 case 200 :
1592 width = 8.5*2.54;
1593 height = 14.*2.54;
1594 break;
1595 case 300 :
1596 width = 11.*2.54;
1597 height = 17.*2.54;
1598 break;
1599 default :
1602 };
1603 WriteReal(CMtoPDF(fXsize*xlow));
1604 WriteReal(CMtoPDF(fYsize*ylow));
1607 PrintStr("]");
1608 PrintStr("@");
1609
1610 Double_t xmargin = CMtoPDF(0.7);
1611 Double_t ymargin = 0;
1612 if (fPageOrientation == 1) ymargin = CMtoPDF(TMath::Sqrt(2.)*0.7);
1613 if (fPageOrientation == 2) ymargin = CMtoPDF(height)-CMtoPDF(0.7);
1614
1615 PrintStr("/CropBox [");
1616 if (fPageOrientation == 1) {
1621 }
1622 if (fPageOrientation == 2) {
1627 }
1628 PrintStr("]");
1629 PrintStr("@");
1630
1631 if (fPageOrientation == 1) PrintStr("/Rotate 0@");
1632 if (fPageOrientation == 2) PrintStr("/Rotate 90@");
1633
1634 PrintStr("/Resources");
1636 PrintStr(" 0 R");
1637 PrintStr("@");
1638
1639 PrintStr("/Contents");
1641 PrintStr(" 0 R@");
1642
1643 PrintStr("/Annots");
1645 PrintStr(" 0 R");
1646 PrintStr("@");
1647
1648 PrintStr(">>@");
1649 EndObject();
1650
1652 PrintStr("<<@");
1653 PrintStr("/Length");
1655 PrintStr(" 0 R@");
1656 PrintStr("/Filter [/FlateDecode]@");
1657 PrintStr(">>@");
1658 PrintStr("stream@");
1660 fCompress = kTRUE;
1661
1662 // Force the line width definition next time TPDF::SetLineWidth will be called.
1663 fLineWidth = -1;
1664
1665 // Force the color definition next time TPDF::SetColor will be called.
1666 fRed = -1;
1667 fGreen = -1;
1668 fBlue = -1;
1669 fAlpha = -1.;
1670
1671 if (fPageOrientation == 2) {
1674 }
1675
1676 WriteCM(1, 0, 0, 1, xmargin, ymargin);
1677 if (fPageOrientation == 2)
1678 WriteCM(0, 1, -1, 0, 0, 0);
1679 if (fgLineJoin) {
1681 PrintFast(2," j");
1682 }
1683 if (fgLineCap) {
1685 PrintFast(2," J");
1686 }
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Deactivate an already open PDF file
1691
1693{
1694 gVirtualPS = nullptr;
1695}
1696
1697////////////////////////////////////////////////////////////////////////////////
1698/// Activate an already open PDF file
1699
1701{
1702 // fType is used to know if the PDF file is open. Unlike TPostScript, TPDF
1703 // has no "workstation type".
1704
1705 if (!fType) {
1706 Error("On", "no PDF file open");
1707 Off();
1708 return;
1709 }
1710 gVirtualPS = this;
1711}
1712
1713////////////////////////////////////////////////////////////////////////////////
1714/// Open a PDF file
1715
1716void TPDF::Open(const char *fname, Int_t wtype)
1717{
1718 Int_t i;
1719
1720 if (fStream) {
1721 Warning("Open", "PDF file already open");
1722 return;
1723 }
1724
1725 fLenBuffer = 0;
1726 fRed = -1;
1727 fGreen = -1;
1728 fBlue = -1;
1729 fAlpha = -1.;
1730 fType = abs(wtype);
1736 if (gPad) {
1737 Double_t ww = gPad->GetWw();
1738 Double_t wh = gPad->GetWh();
1739 if (fType == 113) {
1740 ww *= gPad->GetWNDC();
1741 wh *= gPad->GetHNDC();
1742 }
1743 Double_t ratio = wh/ww;
1744 xrange = fXsize;
1745 yrange = fXsize*ratio;
1746 if (yrange > fYsize) { yrange = fYsize; xrange = yrange/ratio;}
1748 }
1749
1750 // Open OS file
1751 fStream = new std::ofstream();
1752#ifdef R__WIN32
1753 fStream->open(fname, std::ofstream::out | std::ofstream::binary);
1754#else
1755 fStream->open(fname, std::ofstream::out);
1756#endif
1757 if (!fStream || !fStream->good()) {
1758 printf("ERROR in TPDF::Open: Cannot open file:%s\n",fname);
1759 if (!fStream) return;
1760 }
1761
1762 gVirtualPS = this;
1763
1764 for (i=0; i<fSizBuffer; i++) fBuffer[i] = ' ';
1765
1766 // The page orientation is last digit of PDF workstation type
1767 // orientation = 1 for portrait
1768 // orientation = 2 for landscape
1771 Error("Open", "Invalid page orientation %d", fPageOrientation);
1772 return;
1773 }
1774
1775 // format = 0-99 is the European page format (A4,A3 ...)
1776 // format = 100 is the US format 8.5x11.0 inch
1777 // format = 200 is the US format 8.5x14.0 inch
1778 // format = 300 is the US format 11.0x17.0 inch
1779 fPageFormat = fType/1000;
1780 if (fPageFormat == 0) fPageFormat = 4;
1781 if (fPageFormat == 99) fPageFormat = 0;
1782
1783 fRange = kFALSE;
1784
1785 // Set a default range
1787
1788 fObjPos = nullptr;
1789 fObjPosSize = 0;
1790 fNbObj = 0;
1791 fNbPage = 0;
1792 fUrl = kFALSE;
1793
1794 PrintStr("%PDF-1.4@");
1795 PrintStr("%\342\343\317\323");
1796 PrintStr("@");
1797
1799 PrintStr("<<@");
1800 PrintStr("/Type /Catalog@");
1801 PrintStr("/Pages");
1803 PrintStr(" 0 R@");
1804 PrintStr("/Outlines");
1806 PrintStr(" 0 R@");
1807 PrintStr("/PageMode /UseOutlines@");
1808 PrintStr(">>@");
1809 EndObject();
1810
1812 PrintStr("<<@");
1813 PrintStr("/Creator (ROOT Version ");
1814 PrintStr(gROOT->GetVersion());
1815 PrintStr(")");
1816 PrintStr("@");
1817 PrintStr("/CreationDate (");
1818 TDatime t;
1819 Int_t toff = t.Convert(kFALSE) - t.Convert(kTRUE); // time zone and dst offset
1820 toff = toff/60;
1821 char str[24];
1822 snprintf(str,24,"D:%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d%c%2.2d'%2.2d'",
1823 t.GetYear() , t.GetMonth(),
1824 t.GetDay() , t.GetHour(),
1825 t.GetMinute(), t.GetSecond(),
1826 toff < 0 ? '-' : '+',
1827 // TMath::Abs(toff/60), TMath::Abs(toff%60)); // format-truncation warning
1828 TMath::Abs(toff/60) & 0x3F, TMath::Abs(toff%60) & 0x3F); // now 2 digits
1829 PrintStr(str);
1830 PrintStr(")");
1831 PrintStr("@");
1832 PrintStr("/ModDate (");
1833 PrintStr(str);
1834 PrintStr(")");
1835 PrintStr("@");
1836 PrintStr("/Title (");
1837 if (strlen(GetName())<=80) PrintStr(GetName());
1838 PrintStr(")");
1839 PrintStr("@");
1840 PrintStr("/Keywords (ROOT)@");
1841 PrintStr(">>@");
1842 EndObject();
1843
1845 PrintStr("<<@");
1846 PrintStr("/ProcSet [/PDF /Text]@");
1847
1848 PrintStr("/Font@");
1849 PrintStr("<<@");
1850 for (i=0; i<kNumberOfFonts; i++) {
1851 PrintStr(" /F");
1852 WriteInteger(i+1,false);
1854 PrintStr(" 0 R");
1855 }
1856 PrintStr("@");
1857 PrintStr(">>@");
1858
1859 PrintStr("/ExtGState");
1861 PrintStr(" 0 R @");
1862 if (!fAlphas.empty()) fAlphas.clear();
1863
1864 PrintStr("/ColorSpace << /Cs8");
1866 PrintStr(" 0 R >>");
1867 PrintStr("@");
1868 PrintStr("/Pattern");
1870 PrintStr(" 0 R");
1871 PrintStr("@");
1872 PrintStr(">>@");
1873 EndObject();
1874
1875 FontEncode();
1876 PatternEncode();
1877
1878 NewPage();
1880}
1881
1882////////////////////////////////////////////////////////////////////////////////
1883/// Output the string str in the output buffer
1884
1885void TPDF::PrintStr(const char *str)
1886{
1887 Int_t len = strlen(str);
1888 if (len == 0) return;
1890
1891 if (fCompress) {
1892 if (fLenBuffer+len >= fSizBuffer) {
1895 }
1896 strcpy(fBuffer + fLenBuffer, str);
1897 fLenBuffer += len;
1898 return;
1899 }
1900
1902}
1903
1904////////////////////////////////////////////////////////////////////////////////
1905/// Fast version of Print
1906
1907void TPDF::PrintFast(Int_t len, const char *str)
1908{
1910 if (fCompress) {
1911 if (fLenBuffer+len >= fSizBuffer) {
1914 }
1915 strcpy(fBuffer + fLenBuffer, str);
1916 fLenBuffer += len;
1917 return;
1918 }
1919
1921}
1922
1923////////////////////////////////////////////////////////////////////////////////
1924/// Set the range for the paper in centimetres
1925
1927{
1928 fXsize = xsize;
1929 fYsize = ysize;
1930 fRange = kTRUE;
1931}
1932
1933////////////////////////////////////////////////////////////////////////////////
1934/// Set the alpha channel value.
1935
1937{
1938 if (a == fAlpha) return;
1939 fAlpha = a;
1940 if (fAlpha <= 0.000001) fAlpha = 0;
1941
1942 Bool_t known = kFALSE;
1943 for (int i=0; i<(int)fAlphas.size(); i++) {
1944 if (fAlpha == fAlphas[i]) {
1945 known = kTRUE;
1946 break;
1947 }
1948 }
1949 if (!known) fAlphas.push_back(fAlpha);
1950 PrintStr(Form(" /ca%3.2f gs /CA%3.2f gs",fAlpha,fAlpha));
1951}
1952
1953////////////////////////////////////////////////////////////////////////////////
1954/// Set color with its color index.
1955
1957{
1958 if (color < 0) color = 0;
1959 TColor *col = gROOT->GetColor(color);
1960
1961 if (col) {
1962 SetColor(col->GetRed(), col->GetGreen(), col->GetBlue());
1963 SetAlpha(col->GetAlpha());
1964 } else {
1965 SetColor(1., 1., 1.);
1966 SetAlpha(1.);
1967 }
1968}
1969
1970////////////////////////////////////////////////////////////////////////////////
1971/// Set color with its R G B components:
1972///
1973/// - r: % of red in [0,1]
1974/// - g: % of green in [0,1]
1975/// - b: % of blue in [0,1]
1976
1978{
1979 if (r == fRed && g == fGreen && b == fBlue) return;
1980
1981 fRed = r;
1982 fGreen = g;
1983 fBlue = b;
1984 if (fRed <= 0.000001) fRed = 0;
1985 if (fGreen <= 0.000001) fGreen = 0;
1986 if (fBlue <= 0.000001) fBlue = 0;
1987
1988 if (gStyle->GetColorModelPS()) {
1991 if (colBlack==1) {
1992 colCyan = 0;
1993 colMagenta = 0;
1994 colYellow = 0;
1995 } else {
1996 colCyan = (1-fRed-colBlack)/(1-colBlack);
1998 colYellow = (1-fBlue-colBlack)/(1-colBlack);
1999 }
2000 if (colCyan <= 0.000001) colCyan = 0;
2001 if (colMagenta <= 0.000001) colMagenta = 0;
2002 if (colYellow <= 0.000001) colYellow = 0;
2003 if (colBlack <= 0.000001) colBlack = 0;
2008 PrintFast(2," K");
2013 PrintFast(2," k");
2014 } else {
2015 WriteReal(fRed);
2018 PrintFast(3," RG");
2019 WriteReal(fRed);
2022 PrintFast(3," rg");
2023 }
2024}
2025
2026////////////////////////////////////////////////////////////////////////////////
2027/// Set color index for fill areas
2028
2033
2034////////////////////////////////////////////////////////////////////////////////
2035/// Set the fill patterns (1 to 25) for fill areas
2036
2038{
2039 char cpat[10];
2040 TColor *col = gROOT->GetColor(color);
2041 if (!col) return;
2042 PrintStr(" /Cs8 cs");
2043 Double_t colRed = col->GetRed();
2044 Double_t colGreen = col->GetGreen();
2045 Double_t colBlue = col->GetBlue();
2046 if (gStyle->GetColorModelPS()) {
2048 if (colBlack==1) {
2049 WriteReal(0);
2050 WriteReal(0);
2051 WriteReal(0);
2053 } else {
2061 }
2062 } else {
2066 }
2067
2068 if (fPageOrientation == 2) {
2069 switch (ipat) {
2070 case 4: ipat = 5; break;
2071 case 5: ipat = 4; break;
2072 case 6: ipat = 7; break;
2073 case 7: ipat = 6; break;
2074 case 17: ipat = 18; break;
2075 case 18: ipat = 17; break;
2076 case 20: ipat = 16; break;
2077 case 16: ipat = 20; break;
2078 case 21: ipat = 22; break;
2079 case 22: ipat = 21; break;
2080 }
2081 }
2082 snprintf(cpat,10," /P%2.2d scn", ipat);
2083 PrintStr(cpat);
2084}
2085
2086////////////////////////////////////////////////////////////////////////////////
2087/// Set color index for lines
2088
2093
2094////////////////////////////////////////////////////////////////////////////////
2095/// Set the value of the global parameter TPDF::fgLineJoin.
2096/// This parameter determines the appearance of joining lines in a PDF
2097/// output.
2098/// It takes one argument which may be:
2099/// - 0 (miter join)
2100/// - 1 (round join)
2101/// - 2 (bevel join)
2102/// The default value is 0 (miter join).
2103///
2104/// \image html postscript_1.png
2105///
2106/// To change the line join behaviour just do:
2107/// ~~~ {.cpp}
2108/// gStyle->SetJoinLinePS(2); // Set the PDF line join to bevel.
2109/// ~~~
2110
2112{
2114 if (fgLineJoin<0) fgLineJoin=0;
2115 if (fgLineJoin>2) fgLineJoin=2;
2116}
2117
2118////////////////////////////////////////////////////////////////////////////////
2119/// Set the value of the global parameter TPDF::fgLineCap.
2120/// This parameter determines the appearance of line caps in a PDF
2121/// output.
2122/// It takes one argument which may be:
2123/// - 0 (butt caps)
2124/// - 1 (round caps)
2125/// - 2 (projecting caps)
2126/// The default value is 0 (butt caps).
2127///
2128/// \image html postscript_2.png
2129///
2130/// To change the line cap behaviour just do:
2131/// ~~~ {.cpp}
2132/// gStyle->SetCapLinePS(2); // Set the PDF line cap to projecting.
2133/// ~~~
2134
2136{
2138 if (fgLineCap<0) fgLineCap=0;
2139 if (fgLineCap>2) fgLineCap=2;
2140}
2141
2142////////////////////////////////////////////////////////////////////////////////
2143/// Change the line style
2144///
2145/// - linestyle = 2 dashed
2146/// - linestyle = 3 dotted
2147/// - linestyle = 4 dash-dotted
2148/// - linestyle = else solid (1 in is used most of the time)
2149
2151{
2152 if ( linestyle == fLineStyle) return;
2155 PrintFast(2," [");
2156 TObjArray *tokens = st.Tokenize(" ");
2157 for (Int_t j = 0; j<tokens->GetEntries(); j++) {
2158 Int_t it;
2159 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2160 WriteInteger((Int_t)(it/4));
2161 }
2162 delete tokens;
2163 PrintFast(5,"] 0 d");
2164}
2165
2166////////////////////////////////////////////////////////////////////////////////
2167/// Change the line width
2168
2170{
2171 if (linewidth == fLineWidth) return;
2173 if (fLineWidth!=0) {
2175 PrintFast(2," w");
2176 }
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Set color index for markers.
2181
2186
2187////////////////////////////////////////////////////////////////////////////////
2188/// Set color index for text
2189
2194
2195////////////////////////////////////////////////////////////////////////////////
2196/// Draw text
2197///
2198/// - xx: x position of the text
2199/// - yy: y position of the text
2200/// - chars: text to be drawn
2201
2203{
2204 if (fTextSize <= 0) return;
2205
2206 const Double_t kDEGRAD = TMath::Pi()/180.;
2207 char str[8];
2208 Double_t x = xx;
2209 Double_t y = yy;
2210
2211 // Font and text size
2212 Int_t font = abs(fTextFont)/10;
2213 if (font > kNumberOfFonts || font < 1) font = 1;
2214
2215 Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2());
2216 Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1());
2218 if (wh < hh) {
2219 tsize = fTextSize*wh;
2220 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2221 ftsize = (sizeTTF*fXsize*gPad->GetAbsWNDC())/wh;
2222 } else {
2223 tsize = fTextSize*hh;
2224 Int_t sizeTTF = (Int_t)(tsize*kScale+0.5); // TTF size
2225 ftsize = (sizeTTF*fYsize*gPad->GetAbsHNDC())/hh;
2226 }
2227 Double_t fontsize = 72*(ftsize)/2.54;
2228 if (fontsize <= 0) return;
2229
2230 // Text color
2232
2233 // Clipping
2234 PrintStr(" q");
2235 Double_t x1 = XtoPDF(gPad->GetX1());
2236 Double_t x2 = XtoPDF(gPad->GetX2());
2237 Double_t y1 = YtoPDF(gPad->GetY1());
2238 Double_t y2 = YtoPDF(gPad->GetY2());
2239 WriteReal(x1);
2240 WriteReal(y1);
2241 WriteReal(x2 - x1);
2242 WriteReal(y2 - y1);
2243 PrintStr(" re W n");
2244
2245 // Start the text
2246 if (!fCompress) PrintStr("@");
2247
2248 // Text alignment
2249 Float_t tsizex = gPad->AbsPixeltoX(Int_t(tsize))-gPad->AbsPixeltoX(0);
2250 Float_t tsizey = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(Int_t(tsize));
2251 Int_t txalh = fTextAlign/10;
2252 if (txalh < 1) txalh = 1; else if (txalh > 3) txalh = 3;
2253 Int_t txalv = fTextAlign%10;
2254 if (txalv < 1) txalv = 1; else if (txalv > 3) txalv = 3;
2255 if (txalv == 3) {
2258 } else if (txalv == 2) {
2261 }
2262
2263 if (txalh > 1) {
2264 TText t;
2265 UInt_t w=0, h;
2268 t.GetTextExtent(w, h, chars);
2269 Double_t twx = gPad->AbsPixeltoX(w)-gPad->AbsPixeltoX(0);
2270 Double_t twy = gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY(w);
2271 if (txalh == 2) {
2274 }
2275 if (txalh == 3) {
2278 }
2279 }
2280
2281 // Text angle
2282 Double_t a, b, c, d, e, f;
2283 if (fTextAngle == 0) {
2284 a = 1;
2285 b = 0;
2286 c = 0;
2287 d = 1;
2288 e = XtoPDF(x);
2289 f = YtoPDF(y);
2290 } else if (fTextAngle == 90) {
2291 a = 0;
2292 b = 1;
2293 c = -1;
2294 d = 0;
2295 e = XtoPDF(x);
2296 f = YtoPDF(y);
2297 } else if (fTextAngle == 270) {
2298 a = 0;
2299 b = -1;
2300 c = 1;
2301 d = 0;
2302 e = XtoPDF(x);
2303 f = YtoPDF(y);
2304 } else {
2309 e = XtoPDF(x);
2310 f = YtoPDF(y);
2311 }
2312 WriteCM(a, b, c, d, e, f, kFALSE);
2313
2314 // Symbol Italic tan(15) = .26794
2315 if (font == 15)
2316 WriteCM(1, 0, 0.26794, 1, 0, 0, kFALSE);
2317
2318 if (fUrl)
2319 ComputeRect(chars, fontsize, a, b, c, d, e, f);
2320
2321 PrintStr(" BT");
2322
2323 snprintf(str,8," /F%d",font);
2324 PrintStr(str);
2326 PrintStr(" Tf");
2327
2328 const Int_t len=strlen(chars);
2329
2330 // Calculate the individual character placements.
2331 // Otherwise, if a string is printed in one line the kerning is not
2332 // performed. In order to measure the precise character positions we need to
2333 // trick FreeType into rendering high-resolution characters otherwise it will
2334 // stick to the screen pixel grid which is far worse than we can achieve on
2335 // print.
2336 const Float_t scale = 16.0;
2337 // Save current text attributes.
2339 saveAttText.TAttText::operator=(*this);
2340 TText t;
2343 UInt_t wa1=0, wa0=0;
2346 t.TAttText::Modify();
2348 if (wa0-wa1 != 0) kerning = kTRUE;
2349 else kerning = kFALSE;
2350 Int_t *charDeltas = nullptr;
2351 if (kerning) {
2352 charDeltas = new Int_t[len];
2353 for (Int_t i = 0;i < len;i++) {
2354 UInt_t ww=0;
2355 t.GetTextAdvance(ww, chars + i);
2356 charDeltas[i] = wa1 - ww;
2357 }
2358 for (Int_t i = len - 1;i > 0;i--) {
2359 charDeltas[i] -= charDeltas[i-1];
2360 }
2361 char tmp[2];
2362 tmp[1] = 0;
2363 for (Int_t i = 1;i < len;i++) {
2364 tmp[0] = chars[i-1];
2365 UInt_t width=0;
2366 t.GetTextAdvance(width, &tmp[0], kFALSE);
2367 Double_t wwl = gPad->AbsPixeltoX(width - charDeltas[i]) - gPad->AbsPixeltoX(0);
2368 wwl -= 0.5*(gPad->AbsPixeltoX(1) - gPad->AbsPixeltoX(0)); // half a pixel ~ rounding error
2369 charDeltas[i] = (Int_t)((1000.0/Float_t(fontsize))*(XtoPDF(wwl) - XtoPDF(0))/scale);
2370 }
2371 }
2372 // Restore text attributes.
2373 saveAttText.TAttText::Modify();
2374
2375 // Output the text. Escape some characters if needed
2376 if (kerning) PrintStr(" [");
2377 else PrintStr(" (");
2378
2379 for (Int_t i=0; i<len;i++) {
2380 if (chars[i]!='\n') {
2381 if (kerning) PrintStr("(");
2382 if (chars[i]=='(' || chars[i]==')') {
2383 snprintf(str,8,"\\%c",chars[i]);
2384 } else {
2385 snprintf(str,8,"%c",chars[i]);
2386 }
2387 PrintStr(str);
2388 if (kerning) {
2389 PrintStr(") ");
2390 if (i < len-1) {
2392 }
2393 }
2394 }
2395 }
2396
2397 if (kerning) PrintStr("] TJ ET Q");
2398 else PrintStr(") Tj ET Q");
2399 if (!fCompress) PrintStr("@");
2400 if (kerning) delete [] charDeltas;
2401}
2402
2403////////////////////////////////////////////////////////////////////////////////
2404/// Write a string of characters
2405///
2406/// This method writes the string chars into a PDF file
2407/// at position xx,yy in world coordinates.
2408
2409void TPDF::Text(Double_t, Double_t, const wchar_t *)
2410{
2411}
2412
2413////////////////////////////////////////////////////////////////////////////////
2414/// Draw text with URL. Same as Text.
2415///
2416
2417void TPDF::TextUrl(Double_t x, Double_t y, const char *chars, const char *url)
2418{
2419 fUrl = kTRUE;
2420 Text(x, y, chars);
2421 fNbUrl++;
2422 fUrls.push_back(url);
2423 fUrl = kFALSE;
2424}
2425
2426////////////////////////////////////////////////////////////////////////////////
2427/// Write a string of characters in NDC
2428
2430{
2431 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2432 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2433 Text(x, y, chars);
2434}
2435
2436////////////////////////////////////////////////////////////////////////////////
2437/// Write a string of characters in NDC
2438
2439void TPDF::TextNDC(Double_t u, Double_t v, const wchar_t *chars)
2440{
2441 Double_t x = gPad->GetX1() + u*(gPad->GetX2() - gPad->GetX1());
2442 Double_t y = gPad->GetY1() + v*(gPad->GetY2() - gPad->GetY1());
2443 Text(x, y, chars);
2444}
2445
2446////////////////////////////////////////////////////////////////////////////////
2447/// Convert U from NDC coordinate to PDF
2448
2450{
2451 Double_t cm = fXsize*(gPad->GetAbsXlowNDC() + u*gPad->GetAbsWNDC());
2452 return 72*cm/2.54;
2453}
2454
2455////////////////////////////////////////////////////////////////////////////////
2456/// Convert V from NDC coordinate to PDF
2457
2459{
2460 Double_t cm = fYsize*(gPad->GetAbsYlowNDC() + v*gPad->GetAbsHNDC());
2461 return 72*cm/2.54;
2462}
2463
2464////////////////////////////////////////////////////////////////////////////////
2465/// Convert X from world coordinate to PDF
2466
2468{
2469 Double_t u = (x - gPad->GetX1())/(gPad->GetX2() - gPad->GetX1());
2470 return UtoPDF(u);
2471}
2472
2473////////////////////////////////////////////////////////////////////////////////
2474/// Convert Y from world coordinate to PDF
2475
2477{
2478 Double_t v = (y - gPad->GetY1())/(gPad->GetY2() - gPad->GetY1());
2479 return VtoPDF(v);
2480}
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Write the buffer in a compressed way
2484
2486{
2487 z_stream stream;
2488 int err;
2489 char *out = new char[2*fLenBuffer];
2490
2491 stream.next_in = (Bytef*)fBuffer;
2492 stream.avail_in = (uInt)fLenBuffer;
2493 stream.next_out = (Bytef*)out;
2494 stream.avail_out = (uInt)2*fLenBuffer;
2495 stream.zalloc = (alloc_func)nullptr;
2496 stream.zfree = (free_func)nullptr;
2497 stream.opaque = (voidpf)nullptr;
2498
2499 err = deflateInit(&stream, Z_DEFAULT_COMPRESSION);
2500 if (err != Z_OK) {
2501 Error("WriteCompressedBuffer", "error in deflateInit (zlib)");
2502 delete [] out;
2503 return;
2504 }
2505
2506 err = deflate(&stream, Z_FINISH);
2507 if (err != Z_STREAM_END) {
2508 deflateEnd(&stream);
2509 Error("WriteCompressedBuffer", "error in deflate (zlib)");
2510 delete [] out;
2511 return;
2512 }
2513
2514 err = deflateEnd(&stream);
2515 if (err != Z_OK) {
2516 Error("WriteCompressedBuffer", "error in deflateEnd (zlib)");
2517 }
2518
2519 fStream->write(out, stream.total_out);
2520
2521 fNByte += stream.total_out;
2522 fStream->write("\n",1); fNByte++;
2523 fLenBuffer = 0;
2524 delete [] out;
2525 fCompress = kFALSE;
2526}
2527
2528////////////////////////////////////////////////////////////////////////////////
2529/// Write a Real number to the file.
2530/// This method overwrites TVirtualPS::WriteReal. Some PDF reader like
2531/// Acrobat do not work when a PDF file contains reals with exponent. This
2532/// method writes the real number "z" using the format "%f" instead of the
2533/// format "%g" when writing it with "%g" generates a number with exponent.
2534
2536{
2537 char str[15];
2538 if (space) {
2539 snprintf(str,15," %g", z);
2540 if (strstr(str,"e") || strstr(str,"E")) snprintf(str,15," %10.8f", z);
2541 } else {
2542 snprintf(str,15,"%g", z);
2543 if (strstr(str,"e") || strstr(str,"E")) snprintf(str,15,"%10.8f", z);
2544 }
2545 PrintStr(str);
2546}
2547
2548////////////////////////////////////////////////////////////////////////////////
2549/// Patterns encoding
2550
2552{
2554
2556 if (gStyle->GetColorModelPS()) {
2557 PrintStr("[/Pattern /DeviceCMYK]@");
2558 } else {
2559 PrintStr("[/Pattern /DeviceRGB]@");
2560 }
2561 EndObject();
2563 PrintStr("<</ProcSet[/PDF]>>@");
2564 EndObject();
2565
2567 PrintStr("<<@");
2568 PrintStr(" /P01");
2570 PrintStr(" 0 R");
2571 PrintStr(" /P02");
2573 PrintStr(" 0 R");
2574 PrintStr(" /P03");
2576 PrintStr(" 0 R");
2577 PrintStr(" /P04");
2579 PrintStr(" 0 R");
2580 PrintStr(" /P05");
2582 PrintStr(" 0 R");
2583 PrintStr(" /P06");
2585 PrintStr(" 0 R");
2586 PrintStr(" /P07");
2588 PrintStr(" 0 R");
2589 PrintStr(" /P08");
2591 PrintStr(" 0 R");
2592 PrintStr(" /P09");
2594 PrintStr(" 0 R");
2595 PrintStr(" /P10");
2597 PrintStr(" 0 R");
2598 PrintStr(" /P11");
2600 PrintStr(" 0 R");
2601 PrintStr(" /P12");
2603 PrintStr(" 0 R");
2604 PrintStr(" /P13");
2606 PrintStr(" 0 R");
2607 PrintStr(" /P14");
2609 PrintStr(" 0 R");
2610 PrintStr(" /P15");
2612 PrintStr(" 0 R");
2613 PrintStr(" /P16");
2615 PrintStr(" 0 R");
2616 PrintStr(" /P17");
2618 PrintStr(" 0 R");
2619 PrintStr(" /P18");
2621 PrintStr(" 0 R");
2622 PrintStr(" /P19");
2624 PrintStr(" 0 R");
2625 PrintStr(" /P20");
2627 PrintStr(" 0 R");
2628 PrintStr(" /P21");
2630 PrintStr(" 0 R");
2631 PrintStr(" /P22");
2633 PrintStr(" 0 R");
2634 PrintStr(" /P23");
2636 PrintStr(" 0 R");
2637 PrintStr(" /P24");
2639 PrintStr(" 0 R");
2640 PrintStr(" /P25");
2642 PrintStr(" 0 R@");
2643 PrintStr(">>@");
2644 EndObject();
2645
2647
2648 // P01
2650 PrintStr("<</Type/Pattern/Matrix[1 0 0 1 20 28]/PatternType 1/Resources");
2652 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 98 4]/XStep 98/YStep 4/Length 91/Filter/FlateDecode>>");
2653 PrintStr("@");
2654 fStream->write("stream",6); fNByte += 6;
2655 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);
2656 fNByte += 93;
2657 PrintStr("endstream@");
2658 EndObject();
2659
2660 // P02
2662 PrintStr("<</Type/Pattern/Matrix[0.75 0 0 0.75 20 28]/PatternType 1/Resources");
2664 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 96 4]/XStep 96/YStep 4/Length 92/Filter/FlateDecode>>@");
2665 PrintStr("@");
2666 fStream->write("stream",6); fNByte += 6;
2667 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);
2668 fNByte += 94;
2669 PrintStr("endstream@");
2670 EndObject();
2671
2672 // P03
2674 PrintStr("<</Type/Pattern/Matrix[0.5 0 0 0.5 20 28]/PatternType 1/Resources");
2676 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 96 16]/XStep 96/YStep 16/Length 93/Filter/FlateDecode>>@");
2677 PrintStr("@");
2678 fStream->write("stream",6); fNByte += 6;
2679 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);
2680 fNByte += 95;
2681 PrintStr("endstream@");
2682 EndObject();
2683
2684 // P04
2686 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2688 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 63/Filter/FlateDecode>>");
2689 PrintStr("@");
2690 fStream->write("stream",6); fNByte += 6;
2691 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);
2692 fNByte += 65;
2693 PrintStr("endstream@");
2694 EndObject();
2695
2696 // P05
2698 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2700 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
2701 PrintStr("@");
2702 fStream->write("stream",6); fNByte += 6;
2703 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);
2704 fNByte += 68;
2705 PrintStr("endstream@");
2706 EndObject();
2707
2708 // P06
2710 PrintStr("<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources");
2712 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
2713 PrintStr("@");
2714 fStream->write("stream",6); fNByte += 6;
2715 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);
2716 fNByte += 68;
2717 PrintStr("endstream@");
2718 EndObject();
2719
2720 // P07
2722 PrintStr("<</Type/Pattern/Matrix[0.03 0 0 0.03 20 28]/PatternType 1/Resources");
2724 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 68/Filter/FlateDecode>>");
2725 PrintStr("@");
2726 fStream->write("stream",6); fNByte += 6;
2727 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);
2728 fNByte += 70;
2729 PrintStr("endstream@");
2730 EndObject();
2731
2732 // P08
2734 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2736 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 139/Filter/FlateDecode>>");
2737 PrintStr("@");
2738 fStream->write("stream",6); fNByte += 6;
2739 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);
2740 fNByte += 141;
2741 PrintStr("endstream@");
2742 EndObject();
2743
2744 // P09
2746 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2748 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 108/Filter/FlateDecode>>");
2749 PrintStr("@");
2750 fStream->write("stream",6); fNByte += 6;
2751 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);
2752 fNByte += 110;
2753 PrintStr("endstream@");
2754 EndObject();
2755
2756 // P10
2758 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2760 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 93/Filter/FlateDecode>>");
2761 PrintStr("@");
2762 fStream->write("stream",6); fNByte += 6;
2763 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);
2764 fNByte += 95;
2765 PrintStr("endstream@");
2766 EndObject();
2767
2768 // P11
2770 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2772 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 164/Filter/FlateDecode>>");
2773 PrintStr("@");
2774 fStream->write("stream",6); fNByte += 6;
2775 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);
2776 fNByte += 166;
2777 PrintStr("endstream@");
2778 EndObject();
2779
2780 // P12
2782 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2784 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 226/Filter/FlateDecode>>");
2785 PrintStr("@");
2786 fStream->write("stream",6); fNByte += 6;
2787 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);
2788 fNByte += 228;
2789 PrintStr("endstream@");
2790 EndObject();
2791
2792 // P13
2794 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2796 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>");
2797 PrintStr("@");
2798 fStream->write("stream",6); fNByte += 6;
2799 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);
2800 fNByte += 71;
2801 PrintStr("endstream@");
2802 EndObject();
2803
2804 // P14
2806 PrintStr("<</Type/Pattern/Matrix[0.15 0 0 0.15 20 28]/PatternType 1/Resources");
2808 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 80/YStep 80/Length 114/Filter/FlateDecode>>");
2809 PrintStr("@");
2810 fStream->write("stream",6); fNByte += 6;
2811 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);
2812 fNByte += 116;
2813 PrintStr("endstream@");
2814 EndObject();
2815
2816 // P15
2818 PrintStr("<</Type/Pattern/Matrix[0.102 0 0 0.102 20 28]/PatternType 1/Resources");
2820 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 60 60]/XStep 60/YStep 60/Length 218/Filter/FlateDecode>>");
2821 PrintStr("@");
2822 fStream->write("stream",6); fNByte += 6;
2823 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);
2824 fNByte += 220;
2825 PrintStr("endstream@");
2826 EndObject();
2827
2828 // P16
2830 PrintStr("<</Type/Pattern/Matrix[0.1 0 0 0.05 20 28]/PatternType 1/Resources");
2832 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 123/Filter/FlateDecode>>");
2833 PrintStr("@");
2834 fStream->write("stream",6); fNByte += 6;
2835 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);
2836 fNByte += 125;
2837 PrintStr("endstream@");
2838 EndObject();
2839
2840 // P17
2842 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2844 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 66/Filter/FlateDecode>>");
2845 PrintStr("@");
2846 fStream->write("stream",6); fNByte += 6;
2847 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);
2848 fNByte += 68;
2849 PrintStr("endstream@");
2850 EndObject();
2851
2852 // P18
2854 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2856 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 69/Filter/FlateDecode>>");
2857 PrintStr("@");
2858 fStream->write("stream",6); fNByte += 6;
2859 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);
2860 fNByte += 71;
2861 PrintStr("endstream@");
2862 EndObject();
2863
2864 // P19
2866 PrintStr("<</Type/Pattern/Matrix[0.117 0 0 0.117 20 28]/PatternType 1/Resources");
2868 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 149/Filter/FlateDecode>>");
2869 PrintStr("@");
2870 fStream->write("stream",6); fNByte += 6;
2871 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);
2872 fNByte += 151;
2873 PrintStr("endstream@");
2874 EndObject();
2875
2876 // P20
2878 PrintStr("<</Type/Pattern/Matrix[0.05 0 0 0.1 20 28]/PatternType 1/Resources");
2880 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 122/Filter/FlateDecode>>");
2881 PrintStr("@");
2882 fStream->write("stream",6); fNByte += 6;
2883 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);
2884 fNByte += 124;
2885 PrintStr("endstream@");
2886 EndObject();
2887
2888 // P21
2890 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2892 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 117/Filter/FlateDecode>>");
2893 PrintStr("@");
2894 fStream->write("stream",6); fNByte += 6;
2895 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);
2896 fNByte += 119;
2897 PrintStr("endstream@");
2898 EndObject();
2899
2900 // P22
2902 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2904 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 118/Filter/FlateDecode>>");
2905 PrintStr("@");
2906 fStream->write("stream",6); fNByte += 6;
2907 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);
2908 fNByte += 120;
2909 PrintStr("endstream@");
2910 EndObject();
2911
2912 // P23
2914 PrintStr("<</Type/Pattern/Matrix[0.06 0 0 0.06 20 28]/PatternType 1/Resources");
2916 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 169/Filter/FlateDecode>>");
2917 PrintStr("@");
2918 fStream->write("stream",6); fNByte += 6;
2919 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);
2920 fNByte += 171;
2921 PrintStr("endstream@");
2922 EndObject();
2923
2924 // P24
2926 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2928 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 100 100]/XStep 100/YStep 100/Length 280/Filter/FlateDecode>>");
2929 PrintStr("@");
2930 fStream->write("stream",6); fNByte += 6;
2931 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);
2932 fNByte += 282;
2933 PrintStr("endstream@");
2934 EndObject();
2935
2936 // P25
2938 PrintStr("<</Type/Pattern/Matrix[0.125 0 0 0.125 20 28]/PatternType 1/Resources");
2940 PrintStr(" 0 R/PaintType 2/TilingType 1/BBox[0 0 101 101]/XStep 100/YStep 100/Length 54/Filter/FlateDecode>>");
2941 PrintStr("@");
2942 fStream->write("stream",6); fNByte += 6;
2943 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);
2944 fNByte += 56;
2945 PrintStr("endstream@");
2946 EndObject();
2947}
2948
2949////////////////////////////////////////////////////////////////////////////////
2950/// Write and Accumulate (if `acc` is true) the Current Transformation Matrix (CTM)
2951///
2952/// The Current Transformation Matrix (CTM, not CMT) is defined by the six parameters
2953/// `a` `b` `c` `d` `e` `f` passed to the PDF `cm` operator (see the PDF Reference Guide
2954/// page 156 [1] for details).
2955///
2956/// To correctly define the \Rect fields of the Annots created for each #url, one must keep
2957/// track of the current CTM and apply it to the last transformation matrix used for the
2958/// text (for example rotations).
2959///
2960/// [1] https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.4.pdf
2961
2963{
2964 WriteReal(a);
2965 WriteReal(b);
2966 WriteReal(c);
2967 WriteReal(d);
2968 WriteReal(e);
2969 WriteReal(f);
2970 PrintStr(" cm");
2971
2972 // accumulate in CTM ---
2973 if (acc) {
2974 Double_t na, nb, nc, nd, ne, nf;
2975 na = fA * a + fC * b;
2976 nb = fB * a + fD * b;
2977 nc = fA * c + fC * d;
2978 nd = fB * c + fD * d;
2979 ne = fA * e + fC * f + fE;
2980 nf = fB * e + fD * f + fF;
2981 fA = na;
2982 fB = nb;
2983 fC = nc;
2984 fD = nd;
2985 fE = ne;
2986 fF = nf;
2987 }
2988}
2989
2990////////////////////////////////////////////////////////////////////////////////
2991/// Write the annotation objects containing the URLs
2992
2994{
2995 int i;
2997 PrintStr("@");
2998 PrintStr("[");
2999 for (i = 0; i < fNbUrl - 1; i++) {
3000 WriteInteger(fCurrentPage + 5 + i);
3001 PrintStr(" 0 R");
3002 }
3003 PrintStr(" ]@");
3004 EndObject();
3005 for (i = 0; i < fNbUrl - 1; i++) {
3006 NewObject(fCurrentPage + 5 + i);
3007 PrintStr("<<@");
3008 PrintStr("/Type /Annot@");
3009 PrintStr("/Subtype /Link@");
3010 PrintStr("/Rect [");
3012 WriteReal(fRectY1[i]);
3013 WriteReal(fRectX2[i]);
3014 WriteReal(fRectY2[i]);
3015 PrintStr("]@");
3016 PrintStr("/Border [0 0 0]@");
3017 PrintStr("/A << /S /URI /URI (");
3018 PrintStr(fUrls[i].c_str());
3019 PrintStr(") >>@");
3020 PrintStr(">>@");
3021 EndObject();
3022 }
3023 if (!fUrls.empty())
3024 fUrls.clear();
3025 if (!fRectX1.empty())
3026 fRectX1.clear();
3027 if (!fRectY1.empty())
3028 fRectY1.clear();
3029 if (!fRectX2.empty())
3030 fRectX2.clear();
3031 if (!fRectY2.empty())
3032 fRectY2.clear();
3033}
3034
3035////////////////////////////////////////////////////////////////////////////////
3036/// Compute the Rect for url
3037
3040{
3041 double W = 0.52 * fontsize * strlen(chars);
3042 double ascent = 0.72 * fontsize;
3043 double descent = 0.22 * fontsize;
3044
3045 int ax = fTextAlign / 10;
3046 int ay = fTextAlign % 10;
3047 double xShift = 0;
3048 double yShift = 0;
3049 if (ax == 2)
3050 xShift = -W / 2.0;
3051 if (ax == 3)
3052 xShift = -W;
3053 if (ay == 2)
3054 yShift = -(ascent - descent) / 2.0;
3055 if (ay == 3)
3056 yShift = -ascent;
3057 double x1 = xShift;
3058 double x2 = xShift + W;
3059 double y1 = -descent + yShift;
3060 double y2 = ascent + yShift;
3061
3062 Double_t A, B, C, D, E, F;
3063 A = fA * a + fC * b;
3064 B = fB * a + fD * b;
3065 C = fA * c + fC * d;
3066 D = fB * c + fD * d;
3067 E = fA * e + fC * f + fE;
3068 F = fB * e + fD * f + fF;
3069
3070 double bx1 = A * x1 + C * y1 + E;
3071 double by1 = B * x1 + D * y1 + F;
3072 double bx2 = A * x2 + C * y1 + E;
3073 double by2 = B * x2 + D * y1 + F;
3074 double bx3 = A * x2 + C * y2 + E;
3075 double by3 = B * x2 + D * y2 + F;
3076 double bx4 = A * x1 + C * y2 + E;
3077 double by4 = B * x1 + D * y2 + F;
3078
3079 double xmin = bx1;
3080 double xmax = bx1;
3081 double ymin = by1;
3082 double ymax = by1;
3083
3084 if (bx2 < xmin)
3085 xmin = bx2;
3086 if (bx3 < xmin)
3087 xmin = bx3;
3088 if (bx4 < xmin)
3089 xmin = bx4;
3090 if (bx2 > xmax)
3091 xmax = bx2;
3092 if (bx3 > xmax)
3093 xmax = bx3;
3094 if (bx4 > xmax)
3095 xmax = bx4;
3096 if (by2 < ymin)
3097 ymin = by2;
3098 if (by3 < ymin)
3099 ymin = by3;
3100 if (by4 < ymin)
3101 ymin = by4;
3102 if (by2 > ymax)
3103 ymax = by2;
3104 if (by3 > ymax)
3105 ymax = by3;
3106 if (by4 > ymax)
3107 ymax = by4;
3108
3109 fRectX1.push_back(xmin);
3110 fRectY1.push_back(ymin);
3111 fRectX2.push_back(xmax);
3112 fRectY2.push_back(ymax);
3113}
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
short Style_t
Style number (short)
Definition RtypesCore.h:96
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
const Float_t kScale
Definition TASImage.cxx:135
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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 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 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
float xmin
float ymin
float xmax
float ymax
const Int_t kObjFont
Definition TPDF.cxx:86
const Int_t kObjPatternList
Definition TPDF.cxx:89
const Int_t kObjInfo
Definition TPDF.cxx:81
const Int_t kObjRoot
Definition TPDF.cxx:80
const Float_t kScale
Definition TPDF.cxx:77
const Int_t kObjColorSpace
Definition TPDF.cxx:87
const Int_t kNumberOfFonts
Definition TPDF.cxx:95
const Int_t kObjPattern
Definition TPDF.cxx:91
const Int_t kObjContents
Definition TPDF.cxx:85
const Int_t kObjFirstPage
Definition TPDF.cxx:92
const Int_t kObjPages
Definition TPDF.cxx:83
const Int_t kObjPageResources
Definition TPDF.cxx:84
const Int_t kObjPatternResourses
Definition TPDF.cxx:88
const Int_t kObjTransList
Definition TPDF.cxx:90
const Int_t kObjOutlines
Definition TPDF.cxx:82
#define gROOT
Definition TROOT.h:414
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2495
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:84
#define gPad
#define snprintf
Definition civetweb.c:1579
Style_t fFillStyle
Fill area style.
Definition TAttFill.h:25
Color_t fFillColor
Fill area color.
Definition TAttFill.h:24
Width_t fLineWidth
Line width.
Definition TAttLine.h:26
Style_t fLineStyle
Line style.
Definition TAttLine.h:25
Color_t fLineColor
Line color.
Definition TAttLine.h:24
Color_t fMarkerColor
Marker color.
Definition TAttMarker.h:24
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Size_t fMarkerSize
Marker size.
Definition TAttMarker.h:26
Style_t fMarkerStyle
Marker style.
Definition TAttMarker.h:25
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
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:50
Font_t fTextFont
Text font.
Definition TAttText.h:28
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:51
Short_t fTextAlign
Text alignment.
Definition TAttText.h:26
Float_t fTextSize
Text size.
Definition TAttText.h:25
The color creation and management class.
Definition TColor.h:22
Float_t GetRed() const
Definition TColor.h:61
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1926
Float_t GetAlpha() const
Definition TColor.h:67
Float_t GetBlue() const
Definition TColor.h:63
Float_t GetGreen() const
Definition TColor.h:62
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
Int_t GetMonth() const
Definition TDatime.h:66
Int_t GetDay() const
Definition TDatime.h:67
Int_t GetHour() const
Definition TDatime.h:69
Int_t GetSecond() const
Definition TDatime.h:71
Int_t GetYear() const
Definition TDatime.h:65
Int_t GetMinute() const
Definition TDatime.h:70
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition TDatime.cxx:181
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
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
Definition TPDF.cxx:2150
void Off()
Deactivate an already open PDF file.
Definition TPDF.cxx:1692
std::vector< int > fPageObjects
Page object numbers.
Definition TPDF.h:51
Int_t fCurrentPage
Object number of the current page.
Definition TPDF.h:50
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Definition TPDF.cxx:2182
Int_t fType
Workstation type used to know if the PDF is open.
Definition TPDF.h:41
void SetColor(Int_t color=1)
Set color with its color index.
Definition TPDF.cxx:1956
Double_t YtoPDF(Double_t y)
Convert Y from world coordinate to PDF.
Definition TPDF.cxx:2476
void Open(const char *filename, Int_t type=-111) override
Open a PDF file.
Definition TPDF.cxx:1716
void Close(Option_t *opt="") override
Close a PDF file.
Definition TPDF.cxx:215
TPDF()
Default PDF constructor.
Definition TPDF.cxx:104
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition TPDF.cxx:1926
Double_t fD
"d" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:66
void LineTo(Double_t x, Double_t y)
Draw a line to a new position.
Definition TPDF.cxx:1452
Bool_t fUrl
True when the text has an URL.
Definition TPDF.h:61
void SetLineCap(Int_t linecap=0)
Set the value of the global parameter TPDF::fgLineCap.
Definition TPDF.cxx:2135
Double_t XtoPDF(Double_t x)
Convert X from world coordinate to PDF.
Definition TPDF.cxx:2467
void WriteReal(Float_t r, Bool_t space=kTRUE) override
Write a Real number to the file.
Definition TPDF.cxx:2535
Double_t fB
"b" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:64
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TPDF::fgLineJoin.
Definition TPDF.cxx:2111
Double_t CMtoPDF(Double_t u)
Definition TPDF.h:83
void CellArrayEnd() override
End the Cell Array painting.
Definition TPDF.cxx:207
Int_t fObjPosSize
Real size of fObjPos.
Definition TPDF.h:47
void NewPage() override
Start a new PDF page.
Definition TPDF.cxx:1498
Float_t fAlpha
Per cent of transparency.
Definition TPDF.h:37
Float_t fLineScale
Line width scale factor.
Definition TPDF.h:45
void SetFillColor(Color_t cindex=1) override
Set color index for fill areas.
Definition TPDF.cxx:2029
Float_t fGreen
Per cent of green.
Definition TPDF.h:35
Int_t fNbUrl
Number of URLs in the current page.
Definition TPDF.h:62
Int_t fPageOrientation
Page orientation (Portrait, Landscape)
Definition TPDF.h:43
void On()
Activate an already open PDF file.
Definition TPDF.cxx:1700
Bool_t fObjectIsOpen
True if an object is opened.
Definition TPDF.h:57
Int_t fStartStream
Stream start.
Definition TPDF.h:44
Double_t fE
"e" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:67
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Definition TPDF.cxx:384
void SetLineColor(Color_t cindex=1) override
Set color index for lines.
Definition TPDF.cxx:2089
void ComputeRect(const char *chars, Double_t fontsize, Double_t a, Double_t b, Double_t c, Double_t d, Double_t e, Double_t f)
Compute the Rect for url.
Definition TPDF.cxx:3038
void FontEncode()
Font encoding.
Definition TPDF.cxx:1420
Bool_t fCompress
True when fBuffer must be compressed.
Definition TPDF.h:59
static Int_t fgLineCap
Appearance of line caps.
Definition TPDF.h:71
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
Definition TPDF.cxx:2417
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Draw a PolyLine.
Definition TPDF.cxx:1242
Float_t fYsize
Page size along Y.
Definition TPDF.h:40
Double_t UtoPDF(Double_t u)
Convert U from NDC coordinate to PDF.
Definition TPDF.cxx:2449
std::vector< std::string > fUrls
URLs.
Definition TPDF.h:52
std::vector< float > fRectY1
y1 /Rect coordinates for url annots
Definition TPDF.h:54
void SetAlpha(Float_t alpha=1.)
Set the alpha channel value.
Definition TPDF.cxx:1936
Float_t fRed
Per cent of red.
Definition TPDF.h:34
std::vector< float > fRectY2
y2 /Rect coordinates for url annots
Definition TPDF.h:56
Int_t fPageFormat
Page format (A4, Letter etc ...)
Definition TPDF.h:42
Bool_t fRange
True when a range has been defined.
Definition TPDF.h:60
std::vector< float > fRectX1
x1 /Rect coordinates for url annots
Definition TPDF.h:53
void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override
Draw markers at the n WC points xw, yw.
Definition TPDF.cxx:614
std::vector< float > fRectX2
x2 /Rect coordinates for url annots
Definition TPDF.h:55
Float_t fBlue
Per cent of blue.
Definition TPDF.h:36
std::vector< float > fAlphas
List of alpha values used.
Definition TPDF.h:38
void MoveTo(Double_t x, Double_t y)
Move to a new position.
Definition TPDF.cxx:1462
void SetLineScale(Float_t scale=1)
Definition TPDF.h:117
Int_t fNbObj
Number of objects.
Definition TPDF.h:48
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.
Definition TPDF.cxx:450
Double_t fC
"c" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:65
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array.
Definition TPDF.cxx:199
~TPDF() override
Default PDF destructor.
Definition TPDF.cxx:180
void WriteUrlObjects()
Write the annotation objects containing the URLs.
Definition TPDF.cxx:2993
Double_t fA
"a" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:63
void EndObject()
Close the current opened object.
Definition TPDF.cxx:1408
void PrintStr(const char *string="") override
Output the string str in the output buffer.
Definition TPDF.cxx:1885
Int_t fNbPage
Number of pages.
Definition TPDF.h:49
void SetFillPatterns(Int_t ipat, Int_t color)
Set the fill patterns (1 to 25) for fill areas.
Definition TPDF.cxx:2037
void WriteCM(Double_t a, Double_t b, Double_t c, Double_t d, Double_t e, Double_t f, Bool_t acc=kTRUE)
Write and Accumulate (if acc is true) the Current Transformation Matrix (CTM)
Definition TPDF.cxx:2962
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Definition TPDF.cxx:2190
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
Definition TPDF.cxx:568
Float_t fXsize
Page size along X.
Definition TPDF.h:39
void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2) override
Begin the Cell Array painting.
Definition TPDF.cxx:190
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:490
void SetLineWidth(Width_t linewidth=1) override
Change the line width.
Definition TPDF.cxx:2169
Double_t VtoPDF(Double_t v)
Convert V from NDC coordinate to PDF.
Definition TPDF.cxx:2458
Bool_t fPageNotEmpty
True if the current page is not empty.
Definition TPDF.h:58
void NewObject(Int_t n)
Create a new object in the PDF file.
Definition TPDF.cxx:1472
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Definition TPDF.cxx:514
void Text(Double_t x, Double_t y, const char *string) override
Draw text.
Definition TPDF.cxx:2202
void PatternEncode()
Patterns encoding.
Definition TPDF.cxx:2551
Int_t * fObjPos
Objects position.
Definition TPDF.h:46
Double_t fF
"f" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:68
void WriteCompressedBuffer()
Write the buffer in a compressed way.
Definition TPDF.cxx:2485
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition TPDF.cxx:2429
static Int_t fgLineJoin
Appearance of joining lines.
Definition TPDF.h:70
void PrintFast(Int_t nch, const char *string="") override
Fast version of Print.
Definition TPDF.cxx:1907
2-D graphics point (world coordinates).
Definition TPoints.h:19
static char * ReAllocChar(char *vp, size_t size, size_t oldsize)
Reallocate (i.e.
Definition TStorage.cxx:227
Basic string class.
Definition TString.h:138
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
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
Float_t GetLineScalePS() const
Definition TStyle.h:291
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:590
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:619
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:30
Int_t fSizBuffer
Definition TVirtualPS.h:39
Int_t fLenBuffer
Definition TVirtualPS.h:38
virtual void WriteInteger(Int_t i, Bool_t space=kTRUE)
Write one Integer to the file.
virtual void PrintStr(const char *string="")
Output the string str in the output buffer.
virtual void PrintFast(Int_t nch, const char *string="")
Fast version of Print.
std::ofstream * fStream
Definition TVirtualPS.h:41
char * fBuffer
Definition TVirtualPS.h:42
Int_t fNByte
Definition TVirtualPS.h:37
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
#define F(x, y, z)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:691
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:732
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:605
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:599
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
TMarker m
Definition textangle.C:8