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
22protected:
23 TAttFill fAttFill; ///< current fill attributes
24 TAttLine fAttLine; ///< current line attributes
25 TAttMarker fAttMarker; ///< current marker attributes
26 TAttText fAttText; ///< current text attributes
27 Bool_t fFullyTransparent = kFALSE; ///< if transformed fill attributes fully transparent
28
29 TAttFill GetAttFillInternal(Bool_t with_transparency);
30
31public:
32
33 /// _____________________________________________________________________
34 /// old methods only for backward compatibility
35
36 //Line attributes to be set up in TPad.
37 Color_t GetLineColor() const override { return fAttLine.GetLineColor(); }
38 Style_t GetLineStyle() const override { return fAttLine.GetLineStyle(); }
39 Width_t GetLineWidth() const override { return fAttLine.GetLineWidth(); }
40
41 void SetLineColor(Color_t lcolor) override { fAttLine.SetLineColor(lcolor); SetAttLine(fAttLine); }
42 void SetLineStyle(Style_t lstyle) override { fAttLine.SetLineStyle(lstyle); SetAttLine(fAttLine); }
43 void SetLineWidth(Width_t lwidth) override { fAttLine.SetLineWidth(lwidth); SetAttLine(fAttLine); }
44
45 //Fill attributes to be set up in TPad.
46 Color_t GetFillColor() const override { return fAttFill.GetFillColor(); }
47 Style_t GetFillStyle() const override { return fAttFill.GetFillStyle(); }
48 Bool_t IsTransparent() const override { return fAttFill.IsTransparent(); }
49
50 void SetFillColor(Color_t fcolor) override { fAttFill.SetFillColor(fcolor); SetAttFill(fAttFill); }
51 void SetFillStyle(Style_t fstyle) override { fAttFill.SetFillStyle(fstyle); SetAttFill(fAttFill); }
52
53 //Text attributes.
54 Short_t GetTextAlign() const override { return fAttText.GetTextAlign(); }
55 Float_t GetTextAngle() const override { return fAttText.GetTextAngle(); }
56 Color_t GetTextColor() const override { return fAttText.GetTextColor(); }
57 Font_t GetTextFont() const override { return fAttText.GetTextFont(); }
58 Float_t GetTextSize() const override { return fAttText.GetTextSize(); }
59 Float_t GetTextMagnitude() const override { return 1.; }
60
61 void SetTextAlign(Short_t align) override { fAttText.SetTextAlign(align); SetAttText(fAttText); }
62 void SetTextAngle(Float_t tangle) override { fAttText.SetTextAngle(tangle); SetAttText(fAttText); }
63 void SetTextColor(Color_t tcolor) override { fAttText.SetTextColor(tcolor); SetAttText(fAttText); }
64 void SetTextFont(Font_t tfont) override { fAttText.SetTextFont(tfont); SetAttText(fAttText); }
65 void SetTextSize(Float_t tsize) override { fAttText.SetTextSize(tsize); SetAttText(fAttText); }
66 void SetTextSizePixels(Int_t npixels) override { fAttText.SetTextSizePixels(npixels); SetAttText(fAttText); }
67
68 //Marker attributes
69 Color_t GetMarkerColor() const override { return fAttMarker.GetMarkerColor(); }
70 Style_t GetMarkerStyle() const override { return fAttMarker.GetMarkerStyle(); }
71 Size_t GetMarkerSize() const override { return fAttMarker.GetMarkerSize(); }
72
73 void SetMarkerColor(Color_t mcolor) override { fAttMarker.SetMarkerColor(mcolor); SetAttMarker(fAttMarker); }
74 void SetMarkerStyle(Style_t mstyle) override { fAttMarker.SetMarkerStyle(mstyle); SetAttMarker(fAttMarker); }
75 void SetMarkerSize(Size_t msize) override { fAttMarker.SetMarkerSize(msize); SetAttMarker(fAttMarker); }
76
77 /// _____________________________________________________________________
78
79 const TAttFill &GetAttFill() const override { return fAttFill; }
80 const TAttLine &GetAttLine() const override { return fAttLine; }
81 const TAttMarker &GetAttMarker()const override { return fAttMarker; }
82 const TAttText &GetAttText() const override { return fAttText; }
83
84 void SetAttFill(const TAttFill &att) override
85 {
86 if (&att != &fAttFill)
87 att.Copy(fAttFill);
88 }
89
90 void SetAttLine(const TAttLine &att) override
91 {
92 if (&att != &fAttLine)
93 att.Copy(fAttLine);
94 }
95
96 void SetAttMarker(const TAttMarker &att) override
97 {
98 if (&att != &fAttMarker)
99 att.Copy(fAttMarker);
100 }
101
102 void SetAttText(const TAttText &att) override
103 {
104 if (&att != &fAttText)
105 att.Copy(fAttText);
106 }
107
108 void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override;
109 void GetTextExtent(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const wchar_t *mess) override;
110 void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const char *mess) override;
111 void GetTextAscentDescent(Font_t font, Double_t size, UInt_t &a, UInt_t &d, const wchar_t *mess) override;
112 UInt_t GetTextAdvance(Font_t font, Double_t size, const char *text, Bool_t kern) override;
113
114 ClassDefOverride(TPadPainterBase, 0)//Pad painter with attributes handling
115};
116
117#endif
#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
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
float Size_t
Attribute size (float).
Definition RtypesCore.h:103
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
short Width_t
Line width (short).
Definition RtypesCore.h:98
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
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 kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
short Color_t
Color number (short).
Definition RtypesCore.h:99
short Style_t
Style number (short).
Definition RtypesCore.h:96
float Float_t
Float 4 bytes (float).
Definition RtypesCore.h:71
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
void Copy(TAttFill &attfill) const
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
void Copy(TAttText &atttext) const
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
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
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
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
TAttMarker fAttMarker
current marker attributes
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
Style_t GetLineStyle() const override
const TAttLine & GetAttLine() const override
Get line attributes.
Style_t GetFillStyle() const override
Float_t GetTextSize() const override
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
TText * text