Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RTreeViewer.hxx
Go to the documentation of this file.
1// Author: Sergey Linev, 7.10.2022
2
3/*************************************************************************
4 * Copyright (C) 1995-2022, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOT7_RTreeViewer
12#define ROOT7_RTreeViewer
13
15
16#include "Rtypes.h"
17
18#include <memory>
19#include <vector>
20#include <string>
21#include <functional>
22
23class TTree;
24class TBranch;
25class TLeaf;
26class TObjArray;
27
28namespace ROOT {
29
30class RWebWindow;
31class RTreeDrawMonitoring;
32class RTreeDrawInvokeTimer;
33
35
38
39public:
40
41 using PerformDrawCallback_t = std::function<void(const std::string &)>;
42
43 struct RBranchInfo {
44 std::string fName, fTitle;
45 RBranchInfo() = default;
46 RBranchInfo(const std::string &_name, const std::string &_title) : fName(_name), fTitle(_title) {}
47 };
48
49 struct RConfig {
51 std::vector<RBranchInfo> fBranches;
53 };
54
55 RTreeViewer(TTree *tree = nullptr);
56 virtual ~RTreeViewer();
57
58 void SetTitle(const std::string &title) { fTitle = title; }
59 const std::string &GetTitle() const { return fTitle; }
60
61 std::string GetWindowAddr() const;
62
63 std::string GetWindowUrl(bool remote);
64
65 void SetTree(TTree *tree);
66
67 bool SuggestLeaf(const TLeaf *leaf);
68
69 bool SuggestBranch(const TBranch *branch);
70
71 bool SuggestExpression(const std::string &expr);
72
74
75 /** Configures default hierarchy browser visibility, only has effect before showing web window */
76 void SetShowHierarchy(bool on = true) { fShowHierarchy = on; }
77
78 /** Returns default hierarchy browser visibility */
79 bool GetShowHierarchy() const { return fShowHierarchy; }
80
81 void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
82
83 void Update();
84
85 static RTreeViewer *NewViewer(TTree *);
86
87private:
88
89 TTree *fTree{nullptr}; ///<! TTree to show
90 std::string fTitle; ///<! title of tree viewer
91 std::shared_ptr<ROOT::RWebWindow> fWebWindow; ///<! web window
92 bool fShowHierarchy{false}; ///<! show TTree hierarchy
93 RConfig fCfg; ///<! configuration, exchanged between client and server
94 PerformDrawCallback_t fCallback; ///<! callback invoked when tree draw performed
95 std::string fLastSendProgress; ///<! last send progress to client
96 std::unique_ptr<RTreeDrawInvokeTimer> fTimer; ///<! timer to invoke tree draw
97
98 void WebWindowConnect(unsigned connid);
99 void WebWindowCallback(unsigned connid, const std::string &arg);
100
101 void SendCfg(unsigned connid);
102
103 std::string FormatItemName(const std::string &name);
104
105 void AddBranches(TObjArray *branches);
106
107 void UpdateConfig();
108
109 void SendProgress(Double_t nevent = 0.);
110
111 void InvokeTreeDraw();
112};
113
114} // namespace ROOT
115
116#endif
long long Long64_t
Definition RtypesCore.h:69
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Definition TGX11.cxx:110
Web-based ROOT TTree viewer.
std::unique_ptr< RTreeDrawInvokeTimer > fTimer
! timer to invoke tree draw
void Show(const RWebDisplayArgs &args="", bool always_start_new_browser=false)
Show or update viewer in web window If web browser already started - just refresh drawing like "reloa...
void SendProgress(Double_t nevent=0.)
Send progress to the client.
void UpdateConfig()
Update RConfig data.
std::string FormatItemName(const std::string &name)
Format item name used in draw expression.
void InvokeTreeDraw()
Invoke tree drawing.
bool SuggestLeaf(const TLeaf *leaf)
Suggest to use leaf in the gui Normally just assign as last edited expression.
std::string fTitle
! title of tree viewer
void SetTree(TTree *tree)
assign new TTree to the viewer
std::string GetWindowAddr() const
Return address of web window used for tree viewer.
std::string GetWindowUrl(bool remote)
Return URL of web window used for tree viewer See ROOT::RWebWindow::GetUrl docu for more details.
std::string fLastSendProgress
! last send progress to client
PerformDrawCallback_t fCallback
! callback invoked when tree draw performed
void Update()
Update tree viewer in all web displays.
bool fShowHierarchy
! show TTree hierarchy
std::shared_ptr< ROOT::RWebWindow > fWebWindow
! web window
static RTreeViewer * NewViewer(TTree *)
Create new viewer Method used for plugin.
void SendCfg(unsigned connid)
Send data for initialize viewer.
bool SuggestExpression(const std::string &expr)
Suggest to use expression in the gui Normally just assign as last edited expression.
virtual ~RTreeViewer()
destructor
void WebWindowConnect(unsigned connid)
react on new connection
bool GetShowHierarchy() const
Returns default hierarchy browser visibility.
TTree * fTree
! TTree to show
void SetCallback(PerformDrawCallback_t func)
void AddBranches(TObjArray *branches)
Add branches to config.
void WebWindowCallback(unsigned connid, const std::string &arg)
receive data from client
RConfig fCfg
! configuration, exchanged between client and server
RTreeViewer(TTree *tree=nullptr)
constructor
void SetTitle(const std::string &title)
void SetShowHierarchy(bool on=true)
Configures default hierarchy browser visibility, only has effect before showing web window.
bool SuggestBranch(const TBranch *branch)
Suggest to use branch in the gui Normally just assign as last edited expression.
std::function< void(const std::string &)> PerformDrawCallback_t
const std::string & GetTitle() const
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
A TTree is a list of TBranches.
Definition TBranch.h:93
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition TLeaf.h:57
An array of TObjects.
Definition TObjArray.h:31
A TTree represents a columnar dataset.
Definition TTree.h:79
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
RBranchInfo(const std::string &_name, const std::string &_title)
std::vector< RBranchInfo > fBranches