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 {
29namespace Experimental {
30
31class RWebWindow;
32class TProgressTimer;
33
35
36friend class TProgressTimer;
37
38public:
39
40 using PerformDrawCallback_t = std::function<void(const std::string &)>;
41
42 struct RBranchInfo {
43 std::string fName, fTitle;
44 RBranchInfo() = default;
45 RBranchInfo(const std::string &_name, const std::string &_title) : fName(_name), fTitle(_title) {}
46 };
47
48 struct RConfig {
50 std::vector<RBranchInfo> fBranches;
52 };
53
54 RTreeViewer(TTree *tree = nullptr);
55 virtual ~RTreeViewer();
56
57 void SetTitle(const std::string &title) { fTitle = title; }
58 const std::string &GetTitle() const { return fTitle; }
59
60 std::string GetWindowAddr() const;
61
62 void SetTree(TTree *tree);
63
64 bool SuggestLeaf(const TLeaf *leaf);
65
66 bool SuggestBranch(const TBranch *branch);
67
68 bool SuggestExpression(const std::string &expr);
69
71
72 /** Configures default hierarchy browser visibility, only has effect before showing web window */
73 void SetShowHierarchy(bool on = true) { fShowHierarchy = on; }
74
75 /** Returns default hierarchy browser visibility */
76 bool GetShowHierarchy() const { return fShowHierarchy; }
77
78 void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
79
80 void Update();
81
82 static RTreeViewer *NewViewer(TTree *);
83
84private:
85
86 TTree *fTree{nullptr}; ///<! TTree to show
87 std::string fTitle; ///<! title of tree viewer
88 std::shared_ptr<RWebWindow> fWebWindow; ///<! web window
89 bool fShowHierarchy{false}; ///<! show TTree hierarchy
90 RConfig fCfg; ///<! configuration, exchanged between client and server
91 PerformDrawCallback_t fCallback; ///<! callback invoked when tree draw performed
92 std::unique_ptr<TProgressTimer> fProgrTimer; ///<! timer used to get draw progress
93 std::string fLastSendProgress; ///<! last send progress to client
94
95 void WebWindowConnect(unsigned connid);
96 void WebWindowCallback(unsigned connid, const std::string &arg);
97
98 void SendCfg(unsigned connid);
99
100 std::string FormatItemName(const std::string &name);
101
102 void AddBranches(TObjArray *branches);
103
104 void UpdateConfig();
105
106 void SendProgress(bool completed = false);
107
108 void InvokeTreeDraw(const std::string &json);
109};
110
111} // namespace Experimental
112} // namespace ROOT
113
114#endif
nlohmann::json json
long long Long64_t
Definition RtypesCore.h:80
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
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 UpdateConfig()
Update RConfig data.
std::string FormatItemName(const std::string &name)
Format item name used in draw expression.
bool SuggestLeaf(const TLeaf *leaf)
Suggest to use leaf in the gui Normally just assign as last edited expression.
std::string fLastSendProgress
! last send progress to client
void SetTree(TTree *tree)
assign new TTree to the viewer
void SendProgress(bool completed=false)
Send progress to the client.
std::string GetWindowAddr() const
Return URL address of web window used for tree viewer.
bool GetShowHierarchy() const
Returns default hierarchy browser visibility.
void SetTitle(const std::string &title)
const std::string & GetTitle() const
void Update()
Update tree viewer in all web displays.
void InvokeTreeDraw(const std::string &json)
Invoke tree drawing.
std::string fTitle
! title of tree viewer
static RTreeViewer * NewViewer(TTree *)
Create new viewer Method used for plugin.
PerformDrawCallback_t fCallback
! callback invoked when tree draw performed
void SendCfg(unsigned connid)
Send data for initialize viewer.
void SetShowHierarchy(bool on=true)
Configures default hierarchy browser visibility, only has effect before showing web window.
std::function< void(const std::string &)> PerformDrawCallback_t
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
std::unique_ptr< TProgressTimer > fProgrTimer
! timer used to get draw progress
void AddBranches(TObjArray *branches)
Add branches to config.
std::shared_ptr< RWebWindow > fWebWindow
! web window
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
TTree * fTree
! TTree to show
bool SuggestBranch(const TBranch *branch)
Suggest to use branch in the gui Normally just assign as last edited expression.
bool fShowHierarchy
! show TTree hierarchy
void SetCallback(PerformDrawCallback_t func)
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
A TTree is a list of TBranches.
Definition TBranch.h:89
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
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Definition tree.py:1
RBranchInfo(const std::string &_name, const std::string &_title)
std::vector< RBranchInfo > fBranches