21using namespace std::string_literals;
32 drawable->UseStyle(
style);
40 for (
auto &drawable : fPrimitives) {
42 if (drawable->GetId() ==
id)
43 return drawable.get_shared();
64 auto p =
id.find(
"_");
65 if (p == std::string::npos)
68 auto prim = GetPrimitive(std::stoul(
id.substr(0,p)));
72 auto subid =
id.substr(p+1);
77 auto subpad = std::dynamic_pointer_cast<RPadBase>(prim);
79 return subpad ? subpad->FindPrimitiveByDisplayId(subid) :
nullptr;
87 auto p =
id.find(
"_");
88 if (p == std::string::npos)
91 auto prim = GetPrimitive(std::stoul(
id.substr(0,p)));
95 auto subid =
id.substr(p+1);
100 auto subpad = std::dynamic_pointer_cast<RPadBase>(prim);
102 return subpad ? subpad->FindPadForPrimitiveWithDisplayId(subid) :
nullptr;
113 for (
auto &drawable : fPrimitives) {
114 for (
auto &attr: drawable->fAttr) {
116 if (!attr.second->GetBool())
continue;
117 auto pos = attr.first.rfind(
"_color_auto");
118 if ((pos > 0) && (pos == attr.first.length() - 11)) {
125 drawable->fAttr.AddString(attr.first.substr(0,pos) +
"_color_rgb", col.
AsHex());
143 for (
auto &drawable : fPrimitives) {
147 auto item = drawable->Display(ctxt);
150 item = std::make_unique<RDisplayItem>(
true);
152 item->SetObjectIDAsPtr(drawable.get());
155 paditem.
Add(std::move(item), drawable->fStyle.lock());
163std::vector<std::vector<std::shared_ptr<ROOT::Experimental::RPad>>>
166 std::vector<std::vector<std::shared_ptr<RPad>>> ret;
171 if (!nHoriz || !nVert)
177 offset = (offset + padding);
178 offset *= {1. / nHoriz, 1. / nVert};
181 for (
int iHoriz = 0; iHoriz < nHoriz; ++iHoriz) {
183 for (
int iVert = 0; iVert < nVert; ++iVert) {
185 subPos *= {1. * iHoriz, 1. * iVert};
187 auto subpad = Draw<RPad>(
this, subPos, size);
189 ret.back().emplace_back(subpad);
203 auto frame = GetFrame();
205 frame.reset(
new RFrame());
206 fPrimitives.emplace_back(frame);
217 for (
auto &drawable : fPrimitives) {
218 if (drawable->GetCssType() ==
"frame") {
219 const std::shared_ptr<RFrame> frame = std::dynamic_pointer_cast<RFrame>(drawable.get_shared());
220 if (frame)
return frame;
231 for (
auto &drawable : fPrimitives) {
232 if (drawable->GetCssType() ==
"frame") {
233 std::shared_ptr<RFrame> frame = std::dynamic_pointer_cast<RFrame>(drawable.get_shared());
234 if (frame)
return frame;
246 auto frame = GetFrame();
248 if (frame && dimension < frame->GetNDimensions())
249 return &frame->GetUserAxis(dimension);
259 auto frame = GetOrCreateFrame();
260 frame->GrowToDimensions(dimension);
261 return &frame->GetUserAxis(dimension);
269 GetOrCreateFrame()->GrowToDimensions(dimension);
270 GetAxis(dimension)->SetBounds(begin, end);
278 GetOrCreateFrame()->GrowToDimensions(dimension);
279 GetAxis(dimension)->SetBound(boundsKind, bound);
287 GetOrCreateFrame()->GrowToDimensions(dimension);
288 GetAxis(dimension)->SetAutoBounds();
296 auto frame = GetOrCreateFrame();
298 frame->GrowToDimensions(vecBeginAndEnd.size());
299 if (vecBeginAndEnd.size() != frame->GetNDimensions()) {
301 <<
"Array of axis bound has wrong size " << vecBeginAndEnd.size()
302 <<
" versus numer of axes in frame " << frame->GetNDimensions();
306 for (
size_t i = 0,
n = frame->GetNDimensions(); i <
n; ++i)
307 frame->GetUserAxis(i).SetBounds(vecBeginAndEnd[i][0], vecBeginAndEnd[i][1]);
315 auto frame = GetOrCreateFrame();
317 frame->GrowToDimensions(vecBoundAndKind.size());
318 if (vecBoundAndKind.size() != frame->GetNDimensions()) {
320 <<
"Array of axis bound has wrong size " << vecBoundAndKind.size()
321 <<
" versus numer of axes in frame " << frame->GetNDimensions();
325 for (
size_t i = 0,
n = frame->GetNDimensions(); i <
n; ++i)
326 frame->GetUserAxis(i).SetBound(vecBoundAndKind[i].fKind, vecBoundAndKind[i].fBound);
334 for (
auto &handle : fPrimitives) {
335 vect.emplace_back(&handle);
336 auto drawable = handle.get();
337 if (drawable) drawable->CollectShared(vect);
346 auto frame = GetOrCreateFrame();
348 for (
size_t i = 0,
n = frame->GetNDimensions(); i <
n; ++i)
349 frame->GetUserAxis(i).SetAutoBounds();
357 auto frame = GetFrame();
358 if (!frame)
return {};
360 return frame->UserToNormal(pos);
370 for (
auto &drawable : fPrimitives)
371 drawable->SetDrawableVersion(vers);
#define R__LOG_ERROR(...)
static R__DLLEXPORT constexpr RGB_t kRed
static R__DLLEXPORT constexpr RGB_t kGreen
static R__DLLEXPORT constexpr RGB_t kBlue
std::string AsHex(bool with_alpha=false) const
Returns color value in hex format like "66FF66" - without any prefix Alpha parameter can be optionall...
static std::string ObjectIDFromPtr(const void *ptr)
Construct fillid using pointer value.
void SetDrawable(RDrawable *dr, unsigned indx)
Set drawable and its index in list of primitives.
unsigned GetIndex() const
virtual void SetDrawableVersion(Version_t vers)
virtual void UseStyle(const std::shared_ptr< RStyle > &style)
Holds an area where drawing on user coordinate-system can be performed.
class RPadBaseDisplayItem
void SetPadStyle(std::shared_ptr< RStyle > &&style)
Assign style for the pad.
void Add(std::unique_ptr< RDisplayItem > &&item, std::shared_ptr< RStyle > &&style)
Add display item and style which should be used for it.
void SetAttributes(const RAttrMap *f)
Base class for graphic containers for RDrawable-s.
std::shared_ptr< RFrame > GetFrame()
Get a frame object if exists.
std::array< RPadLength::Normal, 2 > UserToNormal(const std::array< RPadLength::User, 2 > &pos) const
Convert user coordinates to normal coordinates.
std::shared_ptr< RFrame > GetOrCreateFrame()
Get a frame object for the pad.
void DisplayPrimitives(RPadBaseDisplayItem &paditem, RDisplayContext &ctxt)
Create display items for all primitives in the pad Each display item gets its special id,...
void UseStyle(const std::shared_ptr< RStyle > &style) override
Use provided style for pad and all primitives inside.
void CollectShared(Internal::RIOSharedVector_t &) override
Collect all shared items to resolve shared_ptr after IO.
std::vector< std::vector< std::shared_ptr< RPad > > > Divide(int nHoriz, int nVert, const RPadExtent &padding={})
Divide this pad into a grid of subpads with padding in between.
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.
void SetAllAxisAutoBounds()
Set the range of an axis as bound kind and bound (up or down).
void SetDrawableVersion(Version_t vers) override
Assign drawable version - for pad itself and all 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::vector< Primitive_t > fPrimitives
Content of the pad.
void SetAllAxisBounds(const std::vector< std::array< double, 2 > > &vecBeginAndEnd)
Set the range of an axis as bound kind and bound (up or down).
RPadUserAxisBase * GetAxis(size_t dimension) const
Get a pad axis from the RFrame.
void AssignAutoColors()
Method collect existing colors and assign new values if required.
RPadUserAxisBase * GetOrCreateAxis(size_t dimension)
Get a pad axis from the RFrame.
std::shared_ptr< RDrawable > FindPrimitiveByDisplayId(const std::string &display_id) const
Find primitive with unique id, produce for RDisplayItem Such id used for client-server identification...
void SetAxisAutoBounds(int dimension)
Set the range of an axis as bound kind and bound (up or down).
std::shared_ptr< RDrawable > FindPrimitive(const std::string &id) const
Find primitive with specified id.
const RPadBase * FindPadForPrimitiveWithDisplayId(const std::string &display_id) const
Find subpad which contains primitive with given display id.
An extent / size (horizontal and vertical) in a RPad.
A position (horizontal and vertical) in a RPad.
Base class for user coordinates (e.g.
EAxisBoundsKind
Types of axis bounds to respect by the painter.
std::vector< RIOSharedBase * > RIOSharedVector_t
RLogChannel & GPadLog()
Log channel for GPad diagnostics.