Logo ROOT   6.14/05
Reference Guide
THistDrawable.hxx
Go to the documentation of this file.
1 /// \file ROOT/THistDrawable.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_THistDrawable
17 #define ROOT7_THistDrawable
18 
19 #include "ROOT/TDrawable.hxx"
21 #include "ROOT/THistImpl.hxx"
22 #include "ROOT/TMenuItem.hxx"
23 
24 #include <memory>
25 
26 namespace ROOT {
27 namespace Experimental {
28 
29 template <int DIMENSIONS, class PRECISION,
30  template <int D_, class P_, template <class P__> class STORAGE> class... STAT>
31 class THist;
32 
33 namespace Detail {
34 template <int DIMENSIONS>
35 class THistImplPrecisionAgnosticBase;
36 }
37 
38 namespace Internal {
39 
41 
42 template <int DIMENSION>
44  static THistPainterBase<DIMENSION> *&GetPainterPtr();
45 
46 protected:
48  virtual ~THistPainterBase();
49 
50 public:
51  static THistPainterBase<DIMENSION> *GetPainter();
52 
53  /// Paint a THist. All we need is access to its GetBinContent()
54  virtual void Paint(TDrawable &obj, const THistDrawingOpts<DIMENSION> &opts, TPadPainter &pad) = 0;
55 };
56 
57 extern template class THistPainterBase<1>;
58 extern template class THistPainterBase<2>;
59 extern template class THistPainterBase<3>;
60 
61 } // namespace Internal
62 
63 template <class DERIVED>
65 public:
66  virtual ~THistDrawableBase() = default;
67 
68  void PopulateMenu(TMenuItems &) final;
69 
70  void Execute(const std::string &) final
71  {
72  // should execute menu item
73  }
74 };
75 
76 template <int DIMENSIONS>
78 public:
80 
81 private:
84 
85 public:
86  THistDrawable();
87 
88  template <class HIST>
89  THistDrawable(const std::shared_ptr<HIST> &hist, const THistDrawingOpts<DIMENSIONS> &opts = {})
90  : fHistImpl(std::shared_ptr<HistImpl_t>(hist, hist->GetImpl())), fOpts(opts)
91  {}
92 
93  template <class HIST>
94  THistDrawable(std::unique_ptr<HIST> &&hist, const THistDrawingOpts<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::TPadPainter &pad) final;
100 
102  const THistDrawingOpts<DIMENSIONS> &GetOptions() const { return fOpts; }
103 };
104 
105 extern template class THistDrawableBase<THistDrawable<1>>;
106 extern template class THistDrawableBase<THistDrawable<2>>;
107 extern template class THistDrawableBase<THistDrawable<3>>;
108 
109 extern template class THistDrawable<1>;
110 extern template class THistDrawable<2>;
111 extern template class THistDrawable<3>;
112 
113 } // namespace Experimental
114 } // namespace ROOT
115 
116 #endif
THistDrawable(std::unique_ptr< HIST > &&hist, const THistDrawingOpts< DIMENSIONS > &opts={})
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.hxx:37
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Internal::TUniWeakPtr< HistImpl_t > fHistImpl
void Execute(const std::string &) final
#define PRECISION
Definition: MnPrint.cxx:26
THistDrawable(const std::shared_ptr< HIST > &hist, const THistDrawingOpts< DIMENSIONS > &opts={})
const THistDrawingOpts< DIMENSIONS > & GetOptions() const
THistDrawingOpts< DIMENSIONS > fOpts
Abstract interface for object painting on the pad/canvas.
Definition: TPadPainter.hxx:37
Base class for THistImplBase that abstracts out the histogram&#39;s PRECISION.
Definition: THistImpl.hxx:71
THistDrawingOpts< DIMENSIONS > & GetOptions()