Logo ROOT  
Reference Guide
RPad.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RPad
10#define ROOT7_RPad
11
12#include "ROOT/RPadBase.hxx"
13
14namespace ROOT {
15namespace Experimental {
16
17/** \class RPad
18\ingroup GpadROOT7
19\brief Graphic container for `RDrawable`-s.
20\authors Axel Naumann <axel@cern.ch> Sergey Linev <s.linev@gsi.de>
21\date 2017-07-06
22\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
23*/
24
25class RPad: public RPadBase {
26
27 /// Pad containing this pad as a sub-pad.
28 RPadBase *fParent{nullptr}; ///< The parent pad, if this pad has one.
29
30 RPadPos fPos; ///< pad position
31 RPadExtent fSize; ///< pad size
32
33 RAttrLine fAttrLine{this, "border_"}; ///<! border attributes
34
35protected:
36
37 std::unique_ptr<RDisplayItem> Display(const RDisplayContext &) final;
38
39public:
40 /// Create a topmost, non-paintable pad.
41 RPad() = default;
42
43 /// Create a child pad.
44 RPad(RPadBase *parent, const RPadPos &pos, const RPadExtent &size): fParent(parent) { fPos = pos; fSize = size; }
45
46 /// Destructor to have a vtable.
47 virtual ~RPad();
48
49 /// Access to the parent pad (const version).
50 const RPadBase *GetParent() const { return fParent; }
51
52 /// Access to the parent pad (non-const version).
53 RPadBase *GetParent() { return fParent; }
54
55 /// Access to the top-most canvas (const version).
56 const RCanvas *GetCanvas() const override { return fParent ? fParent->GetCanvas() : nullptr; }
57
58 /// Access to the top-most canvas (non-const version).
59 RCanvas *GetCanvas() override { return fParent ? fParent->GetCanvas() : nullptr; }
60
61 /// Get the position of the pad in parent (!) coordinates.
62 const RPadPos &GetPos() const { return fPos; }
63
64 /// Get the size of the pad in parent (!) coordinates.
65 const RPadExtent &GetSize() const { return fSize; }
66
67 /// Set the size of the pad in parent (!) coordinates.
68 void SetSize(const RPadExtent &sz) { fSize = sz; }
69
70 /// Set position
71 void SetPos(const RPadPos &p) { fPos = p; }
72
73 const RAttrLine &GetAttrLine() const { return fAttrLine; }
74 RPad &SetAttrLine(const RAttrLine &attr) { fAttrLine = attr; return *this; }
76
77 /// Convert a `Pixel` position to Canvas-normalized positions.
78 std::array<RPadLength::Normal, 2> PixelsToNormal(const std::array<RPadLength::Pixel, 2> &pos) const override
79 {
80 std::array<RPadLength::Normal, 2> posInParentNormal = fParent->PixelsToNormal(pos);
81 std::array<RPadLength::Normal, 2> myPixelInNormal =
83 std::array<RPadLength::Normal, 2> myUserInNormal =
84 fParent->UserToNormal({{fSize.Horiz().GetUser(), fSize.Vert().GetUser()}});
85 // If the parent says pos is at 0.6 in normal coords, and our size converted to normal is 0.2, then pos in our
86 // coord system is 3.0!
87 return {{posInParentNormal[0] / (fSize.Horiz().GetNormal() + myPixelInNormal[0] + myUserInNormal[0]),
88 posInParentNormal[1] / (fSize.Vert().GetNormal() + myPixelInNormal[1] + myUserInNormal[1])}};
89 }
90
91 /// Convert a RPadPos to [x, y] of normalized coordinates.
92 std::array<RPadLength::Normal, 2> ToNormal(const RPadPos &pos) const
93 {
94 std::array<RPadLength::Normal, 2> pixelsInNormal = PixelsToNormal({{pos.Horiz().GetPixel(), pos.Vert().GetPixel()}});
95 std::array<RPadLength::Normal, 2> userInNormal = UserToNormal({{pos.Horiz().GetUser(), pos.Vert().GetUser()}});
96 return {{pos.Horiz().GetNormal() + pixelsInNormal[0] + userInNormal[0],
97 pos.Vert().GetNormal() + pixelsInNormal[1] + userInNormal[1]}};
98 }
99
100
101};
102
103} // namespace Experimental
104} // namespace ROOT
105
106#endif
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition: TGWin32.cxx:4287
Drawing line attributes for different objects.
Definition: RAttrLine.hxx:26
A window's topmost RPad.
Definition: RCanvas.hxx:46
Base class for graphic containers for RDrawable-s.
Definition: RPadBase.hxx:37
std::array< RPadLength::Normal, 2 > UserToNormal(const std::array< RPadLength::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
Definition: RPadBase.cxx:355
virtual std::array< RPadLength::Normal, 2 > PixelsToNormal(const std::array< RPadLength::Pixel, 2 > &pos) const =0
Convert a Pixel position to Canvas-normalized positions.
virtual const RCanvas * GetCanvas() const =0
Access to the top-most canvas, if any (const version).
An extent / size (horizontal and vertical) in a RPad.
Definition: RPadExtent.hxx:27
A position (horizontal and vertical) in a RPad.
Definition: RPadPos.hxx:28
RPadLength & Horiz()
Definition: RPadPos.hxx:50
Graphic container for RDrawable-s.
Definition: RPad.hxx:25
std::unique_ptr< RDisplayItem > Display(const RDisplayContext &) final
Create pad display item.
Definition: RPad.cxx:27
const RPadExtent & GetSize() const
Get the size of the pad in parent (!) coordinates.
Definition: RPad.hxx:65
void SetSize(const RPadExtent &sz)
Set the size of the pad in parent (!) coordinates.
Definition: RPad.hxx:68
const RCanvas * GetCanvas() const override
Access to the top-most canvas (const version).
Definition: RPad.hxx:56
const RPadBase * GetParent() const
Access to the parent pad (const version).
Definition: RPad.hxx:50
RCanvas * GetCanvas() override
Access to the top-most canvas (non-const version).
Definition: RPad.hxx:59
virtual ~RPad()
Destructor to have a vtable.
RPad & SetAttrLine(const RAttrLine &attr)
Definition: RPad.hxx:74
RPadBase * GetParent()
Access to the parent pad (non-const version).
Definition: RPad.hxx:53
RPadPos fPos
pad position
Definition: RPad.hxx:30
std::array< RPadLength::Normal, 2 > ToNormal(const RPadPos &pos) const
Convert a RPadPos to [x, y] of normalized coordinates.
Definition: RPad.hxx:92
RAttrLine fAttrLine
! border attributes
Definition: RPad.hxx:33
RAttrLine & AttrLine()
Definition: RPad.hxx:75
std::array< RPadLength::Normal, 2 > PixelsToNormal(const std::array< RPadLength::Pixel, 2 > &pos) const override
Convert a Pixel position to Canvas-normalized positions.
Definition: RPad.hxx:78
const RAttrLine & GetAttrLine() const
Definition: RPad.hxx:73
RPad(RPadBase *parent, const RPadPos &pos, const RPadExtent &size)
Create a child pad.
Definition: RPad.hxx:44
RPadBase * fParent
Pad containing this pad as a sub-pad.
Definition: RPad.hxx:28
RPad()=default
Create a topmost, non-paintable pad.
void SetPos(const RPadPos &p)
Set position.
Definition: RPad.hxx:71
const RPadPos & GetPos() const
Get the position of the pad in parent (!) coordinates.
Definition: RPad.hxx:62
RPadExtent fSize
pad size
Definition: RPad.hxx:31
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21