Logo ROOT  
Reference Guide
TWebPadPainter.h
Go to the documentation of this file.
1// Author: Sergey Linev, GSI 10/04/2017
2
3/*************************************************************************
4 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT_TWebPadPainter
12#define ROOT_TWebPadPainter
13
14#include "TVirtualPadPainter.h"
15
16#include "TAttLine.h"
17#include "TAttFill.h"
18#include "TAttText.h"
19#include "TAttMarker.h"
20#include <string>
21
22#include "TWebPainting.h"
23
24class TWebCanvas;
25
26class TWebPadPainter : public TVirtualPadPainter, public TAttLine, public TAttFill, public TAttText, public TAttMarker {
27
28friend class TWebCanvas;
29
30protected:
31
32 TWebPainting *fPainting{nullptr}; ///!< object to store all painting, owned by TWebPS object
33
34 enum { attrLine = 0x1, attrFill = 0x2, attrMarker = 0x4, attrText = 0x8, attrAll = 0xf };
35
36 Float_t *StoreOperation(const std::string &oper, unsigned attrkind, int opersize = 0);
37
38public:
39
40 TWebPadPainter() {} // NOLINT: not allowed to use = default because of TObject::kIsOnHeap detection, see ROOT-10300
41
43
44 //Final overrides for TVirtualPadPainter pure virtual functions.
45 //1. Part, which simply catch attributes.
46 //Line attributes.
47 Color_t GetLineColor() const override { return TAttLine::GetLineColor(); }
48 Style_t GetLineStyle() const override { return TAttLine::GetLineStyle(); }
49 Width_t GetLineWidth() const override { return TAttLine::GetLineWidth(); }
50
51 void SetLineColor(Color_t lcolor) override { TAttLine::SetLineColor(lcolor); }
52 void SetLineStyle(Style_t lstyle) override { TAttLine::SetLineStyle(lstyle); }
53 void SetLineWidth(Width_t lwidth) override { TAttLine::SetLineWidth(lwidth); }
54
55 //Fill attributes.
56 Color_t GetFillColor() const override { return TAttFill::GetFillColor(); }
57 Style_t GetFillStyle() const override { return TAttFill::GetFillStyle(); }
58 Bool_t IsTransparent() const override { return TAttFill::IsTransparent(); }
59
60 void SetFillColor(Color_t fcolor) override { TAttFill::SetFillColor(fcolor); }
61 void SetFillStyle(Style_t fstyle) override { TAttFill::SetFillStyle(fstyle); }
63
64 //Text attributes.
65 Short_t GetTextAlign() const override { return TAttText::GetTextAlign(); }
66 Float_t GetTextAngle() const override { return TAttText::GetTextAngle(); }
67 Color_t GetTextColor() const override { return TAttText::GetTextColor(); }
68 Font_t GetTextFont() const override { return TAttText::GetTextFont(); }
69 Float_t GetTextSize() const override { return TAttText::GetTextSize(); }
70 Float_t GetTextMagnitude() const override { return 0; }
71
72 void SetTextAlign(Short_t align) override { TAttText::SetTextAlign(align); }
73 void SetTextAngle(Float_t tangle) override { TAttText::SetTextAngle(tangle); }
74 void SetTextColor(Color_t tcolor) override { TAttText::SetTextColor(tcolor); }
75 void SetTextFont(Font_t tfont) override { TAttText::SetTextFont(tfont); }
76 void SetTextSize(Float_t tsize) override { TAttText::SetTextSize(tsize); }
77 void SetTextSizePixels(Int_t npixels) override { TAttText::SetTextSizePixels(npixels); }
78
79 //2. "Off-screen management" part.
80 Int_t CreateDrawable(UInt_t, UInt_t) override { return -1; }
81 void ClearDrawable() override {}
82 void CopyDrawable(Int_t, Int_t, Int_t) override {}
83 void DestroyDrawable(Int_t) override {}
84 void SelectDrawable(Int_t) override {}
85
86 //jpg, png, bmp, gif output.
87 void SaveImage(TVirtualPad *, const char *, Int_t) const override;
88
89 //TASImage support (noop for a non-gl pad).
90 void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
91 Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) override;
92
94 void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override;
95
97 //TPad needs double and float versions.
98 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
99 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
100
101 //TPad needs both double and float versions of DrawPolyLine.
102 void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
103 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
104 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
105
106 //TPad needs both versions.
107 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
108 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
109
110 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
111 void DrawText(Double_t x, Double_t y, const wchar_t *text, ETextMode mode) override;
112 void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override;
113 void DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) override;
114
115private:
116 //Let's make this clear:
117 TWebPadPainter(const TWebPadPainter &rhs) = delete;
121
122 ClassDefOverride(TWebPadPainter, 0) //Abstract interface for painting in TPad
123};
124
125#endif
short Style_t
Definition: RtypesCore.h:89
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
short Color_t
Definition: RtypesCore.h:92
unsigned int UInt_t
Definition: RtypesCore.h:46
short Width_t
Definition: RtypesCore.h:91
float Float_t
Definition: RtypesCore.h:57
short Font_t
Definition: RtypesCore.h:88
short Short_t
Definition: RtypesCore.h:39
double Double_t
Definition: RtypesCore.h:59
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
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 percent
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 text
Option_t Option_t TPoint TPoint const char y1
Fill Area Attributes class.
Definition: TAttFill.h:19
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual Bool_t IsTransparent() const
Definition: TAttFill.h:44
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
Line Attributes class.
Definition: TAttLine.h:18
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
Marker Attributes class.
Definition: TAttMarker.h:19
Text Attributes class.
Definition: TAttText.h:18
virtual Float_t GetTextSize() const
Return the text size.
Definition: TAttText.h:36
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:42
virtual Short_t GetTextAlign() const
Return the text alignment.
Definition: TAttText.h:32
virtual Font_t GetTextFont() const
Return the text font.
Definition: TAttText.h:35
virtual Color_t GetTextColor() const
Return the text color.
Definition: TAttText.h:34
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition: TAttText.h:43
virtual Float_t GetTextAngle() const
Return the text angle.
Definition: TAttText.h:33
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:46
virtual void SetTextSizePixels(Int_t npixels)
Set the text size in pixel.
Definition: TAttText.cxx:423
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition: TAttText.h:47
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
Basic TCanvasImp ABI implementation for Web-based GUI Provides painting of main ROOT6 classes in web ...
Definition: TWebCanvas.h:34
Implement TVirtualPadPainter which abstracts painting operations.
Float_t GetTextMagnitude() const override
void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY, Bool_t enableAlphaBlending) override
Noop, for non-gl pad TASImage calls gVirtualX->CopyArea.
Style_t GetFillStyle() const override
Return the fill area style.
void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override
Paint filled area.
Color_t GetTextColor() const override
Return the text color.
void SetFillStyle(Style_t fstyle) override
Set the fill area style.
void SetTextSize(Float_t tsize) override
Set the text size.
void SetTextAlign(Short_t align) override
Set the text alignment.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override
Paint a simple box.
TWebPainting * fPainting
void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override
Paint text in normalized coordinates.
void SelectDrawable(Int_t) override
Int_t CreateDrawable(UInt_t, UInt_t) override
Float_t * StoreOperation(const std::string &oper, unsigned attrkind, int opersize=0)
Store operation identifier with appropriate attributes.
TWebPadPainter(TWebPadPainter &&rhs)=delete
void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override
Paint text.
Float_t GetTextAngle() const override
Return the text angle.
void SetLineWidth(Width_t lwidth) override
Set the line width.
void SetTextSizePixels(Int_t npixels) override
Set the text size in pixel.
void SetTextAngle(Float_t tangle) override
Set the text angle.
Bool_t IsTransparent() const override
TWebPadPainter(const TWebPadPainter &rhs)=delete
void ClearDrawable() override
void SetLineStyle(Style_t lstyle) override
Set the line style.
Short_t GetTextAlign() const override
Return the text alignment.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Paint a simple line in normalized coordinates.
void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override
Paint polymarker.
Font_t GetTextFont() const override
Return the text font.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Paint polyline in normalized coordinates.
Style_t GetLineStyle() const override
Return the line style.
void SetPainting(TWebPainting *p)
Width_t GetLineWidth() const override
Return the line width.
void SetTextFont(Font_t tfont) override
Set the text font.
void SaveImage(TVirtualPad *, const char *, Int_t) const override
Produce image from WebPadPainter.
void SetTextColor(Color_t tcolor) override
Set the text color.
Color_t GetFillColor() const override
Return the fill area color.
Float_t GetTextSize() const override
Return the text size.
void SetLineColor(Color_t lcolor) override
Set the line color.
void CopyDrawable(Int_t, Int_t, Int_t) override
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override
Paint Polyline.
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Paint a simple line.
Color_t GetLineColor() const override
Return the line color.
void SetFillColor(Color_t fcolor) override
Set the fill area color.
void SetOpacity(Int_t percent) override
TWebPadPainter & operator=(const TWebPadPainter &rhs)=delete
void DestroyDrawable(Int_t) override
Object used to store paint operations and deliver them to JSROOT.
Definition: TWebPainting.h:25
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16