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