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// Warning: This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
4
5/*************************************************************************
6 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT7_RBrowser
14#define ROOT7_RBrowser
15
16#include <ROOT/RWebWindow.hxx>
17#include <ROOT/RBrowserData.hxx>
18
19#include <vector>
20#include <memory>
21
22namespace ROOT {
23
24class RBrowserWidget;
25class RBrowserTimer;
26
27class RBrowser {
28
29 friend class RBrowserTimer;
30
31protected:
32
33 std::string fTitle; ///<! title
34 unsigned fConnId{0}; ///<! default connection id
35
36 bool fUseRCanvas{false}; ///<! which canvas should be used
37 bool fCatchWindowShow{true}; ///<! if arbitrary RWebWindow::Show calls should be catched by browser
38 std::string fActiveWidgetName; ///<! name of active widget
39 std::vector<std::shared_ptr<RBrowserWidget>> fWidgets; ///<! all browser widgets
40 int fWidgetCnt{0}; ///<! counter for created widgets
41 std::string fPromptFileOutput; ///<! file name for prompt output
42 float fLastProgressSend{0}; ///<! last value of send progress
43 long long fLastProgressSendTm{0}; ///<! time when last progress message was send
44
45 std::shared_ptr<RWebWindow> fWebWindow; ///<! web window to browser
46
47 RBrowserData fBrowsable; ///<! central browsing element
48 std::unique_ptr<RBrowserTimer> fTimer; ///<! timer to handle postponed requests
49 std::vector<std::vector<std::string>> fPostponed; ///<! postponed messages, handled in timer
50
51 std::shared_ptr<RBrowserWidget> AddWidget(const std::string &kind);
52 std::shared_ptr<RBrowserWidget> AddCatchedWidget(RWebWindow *win, const std::string &kind);
53 std::shared_ptr<RBrowserWidget> FindWidget(const std::string &name, const std::string &kind = "") const;
54 std::shared_ptr<RBrowserWidget> GetActiveWidget() const { return FindWidget(fActiveWidgetName); }
55
56 void CloseTab(const std::string &name);
57
58 std::string ProcessBrowserRequest(const std::string &msg);
59 std::string ProcessDblClick(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
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:27
bool fUseRCanvas
! which canvas should be used
Definition RBrowser.hxx:36
std::unique_ptr< RBrowserTimer > fTimer
! timer to handle postponed requests
Definition RBrowser.hxx:48
RBrowserData fBrowsable
! central browsing element
Definition RBrowser.hxx:47
std::shared_ptr< RBrowserWidget > AddWidget(const std::string &kind)
Creates new widget.
Definition RBrowser.cxx:541
std::vector< std::string > GetRootHistory()
Get content of history file.
Definition RBrowser.cxx:631
void AddInitWidget(const std::string &kind)
Create new widget and send init message to the client.
Definition RBrowser.cxx:592
std::vector< std::vector< std::string > > fPostponed
! postponed messages, handled in timer
Definition RBrowser.hxx:49
std::shared_ptr< RWebWindow > fWebWindow
! web window to browser
Definition RBrowser.hxx:45
int fWidgetCnt
! counter for created widgets
Definition RBrowser.hxx:40
std::shared_ptr< RBrowserWidget > GetActiveWidget() const
Definition RBrowser.hxx:54
std::string ProcessDblClick(unsigned connid, std::vector< std::string > &args)
Process dbl click on browser item.
Definition RBrowser.cxx:398
void AddTCanvas()
Definition RBrowser.hxx:85
void ClearOnClose(const std::shared_ptr< void > &handle)
Set handle which will be cleared when connection is closed.
Definition RBrowser.cxx:975
std::string fActiveWidgetName
! name of active widget
Definition RBrowser.hxx:38
void SetWorkingPath(const std::string &path)
Set working path in the browser.
Definition RBrowser.cxx:934
void Hide()
hide Browser
Definition RBrowser.cxx:519
std::string NewWidgetMsg(std::shared_ptr< RBrowserWidget > &widget)
Create message which send to client to create new widget.
Definition RBrowser.cxx:742
bool fCatchWindowShow
! if arbitrary RWebWindow::Show calls should be catched by browser
Definition RBrowser.hxx:37
std::string fPromptFileOutput
! file name for prompt output
Definition RBrowser.hxx:41
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:507
std::string GetCurrentWorkingDirectory()
Return the current directory of ROOT.
Definition RBrowser.cxx:734
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:602
std::shared_ptr< RBrowserWidget > AddCatchedWidget(RWebWindow *win, const std::string &kind)
Add widget catched from external scripts.
Definition RBrowser.cxx:573
bool GetUseRCanvas() const
Definition RBrowser.hxx:82
std::vector< std::shared_ptr< RBrowserWidget > > fWidgets
! all browser widgets
Definition RBrowser.hxx:39
virtual ~RBrowser()
destructor
Definition RBrowser.cxx:340
void ProcessSaveFile(const std::string &fname, const std::string &content)
Process file save command in the editor.
Definition RBrowser.cxx:373
void CheckWidgtesModified()
Check if any widget was modified and update if necessary.
Definition RBrowser.cxx:752
float fLastProgressSend
! last value of send progress
Definition RBrowser.hxx:42
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:529
std::string ProcessBrowserRequest(const std::string &msg)
Process browser request.
Definition RBrowser.cxx:349
std::vector< std::string > GetRootLogs()
Get content of log file.
Definition RBrowser.cxx:654
void ProcessMsg(unsigned connid, const std::string &arg)
Process received message from the client.
Definition RBrowser.cxx:789
void CloseTab(const std::string &name)
Close and delete specified widget.
Definition RBrowser.cxx:618
void ProcessPostponedRequests()
Process postponed requests - decouple from websocket handling Only requests which can take longer tim...
Definition RBrowser.cxx:762
unsigned fConnId
! default connection id
Definition RBrowser.hxx:34
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...
Definition RBrowser.cxx:949
std::string fTitle
! title
Definition RBrowser.hxx:33
void SendInitMsg(unsigned connid)
Process client connect.
Definition RBrowser.cxx:672
void SendProgress(unsigned connid, float progr)
Send generic progress message to the web window Should show progress bar on client side.
Definition RBrowser.cxx:715
long long fLastProgressSendTm
! time when last progress message was send
Definition RBrowser.hxx:43
void ProcessRunMacro(const std::string &file_path)
Process run macro command in the editor.
Definition RBrowser.cxx:384
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...