Logo ROOT  
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
27namespace ROOT {
28namespace Experimental {
29
30template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
31class RHist;
32
33namespace Detail {
34template <int DIMENSIONS>
35class RHistImplPrecisionAgnosticBase;
36}
37
38template <int DIMENSIONS>
39class RHistDrawable : public RDrawable {
40public:
42
43private:
44 Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
45
46protected:
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
57public:
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
76template <int DIMENSIONS> inline RHistDrawable<DIMENSIONS>::RHistDrawable() : RDrawable("hist") {}
77
78
79class RHist1Drawable final : public RHistDrawable<1> {
80private:
81 RAttrLine fAttrLine{this, "line_"}; ///<! line attributes
82
83public:
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; }
92};
93
94
95class RHist2Drawable final : public RHistDrawable<2> {
96public:
97 RHist2Drawable() = default;
98
99 template <class HIST>
100 RHist2Drawable(const std::shared_ptr<HIST> &hist) : RHistDrawable<2>(hist) {}
101};
102
103
104
105inline auto GetDrawable(const std::shared_ptr<RH1D> &histimpl)
106{
107 return std::make_shared<RHist1Drawable>(histimpl);
108}
109
110inline auto GetDrawable(const std::shared_ptr<RH1I> &histimpl)
111{
112 return std::make_shared<RHist1Drawable>(histimpl);
113}
114
115inline auto GetDrawable(const std::shared_ptr<RH1C> &histimpl)
116{
117 return std::make_shared<RHist1Drawable>(histimpl);
118}
119
120inline auto GetDrawable(const std::shared_ptr<RH1F> &histimpl)
121{
122 return std::make_shared<RHist1Drawable>(histimpl);
123}
124
125inline auto GetDrawable(const std::shared_ptr<RH2D> &histimpl)
126{
127 return std::make_shared<RHist2Drawable>(histimpl);
128}
129
130inline auto GetDrawable(const std::shared_ptr<RH2I> &histimpl)
131{
132 return std::make_shared<RHistDrawable<2>>(histimpl);
133}
134
135inline auto GetDrawable(const std::shared_ptr<RH2C> &histimpl)
136{
137 return std::make_shared<RHistDrawable<2>>(histimpl);
138}
139
140inline auto GetDrawable(const std::shared_ptr<RH2F> &histimpl)
141{
142 return std::make_shared<RHistDrawable<2>>(histimpl);
143}
144
145inline auto GetDrawable(const std::shared_ptr<RH3D> &histimpl)
146{
147 return std::make_shared<RHistDrawable<3>>(histimpl);
148}
149
150inline auto GetDrawable(const std::shared_ptr<RH3I> &histimpl)
151{
152 return std::make_shared<RHistDrawable<3>>(histimpl);
153}
154
155inline auto GetDrawable(const std::shared_ptr<RH3C> &histimpl)
156{
157 return std::make_shared<RHistDrawable<3>>(histimpl);
158}
159
160inline 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
Base class for RHistImplBase that abstracts out the histogram's PRECISION.
Definition: RHistImpl.hxx:71
Drawing line attributes for different objects.
Definition: RAttrLine.hxx:26
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:102
RAttrLine fAttrLine
! line attributes
RHist1Drawable(const std::shared_ptr< HIST > &hist)
RHistDrawable & SetAttrLine(const RAttrLine &attr)
const RAttrLine & GetAttrLine() const
RHist2Drawable(const std::shared_ptr< HIST > &hist)
Internal::RIOShared< HistImpl_t > fHistImpl
I/O capable reference on histogram.
std::shared_ptr< HistImpl_t > GetHist() const
void CollectShared(Internal::RIOSharedVector_t &vect) override
RHistDrawable(const std::shared_ptr< HIST > &hist)
void PopulateMenu(RMenuItems &) override
List of items for object context menu.
Definition: RMenuItems.hxx:153
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition: RDrawable.hxx:51
auto GetDrawable(const std::shared_ptr< DRAWABLE > &drawable)
Central method to insert drawable in list of pad primitives By default drawable placed as is.
Definition: RDrawable.hxx:216
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21