Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RPadDisplayItem.hxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2017, 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_RPadDisplayItem
10 #define ROOT7_RPadDisplayItem
11 
12 #include <ROOT/RDisplayItem.hxx>
13 #include <ROOT/RFrame.hxx>
14 #include <ROOT/RPad.hxx>
15 #include "ROOT/RStyle.hxx"
16 
17 namespace ROOT {
18 namespace Experimental {
19 
20 
21 /** class RPadBaseDisplayItem
22 \ingroup GpadROOT7
23 \brief Display item for the RPadBase class, includes primitives, attributes and frame
24 \author Sergey Linev
25 \date 2017-05-31
26 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
27 */
28 
29 class RPadBaseDisplayItem : public RDisplayItem {
30 public:
31  // list of snapshot for primitives in pad
32  using PadPrimitives_t = std::vector<std::unique_ptr<RDisplayItem>>;
33 
34 protected:
35  const RFrame *fFrame{nullptr}; ///< temporary pointer on frame object
36  const RAttrMap *fAttr{nullptr}; ///< temporary pointer on attributes
37  PadPrimitives_t fPrimitives; ///< display items for all primitives in the pad
38  std::vector<std::shared_ptr<RStyle>> fStyles; ///<! locked styles of the objects and pad until streaming is performed
39 public:
40  RPadBaseDisplayItem() = default;
41  virtual ~RPadBaseDisplayItem() = default;
42  void SetFrame(const RFrame *f) { fFrame = f; }
43  void SetAttributes(const RAttrMap *f) { fAttr = f; }
44  /// Add display item and style which should be used for it
45  void Add(std::unique_ptr<RDisplayItem> &&item, std::shared_ptr<RStyle> &&style)
46  {
47  if (style) {
48  item->SetStyle(style.get());
49  fStyles.emplace_back(std::move(style));
50  }
51  fPrimitives.push_back(std::move(item));
52  }
53  /// Assign style for the pad
54  void SetPadStyle(std::shared_ptr<RStyle> &&style)
55  {
56  if (style) {
57  SetStyle(style.get());
58  fStyles.emplace_back(std::move(style));
59  }
60  }
61 };
62 
63 /** class RPadDisplayItem
64 \ingroup GpadROOT7
65 \brief Display item for the RPad class, add pad position and size
66 \author Sergey Linev
67 \date 2017-05-31
68 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
69 */
70 
71 class RPadDisplayItem : public RPadBaseDisplayItem {
72 
73 protected:
74  const RPadPos *fPos{nullptr}; ///< pad position
75  const RPadExtent *fSize{nullptr}; ///< pad size
76 public:
77  RPadDisplayItem() = default;
78  virtual ~RPadDisplayItem() {}
79  void SetPadPosSize(const RPadPos *pos, const RPadExtent *size) { fPos = pos; fSize = size; }
80 
81  void BuildFullId(const std::string &prefix) override
82  {
83  RDisplayItem::BuildFullId(prefix);
84  std::string subprefix = prefix + std::to_string(GetIndex()) + "_";
85  for (auto &item : fPrimitives)
86  item->BuildFullId(subprefix);
87  }
88 };
89 
90 
91 /** class RCanvasDisplayItem
92 \ingroup GpadROOT7
93 \brief Display item for the RCanvas class, add canvas title and size
94 \author Sergey Linev
95 \date 2017-05-31
96 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
97 */
98 
99 class RCanvasDisplayItem : public RPadBaseDisplayItem {
100 
101 protected:
102  std::string fTitle; ///< title of the canvas
103  std::array<int, 2> fWinSize; ///< canvas window size
104 public:
105  RCanvasDisplayItem() = default;
106  virtual ~RCanvasDisplayItem() = default;
107  void SetTitle(const std::string &title) { fTitle = title; }
108  void SetWindowSize(const std::array<RPadLength::Pixel, 2> &win) { fWinSize[0] = (int) win[0].fVal; fWinSize[1] = (int) win[1].fVal; }
109 
110  void BuildFullId(const std::string &prefix) override
111  {
112  for (auto &item : fPrimitives)
113  item->BuildFullId(prefix);
114  }
115 };
116 
117 
118 
119 } // Experimental
120 } // ROOT
121 
122 #endif