Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPadPainterBase.h
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Sergey Linev 1/04/2026
3
4/*************************************************************************
5 * Copyright (C) 1995-2026, 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_TPadPainterBase
13#define ROOT_TPadPainterBase
14
15#include "TVirtualPadPainter.h"
16#include "TAttFill.h"
17#include "TAttLine.h"
18#include "TAttMarker.h"
19#include "TAttText.h"
20
21class TTFhandle;
22
24protected:
26 TVirtualPad *fPad = nullptr;
27
28 TAttFill fAttFill; ///< current fill attributes
29 TAttLine fAttLine; ///< current line attributes
30 TAttMarker fAttMarker; ///< current marker attributes
31 TAttText fAttText; ///< current text attributes
32 Bool_t fFullyTransparent = kFALSE; ///< if transformed fill attributes fully transparent
33
35 virtual Double_t GetTTFScale() const { return 1.; }
36
37public:
38
39 /// _____________________________________________________________________
40 /// old methods only for backward compatibility
41
42 //Line attributes to be set up in TPad.
43 Color_t GetLineColor() const override { return fAttLine.GetLineColor(); }
44 Style_t GetLineStyle() const override { return fAttLine.GetLineStyle(); }
45 Width_t GetLineWidth() const override { return fAttLine.GetLineWidth(); }
46
50
51 //Fill attributes to be set up in TPad.
52 Color_t GetFillColor() const override { return fAttFill.GetFillColor(); }
53 Style_t GetFillStyle() const override { return fAttFill.GetFillStyle(); }
54 Bool_t IsTransparent() const override { return fAttFill.IsTransparent(); }
55
58
59 //Text attributes.
60 Short_t GetTextAlign() const override { return fAttText.GetTextAlign(); }
61 Float_t GetTextAngle() const override { return fAttText.GetTextAngle(); }
62 Color_t GetTextColor() const override { return fAttText.GetTextColor(); }
63 Font_t GetTextFont() const override { return fAttText.GetTextFont(); }
64 Float_t GetTextSize() const override { return fAttText.GetTextSize(); }
65 Float_t GetTextMagnitude() const override { return 1.; }
66
67 void SetTextAlign(Short_t align) override { fAttText.SetTextAlign(align); SetAttText(fAttText); }
73
74 //Marker attributes
75 Color_t GetMarkerColor() const override { return fAttMarker.GetMarkerColor(); }
76 Style_t GetMarkerStyle() const override { return fAttMarker.GetMarkerStyle(); }
77 Size_t GetMarkerSize() const override { return fAttMarker.GetMarkerSize(); }
78
82
83 /// _____________________________________________________________________
84
85 void OnPad(TVirtualPad *pad) override { fPad = pad; }
86
87
88 const TAttFill &GetAttFill() const override { return fAttFill; }
89 const TAttLine &GetAttLine() const override { return fAttLine; }
90 const TAttMarker &GetAttMarker()const override { return fAttMarker; }
91 const TAttText &GetAttText() const override { return fAttText; }
92
93 void SetAttFill(const TAttFill &att) override
94 {
95 if (&att != &fAttFill)
96 att.Copy(fAttFill);
97 }
98
99 void SetAttLine(const TAttLine &att) override
100 {
101 if (&att != &fAttLine)
102 att.Copy(fAttLine);
103 }
104
105 void SetAttMarker(const TAttMarker &att) override
106 {
107 if (&att != &fAttMarker)
108 att.Copy(fAttMarker);
109 }
110
111 void SetAttText(const TAttText &att) override
112 {
113 if (&att != &fAttText)
114 att.Copy(fAttText);
115 }
116
118
119 void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override;
120 void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const wchar_t *mess) override;
121 void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override;
122 void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const wchar_t *mess) override;
123 UInt_t GetTextAdvance(Font_t font, Double_t size, const char *text, Bool_t kern) override;
124
125 void DrawText(Double_t x, Double_t y, const char *text, ETextMode mode) override;
126 void DrawText(Double_t x, Double_t y, const wchar_t *text, ETextMode mode) override;
127 void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override;
128 void DrawTextNDC(Double_t u, Double_t v, const wchar_t *text, ETextMode mode) override;
129
130 ClassDefOverride(TPadPainterBase, 0)//Pad painter with attributes handling
131};
132
133#endif
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
#define d(i)
Definition RSha256.hxx:102
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
short Style_t
Style number (short)
Definition RtypesCore.h:97
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
float Size_t
Attribute size (float)
Definition RtypesCore.h:104
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
#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 TPoint TPoint const char mode
Option_t Option_t TPoint TPoint DrawText
Option_t Option_t TPoint TPoint const char text
Fill Area Attributes class.
Definition TAttFill.h:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual Bool_t IsTransparent() const
Definition TAttFill.h:49
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
Line Attributes class.
Definition TAttLine.h:21
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
Marker Attributes class.
Definition TAttMarker.h:22
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:35
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:34
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:36
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Text Attributes class.
Definition TAttText.h:21
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
virtual Short_t GetTextAlign() const
Return the text alignment.
Definition TAttText.h:35
virtual Font_t GetTextFont() const
Return the text font.
Definition TAttText.h:38
virtual Color_t GetTextColor() const
Return the text color.
Definition TAttText.h:37
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:36
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
virtual void SetTextSizePixels(Int_t npixels)
Set the text size in pixel.
Definition TAttText.cxx:441
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
Extends TVirtualPadPainter interface to simplify work with graphical attributes.
void SetMarkerStyle(Style_t mstyle) override
void SetAttFill(const TAttFill &att) override
Set fill attributes.
void SetLineStyle(Style_t lstyle) override
void DrawTextNDC(Double_t u, Double_t v, const char *text, ETextMode mode) override
Paint text at NDC coordinates.
Color_t GetMarkerColor() const override
void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override
Returns text extend.
void SetFillColor(Color_t fcolor) override
const TAttText & GetAttText() const override
Get text attributes.
void SetAttText(const TAttText &att) override
Set text attributes.
void SetTextSize(Float_t tsize) override
Bool_t IsTransparent() const override
UInt_t GetTextAdvance(Font_t font, Double_t size, const char *text, Bool_t kern) override
Returns text advance.
Short_t GetTextAlign() const override
void SetTextAngle(Float_t tangle) override
void SetTextSizePixels(Int_t npixels) override
const TAttMarker & GetAttMarker() const override
Get marker attributes.
Size_t GetMarkerSize() const override
const TAttFill & GetAttFill() const override
Get fill attributes.
TAttLine fAttLine
current line attributes
TAttText fAttText
current text attributes
Style_t GetMarkerStyle() const override
void SetTextFont(Font_t tfont) override
void SetMarkerColor(Color_t mcolor) override
void SetLineColor(Color_t lcolor) override
Font_t GetTextFont() const override
void SetTextAlign(Short_t align) override
void SetFillStyle(Style_t fstyle) override
Color_t GetLineColor() const override
Width_t GetLineWidth() const override
Bool_t fFullyTransparent
if transformed fill attributes fully transparent
void OnPad(TVirtualPad *pad) override
Float_t GetTextMagnitude() const override
void SetAttMarker(const TAttMarker &att) override
Set marker attributes.
void SetAttLine(const TAttLine &att) override
Set line attributes.
Color_t GetFillColor() const override
Float_t GetTextAngle() const override
void SetLineWidth(Width_t lwidth) override
WinContext_t fWinContext
TAttMarker fAttMarker
current marker attributes
virtual Double_t GetTTFScale() const
TVirtualPad * fPad
TAttFill fAttFill
current fill attributes
TAttFill GetAttFillInternal(Bool_t with_transparency)
Returns fill attributes after modification Checks for special fill styles 4000 .
void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override
Returns text accent / descent.
void SetMarkerSize(Size_t msize) override
Color_t GetTextColor() const override
void SetTextColor(Color_t tcolor) override
virtual void DrawTTFglyphs(Int_t x, Int_t y, TTFhandle &ttf, ETextMode mode)
Performs rendering of TTF glyphs on output device Can be implemented in derived classes instead of im...
Style_t GetLineStyle() const override
const TAttLine & GetAttLine() const override
Get line attributes.
Style_t GetFillStyle() const override
Float_t GetTextSize() const override
Dynamic handle to work with freetype 2 library.
Definition TTFhandle.h:21
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