File indexing completed on 2025-01-18 10:10:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_RPadDisplayItem
0010 #define ROOT7_RPadDisplayItem
0011
0012 #include <ROOT/RDisplayItem.hxx>
0013 #include <ROOT/RPad.hxx>
0014 #include "ROOT/RStyle.hxx"
0015
0016 namespace ROOT {
0017 namespace Experimental {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 class RPadBaseDisplayItem : public RDisplayItem {
0029 public:
0030
0031 using PadPrimitives_t = std::vector<std::unique_ptr<RDisplayItem>>;
0032
0033 protected:
0034 const RAttrMap *fAttr{nullptr};
0035 PadPrimitives_t fPrimitives;
0036 std::vector<std::shared_ptr<RStyle>> fStyles;
0037 public:
0038 RPadBaseDisplayItem() = default;
0039 ~RPadBaseDisplayItem() override = default;
0040 void SetAttributes(const RAttrMap *f) { fAttr = f; }
0041
0042 void Add(std::unique_ptr<RDisplayItem> &&item, std::shared_ptr<RStyle> &&style)
0043 {
0044 if (style) {
0045 item->SetStyle(style.get());
0046 fStyles.emplace_back(std::move(style));
0047 }
0048 fPrimitives.push_back(std::move(item));
0049 }
0050
0051 void SetPadStyle(std::shared_ptr<RStyle> &&style)
0052 {
0053 if (style) {
0054 SetStyle(style.get());
0055 fStyles.emplace_back(std::move(style));
0056 }
0057 }
0058 };
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 class RPadDisplayItem : public RPadBaseDisplayItem {
0069
0070 protected:
0071 const RPadPos *fPos{nullptr};
0072 const RPadExtent *fSize{nullptr};
0073 public:
0074 RPadDisplayItem() = default;
0075 ~RPadDisplayItem() override {}
0076 void SetPadPosSize(const RPadPos *pos, const RPadExtent *size) { fPos = pos; fSize = size; }
0077
0078 void BuildFullId(const std::string &prefix) override
0079 {
0080 RDisplayItem::BuildFullId(prefix);
0081 std::string subprefix = prefix + std::to_string(GetIndex()) + "_";
0082 for (auto &item : fPrimitives)
0083 item->BuildFullId(subprefix);
0084 }
0085 };
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 class RCanvasDisplayItem : public RPadBaseDisplayItem {
0097
0098 protected:
0099 std::string fTitle;
0100 std::array<int, 2> fWinSize;
0101 public:
0102 RCanvasDisplayItem() = default;
0103 ~RCanvasDisplayItem() override = default;
0104 void SetTitle(const std::string &title) { fTitle = title; }
0105 void SetWindowSize(int width, int height) { fWinSize[0] = width; fWinSize[1] = height; }
0106
0107 void BuildFullId(const std::string &prefix) override
0108 {
0109 for (auto &item : fPrimitives)
0110 item->BuildFullId(prefix);
0111 }
0112 };
0113
0114
0115
0116 }
0117 }
0118
0119 #endif