Logo ROOT   6.10/09
Reference Guide
THistPainter.cxx
Go to the documentation of this file.
1 /// \file THistPainter.cxx
2 /// \ingroup HistPainter 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-2016, 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 //#include "ROOT/THistPainter.hxx" see ROOT/THistDrawable.h
16 
17 #include "ROOT/THistDrawable.hxx"
18 #include "TH1.h"
19 
20 #include <iostream>
21 #include <cassert>
22 
23 using namespace ROOT::Experimental;
24 using namespace ROOT::Experimental::Internal;
25 
26 namespace {
27 class THistPainter1D: public THistPainterBase<1> {
28 public:
29  void Paint(TDrawable& hist, THistDrawOptions<1> /*opts*/,
30  TCanvas& /*canv*/) final {
31  // TODO: paint!
32  std::cout << "Painting histogram @" << &hist << '\n';
33  }
34  virtual ~THistPainter1D() final {}
35 };
36 
37 class THistPainter2D: public THistPainterBase<2> {
38 public:
39  void Paint(TDrawable& drw, THistDrawOptions<2> /*opts*/,
40  TCanvas& /* canv */) final {
41  std::cout << "Painting histogram @" << &drw << '\n';
42  assert(dynamic_cast<THistDrawable<2>*>(&drw) && "Wrong drawable type");
43  THistDrawable<2>& hd = static_cast<THistDrawable<2>&>(drw);
44  hd.GetOldHist()->Paint("BOX");
45  }
46  virtual ~THistPainter2D() final {}
47 };
48 
49 class THistPainter3D: public THistPainterBase<3> {
50 public:
51  void Paint(TDrawable& hist, THistDrawOptions<3> /*opts*/,
52  TCanvas& /*canv*/) final {
53  // TODO: paint!
54  std::cout << "Painting histogram @" << &hist << '\n';
55  }
56  virtual ~THistPainter3D() final {}
57 };
58 
59 
60 struct HistPainterReg {
61  THistPainter1D fPainter1D;
62  THistPainter2D fPainter2D;
63  THistPainter3D fPainter3D;
64 } histPainterReg;
65 } // unnamed namespace
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
Definition: TH1.cxx:5539
Graphic container for TDrawable-s.
Definition: TCanvas.hxx:38
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.hxx:30
Drawing options for a histogram with DIMENSIONS.