Logo ROOT   6.14/05
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
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2016, 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 //#include "ROOT/THistPainter.hxx" see ROOT/THistDrawable.h
17 
18 #include "ROOT/THistDrawable.hxx"
19 #include "ROOT/TPadPainter.hxx"
20 #include "ROOT/TDisplayItem.hxx"
21 
22 #include <iostream>
23 #include <cassert>
24 
25 using namespace ROOT::Experimental;
26 using namespace ROOT::Experimental::Internal;
27 
28 namespace {
29 class THistPainter1D : public THistPainterBase<1> {
30 public:
31  void Paint(TDrawable &drw, const THistDrawingOpts<1> & /*opts*/, TPadPainter &pad) final
32  {
33  // TODO: paint!
34  std::cout << "Painting 1D histogram @" << &drw << '\n';
35 
36  assert(dynamic_cast<THistDrawable<1> *>(&drw) && "Wrong drawable type");
37  THistDrawable<1> &hd = static_cast<THistDrawable<1> &>(drw);
38 
39  pad.AddDisplayItem(
40  std::make_unique<ROOT::Experimental::TOrdinaryDisplayItem<ROOT::Experimental::THistDrawable<1>>>(&hd));
41  }
42  virtual ~THistPainter1D() final {}
43 };
44 
45 class THistPainter2D : public THistPainterBase<2> {
46 public:
47  void Paint(TDrawable &drw, const THistDrawingOpts<2> & /*opts*/, TPadPainter &pad) final
48  {
49  std::cout << "Painting 2D histogram @" << &drw << '\n';
50  assert(dynamic_cast<THistDrawable<2> *>(&drw) && "Wrong drawable type");
51  THistDrawable<2> &hd = static_cast<THistDrawable<2> &>(drw);
52 
53  pad.AddDisplayItem(
54  std::make_unique<ROOT::Experimental::TOrdinaryDisplayItem<ROOT::Experimental::THistDrawable<2>>>(&hd));
55  }
56  virtual ~THistPainter2D() final {}
57 };
58 
59 class THistPainter3D : public THistPainterBase<3> {
60 public:
61  void Paint(TDrawable &hist, const THistDrawingOpts<3> & /*opts*/, TPadPainter & /*canv*/) final
62  {
63  // TODO: paint!
64  std::cout << "Painting 3D histogram (to be done) @" << &hist << '\n';
65  }
66  virtual ~THistPainter3D() final {}
67 };
68 
69 struct HistPainterReg {
70  THistPainter1D fPainter1D;
71  THistPainter2D fPainter2D;
72  THistPainter3D fPainter3D;
73 } histPainterReg;
74 } // unnamed namespace
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.hxx:37
Drawing options for a 2D histogram.
Drawing options for a 1D histogram.
Drawing options for a 3D histogram.
Abstract interface for object painting on the pad/canvas.
Definition: TPadPainter.hxx:37