Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RHistDrawable.hxx
Go to the documentation of this file.
1 /// \file ROOT/RHistDrawable.h
2 /// \ingroup HistDraw ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2015-07-09
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_RHistDrawable
17 #define ROOT7_RHistDrawable
18 
19 #include <ROOT/RDrawable.hxx>
20 #include <ROOT/RAttrLine.hxx>
21 #include <ROOT/RHist.hxx>
22 #include <ROOT/RHistImpl.hxx>
23 #include <ROOT/RMenuItem.hxx>
24 
25 #include <memory>
26 
27 namespace ROOT {
28 namespace Experimental {
29 
30 template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
31 class RHist;
32 
33 namespace Detail {
34 template <int DIMENSIONS>
35 class RHistImplPrecisionAgnosticBase;
36 }
37 
38 template <int DIMENSIONS>
39 class RHistDrawable final: public RDrawable {
40 public:
41  using HistImpl_t = Detail::RHistImplPrecisionAgnosticBase<DIMENSIONS>;
42 
43 private:
44  Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
45 
46  RAttrLine fAttrLine{this, "line_"}; ///<! line attributes
47 
48 protected:
49 
50  void CollectShared(Internal::RIOSharedVector_t &vect) final { vect.emplace_back(&fHistImpl); }
51 
52 public:
53  RHistDrawable();
54  virtual ~RHistDrawable() = default;
55 
56  template <class HIST>
57  RHistDrawable(const std::shared_ptr<HIST> &hist) : RHistDrawable()
58  {
59  fHistImpl = std::shared_ptr<HistImpl_t>(hist, hist->GetImpl());
60  }
61 
62  const RAttrLine &GetAttrLine() const { return fAttrLine; }
63  RHistDrawable &SetAttrLine(const RAttrLine &attr) { fAttrLine = attr; return *this; }
64  RAttrLine &AttrLine() { return fAttrLine; }
65 
66  std::shared_ptr<HistImpl_t> GetHist() const { return fHistImpl.get_shared(); }
67 
68  void PopulateMenu(RMenuItems &) final
69  {
70  // populate menu
71  }
72 
73  void Execute(const std::string &) final
74  {
75  // should execute menu item
76  }
77 
78 // template <class HIST>
79 // RHistDrawable(std::unique_ptr<HIST> &&hist)
80 // : fHistImpl(std::unique_ptr<HistImpl_t>(std::move(*hist).TakeImpl())), fOpts(opts)
81 // {}
82 
83 };
84 
85 template <int DIMENSIONS> inline RHistDrawable<DIMENSIONS>::RHistDrawable() : RDrawable("hist") {}
86 
87 inline auto GetDrawable(const std::shared_ptr<RH1D> &histimpl)
88 {
89  return std::make_shared<RHistDrawable<1>>(histimpl);
90 }
91 
92 inline auto GetDrawable(const std::shared_ptr<RH1I> &histimpl)
93 {
94  return std::make_shared<RHistDrawable<1>>(histimpl);
95 }
96 
97 inline auto GetDrawable(const std::shared_ptr<RH1C> &histimpl)
98 {
99  return std::make_shared<RHistDrawable<1>>(histimpl);
100 }
101 
102 inline auto GetDrawable(const std::shared_ptr<RH1F> &histimpl)
103 {
104  return std::make_shared<RHistDrawable<1>>(histimpl);
105 }
106 
107 inline auto GetDrawable(const std::shared_ptr<RH2D> &histimpl)
108 {
109  return std::make_shared<RHistDrawable<2>>(histimpl);
110 }
111 
112 inline auto GetDrawable(const std::shared_ptr<RH2I> &histimpl)
113 {
114  return std::make_shared<RHistDrawable<2>>(histimpl);
115 }
116 
117 inline auto GetDrawable(const std::shared_ptr<RH2C> &histimpl)
118 {
119  return std::make_shared<RHistDrawable<2>>(histimpl);
120 }
121 
122 inline auto GetDrawable(const std::shared_ptr<RH2F> &histimpl)
123 {
124  return std::make_shared<RHistDrawable<2>>(histimpl);
125 }
126 
127 inline auto GetDrawable(const std::shared_ptr<RH3D> &histimpl)
128 {
129  return std::make_shared<RHistDrawable<3>>(histimpl);
130 }
131 
132 inline auto GetDrawable(const std::shared_ptr<RH3I> &histimpl)
133 {
134  return std::make_shared<RHistDrawable<3>>(histimpl);
135 }
136 
137 inline auto GetDrawable(const std::shared_ptr<RH3C> &histimpl)
138 {
139  return std::make_shared<RHistDrawable<3>>(histimpl);
140 }
141 
142 inline auto GetDrawable(const std::shared_ptr<RH3F> &histimpl)
143 {
144  return std::make_shared<RHistDrawable<3>>(histimpl);
145 }
146 
147 } // namespace Experimental
148 } // namespace ROOT
149 
150 #endif