Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPDF.h
Go to the documentation of this file.
1// @(#)root/postscript:$Id: TPDF.h,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#ifndef ROOT_TPDF
13#define ROOT_TPDF
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TPDF //
19// //
20// PDF driver. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TVirtualPS.h"
25#include <vector>
26#include <string>
27
28
29class TPoints;
30
31class TPDF : public TVirtualPS {
32
33protected:
34 Float_t fRed = 0.; ///< Per cent of red
35 Float_t fGreen = 0.; ///< Per cent of green
36 Float_t fBlue = 0.; ///< Per cent of blue
37 Float_t fAlpha = 1.; ///< Per cent of transparency
38 std::vector<float> fAlphas; ///< List of alpha values used
39 Float_t fXsize = 0.; ///< Page size along X
40 Float_t fYsize = 0.; ///< Page size along Y
41 Int_t fType = 0; ///< Workstation type used to know if the PDF is open
42 Int_t fPageFormat = 0; ///< Page format (A4, Letter etc ...)
43 Int_t fPageOrientation = 0; ///< Page orientation (Portrait, Landscape)
44 Int_t fStartStream = 0; ///< Stream start
45 Float_t fLineScale = 0.; ///< Line width scale factor
46 std::vector<Int_t> fObjPos; ///< Objects position
47 Int_t fNbPage = 0; ///< Number of pages
48 Int_t fCurrentPage = 0; ///< Object number of the current page
49 std::vector<int> fPageObjects; ///< Page object numbers
50 std::vector<std::string> fUrls; ///< URLs
51 std::vector<float> fRectX1; ///< x1 /Rect coordinates for url annots
52 std::vector<float> fRectY1; ///< y1 /Rect coordinates for url annots
53 std::vector<float> fRectX2; ///< x2 /Rect coordinates for url annots
54 std::vector<float> fRectY2; ///< y2 /Rect coordinates for url annots
55 Bool_t fObjectIsOpen = kFALSE; ///< True if an object is opened
56 Bool_t fPageNotEmpty = kFALSE; ///< True if the current page is not empty
57 Bool_t fCompress = kFALSE; ///< True when fBuffer must be compressed
58 Bool_t fRange = kFALSE; ///< True when a range has been defined
59 Bool_t fUrl = kFALSE; ///< True when the text has an URL
60 Int_t fNbUrl = 1; ///< Number of URLs in the current page
61 Double_t fA = 1.; ///< "a" value of the Current Transformation Matrix (CTM)
62 Double_t fB = 0.; ///< "b" value of the Current Transformation Matrix (CTM)
63 Double_t fC = 0.; ///< "c" value of the Current Transformation Matrix (CTM)
64 Double_t fD = 1.; ///< "d" value of the Current Transformation Matrix (CTM)
65 Double_t fE = 0.; ///< "e" value of the Current Transformation Matrix (CTM)
66 Double_t fF = 0.; ///< "f" value of the Current Transformation Matrix (CTM)
67
68 // Transient scratch state for the in-flight Cell Array: only meaningful
69 // between a CellArrayBegin and the matching CellArrayEnd, never streamed,
70 // so every member below is marked transient (///<!).
71 Int_t fCellArrayW = 0; ///<! Cell array width in cells
72 Int_t fCellArrayH = 0; ///<! Cell array height in cells
73 Double_t fCellArrayXpdf = 0.; ///<! PDF x of the image's left edge
74 Double_t fCellArrayYpdfBot = 0.; ///<! PDF y of the image's bottom edge
75 Double_t fCellArrayWpdf = 0.; ///<! PDF width of the image
76 Double_t fCellArrayHpdf = 0.; ///<! PDF height of the image
77 std::vector<unsigned char> fCellArrayRGB; ///<! Pixel buffer (3 bytes per pixel, top-to-bottom)
78
79 /// A bitmap embedded as a PDF image XObject. Buffered until Close() because
80 /// a PDF object cannot be opened while a page content stream is still being
81 /// written; the page stream only carries a placement matrix and a "/ImN Do".
82 struct PDFImage {
83 Int_t fW = 0; ///< Width in pixels
84 Int_t fH = 0; ///< Height in pixels
85 Bool_t fFlate = kTRUE; ///< True if fData is Flate-compressed
86 std::vector<unsigned char> fData; ///< 8-bit DeviceRGB samples (raw or Flate)
87 };
88 std::vector<PDFImage> fImageObjects; ///<! Embedded image XObjects, flushed in Close()
89
90 static Int_t fgLineJoin; ///< Appearance of joining lines
91 static Int_t fgLineCap; ///< Appearance of line caps
92
94
95public:
96 TPDF();
97 TPDF(const char *filename, Int_t type=-111);
98 ~TPDF() override;
99
101 void CellArrayFill(Int_t r, Int_t g, Int_t b) override;
102 void CellArrayEnd() override;
103 void Close(Option_t *opt = "") override;
104 Double_t CMtoPDF(Double_t u) { return Int_t(0.5 + 72 * u / 2.54); }
108 Int_t mode, Int_t border, Int_t dark, Int_t light) override;
111 void DrawPolyLine(Int_t n, TPoints *xy);
113 void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override;
114 void DrawPolyMarker(Int_t n, Double_t *x, Double_t *y) override;
115 void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override;
116 void DrawPS(Int_t n, Double_t *xw, Double_t *yw) override;
117 void LineTo(Double_t x, Double_t y);
118 void MoveTo(Double_t x, Double_t y);
119 void EndObject();
120 void FontEncode();
121 void NewObject(Int_t n);
122 void NewPage() override;
123 void Off();
124 void On();
125 void Open(const char *filename, Int_t type = -111) override;
126 void PatternEncode();
127 void PrintFast(Int_t nch, const char *string = "") override;
128 void PrintStr(const char *string = "") override;
130 void SetAlpha(Float_t alpha = 1.);
131 void SetColor(Int_t color = 1);
132 void SetColor(Float_t r, Float_t g, Float_t b) override;
133 void SetFillColor( Color_t cindex = 1) override;
134 void SetFillPatterns(Int_t ipat, Int_t color);
135 void SetLineColor( Color_t cindex = 1) override;
136 void SetLineJoin(Int_t linejoin = 0);
137 void SetLineCap(Int_t linecap = 0);
139 void SetLineStyle(Style_t linestyle = 1) override;
140 void SetLineWidth(Width_t linewidth = 1) override;
141 void SetMarkerColor(Color_t cindex = 1) override;
142 void SetTextColor(Color_t cindex = 1) override;
143 void Text(Double_t x, Double_t y, const char *string) override;
144 void Text(Double_t, Double_t, const wchar_t *) override;
145 void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override;
146 void TextNDC(Double_t u, Double_t v, const char *string);
147 void TextNDC(Double_t, Double_t, const wchar_t *);
150 void WriteReal(Float_t r, Bool_t space = kTRUE) override;
151 void WriteUrlObjects();
156
157 ClassDefOverride(TPDF, 1); // PDF driver
158};
159
160#endif
#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 e(i)
Definition RSha256.hxx:103
short Style_t
Style number (short)
Definition RtypesCore.h:96
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
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
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint DrawPolyMarker
Option_t Option_t SetFillColor
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 type
Option_t Option_t TPoint TPoint const char y1
Interface to PDF.
Definition TPDF.h:31
void SetLineStyle(Style_t linestyle=1) override
Change the line style.
Definition TPDF.cxx:2244
void Off()
Deactivate an already open PDF file.
Definition TPDF.cxx:1786
std::vector< int > fPageObjects
Page object numbers.
Definition TPDF.h:49
Int_t fCurrentPage
Object number of the current page.
Definition TPDF.h:48
void SetMarkerColor(Color_t cindex=1) override
Set color index for markers.
Definition TPDF.cxx:2276
Double_t fCellArrayHpdf
! PDF height of the image
Definition TPDF.h:76
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:2050
Double_t YtoPDF(Double_t y)
Convert Y from world coordinate to PDF.
Definition TPDF.cxx:2570
void Open(const char *filename, Int_t type=-111) override
Open a PDF file.
Definition TPDF.cxx:1810
void Close(Option_t *opt="") override
Close a PDF file.
Definition TPDF.cxx:264
std::vector< Int_t > fObjPos
Objects position.
Definition TPDF.h:46
TPDF()
Default PDF constructor.
Definition TPDF.cxx:105
void Range(Float_t xrange, Float_t yrange)
Set the range for the paper in centimetres.
Definition TPDF.cxx:2020
Double_t fD
"d" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:64
void LineTo(Double_t x, Double_t y)
Draw a line to a new position.
Definition TPDF.cxx:1553
Bool_t fUrl
True when the text has an URL.
Definition TPDF.h:59
void SetLineCap(Int_t linecap=0)
Set the value of the global parameter TPDF::fgLineCap.
Definition TPDF.cxx:2229
Double_t XtoPDF(Double_t x)
Convert X from world coordinate to PDF.
Definition TPDF.cxx:2561
void WriteReal(Float_t r, Bool_t space=kTRUE) override
Write a Real number to the file.
Definition TPDF.cxx:2629
Double_t fB
"b" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:62
void SetLineJoin(Int_t linejoin=0)
Set the value of the global parameter TPDF::fgLineJoin.
Definition TPDF.cxx:2205
Double_t CMtoPDF(Double_t u)
Definition TPDF.h:104
void CellArrayEnd() override
End the Cell Array painting.
Definition TPDF.cxx:201
Double_t fCellArrayWpdf
! PDF width of the image
Definition TPDF.h:75
void NewPage() override
Start a new PDF page.
Definition TPDF.cxx:1592
Float_t fAlpha
Per cent of transparency.
Definition TPDF.h:37
Float_t fLineScale
Line width scale factor.
Definition TPDF.h:45
Float_t fGreen
Per cent of green.
Definition TPDF.h:35
Int_t fNbUrl
Number of URLs in the current page.
Definition TPDF.h:60
Int_t fPageOrientation
Page orientation (Portrait, Landscape)
Definition TPDF.h:43
void On()
Activate an already open PDF file.
Definition TPDF.cxx:1794
Bool_t fObjectIsOpen
True if an object is opened.
Definition TPDF.h:55
Int_t fStartStream
Stream start.
Definition TPDF.h:44
Double_t fE
"e" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:65
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Draw a Box.
Definition TPDF.cxx:485
std::vector< unsigned char > fCellArrayRGB
! Pixel buffer (3 bytes per pixel, top-to-bottom)
Definition TPDF.h:77
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:3132
void FontEncode()
Font encoding.
Definition TPDF.cxx:1521
Bool_t fCompress
True when fBuffer must be compressed.
Definition TPDF.h:57
static Int_t fgLineCap
Appearance of line caps.
Definition TPDF.h:91
void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override
Draw text with URL.
Definition TPDF.cxx:2511
void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override
Draw a PolyLine.
Definition TPDF.cxx:1343
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:2543
std::vector< std::string > fUrls
URLs.
Definition TPDF.h:50
std::vector< float > fRectY1
y1 /Rect coordinates for url annots
Definition TPDF.h:52
void SetAlpha(Float_t alpha=1.)
Set the alpha channel value.
Definition TPDF.cxx:2030
Float_t fRed
Per cent of red.
Definition TPDF.h:34
std::vector< float > fRectY2
y2 /Rect coordinates for url annots
Definition TPDF.h:54
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:58
std::vector< float > fRectX1
x1 /Rect coordinates for url annots
Definition TPDF.h:51
std::vector< float > fRectX2
x2 /Rect coordinates for url annots
Definition TPDF.h:53
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:1563
void SetLineScale(Float_t scale=1)
Definition TPDF.h:138
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:551
Double_t fC
"c" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:63
void CellArrayFill(Int_t r, Int_t g, Int_t b) override
Paint the Cell Array: append one RGB pixel to the in-flight buffer.
Definition TPDF.cxx:175
~TPDF() override
Default PDF destructor.
Definition TPDF.cxx:131
void WriteUrlObjects()
Write the annotation objects containing the URLs.
Definition TPDF.cxx:3087
void EnsureBufferSize(Int_t required_size)
Ensure that required space in the buffer is available.
Definition TPDF.cxx:1974
Double_t fA
"a" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:61
void EndObject()
Close the current opened object.
Definition TPDF.cxx:1509
Int_t fCellArrayW
! Cell array width in cells
Definition TPDF.h:71
void PrintStr(const char *string="") override
Output the string str in the output buffer.
Definition TPDF.cxx:1987
Int_t fNbPage
Number of pages.
Definition TPDF.h:47
void SetFillPatterns(Int_t ipat, Int_t color)
Set the fill patterns (1 to 25) for fill areas.
Definition TPDF.cxx:2131
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:3056
void SetTextColor(Color_t cindex=1) override
Set color index for text.
Definition TPDF.cxx:2284
void DrawPolyLineNDC(Int_t n, TPoints *uv)
Draw a PolyLine in NDC space.
Definition TPDF.cxx:669
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:146
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:591
Double_t VtoPDF(Double_t v)
Convert V from NDC coordinate to PDF.
Definition TPDF.cxx:2552
std::vector< PDFImage > fImageObjects
! Embedded image XObjects, flushed in Close()
Definition TPDF.h:88
Bool_t fPageNotEmpty
True if the current page is not empty.
Definition TPDF.h:56
void NewObject(Int_t n)
Create a new object in the PDF file.
Definition TPDF.cxx:1573
void DrawPolyLine(Int_t n, TPoints *xy)
Draw a PolyLine.
Definition TPDF.cxx:615
Double_t fCellArrayXpdf
! PDF x of the image's left edge
Definition TPDF.h:73
void Text(Double_t x, Double_t y, const char *string) override
Draw text.
Definition TPDF.cxx:2296
void PatternEncode()
Patterns encoding.
Definition TPDF.cxx:2645
Double_t fCellArrayYpdfBot
! PDF y of the image's bottom edge
Definition TPDF.h:74
Double_t fF
"f" value of the Current Transformation Matrix (CTM)
Definition TPDF.h:66
Int_t fCellArrayH
! Cell array height in cells
Definition TPDF.h:72
void WriteCompressedBuffer()
Write the buffer in a compressed way.
Definition TPDF.cxx:2579
void TextNDC(Double_t u, Double_t v, const char *string)
Write a string of characters in NDC.
Definition TPDF.cxx:2523
static Int_t fgLineJoin
Appearance of joining lines.
Definition TPDF.h:90
void PrintFast(Int_t nch, const char *string="") override
Fast version of Print.
Definition TPDF.cxx:2005
2-D graphics point (world coordinates).
Definition TPoints.h:19
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:30
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 H(x, y, z)
A bitmap embedded as a PDF image XObject.
Definition TPDF.h:82
Int_t fW
Width in pixels.
Definition TPDF.h:83
Bool_t fFlate
True if fData is Flate-compressed.
Definition TPDF.h:85
std::vector< unsigned char > fData
8-bit DeviceRGB samples (raw or Flate)
Definition TPDF.h:86
Int_t fH
Height in pixels.
Definition TPDF.h:84