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::shared_ptr<ROOT::RWebWindow> GetWindow() { return fWebWindow; }
62
63 std::string GetWindowAddr() const;
64
65 std::string GetWindowUrl(bool remote);
66
67 void SetTree(TTree *tree);
68
69 bool SuggestLeaf(const TLeaf *leaf);
70
71 bool SuggestBranch(const TBranch *branch);
72
73 bool SuggestExpression(const std::string &expr);
74
76
77 /** Configures default hierarchy browser visibility, only has effect before showing web window */
78 void SetShowHierarchy(bool on = true) { fShowHierarchy = on; }
79
80 /** Returns default hierarchy browser visibility */
81 bool GetShowHierarchy() const { return fShowHierarchy; }
82
83 void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
84
85 void Update();
86
87 static RTreeViewer *NewViewer(TTree *);
88
89private:
90
91 TTree *fTree{nullptr}; ///<! TTree to show
92 std::string fTitle; ///<! title of tree viewer
93 std::shared_ptr<ROOT::RWebWindow> fWebWindow; ///<! web window
94 bool fShowHierarchy{false}; ///<! show TTree hierarchy
95 RConfig fCfg; ///<! configuration, exchanged between client and server
96 PerformDrawCallback_t fCallback; ///<! callback invoked when tree draw performed
97 std::string fLastSendProgress; ///<! last send progress to client
98 std::unique_ptr<RTreeDrawInvokeTimer> fTimer; ///<! timer to invoke tree draw
99
100 void WebWindowConnect(unsigned connid);
101 void WebWindowCallback(unsigned connid, const std::string &arg);
102
103 void SendCfg(unsigned connid);
104
105 std::string FormatItemName(const std::string &name);
106
108
109 void UpdateConfig();
110
111 void SendProgress(Double_t nevent = 0.);
112
113 void InvokeTreeDraw();
114};
115
116} // namespace ROOT
117
118#endif
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.
std::shared_ptr< ROOT::RWebWindow > GetWindow()
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