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