Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPadPainter.h
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Olivier Couet, Timur Pocheptsov 06/05/2009
3
4/*************************************************************************
5 * Copyright (C) 1995-2009, 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_TPadPainter
13#define ROOT_TPadPainter
14
15#include "TVirtualPadPainter.h"
16#include "GuiTypes.h"
17
18/*
19TVirtualPadPainter is an attempt to abstract
20painting operation furthermore. gVirtualX can
21be X11 or GDI, but pad painter can be gVirtualX (X11 or GDI),
22or gl pad painter.
23*/
24
25class TVirtualPad;
26
29 Int_t fSetLineWidth = 0; ///< remember set width to optimize some painting
30 Style_t fSetFillStyle = 0; ///< remember set fill style to optimize painting
31
32public:
34 //Final overriders for TVirtualPadPainter pure virtual functions.
35 //1. Part, which simply delegates to TVirtualX.
36
37 //Line attributes.
38 Color_t GetLineColor() const override;
39 Style_t GetLineStyle() const override;
40 Width_t GetLineWidth() const override;
41
42 void SetLineColor(Color_t lcolor) override;
43 void SetLineStyle(Style_t lstyle) override;
44 void SetLineWidth(Width_t lwidth) override;
45
46 //Fill attributes.
47 Color_t GetFillColor() const override;
48 Style_t GetFillStyle() const override;
49 Bool_t IsTransparent() const override;
50
51 void SetFillColor(Color_t fcolor) override;
52 void SetFillStyle(Style_t fstyle) override;
53 void SetOpacity(Int_t percent) override;
54
55 //Text attributes.
56 Short_t GetTextAlign() const override;
57 Float_t GetTextAngle() const override;
58 Color_t GetTextColor() const override;
59 Font_t GetTextFont() const override;
60 Float_t GetTextSize() const override;
61 Float_t GetTextMagnitude() const override;
62
63 void SetTextAlign(Short_t align) override;
64 void SetTextAngle(Float_t tangle) override;
65 void SetTextColor(Color_t tcolor) override;
66 void SetTextFont(Font_t tfont) override;
67 void SetTextSize(Float_t tsize) override;
68 void SetTextSizePixels(Int_t npixels) override;
69
70 //Marker attributes
71 Color_t GetMarkerColor() const override;
72 Style_t GetMarkerStyle() const override;
73 Size_t GetMarkerSize() const override;
74
75 void SetMarkerColor(Color_t mcolor) override;
76 void SetMarkerStyle(Style_t mstyle) override;
77 void SetMarkerSize(Size_t msize) override;
78
79 //Overall attributes
80 void SetAttFill(const TAttFill &att) override;
81 void SetAttLine(const TAttLine &att) override;
82 void SetAttMarker(const TAttMarker &att) override;
83 void SetAttText(const TAttText &att) override;
84
85 //2. "Off-screen management" part.
87 void ClearDrawable() override;
89 void CopyDrawable(Int_t device, Int_t px, Int_t py) override;
90 void DestroyDrawable(Int_t device) override;
91 void SelectDrawable(Int_t device) override;
92 void UpdateDrawable(Int_t mode) override;
93 void SetDrawMode(Int_t device, Int_t mode) override;
94
95
96 //TASImage support (noop for a non-gl pad).
97 void DrawPixels(const unsigned char *pixelData, UInt_t width, UInt_t height,
99
100 void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override;
102
104
105 //TPad needs double and float versions.
106 void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y) override;
107 void DrawFillArea(Int_t n, const Float_t *x, const Float_t *y) override;
108
109 //TPad needs both double and float versions of DrawPolyLine.
110 void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override;
111 void DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y) override;
112 void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override;
113
114 void DrawSegments(Int_t n, Double_t *x, Double_t *y) override;
115 void DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v) override;
116
117 //TPad needs both versions.
118 void DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y) override;
119 void DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y) override;
120
121 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
122 void DrawText(Double_t x, Double_t y, const wchar_t *text, ETextMode mode) override;
123 void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override;
124 void DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) override;
125
126 //jpg, png, bmp, gif output.
127 void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override;
128
129 Bool_t IsNative() const override { return kTRUE; }
130
131 Bool_t IsCocoa() const override;
132
133 Bool_t IsSupportAlpha() const override;
134
135private:
136 //Let's make this clear:
137 TPadPainter(const TPadPainter &) = delete;
141
142 ClassDefOverride(TPadPainter, 0) //TPad painting
143};
144
145#endif
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
#define h(i)
Definition RSha256.hxx:106
short Style_t
Style number (short)
Definition RtypesCore.h:96
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
short Color_t
Color number (short)
Definition RtypesCore.h:99
float Size_t
Attribute size (float)
Definition RtypesCore.h:103
short Width_t
Line width (short)
Definition RtypesCore.h:98
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Font_t
Font number (short)
Definition RtypesCore.h:95
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Option_t Option_t SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t SetTextSize
Option_t Option_t DrawFillArea
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 SetTextFont
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 DrawLine
Option_t Option_t SetMarkerStyle
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 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 DrawText
Option_t Option_t TPoint TPoint SetOpacity
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:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:21
Text Attributes class.
Definition TAttText.h:21
Implement TVirtualPadPainter which abstracts painting operations.
Definition TPadPainter.h:27
void DrawSegments(Int_t n, Double_t *x, Double_t *y) override
Paint N segments on the pad.
Size_t GetMarkerSize() const override
Delegate to gVirtualX.
TPadPainter()
Empty ctor. We need it only because of explicit copy ctor.
void SetAttText(const TAttText &att) override
Set text attributes.
Color_t GetFillColor() const override
Delegate to gVirtualX.
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 GetMarkerStyle() const override
Delegate to gVirtualX.
Float_t GetTextAngle() const override
Delegate to gVirtualX.
void UpdateDrawable(Int_t mode) override
Call low-level update of selected drawable, redirect to gVirtualX.
void CopyDrawable(Int_t device, Int_t px, Int_t py) override
Copy a gVirtualX pixmap.
void SetAttMarker(const TAttMarker &att) override
Set marker attributes.
TPadPainter & operator=(TPadPainter &&)=delete
Style_t fSetFillStyle
remember set fill style to optimize painting
Definition TPadPainter.h:30
Int_t fSetLineWidth
remember set width to optimize some painting
Definition TPadPainter.h:29
Float_t GetTextSize() const override
Delegate to gVirtualX.
Style_t GetFillStyle() const override
Delegate to gVirtualX.
void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y) override
Paint Polyline.
Short_t GetTextAlign() const override
Delegate to gVirtualX.
Style_t GetLineStyle() const override
Delegate to gVirtualX.
Bool_t IsTransparent() const override
Delegate to gVirtualX.
Int_t ResizeDrawable(Int_t device, UInt_t w, UInt_t h) override
Resize a gVirtualX Pixmap.
Float_t GetTextMagnitude() const override
Delegate to gVirtualX.
void SetMarkerColor(Color_t mcolor) override
Delegate to gVirtualX.
Bool_t IsSupportAlpha() const override
Returns true if trasnparent colors are supported.
Color_t GetTextColor() const override
Delegate to gVirtualX.
Int_t CreateDrawable(UInt_t w, UInt_t h) override
Create a gVirtualX Pixmap.
void SetTextAlign(Short_t align) override
Delegate to gVirtualX.
void SetMarkerSize(Size_t msize) override
Delegate to gVirtualX.
void SetAttFill(const TAttFill &att) override
Set fill attributes.
void SetTextAngle(Float_t tangle) override
Delegate to gVirtualX.
void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override
Paint text in normalized coordinates.
Bool_t IsCocoa() const override
Returns true when cocoa backend is used.
void SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const override
Save the image displayed in the canvas pointed by "pad" into a binary file.
void SetLineStyle(Style_t lstyle) override
Delegate to gVirtualX.
TPadPainter(const TPadPainter &)=delete
Font_t GetTextFont() const override
Delegate to gVirtualX.
void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v) override
Paint polyline in normalized coordinates.
void SetDrawMode(Int_t device, Int_t mode) override
Set drawing mode for specified device.
void ClearDrawable() override
Clear the current gVirtualX window.
void DestroyDrawable(Int_t device) override
Close the current gVirtualX pixmap.
WinContext_t fWinContext
Definition TPadPainter.h:28
Width_t GetLineWidth() const override
Delegate to gVirtualX.
void SetTextColor(Color_t tcolor) override
Delegate to gVirtualX.
Bool_t IsNative() const override
void SetTextSizePixels(Int_t npixels) override
Delegate to gVirtualX.
void DrawSegmentsNDC(Int_t n, Double_t *u, Double_t *v) override
Paint N segments in normalized coordinates on the pad.
void SetAttLine(const TAttLine &att) override
Set line attributes.
void SelectDrawable(Int_t device) override
Select the window in which the graphics will go.
void DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode) override
Paint a simple box.
Color_t GetLineColor() const override
Delegate to gVirtualX.
void DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Paint a simple line in normalized coordinates.
Color_t GetMarkerColor() const override
Delegate to gVirtualX.
TPadPainter(TPadPainter &&)=delete
TPadPainter & operator=(const TPadPainter &)=delete
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
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16