Logo ROOT   6.12/07
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"
20 #include "ROOT/TDisplayItem.hxx"
21 #include "TH1.h"
22 
23 #include <iostream>
24 #include <cassert>
25 
26 using namespace ROOT::Experimental;
27 using namespace ROOT::Experimental::Internal;
28 
29 namespace {
30 class THistPainter1D: public THistPainterBase<1> {
31 public:
32  void Paint(TDrawable &drw, const THistDrawingOpts<1> & /*opts*/, TVirtualCanvasPainter &canv) final
33  {
34  // TODO: paint!
35  std::cout << "Painting 1D histogram @" << &drw << '\n';
36 
37  assert(dynamic_cast<THistDrawable<1> *>(&drw) && "Wrong drawable type");
38  THistDrawable<1> &hd = static_cast<THistDrawable<1> &>(drw);
39 
41  // res->SetOption("col");
42 
43  canv.AddDisplayItem(res);
44  }
45  virtual ~THistPainter1D() final {}
46 };
47 
48 class THistPainter2D: public THistPainterBase<2> {
49 public:
50  void Paint(TDrawable &drw, const THistDrawingOpts<2> & /*opts*/, TVirtualCanvasPainter &canv) final
51  {
52  std::cout << "Painting 2D histogram @" << &drw << '\n';
53  assert(dynamic_cast<THistDrawable<2> *>(&drw) && "Wrong drawable type");
54  THistDrawable<2> &hd = static_cast<THistDrawable<2> &>(drw);
55 
57  // res->SetOption("col");
58 
59  canv.AddDisplayItem(res);
60 
61  // hd.GetOldHist()->Paint("BOX");
62  }
63  virtual ~THistPainter2D() final {}
64 };
65 
66 class THistPainter3D: public THistPainterBase<3> {
67 public:
68  void Paint(TDrawable &hist, const THistDrawingOpts<3> & /*opts*/, TVirtualCanvasPainter & /*canv*/) final
69  {
70  // TODO: paint!
71  std::cout << "Painting 3D histogram (to be done) @" << &hist << '\n';
72  }
73  virtual ~THistPainter3D() final {}
74 };
75 
76 struct HistPainterReg {
77  THistPainter1D fPainter1D;
78  THistPainter2D fPainter2D;
79  THistPainter3D fPainter3D;
80 } histPainterReg;
81 } // unnamed namespace
Base class for drawable entities: objects that can be painted on a TPad.
Definition: TDrawable.hxx:36
Drawing options for a 1D histogram.
Drawing options for a 1D histogram.
Drawing options for a 1D histogram.
Abstract interface for painting a canvas.
Base class for painting data for JS.