Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TLeafDraw7Provider.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#include "TLeafProvider.hxx"
10
11#include <ROOT/RCanvas.hxx>
13
14using namespace ROOT::Experimental;
15
16/** Provider for drawing of ROOT7 classes */
17
19public:
20 bool AddHist(std::shared_ptr<RPadBase> &subpad, TH1 *hist, const std::string &opt)
21 {
22 if (!hist)
23 return false;
24
25 if (subpad->NumPrimitives() > 0) {
26 subpad->Wipe();
27 subpad->GetCanvas()->Modified();
28 subpad->GetCanvas()->Update(true);
29 }
30
31 std::shared_ptr<TH1> shared;
32 shared.reset(hist);
33
34 subpad->Draw<ROOT::Experimental::TObjectDrawable>(shared, opt);
35 subpad->GetCanvas()->Update(true);
36 return true;
37 }
38
40 {
41 RegisterDraw7(TLeaf::Class(), [this](std::shared_ptr<RPadBase> &subpad, std::unique_ptr<RHolder> &obj, const std::string &opt) -> bool {
42 return AddHist(subpad, DrawLeaf(obj), opt);
43 });
44
45 RegisterDraw7(TBranchElement::Class(), [this](std::shared_ptr<RPadBase> &subpad, std::unique_ptr<RHolder> &obj, const std::string &opt) -> bool {
46 return AddHist(subpad, DrawBranchElement(obj), opt);
47 });
48
49 RegisterDraw7(TBranch::Class(), [this](std::shared_ptr<RPadBase> &subpad, std::unique_ptr<RHolder> &obj, const std::string &opt) -> bool {
50 return AddHist(subpad, DrawBranch(obj), opt);
51 });
52
53 RegisterDraw7(TVirtualBranchBrowsable::Class(), [this](std::shared_ptr<RPadBase> &subpad, std::unique_ptr<RHolder> &obj, const std::string &opt) -> bool {
54 return AddHist(subpad, DrawBranchBrowsable(obj), opt);
55 });
56
57 }
58
60
TLeafDraw7Provider newTLeafDraw7Provider
void RegisterDraw7(const TClass *cl, Draw7Func_t func)
Provides v7 drawing facilities for TObject types (TGraph, TH1, TH2, etc).
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
Provider for drawing of ROOT7 classes.
bool AddHist(std::shared_ptr< RPadBase > &subpad, TH1 *hist, const std::string &opt)
Provider for drawing of branches / leafs in the TTree.
TH1 * DrawBranch(std::unique_ptr< RHolder > &obj)
TH1 * DrawBranchBrowsable(std::unique_ptr< RHolder > &obj)
TH1 * DrawBranchElement(std::unique_ptr< RHolder > &obj)
TH1 * DrawLeaf(std::unique_ptr< RHolder > &obj)