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/RMenuItem.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 final: public RDrawable {
40public:
42
43private:
44 Internal::RIOShared<HistImpl_t> fHistImpl; ///< I/O capable reference on histogram
45
46 RAttrLine fAttrLine{this, "line_"}; ///<! line attributes
47
48protected:
49
50 void CollectShared(Internal::RIOSharedVector_t &vect) final { vect.emplace_back(&fHistImpl); }
51
52public:
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; }
65
66 std::shared_ptr<HistImpl_t> GetHist() const { return fHistImpl.get_shared(); }
67
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
85template <int DIMENSIONS> inline RHistDrawable<DIMENSIONS>::RHistDrawable() : RDrawable("hist") {}
86
87inline auto GetDrawable(const std::shared_ptr<RH1D> &histimpl)
88{
89 return std::make_shared<RHistDrawable<1>>(histimpl);
90}
91
92inline auto GetDrawable(const std::shared_ptr<RH1I> &histimpl)
93{
94 return std::make_shared<RHistDrawable<1>>(histimpl);
95}
96
97inline auto GetDrawable(const std::shared_ptr<RH1C> &histimpl)
98{
99 return std::make_shared<RHistDrawable<1>>(histimpl);
100}
101
102inline auto GetDrawable(const std::shared_ptr<RH1F> &histimpl)
103{
104 return std::make_shared<RHistDrawable<1>>(histimpl);
105}
106
107inline auto GetDrawable(const std::shared_ptr<RH2D> &histimpl)
108{
109 return std::make_shared<RHistDrawable<2>>(histimpl);
110}
111
112inline auto GetDrawable(const std::shared_ptr<RH2I> &histimpl)
113{
114 return std::make_shared<RHistDrawable<2>>(histimpl);
115}
116
117inline auto GetDrawable(const std::shared_ptr<RH2C> &histimpl)
118{
119 return std::make_shared<RHistDrawable<2>>(histimpl);
120}
121
122inline auto GetDrawable(const std::shared_ptr<RH2F> &histimpl)
123{
124 return std::make_shared<RHistDrawable<2>>(histimpl);
125}
126
127inline auto GetDrawable(const std::shared_ptr<RH3D> &histimpl)
128{
129 return std::make_shared<RHistDrawable<3>>(histimpl);
130}
131
132inline auto GetDrawable(const std::shared_ptr<RH3I> &histimpl)
133{
134 return std::make_shared<RHistDrawable<3>>(histimpl);
135}
136
137inline auto GetDrawable(const std::shared_ptr<RH3C> &histimpl)
138{
139 return std::make_shared<RHistDrawable<3>>(histimpl);
140}
141
142inline 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
Base class for RHistImplBase that abstracts out the histogram's PRECISION.
Definition: RHistImpl.hxx:70
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:99
Internal::RIOShared< HistImpl_t > fHistImpl
I/O capable reference on histogram.
const RAttrLine & GetAttrLine() const
RHistDrawable & SetAttrLine(const RAttrLine &attr)
RAttrLine fAttrLine
! line attributes
std::shared_ptr< HistImpl_t > GetHist() const
void PopulateMenu(RMenuItems &) final
Method can be used to provide menu items for the drawn object.
void Execute(const std::string &) final
RHistDrawable(const std::shared_ptr< HIST > &hist)
void CollectShared(Internal::RIOSharedVector_t &vect) final
List of items for object context menu.
Definition: RMenuItem.hxx:151
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition: RDrawable.hxx:48
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:153
VSD Structures.
Definition: StringConv.hxx:21