Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:26:17

0001 // @(#)root/postscript:$Id: TPDF.h,v 1.0
0002 // Author: Olivier Couet
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TPDF
0013 #define ROOT_TPDF
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TPDF                                                                 //
0019 //                                                                      //
0020 // PDF driver.                                                          //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TVirtualPS.h"
0025 #include <vector>
0026 #include <string>
0027 
0028 
0029 class TPoints;
0030 
0031 class TPDF : public TVirtualPS {
0032 
0033 protected:
0034    Float_t fRed;                   ///< Per cent of red
0035    Float_t fGreen;                 ///< Per cent of green
0036    Float_t fBlue;                  ///< Per cent of blue
0037    Float_t fAlpha;                 ///< Per cent of transparency
0038    std::vector<float> fAlphas;     ///< List of alpha values used
0039    Float_t fXsize;                 ///< Page size along X
0040    Float_t fYsize;                 ///< Page size along Y
0041    Int_t fType;                    ///< Workstation type used to know if the PDF is open
0042    Int_t fPageFormat;              ///< Page format (A4, Letter etc ...)
0043    Int_t fPageOrientation;         ///< Page orientation (Portrait, Landscape)
0044    Int_t fStartStream;             ///< Stream start
0045    Float_t fLineScale;             ///< Line width scale factor
0046    Int_t *fObjPos{nullptr};        ///< Objects position
0047    Int_t fObjPosSize{0};           ///< Real size of fObjPos
0048    Int_t fNbObj{0};                ///< Number of objects
0049    Int_t fNbPage;                  ///< Number of pages
0050    Int_t fCurrentPage;             ///< Object number of the current page
0051    std::vector<int> fPageObjects;  ///< Page object numbers
0052    std::vector<std::string> fUrls; ///< URLs
0053    std::vector<float> fRectX1;     ///< x1 /Rect coordinates for url annots
0054    std::vector<float> fRectY1;     ///< y1 /Rect coordinates for url annots
0055    std::vector<float> fRectX2;     ///< x2 /Rect coordinates for url annots
0056    std::vector<float> fRectY2;     ///< y2 /Rect coordinates for url annots
0057    Bool_t fObjectIsOpen;           ///< True if an object is opened
0058    Bool_t fPageNotEmpty;           ///< True if the current page is not empty
0059    Bool_t fCompress;               ///< True when fBuffer must be compressed
0060    Bool_t fRange;                  ///< True when a range has been defined
0061    Bool_t fUrl;                    ///< True when the text has an URL
0062    Int_t fNbUrl;                   ///< Number of URLs in the current page
0063    Double_t fA;                    ///< "a" value of the Current Transformation Matrix (CTM)
0064    Double_t fB;                    ///< "b" value of the Current Transformation Matrix (CTM)
0065    Double_t fC;                    ///< "c" value of the Current Transformation Matrix (CTM)
0066    Double_t fD;                    ///< "d" value of the Current Transformation Matrix (CTM)
0067    Double_t fE;                    ///< "e" value of the Current Transformation Matrix (CTM)
0068    Double_t fF;                    ///< "f" value of the Current Transformation Matrix (CTM)
0069 
0070    static Int_t fgLineJoin; ///< Appearance of joining lines
0071    static Int_t fgLineCap;  ///< Appearance of line caps
0072 
0073 
0074 public:
0075    TPDF();
0076    TPDF(const char *filename, Int_t type=-111);
0077    ~TPDF() override;
0078 
0079    void CellArrayBegin(Int_t W, Int_t H, Double_t x1, Double_t x2, Double_t y1, Double_t y2) override;
0080    void CellArrayFill(Int_t r, Int_t g, Int_t b) override;
0081    void CellArrayEnd() override;
0082    void Close(Option_t *opt = "") override;
0083    Double_t CMtoPDF(Double_t u) { return Int_t(0.5 + 72 * u / 2.54); }
0084    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);
0085    void DrawBox(Double_t x1, Double_t y1,Double_t x2, Double_t  y2) override;
0086    void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t  yt,
0087                   Int_t mode, Int_t border, Int_t dark, Int_t light) override;
0088    void DrawHatch(Float_t dy, Float_t angle, Int_t n, Float_t *x, Float_t *y);
0089    void DrawHatch(Float_t dy, Float_t angle, Int_t n, Double_t *x, Double_t *y);
0090    void DrawPolyLine(Int_t n, TPoints *xy);
0091    void DrawPolyLineNDC(Int_t n, TPoints *uv);
0092    void DrawPolyMarker(Int_t n, Float_t *x, Float_t *y) override;
0093    void DrawPolyMarker(Int_t n, Double_t *x, Double_t *y) override;
0094    void DrawPS(Int_t n, Float_t *xw, Float_t *yw) override;
0095    void DrawPS(Int_t n, Double_t *xw, Double_t *yw) override;
0096    void LineTo(Double_t x, Double_t y);
0097    void MoveTo(Double_t x, Double_t y);
0098    void EndObject();
0099    void FontEncode();
0100    void NewObject(Int_t n);
0101    void NewPage() override;
0102    void Off();
0103    void On();
0104    void Open(const char *filename, Int_t type = -111) override;
0105    void PatternEncode();
0106    void PrintFast(Int_t nch, const char *string = "") override;
0107    void PrintStr(const char *string = "") override;
0108    void Range(Float_t xrange, Float_t yrange);
0109    void SetAlpha(Float_t alpha = 1.);
0110    void SetColor(Int_t color = 1);
0111    void SetColor(Float_t r, Float_t g, Float_t b) override;
0112    void SetFillColor( Color_t cindex = 1) override;
0113    void SetFillPatterns(Int_t ipat, Int_t color);
0114    void SetLineColor( Color_t cindex = 1) override;
0115    void SetLineJoin(Int_t linejoin = 0);
0116    void SetLineCap(Int_t linecap = 0);
0117    void SetLineScale(Float_t scale = 1) {fLineScale = scale;}
0118    void SetLineStyle(Style_t linestyle = 1) override;
0119    void SetLineWidth(Width_t linewidth = 1) override;
0120    void SetMarkerColor(Color_t cindex = 1) override;
0121    void SetTextColor(Color_t cindex = 1) override;
0122    void Text(Double_t x, Double_t y, const char *string) override;
0123    void Text(Double_t, Double_t, const wchar_t *) override;
0124    void TextUrl(Double_t x, Double_t y, const char *string, const char *url) override;
0125    void TextNDC(Double_t u, Double_t v, const char *string);
0126    void TextNDC(Double_t, Double_t, const wchar_t *);
0127    void WriteCompressedBuffer();
0128    void WriteCM(Double_t a, Double_t b, Double_t c, Double_t d, Double_t e, Double_t f, Bool_t acc = kTRUE);
0129    void WriteReal(Float_t r, Bool_t space = kTRUE) override;
0130    void WriteUrlObjects();
0131    Double_t UtoPDF(Double_t u);
0132    Double_t VtoPDF(Double_t v);
0133    Double_t XtoPDF(Double_t x);
0134    Double_t YtoPDF(Double_t y);
0135 
0136    ClassDefOverride(TPDF, 1); // PDF driver
0137 };
0138 
0139 #endif