Logo ROOT   master
Reference Guide
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/RMenuItems.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>
36 }
37 
38 template <int DIMENSIONS>
39 class RHistDrawable : public RDrawable {
40 public:
42 
43 private:
44  Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
45 
46 protected:
47 
48  void CollectShared(Internal::RIOSharedVector_t &vect) override { vect.emplace_back(&fHistImpl); }
49 
50  bool IsFrameRequired() const final { return true; }
51 
52  void PopulateMenu(RMenuItems &) override
53  {
54  // populate menu
55  }
56 
57 public:
58  RHistDrawable();
59  virtual ~RHistDrawable() = default;
60 
61  template <class HIST>
62  RHistDrawable(const std::shared_ptr<HIST> &hist) : RHistDrawable()
63  {
64  fHistImpl = std::shared_ptr<HistImpl_t>(hist, hist->GetImpl());
65  }
66 
67  std::shared_ptr<HistImpl_t> GetHist() const { return fHistImpl.get_shared(); }
68 
69 // template <class HIST>
70 // RHistDrawable(std::unique_ptr<HIST> &&hist)
71 // : fHistImpl(std::unique_ptr<HistImpl_t>(std::move(*hist).TakeImpl())), fOpts(opts)
72 // {}
73 
74 };
75 
76 template <int DIMENSIONS> inline RHistDrawable<DIMENSIONS>::RHistDrawable() : RDrawable("hist") {}
77 
78 
79 class RHist1Drawable final : public RHistDrawable<1> {
80 private:
81  RAttrLine fAttrLine{this, "line_"}; ///<! line attributes
82 
83 public:
84  RHist1Drawable() = default;
85 
86  template <class HIST>
87  RHist1Drawable(const std::shared_ptr<HIST> &hist) : RHistDrawable<1>(hist) {}
88 
89  const RAttrLine &GetAttrLine() const { return fAttrLine; }
90  RHistDrawable &SetAttrLine(const RAttrLine &attr) { fAttrLine = attr; return *this; }
91  RAttrLine &AttrLine() { return fAttrLine; }
92 };
93 
94 
95 class RHist2Drawable final : public RHistDrawable<2> {
96 public:
97  RHist2Drawable() = default;
98 
99  template <class HIST>
100  RHist2Drawable(const std::shared_ptr<HIST> &hist) : RHistDrawable<2>(hist) {}
101 };
102 
103 
104 
105 inline auto GetDrawable(const std::shared_ptr<RH1D> &histimpl)
106 {
107  return std::make_shared<RHist1Drawable>(histimpl);
108 }
109 
110 inline auto GetDrawable(const std::shared_ptr<RH1I> &histimpl)
111 {
112  return std::make_shared<RHist1Drawable>(histimpl);
113 }
114 
115 inline auto GetDrawable(const std::shared_ptr<RH1C> &histimpl)
116 {
117  return std::make_shared<RHist1Drawable>(histimpl);
118 }
119 
120 inline auto GetDrawable(const std::shared_ptr<RH1F> &histimpl)
121 {
122  return std::make_shared<RHist1Drawable>(histimpl);
123 }
124 
125 inline auto GetDrawable(const std::shared_ptr<RH2D> &histimpl)
126 {
127  return std::make_shared<RHist2Drawable>(histimpl);
128 }
129 
130 inline auto GetDrawable(const std::shared_ptr<RH2I> &histimpl)
131 {
132  return std::make_shared<RHistDrawable<2>>(histimpl);
133 }
134 
135 inline auto GetDrawable(const std::shared_ptr<RH2C> &histimpl)
136 {
137  return std::make_shared<RHistDrawable<2>>(histimpl);
138 }
139 
140 inline auto GetDrawable(const std::shared_ptr<RH2F> &histimpl)
141 {
142  return std::make_shared<RHistDrawable<2>>(histimpl);
143 }
144 
145 inline auto GetDrawable(const std::shared_ptr<RH3D> &histimpl)
146 {
147  return std::make_shared<RHistDrawable<3>>(histimpl);
148 }
149 
150 inline auto GetDrawable(const std::shared_ptr<RH3I> &histimpl)
151 {
152  return std::make_shared<RHistDrawable<3>>(histimpl);
153 }
154 
155 inline auto GetDrawable(const std::shared_ptr<RH3C> &histimpl)
156 {
157  return std::make_shared<RHistDrawable<3>>(histimpl);
158 }
159 
160 inline auto GetDrawable(const std::shared_ptr<RH3F> &histimpl)
161 {
162  return std::make_shared<RHistDrawable<3>>(histimpl);
163 }
164 
165 } // namespace Experimental
166 } // namespace ROOT
167 
168 #endif
Internal::RIOShared< HistImpl_t > fHistImpl
I/O capable reference on histogram.
const RAttrLine & GetAttrLine() const
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:102
Base class for RHistImplBase that abstracts out the histogram&#39;s PRECISION.
Returns the available number of logical cores.
Definition: RNumpyDS.hxx:30
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a valu...
RHist1Drawable(const std::shared_ptr< HIST > &hist)
Drawing line attributes for different objects.
Definition: RAttrLine.hxx:26
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition: RDrawable.hxx:51
void CollectShared(Internal::RIOSharedVector_t &vect) override
void PopulateMenu(RMenuItems &) override
RHistDrawable & SetAttrLine(const RAttrLine &attr)
List of items for object context menu.
Definition: RMenuItems.hxx:153
auto GetDrawable(const std::shared_ptr< RH3F > &histimpl)
RHist2Drawable(const std::shared_ptr< HIST > &hist)
std::shared_ptr< HistImpl_t > GetHist() const
RHistDrawable(const std::shared_ptr< HIST > &hist)