Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:35

0001 // Author:  Sergey Linev, GSI  10/04/2017
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_TWebPadPainter
0012 #define ROOT_TWebPadPainter
0013 
0014 #include "TVirtualPadPainter.h"
0015 
0016 #include "TAttLine.h"
0017 #include "TAttFill.h"
0018 #include "TAttText.h"
0019 #include "TAttMarker.h"
0020 #include <string>
0021 
0022 #include "TWebPainting.h"
0023 
0024 class TWebCanvas;
0025 
0026 class TWebPadPainter : public TVirtualPadPainter, public TAttLine, public TAttFill, public TAttText, public TAttMarker {
0027 
0028 friend class TWebCanvas;
0029 
0030 protected:
0031 
0032    TWebPainting *fPainting{nullptr};      ///!< object to store all painting, owned by TWebPS object
0033 
0034    enum { attrLine = 0x1, attrFill = 0x2, attrMarker = 0x4, attrText = 0x8, attrAll = 0xf };
0035 
0036    Float_t *StoreOperation(const std::string &oper, unsigned attrkind, int opersize = 0);
0037 
0038 public:
0039 
0040    TWebPadPainter() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
0041 
0042    void SetPainting(TWebPainting *p) { fPainting = p; }
0043 
0044    //Final overrides for TVirtualPadPainter pure virtual functions.
0045    //1. Part, which simply catch attributes.
0046    //Line attributes.
0047    Color_t  GetLineColor() const override { return TAttLine::GetLineColor(); }
0048    Style_t  GetLineStyle() const override { return TAttLine::GetLineStyle(); }
0049    Width_t  GetLineWidth() const override { return TAttLine::GetLineWidth(); }
0050 
0051    void     SetLineColor(Color_t lcolor) override { TAttLine::SetLineColor(lcolor); }
0052    void     SetLineStyle(Style_t lstyle) override { TAttLine::SetLineStyle(lstyle); }
0053    void     SetLineWidth(Width_t lwidth) override { TAttLine::SetLineWidth(lwidth); }
0054 
0055    //Fill attributes.
0056    Color_t  GetFillColor() const override { return TAttFill::GetFillColor(); }
0057    Style_t  GetFillStyle() const override { return TAttFill::GetFillStyle(); }
0058    Bool_t   IsTransparent() const override { return TAttFill::IsTransparent(); }
0059 
0060    void     SetFillColor(Color_t fcolor) override { TAttFill::SetFillColor(fcolor); }
0061    void     SetFillStyle(Style_t fstyle) override { TAttFill::SetFillStyle(fstyle); }
0062    void     SetOpacity(Int_t percent) override { TAttFill::SetFillStyle(4000 + percent); }
0063 
0064    //Text attributes.
0065    Short_t  GetTextAlign() const override { return TAttText::GetTextAlign(); }
0066    Float_t  GetTextAngle() const override { return TAttText::GetTextAngle(); }
0067    Color_t  GetTextColor() const override { return TAttText::GetTextColor(); }
0068    Font_t   GetTextFont()  const override { return TAttText::GetTextFont(); }
0069    Float_t  GetTextSize()  const override { return TAttText::GetTextSize(); }
0070    Float_t  GetTextMagnitude() const override { return  0; }
0071 
0072    void     SetTextAlign(Short_t align) override { TAttText::SetTextAlign(align); }
0073    void     SetTextAngle(Float_t tangle) override { TAttText::SetTextAngle(tangle); }
0074    void     SetTextColor(Color_t tcolor) override { TAttText::SetTextColor(tcolor); }
0075    void     SetTextFont(Font_t tfont) override { TAttText::SetTextFont(tfont); }
0076    void     SetTextSize(Float_t tsize) override { TAttText::SetTextSize(tsize); }
0077    void     SetTextSizePixels(Int_t npixels) override { TAttText::SetTextSizePixels(npixels); }
0078 
0079    //2. "Off-screen management" part.
0080    Int_t    CreateDrawable(UInt_t, UInt_t) override { return -1; }
0081    void     ClearDrawable() override {}
0082    void     CopyDrawable(Int_t, Int_t, Int_t) override {}
0083    void     DestroyDrawable(Int_t) override {}
0084    void     SelectDrawable(Int_t) override {}
0085 
0086    //jpg, png, bmp, gif output.
0087    void     SaveImage(TVirtualPad *, const char *, Int_t) const override;
0088 
0089    //TASImage support (noop for a non-gl pad).
0090    void     DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
0091                        Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) override;
0092 
0093    void     DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
0094    void     DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override;
0095 
0096    void     DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override;
0097    //TPad needs double and float versions.
0098    void     DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
0099    void     DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
0100 
0101    //TPad needs both double and float versions of DrawPolyLine.
0102    void     DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
0103    void     DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
0104    void     DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
0105 
0106    //TPad needs both versions.
0107    void     DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
0108    void     DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
0109 
0110    void     DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
0111    void     DrawText(Double_t x, Double_t y, const wchar_t *text, ETextMode mode) override;
0112    void     DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override;
0113    void     DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) override;
0114 
0115 private:
0116    //Let's make this clear:
0117    TWebPadPainter(const TWebPadPainter &rhs) = delete;
0118    TWebPadPainter(TWebPadPainter && rhs) = delete;
0119    TWebPadPainter & operator = (const TWebPadPainter &rhs) = delete;
0120    TWebPadPainter & operator = (TWebPadPainter && rhs) = delete;
0121 
0122    ClassDefOverride(TWebPadPainter, 0) //Abstract interface for painting in TPad
0123 };
0124 
0125 #endif