ROOT  6.06/09
Reference Guide
THistDrawable.h
Go to the documentation of this file.
1 /// \file ROOT/THistDrawable.h
2 /// \ingroup Hist 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 is welcome!
6 
7 /*************************************************************************
8  * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
9  * All rights reserved. *
10  * *
11  * For the licensing terms see $ROOTSYS/LICENSE. *
12  * For the list of contributors see $ROOTSYS/README/CREDITS. *
13  *************************************************************************/
14 
15 #ifndef ROOT7_THistDrawable
16 #define ROOT7_THistDrawable
17 
18 #include "ROOT/TCoopPtr.h"
19 #include "ROOT/TDrawable.h"
20 #include "ROOT/THistDrawOptions.h"
21 #include "ROOT/TLogger.h"
22 
23 #include "TSystem.h"
24 
25 #include <memory>
26 
27 namespace ROOT {
28 
29 template<int DIMENSIONS, class PRECISION> class THist;
30 
31 namespace Internal {
32 
33 template <int DIMENSION>
36 
37 protected:
38  THistPainterBase() { fgPainter = this; }
39  virtual ~THistPainterBase();
40 
41 public:
43  if (!fgPainter)
44  gSystem->Load("libHistPainter");
45  return fgPainter;
46  }
47 
48  /// Paint a THist. All we need is access to its GetBinContent()
49  virtual void Paint(TDrawable& obj, THistDrawOptions<DIMENSION> opts) = 0;
50 };
51 
52 extern template class THistPainterBase<1>;
53 extern template class THistPainterBase<2>;
54 extern template class THistPainterBase<3>;
55 
56 template <int DIMENSION, class PRECISION>
57 class THistDrawable final: public TDrawable {
58 private:
61 
62 public:
64  THistDrawOptions<DIMENSION> opts): fHist(hist), fOpts(opts) {}
65 
66  ~THistDrawable() = default;
67 
68  /// Paint the histogram
69  void Paint() final {
70  THistPainterBase<DIMENSION>::GetPainter()->Paint(*this, fOpts);
71  }
72 };
73 
74 } // namespace Internal
75 } // namespace ROOT
76 
77 #endif
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.h:25
THistDrawable(TCoopPtr< THist< DIMENSION, PRECISION >> hist, THistDrawOptions< DIMENSION > opts)
Definition: THistDrawable.h:63
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1818
virtual void Paint(TDrawable &obj, THistDrawOptions< DIMENSION > opts)=0
Paint a THist. All we need is access to its GetBinContent()
THistDrawOptions< DIMENSION > fOpts
Definition: THistDrawable.h:60
static THistPainterBase< DIMENSION > * fgPainter
Definition: THistDrawable.h:35
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
static THistPainterBase< DIMENSION > * GetPainter()
Definition: THistDrawable.h:42
TCoopPtr< THist< DIMENSION, PRECISION > > fHist
Definition: THistDrawable.h:59
Drawing options for a histogram with DIMENSIONS.
void Paint() final
Paint the histogram.
Definition: THistDrawable.h:69
TObject * obj
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition: THist.h:31
Several pointers point to the same object, any of them can delete the object, setting all of them to ...
Definition: TCoopPtr.h:46