Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RBrowser.hxx
Go to the documentation of this file.
1// Authors: Bertrand Bellenot <bertrand.bellenot@cern.ch> Sergey Linev <S.Linev@gsi.de>
2// Date: 2019-02-28
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT7_RBrowser
13#define ROOT7_RBrowser
14
15#include <ROOT/RWebWindow.hxx>
16#include <ROOT/RBrowserData.hxx>
17
18#include <vector>
19#include <memory>
20
21namespace ROOT {
22
23class RBrowserWidget;
24class RBrowserTimer;
25
26class RBrowser {
27
28 friend class RBrowserTimer;
29
30protected:
31
32 std::string fTitle; ///<! title
33 unsigned fConnId{0}; ///<! default connection id
34
35 bool fUseRCanvas{false}; ///<! which canvas should be used
36 bool fCatchWindowShow{true}; ///<! if arbitrary RWebWindow::Show calls should be catched by browser
37 std::string fActiveWidgetName; ///<! name of active widget
38 std::vector<std::shared_ptr<RBrowserWidget>> fWidgets; ///<! all browser widgets
39 int fWidgetCnt{0}; ///<! counter for created widgets
40 std::string fPromptFileOutput; ///<! file name for prompt output
41 float fLastProgressSend{0}; ///<! last value of send progress
42 long long fLastProgressSendTm{0}; ///<! time when last progress message was send
43
44 std::shared_ptr<RWebWindow> fWebWindow; ///<! web window to browser
45
46 RBrowserData fBrowsable; ///<! central browsing element
47 std::unique_ptr<RBrowserTimer> fTimer; ///<! timer to handle postponed requests
48 std::vector<std::vector<std::string>> fPostponed; ///<! postponed messages, handled in timer
49
50 std::shared_ptr<RBrowserWidget> AddWidget(const std::string &kind);
51 std::shared_ptr<RBrowserWidget> AddCatchedWidget(RWebWindow *win, const std::string &kind);
52 std::shared_ptr<RBrowserWidget> FindWidget(const std::string &name, const std::string &kind = "") const;
53 std::shared_ptr<RBrowserWidget> GetActiveWidget() const { return FindWidget(fActiveWidgetName); }
54
55 void CloseTab(const std::string &name);
56
57 std::string ProcessBrowserRequest(const std::string &msg);
58 std::string ProcessDblClick(unsigned connid, std::vector<std::string> &args);
59 std::string ProcessDrop(unsigned connid, std::vector<std::string> &args);
60 std::string NewWidgetMsg(std::shared_ptr<RBrowserWidget> &widget);
61 void ProcessRunMacro(const std::string &file_path);
62 void ProcessSaveFile(const std::string &fname, const std::string &content);
63 std::string GetCurrentWorkingDirectory();
64
65 std::vector<std::string> GetRootHistory();
66 std::vector<std::string> GetRootLogs();
67
68 void SendInitMsg(unsigned connid);
69 void ProcessMsg(unsigned connid, const std::string &arg);
70 void SendProgress(unsigned connid, float progr);
71
72 void AddInitWidget(const std::string &kind);
73
74 void CheckWidgtesModified(unsigned connid);
75
77
78public:
79 RBrowser(bool use_rcanvas = false);
80 virtual ~RBrowser();
81
82 bool GetUseRCanvas() const { return fUseRCanvas; }
83 void SetUseRCanvas(bool on = true) { fUseRCanvas = on; }
84
85 void AddTCanvas() { AddInitWidget("tcanvas"); }
86 void AddRCanvas() { AddInitWidget("rcanvas"); }
87
88 /// show Browser in specified place
89 void Show(const RWebDisplayArgs &args = "", bool always_start_new_browser = false);
90
91 /// hide Browser
92 void Hide();
93
94 std::string GetWindowUrl(bool remote);
95
96 void SetWorkingPath(const std::string &path);
97
98 /// Enable/disable catch of RWebWindow::Show calls to embed created widgets, default on
99 void SetCatchWindowShow(bool on = true) { fCatchWindowShow = on; }
100
101 /// Is RWebWindow::Show calls catched for embeding of created widgets
102 bool GetCatchWindowShow() const { return fCatchWindowShow; }
103
104 bool ActivateWidget(const std::string &title, const std::string &kind = "");
105
106 void ClearOnClose(const std::shared_ptr<void> &handle);
107
108};
109
110} // namespace ROOT
111
112#endif
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
char name[80]
Definition TGX11.cxx:110
Way to browse (hopefully) everything in ROOT.
Web-based ROOT files and objects browser.
Definition RBrowser.hxx:26
bool fUseRCanvas
! which canvas should be used
Definition RBrowser.hxx:35
std::unique_ptr< RBrowserTimer > fTimer
! timer to handle postponed requests
Definition RBrowser.hxx:47
RBrowserData fBrowsable
! central browsing element
Definition RBrowser.hxx:46
std::shared_ptr< RBrowserWidget > AddWidget(const std::string &kind)
Creates new widget.
Definition RBrowser.cxx:609
std::vector< std::string > GetRootHistory()
Get content of history file.
Definition RBrowser.cxx:698
void AddInitWidget(const std::string &kind)
Create new widget and send init message to the client.
Definition RBrowser.cxx:659
std::vector< std::vector< std::string > > fPostponed
! postponed messages, handled in timer
Definition RBrowser.hxx:48
std::shared_ptr< RWebWindow > fWebWindow
! web window to browser
Definition RBrowser.hxx:44
std::string ProcessDrop(unsigned connid, std::vector< std::string > &args)
Process drop of item in the current tab.
Definition RBrowser.cxx:546
int fWidgetCnt
! counter for created widgets
Definition RBrowser.hxx:39
std::shared_ptr< RBrowserWidget > GetActiveWidget() const
Definition RBrowser.hxx:53
std::string ProcessDblClick(unsigned connid, std::vector< std::string > &args)
Process dbl click on browser item.
Definition RBrowser.cxx:442
void AddTCanvas()
Definition RBrowser.hxx:85
void ClearOnClose(const std::shared_ptr< void > &handle)
Set handle which will be cleared when connection is closed.
std::string fActiveWidgetName
! name of active widget
Definition RBrowser.hxx:37
RBrowser(bool use_rcanvas=false)
constructor
Definition RBrowser.cxx:286
void SetWorkingPath(const std::string &path)
Set working path in the browser.
void Hide()
hide Browser
Definition RBrowser.cxx:587
std::string NewWidgetMsg(std::shared_ptr< RBrowserWidget > &widget)
Create message which send to client to create new widget.
Definition RBrowser.cxx:815
bool fCatchWindowShow
! if arbitrary RWebWindow::Show calls should be catched by browser
Definition RBrowser.hxx:36
std::string fPromptFileOutput
! file name for prompt output
Definition RBrowser.hxx:40
void SetCatchWindowShow(bool on=true)
Enable/disable catch of RWebWindow::Show calls to embed created widgets, default on.
Definition RBrowser.hxx:99
void Show(const RWebDisplayArgs &args="", bool always_start_new_browser=false)
show Browser in specified place
Definition RBrowser.cxx:577
std::string GetCurrentWorkingDirectory()
Return the current directory of ROOT.
Definition RBrowser.cxx:807
bool GetCatchWindowShow() const
Is RWebWindow::Show calls catched for embeding of created widgets.
Definition RBrowser.hxx:102
void SetUseRCanvas(bool on=true)
Definition RBrowser.hxx:83
std::shared_ptr< RBrowserWidget > FindWidget(const std::string &name, const std::string &kind="") const
Find widget by name or kind.
Definition RBrowser.cxx:669
std::shared_ptr< RBrowserWidget > AddCatchedWidget(RWebWindow *win, const std::string &kind)
Add widget catched from external scripts.
Definition RBrowser.cxx:639
bool GetUseRCanvas() const
Definition RBrowser.hxx:82
std::vector< std::shared_ptr< RBrowserWidget > > fWidgets
! all browser widgets
Definition RBrowser.hxx:38
virtual ~RBrowser()
destructor
Definition RBrowser.cxx:381
void ProcessSaveFile(const std::string &fname, const std::string &content)
Process file save command in the editor.
Definition RBrowser.cxx:417
float fLastProgressSend
! last value of send progress
Definition RBrowser.hxx:41
std::string GetWindowUrl(bool remote)
Return URL parameter for the window showing ROOT Browser See ROOT::RWebWindow::GetUrl docu for more d...
Definition RBrowser.cxx:597
std::string ProcessBrowserRequest(const std::string &msg)
Process browser request.
Definition RBrowser.cxx:393
std::vector< std::string > GetRootLogs()
Get content of log file.
Definition RBrowser.cxx:721
void ProcessMsg(unsigned connid, const std::string &arg)
Process received message from the client.
Definition RBrowser.cxx:877
void CheckWidgtesModified(unsigned connid)
Check if any widget was modified and update if necessary.
Definition RBrowser.cxx:825
void CloseTab(const std::string &name)
Close and delete specified widget.
Definition RBrowser.cxx:685
void ProcessPostponedRequests()
Process postponed requests - decouple from websocket handling Only requests which can take longer tim...
Definition RBrowser.cxx:847
unsigned fConnId
! default connection id
Definition RBrowser.hxx:33
bool ActivateWidget(const std::string &title, const std::string &kind="")
Activate widget in RBrowser One should specify title and (optionally) kind of widget like "tcanvas" o...
std::string fTitle
! title
Definition RBrowser.hxx:32
void SendInitMsg(unsigned connid)
Process client connect.
Definition RBrowser.cxx:739
void SendProgress(unsigned connid, float progr)
Send generic progress message to the web window Should show progress bar on client side.
Definition RBrowser.cxx:788
long long fLastProgressSendTm
! time when last progress message was send
Definition RBrowser.hxx:42
void ProcessRunMacro(const std::string &file_path)
Process run macro command in the editor.
Definition RBrowser.cxx:428
void AddRCanvas()
Definition RBrowser.hxx:86
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
Represents web window, which can be shown in web browser or any other supported environment.
Namespace for new ROOT classes and functions.