29 namespace Experimental {
34 class TVirtualCanvasPainter;
59 template <
class DRAWABLE>
62 DRAWABLE &drw = *uPtr;
63 fPrimitives.emplace_back(std::move(uPtr));
64 return drw.GetOptions();
79 std::vector<std::vector<TPad *>> Divide(
int nHoriz,
int nVert,
const TPadExtent &padding = {});
84 auto &
Draw(
const std::shared_ptr<T> &what)
92 auto &
Draw(std::unique_ptr<T> &&what)
95 return AddDrawable(
GetDrawable(std::move(what), *
this));
99 template <class T, class = typename std::enable_if<!ROOT::TypeTraits::IsSmartOrDumbPtr<T>::value>
::type>
103 return Draw(std::make_unique<T>(what));
119 virtual std::array<TPadCoord::Normal, 2> PixelsToNormal(
const std::array<TPadCoord::Pixel, 2> &pos)
const = 0;
122 virtual const TCanvas &GetCanvas()
const = 0;
125 virtual TCanvas &GetCanvas() = 0;
128 std::array<TPadCoord::Normal, 2>
UserToNormal(
const std::array<TPadCoord::User, 2> &pos)
const 130 return fFrame->UserToNormal(pos);
149 friend std::unique_ptr<TPadDrawable>
GetDrawable(std::unique_ptr<TPad> &&pad,
const TPadBase &parent);
173 std::array<TPadCoord::Normal, 2>
PixelsToNormal(
const std::array<TPadCoord::Pixel, 2> &pos)
const override 175 std::array<TPadCoord::Normal, 2> posInParentNormal = fParent->
PixelsToNormal(pos);
176 std::array<TPadCoord::Normal, 2> myPixelInNormal =
178 std::array<TPadCoord::Normal, 2> myUserInNormal =
182 return {{posInParentNormal[0] / (fSize.
fHoriz.
fNormal + myPixelInNormal[0] + myUserInNormal[0]),
183 posInParentNormal[1] / (fSize.
fVert.
fNormal + myPixelInNormal[1] + myUserInNormal[1])}};
191 return {{pos.
fHoriz.
fNormal + pixelsInNormal[0] + userInNormal[0],
192 pos.
fVert.
fNormal + pixelsInNormal[1] + userInNormal[1]}};
218 const std::unique_ptr<TPad>
fPad;
239 return std::make_unique<TPadDrawable>(std::move(pad), parent);
Draw a TPad, by drawing its contained graphical elements at the pad offset in the parent pad...
virtual std::array< TPadCoord::Normal, 2 > PixelsToNormal(const std::array< TPadCoord::Pixel, 2 > &pos) const =0
Convert a Pixel position to Canvas-normalized positions.
Base class for drawable entities: objects that can be painted on a TPad.
Namespace for new ROOT classes and functions.
TPadExtent fSize
Size of the pad in the parent's (!) coordinate system.
A window's topmost TPad.
std::array< TPadCoord::Normal, 2 > PixelsToNormal(const std::array< TPadCoord::Pixel, 2 > &pos) const override
Convert a Pixel position to Canvas-normalized positions.
Base class for drawing options.
Drawing options for a TPad.
TPad(TPadBase &parent, const TPadExtent &size)
Create a child pad.
TPadPos fPos
Offset with respect to parent TPad.
auto & Draw(const T &what)
Add a copy of something to be painted.
TPadDrawingOpts & At(const TPadPos &pos)
Set the position of this pad with respect to the parent pad.
Normal fNormal
The normalized coordinate summand.
std::unique_ptr< TFrame > fFrame
TFrame with user coordinate system, if used by this pad.
virtual const TCanvas & GetCanvas() const =0
Access to the top-most canvas, if any (const version).
void Wipe()
Remove an object from the list of primitives.
const TPadExtent & GetSize() const
Get the size of the pad in parent (!) coordinates.
Primitives_t fPrimitives
Content of the pad.
A position (horizontal and vertical) in a TPad.
Base class for graphic containers for TDrawable-s.
const Primitives_t & GetPrimitives() const
Get the elements contained in the canvas.
TPadDrawingOpts(TPadBase &parent)
auto & Draw(const std::shared_ptr< T > &what)
Add something to be painted.
auto & Draw(std::unique_ptr< T > &&what)
Add something to be painted. The pad claims ownership.
TCanvas & GetCanvas() override
Access to the top-most canvas (non-const version).
Pixel fPixel
The pixel coordinate summand.
const TCanvas & GetCanvas() const override
Access to the top-most canvas (const version).
std::array< TPadCoord::Normal, 2 > UserToNormal(const std::array< TPadCoord::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
const TPadBase & GetParent() const
Access to the parent pad (const version).
The most important graphics class in the ROOT system.
auto & AddDrawable(std::unique_ptr< DRAWABLE > &&uPtr)
Adds a DRAWABLE to fPrimitives, returning the drawing options as given by DRAWABLE::Options().
std::vector< std::unique_ptr< TDrawable > > Primitives_t
Abstract interface for painting a canvas.
TPadDrawingOpts & GetOptions()
Drawing options.
std::array< TPadCoord::Normal, 2 > ToNormal(const Internal::TPadHorizVert &pos) const
Convert a TPadPos to [x, y] of normalized coordinates.
TPadCoord fVert
Vertical position.
Binding & operator=(OUT(*fun)(void))
An extent / size (horizontal and vertical) in a TPad.
User fUser
The user coordinate summand.
TPadCoord fHoriz
Horizontal position.
TPadBase & GetParent()
Access to the parent pad (non-const version).
void Paint(Internal::TVirtualCanvasPainter &) final
Paint the pad.
std::unique_ptr< TPadDrawable > GetDrawable(std::unique_ptr< TPad > &&pad, TPadBase &parent)
const std::unique_ptr< TPad > fPad
The pad to be painted.
Graphic container for TDrawable-s.
TPadDrawingOpts fOpts
The drawing options.
A 2D (horizontal and vertical) combination of TPadCoords.