32namespace Experimental {
61 template <
class DRAWABLE>
68 using Options_t =
typename std::remove_reference<
decltype(uPtr->GetOptions())>
::type;
69 auto spDrawable = std::static_pointer_cast<DRAWABLE>(
fPrimitives.back());
72 return std::shared_ptr<Options_t>(spDrawable, &spDrawable->GetOptions());
87 std::vector<std::vector<RPad *>>
Divide(
int nHoriz,
int nVert,
const RPadExtent &padding = {});
92 template <
class T,
class...
ARGS>
93 auto Draw(
const std::shared_ptr<T> &what,
ARGS... args)
101 template <
class T,
class...
ARGS>
110 template <
class T,
class...
ARGS,
class =
typename std::enable_if<!ROOT::TypeTraits::IsSmartOrDumbPtr<T>::value>
::type>
114 return Draw(std::make_unique<T>(what), args...);
120 [&opts](
const std::shared_ptr<RDrawable>& drawable) { return &drawable->GetOptionsBase() == &opts; });
127 std::shared_ptr<RDrawable>
FindDrawable(
const std::string &
id)
const;
147 void SetAllAxisBounds(
const std::vector<std::array<double, 2>> &vecBeginAndEnd);
154 void SetAllAxisBound(
const std::vector<BoundKindAndValue> &vecBoundAndKind);
161 virtual std::array<RPadLength::Normal, 2>
PixelsToNormal(
const std::array<RPadLength::Pixel, 2> &pos)
const = 0;
170 std::array<RPadLength::Normal, 2>
UserToNormal(
const std::array<RPadLength::User, 2> &pos)
const
172 return fFrame->UserToNormal(pos);
224 friend std::unique_ptr<RPadDrawable>
GetDrawable(std::unique_ptr<RPad> &&pad);
257 std::array<RPadLength::Normal, 2>
PixelsToNormal(
const std::array<RPadLength::Pixel, 2> &pos)
const override
260 std::array<RPadLength::Normal, 2> myPixelInNormal =
262 std::array<RPadLength::Normal, 2> myUserInNormal =
266 return {{posInParentNormal[0] / (
fSize.
fHoriz.
fNormal + myPixelInNormal[0] + myUserInNormal[0]),
267 posInParentNormal[1] / (
fSize.
fVert.
fNormal + myPixelInNormal[1] + myUserInNormal[1])}};
275 return {{pos.
fHoriz.
fNormal + pixelsInNormal[0] + userInNormal[0],
276 pos.
fVert.
fNormal + pixelsInNormal[1] + userInNormal[1]}};
285 const std::shared_ptr<RPad>
fPad;
300template <
class...
ARGS>
301inline std::shared_ptr<RPadDrawable>
GetDrawable(std::unique_ptr<RPad> &&pad,
ARGS... args)
303 return std::make_shared<RPadDrawable>(std::move(pad),
RPad::DrawingOpts(args...));
306template <
class...
ARGS>
307inline std::shared_ptr<RPadDrawable>
GetDrawable(
const std::shared_ptr<RPad> &pad,
ARGS... args)
Abstract interface for object painting on the pad/canvas.
class ROOT::Experimental::RAttrBox Drawing attributes for a box: rectangular lines with size and posi...
A collection of graphics attributes, for instance everything describing a line: color,...
void Set(const Name &name, const T &val)
Insert or update the attribute value identified by name to the given value.
static constexpr const FromOption_t FromOption
Holds a user coordinate system with a palette.
Base class for graphic containers for RDrawable-s.
RPadBase & operator=(const RPadBase &)=delete
Disable assignment.
RPadBase(const RPadBase &)=delete
Disable copy construction.
const RFrame * GetFrame() const
virtual std::array< RPadLength::Normal, 2 > PixelsToNormal(const std::array< RPadLength::Pixel, 2 > &pos) const =0
Convert a Pixel position to Canvas-normalized positions.
std::array< RPadLength::Normal, 2 > UserToNormal(const std::array< RPadLength::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
void CreateFrameIfNeeded()
Primitives_t fPrimitives
Content of the pad.
auto Draw(const T &what, ARGS... args)
Add a copy of something to be painted.
std::vector< std::shared_ptr< RDrawable > > Primitives_t
void SetAllAxisBound(const std::vector< BoundKindAndValue > &vecBoundAndKind)
Set the range of an axis as bound kind and bound (up or down).
void SetAxisBounds(int dimension, double begin, double end)
Set the range of an axis as begin, end.
virtual const RCanvas * GetCanvas() const =0
Access to the top-most canvas, if any (const version).
void SetAllAxisAutoBounds()
Set the range of an axis as bound kind and bound (up or down).
bool Remove(RDrawingOptsBase &opts)
Remove an object from the list of primitives.
void SetAxisBound(int dimension, RPadUserAxisBase::EAxisBoundsKind boundsKind, double bound)
Set the range of an axis as bound kind and bound (up or down).
std::unique_ptr< RFrame > fFrame
RFrame with user coordinate system, if used by this pad.
const Primitives_t & GetPrimitives() const
Get the elements contained in the canvas.
void SetAllAxisBounds(const std::vector< std::array< double, 2 > > &vecBeginAndEnd)
Set the range of an axis as bound kind and bound (up or down).
auto Draw(std::unique_ptr< T > &&what, ARGS... args)
Add something to be painted.
virtual RCanvas * GetCanvas()=0
Access to the top-most canvas, if any (non-const version).
RPadUserAxisBase * GetAxis(size_t dimension) const
Get a pad axis from the RFrame.
RPadUserAxisBase * GetOrCreateAxis(size_t dimension)
Get a pad axis from the RFrame.
RFrame * GetOrCreateFrame()
void AssignUniqueID(std::shared_ptr< RDrawable > &ptr)
auto Draw(const std::shared_ptr< T > &what, ARGS... args)
Add something to be painted.
void Wipe()
Wipe the pad by clearing the list of primitives.
void SetAxisAutoBounds(int dimension)
Set the range of an axis as bound kind and bound (up or down).
auto AddDrawable(std::shared_ptr< DRAWABLE > &&uPtr)
Adds a DRAWABLE to fPrimitives, returning a shared_ptr to DRAWABLE::GetOptions().
RPadBase()=default
Allow derived classes to default construct a RPadBase.
std::vector< std::vector< RPad * > > Divide(int nHoriz, int nVert, const RPadExtent &padding={})
Divide this pad into a grid of subpads with padding in between.
std::shared_ptr< RDrawable > FindDrawable(const std::string &id) const
Draw a RPad, by drawing its contained graphical elements at the pad offset in the parent pad.
void Paint(Internal::RPadPainter &) final
Paint primitives from the pad.
RPadDrawable(const std::shared_ptr< RPad > &pPad, const RPad::DrawingOpts &opts={})
Move a sub-pad into this (i.e. parent's) list of drawables.
const std::shared_ptr< RPad > fPad
The pad to be painted.
RPad::DrawingOpts & GetOptions()
Drawing options.
Pixel fPixel
The pixel coordinate summand.
User fUser
The user coordinate summand.
Normal fNormal
The normalized coordinate summand.
EAxisBoundsKind
Types of axis bounds to respect by the painter.
@ kAxisBoundsAuto
no defined axis range; the painter will decide
Drawing options for a RPad.
RPadExtent GetSize() const
DrawingOpts(const RPadPos &pos, const RPadExtent &size)
DrawingOpts & SetPos(const RPadPos &pos)
The position (offset) of the pad.
DrawingOpts & SetSize(const RPadExtent &size)
The size of the pad.
Graphic container for RDrawable-s.
const RPadExtent & GetSize() const
Get the size of the pad in parent (!) coordinates.
const RCanvas * GetCanvas() const override
Access to the top-most canvas (const version).
const RPadBase * GetParent() const
Access to the parent pad (const version).
RCanvas * GetCanvas() override
Access to the top-most canvas (non-const version).
friend std::unique_ptr< RPadDrawable > GetDrawable(std::unique_ptr< RPad > &&pad)
virtual ~RPad()
Destructor to have a vtable.
RPadBase * GetParent()
Access to the parent pad (non-const version).
DrawingOpts & GetDrawingOpts()
Drawing options.
RPadPos fPos
Position of the pad in the parent's (!) coordinate system.
std::array< RPadLength::Normal, 2 > PixelsToNormal(const std::array< RPadLength::Pixel, 2 > &pos) const override
Convert a Pixel position to Canvas-normalized positions.
RPad(RPadBase &parent, const RPadPos &pos, const RPadExtent &size)
Create a child pad.
DrawingOpts fOpts
The parent pad, if this pad has one.
RPadBase * fParent
Pad containing this pad as a sub-pad.
std::array< RPadLength::Normal, 2 > ToNormal(const Internal::RPadHorizVert &pos) const
Convert a RPadPos to [x, y] of normalized coordinates.
RPad()=default
Create a topmost, non-paintable pad.
const RPadPos & GetPos() const
Get the position of the pad in parent (!) coordinates.
RPadExtent fSize
Size of the pad in the parent's (!) coordinate system.
std::shared_ptr< RPadDrawable > GetDrawable(std::unique_ptr< RPad > &&pad, ARGS... args)
Namespace for new ROOT classes and functions.
A 2D (horizontal and vertical) combination of RPadLengths.
RPadLength fHoriz
Horizontal position.
RPadLength fVert
Vertical position.
Simple struct representing an axis bound.
RPadUserAxisBase::EAxisBoundsKind fKind
An extent / size (horizontal and vertical) in a RPad.
A position (horizontal and vertical) in a RPad.