Logo ROOT   6.18/05
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"
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
38namespace Internal {
39
41
42template <int DIMENSION>
45
46protected:
48 virtual ~RHistPainterBase();
49
50public:
52
53 /// Paint a RHist. All we need is access to its GetBinContent()
54 virtual void Paint(RDrawable &obj, const RHistDrawingOpts<DIMENSION> &opts, RPadPainter &pad) = 0;
55};
56
57extern template class RHistPainterBase<1>;
58extern template class RHistPainterBase<2>;
59extern template class RHistPainterBase<3>;
60
61} // namespace Internal
62
63template <class DERIVED>
65public:
67
68 void PopulateMenu(RMenuItems &) final;
69
70 void Execute(const std::string &) final
71 {
72 // should execute menu item
73 }
74};
75
76template <int DIMENSIONS>
78public:
80
81private:
84
85public:
87
88 template <class HIST>
89 RHistDrawable(const std::shared_ptr<HIST> &hist, const RHistDrawingOpts<DIMENSIONS> &opts = {})
90 : fHistImpl(std::shared_ptr<HistImpl_t>(hist, hist->GetImpl())), fOpts(opts)
91 {}
92
93 template <class HIST>
94 RHistDrawable(std::unique_ptr<HIST> &&hist, const RHistDrawingOpts<DIMENSIONS> &opts = {})
95 : fHistImpl(std::unique_ptr<HistImpl_t>(std::move(*hist).TakeImpl())), fOpts(opts)
96 {}
97
98 /// Paint the histogram
99 void Paint(Internal::RPadPainter &pad) final;
100
102 const RHistDrawingOpts<DIMENSIONS> &GetOptions() const { return fOpts; }
103};
104
105extern template class RHistDrawableBase<RHistDrawable<1>>;
106extern template class RHistDrawableBase<RHistDrawable<2>>;
107extern template class RHistDrawableBase<RHistDrawable<3>>;
108
109extern template class RHistDrawable<1>;
110extern template class RHistDrawable<2>;
111extern template class RHistDrawable<3>;
112
113
114/// Interface to graphics taking a shared_ptr<RHist>.
115template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
116std::shared_ptr<RHistDrawable<DIMENSIONS>>
118 const RHistDrawingOpts<DIMENSIONS> &opts = {})
119{
120 return std::make_unique<RHistDrawable<DIMENSIONS>>(hist, opts);
121}
122
123/// Interface to graphics taking a unique_ptr<RHist>.
124template <int DIMENSIONS, class PRECISION, template <int D_, class P_> class... STAT>
125std::shared_ptr<RHistDrawable<DIMENSIONS>>
127 const RHistDrawingOpts<DIMENSIONS> &opts = {})
128{
129 return std::make_unique<RHistDrawable<DIMENSIONS>>(std::move(hist), opts);
130}
131
132} // namespace Experimental
133} // namespace ROOT
134
135#endif
Base class for RHistImplBase that abstracts out the histogram's PRECISION.
Definition: RHistImpl.hxx:70
static RHistPainterBase< DIMENSION > *& GetPainterPtr()
virtual void Paint(RDrawable &obj, const RHistDrawingOpts< DIMENSION > &opts, RPadPainter &pad)=0
Paint a RHist. All we need is access to its GetBinContent()
static RHistPainterBase< DIMENSION > * GetPainter()
Abstract interface for object painting on the pad/canvas.
Definition: RPadPainter.hxx:37
Base class for drawable entities: objects that can be painted on a RPad.
Definition: RDrawable.hxx:37
void Execute(const std::string &) final
RHistDrawable(const std::shared_ptr< HIST > &hist, const RHistDrawingOpts< DIMENSIONS > &opts={})
RHistDrawable(std::unique_ptr< HIST > &&hist, const RHistDrawingOpts< DIMENSIONS > &opts={})
const RHistDrawingOpts< DIMENSIONS > & GetOptions() const
RHistDrawingOpts< DIMENSIONS > & GetOptions()
RHistDrawingOpts< DIMENSIONS > fOpts
Internal::TUniWeakPtr< HistImpl_t > fHistImpl
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition: RHist.hxx:52
std::shared_ptr< RPadDrawable > GetDrawable(std::unique_ptr< RPad > &&pad, ARGS... args)
Definition: RPad.hxx:301
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21