Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RWebDisplayArgs.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <s.linev@gsi.de>
2// Date: 2018-10-24
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-2019, 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_RWebDisplayArgs
14#define ROOT7_RWebDisplayArgs
15
16#include <string>
17#include <memory>
18
19class THttpServer;
20
21namespace ROOT {
22
23namespace Experimental {
24class RLogChannel;
25} // namespace Experimental
26
27/// Log channel for WebGUI diagnostics.
29
30
31class RWebWindow;
32
34
35friend class RWebWindow;
36
37public:
39 kChrome, ///< Google Chrome browser
40 kEdge, ///< Microsoft Edge browser (Windows only)
41 kSafari, ///< Safari browser
42 kFirefox, ///< Mozilla Firefox browser
43 kNative, ///< either Chrome or Firefox - both support major functionality
44 kCEF, ///< Chromium Embedded Framework - local display with CEF libs
45 kQt5, ///< Qt5 QWebEngine libraries - Chromium code packed in qt5
46 kQt6, ///< Qt6 QWebEngine libraries - Chromium code packed in qt6
47 kLocal, ///< either CEF or Qt5 - both runs on local display without real http server
48 kDefault, ///< default system web browser, can not be used in batch mode
49 kServer, ///< indicates that ROOT runs as server and just printouts window URL, browser should be started by the user
50 kEmbedded, ///< window will be embedded into other, no extra browser need to be started
51 kOff, ///< disable web display, do not start any browser
52 kOn, ///< web display enable, first try use embed displays like Qt or CEF, then native browsers and at the end default system browser
53 kCustom ///< custom web browser, execution string should be provided
54 };
55
56protected:
57 EBrowserKind fKind{kNative}; ///<! id of web browser used for display
58 std::string fUrl; ///<! URL to display
59 std::string fExtraArgs; ///<! extra arguments which will be append to exec string
60 std::string fPageContent; ///<! HTML page content
61 std::string fRedirectOutput; ///<! filename where browser output should be redirected
62 std::string fWidgetKind; ///<! widget kind, used to identify that will be displayed in the web window
63 bool fBatchMode{false}; ///<! is browser runs in batch mode
64 bool fHeadless{false}; ///<! is browser runs in headless mode
65 bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
66 THttpServer *fServer{nullptr}; ///<! http server which handle all requests
67 int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
68 int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
69 int fX{-1}; ///<! custom window x position, negative is default
70 int fY{-1}; ///<! custom window y position, negative is default
71 std::string fUrlOpt; ///<! extra URL options, which are append to window URL
72 std::string fExec; ///<! string to run browser, used with kCustom type
73 void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
74
75 std::shared_ptr<RWebWindow> fMaster; ///<! master window
76 unsigned fMasterConnection{0}; ///<! used master connection
77 int fMasterChannel{-1}; ///<! used master channel
78
79 bool SetSizeAsStr(const std::string &str);
80 bool SetPosAsStr(const std::string &str);
81
82public:
84
85 RWebDisplayArgs(const std::string &browser);
86
87 RWebDisplayArgs(const char *browser);
88
89 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
90
91 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, unsigned conndid = 0, int channel = -1);
92
94
95 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
96 /// set browser kind, see EBrowserKind for allowed values
97 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
98 /// returns configured browser kind, see EBrowserKind for supported values
99 EBrowserKind GetBrowserKind() const { return fKind; }
100 std::string GetBrowserName() const;
101
102 void SetMasterWindow(std::shared_ptr<RWebWindow> master, unsigned connid = 0, int channel = -1);
103
104 /// returns true if interactive browser window supposed to be started
106 {
107 return !IsHeadless() &&
108 ((GetBrowserKind() == kOn) || (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) ||
111 }
112
113 /// returns true if local display like CEF or Qt5 QWebEngine should be used
114 bool IsLocalDisplay() const
115 {
116 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
117 }
118
119 /// returns true if browser supports headless mode
120 bool IsSupportHeadless() const
121 {
122 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kDefault) || (GetBrowserKind() == kOn) ||
124 (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
125 }
126
127 /// set window url
128 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
129 /// returns window url
130 const std::string &GetUrl() const { return fUrl; }
131
132 /// set widget kind
133 RWebDisplayArgs &SetWidgetKind(const std::string &kind) { fWidgetKind = kind; return *this; }
134 /// returns widget kind
135 const std::string &GetWidgetKind() const { return fWidgetKind; }
136
137 /// set window url
138 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
139 /// returns window url
140 const std::string &GetPageContent() const { return fPageContent; }
141
142 /// Set standalone mode for running browser, default on
143 /// When disabled, normal browser window (or just tab) will be started
144 void SetStandalone(bool on = true) { fStandalone = on; }
145 /// Return true if browser should runs in standalone mode
146 bool IsStandalone() const { return fStandalone; }
147
148 /// set window url options
149 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
150 /// returns window url options
151 const std::string &GetUrlOpt() const { return fUrlOpt; }
152
153 /// append extra url options, add "&" as separator if required
154 void AppendUrlOpt(const std::string &opt);
155
156 /// returns window url with append options
157 std::string GetFullUrl() const;
158
159 /// set batch mode
160 void SetBatchMode(bool on = true) { fBatchMode = on; }
161 /// returns batch mode
162 bool IsBatchMode() const { return fBatchMode; }
163
164 /// set headless mode
165 void SetHeadless(bool on = true) { fHeadless = on; }
166 /// returns headless mode
167 bool IsHeadless() const { return fHeadless; }
168
169 /// set preferable web window width
170 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
171 /// set preferable web window height
172 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
173 /// set preferable web window width and height
174 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
175
176 /// set preferable web window x position, negative is default
177 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
178 /// set preferable web window y position, negative is default
179 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
180 /// set preferable web window x and y position, negative is default
181 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
182
183 /// returns preferable web window width
184 int GetWidth() const { return fWidth; }
185 /// returns preferable web window height
186 int GetHeight() const { return fHeight; }
187 /// set preferable web window x position
188 int GetX() const { return fX; }
189 /// set preferable web window y position
190 int GetY() const { return fY; }
191
192 /// set extra command line arguments for starting web browser command
193 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
194 /// get extra command line arguments for starting web browser command
195 const std::string &GetExtraArgs() const { return fExtraArgs; }
196
197 /// specify file name to which web browser output should be redirected
198 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
199 /// get file name to which web browser output should be redirected
200 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
201
202 /// set custom executable to start web browser
203 void SetCustomExec(const std::string &exec);
204 /// returns custom executable to start web browser
205 std::string GetCustomExec() const;
206
207 /// set http server instance, used for window display
209 /// returns http server instance, used for window display
210 THttpServer *GetHttpServer() const { return fServer; }
211
212 /// [internal] set web-driver data, used to start window
214 /// [internal] returns web-driver data, used to start window
215 void *GetDriverData() const { return fDriverData; }
216
217 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "", unsigned qtversion = 0x50000);
218};
219
220} // namespace ROOT
221
222#endif
#define h(i)
Definition RSha256.hxx:106
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
A log configuration for a channel, e.g.
Definition RLogger.hxx:101
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
std::string GetBrowserName() const
Returns configured browser name.
virtual ~RWebDisplayArgs()
Destructor.
EBrowserKind GetBrowserKind() const
returns configured browser kind, see EBrowserKind for supported values
RWebDisplayArgs & SetUrlOpt(const std::string &opt)
set window url options
RWebDisplayArgs & SetBrowserKind(EBrowserKind kind)
set browser kind, see EBrowserKind for allowed values
RWebDisplayArgs & SetX(int x=-1)
set preferable web window x position, negative is default
const std::string & GetRedirectOutput() const
get file name to which web browser output should be redirected
bool IsSupportHeadless() const
returns true if browser supports headless mode
void SetStandalone(bool on=true)
Set standalone mode for running browser, default on When disabled, normal browser window (or just tab...
int fHeight
! custom window height, when not specified - used RWebWindow geometry
bool SetPosAsStr(const std::string &str)
Set position of web browser window as string like "100,100".
std::string fExec
! string to run browser, used with kCustom type
void SetBatchMode(bool on=true)
set batch mode
RWebDisplayArgs & SetWidgetKind(const std::string &kind)
set widget kind
THttpServer * GetHttpServer() const
returns http server instance, used for window display
void * fDriverData
! special data delivered to driver, can be used for QWebEngine
bool fBatchMode
! is browser runs in batch mode
const std::string & GetWidgetKind() const
returns widget kind
bool fStandalone
! indicates if browser should run isolated from other browser instances
RWebDisplayArgs & SetSize(int w, int h)
set preferable web window width and height
RWebDisplayArgs & SetUrl(const std::string &url)
set window url
int GetWidth() const
returns preferable web window width
RWebDisplayArgs & SetPageContent(const std::string &cont)
set window url
bool fHeadless
! is browser runs in headless mode
std::string fWidgetKind
! widget kind, used to identify that will be displayed in the web window
std::string fUrlOpt
! extra URL options, which are append to window URL
const std::string & GetUrl() const
returns window url
void SetCustomExec(const std::string &exec)
set custom executable to start web browser
int fWidth
! custom window width, when not specified - used RWebWindow geometry
std::string fUrl
! URL to display
void SetMasterWindow(std::shared_ptr< RWebWindow > master, unsigned connid=0, int channel=-1)
Assign window, connection and channel id where other window will be embed.
void AppendUrlOpt(const std::string &opt)
append extra url options, add "&" as separator if required
int GetY() const
set preferable web window y position
std::string GetFullUrl() const
returns window url with append options
bool IsStandalone() const
Return true if browser should runs in standalone mode.
int GetHeight() const
returns preferable web window height
RWebDisplayArgs & SetBrowserKind(const std::string &kind)
Set browser kind as string argument.
EBrowserKind fKind
! id of web browser used for display
std::string GetCustomExec() const
returns custom executable to start web browser
void SetExtraArgs(const std::string &args)
set extra command line arguments for starting web browser command
unsigned fMasterConnection
! used master connection
static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt="", unsigned qtversion=0x50000)
Returns string which can be used as argument in RWebWindow::Show() method to display web window in pr...
RWebDisplayArgs & SetPos(int x=-1, int y=-1)
set preferable web window x and y position, negative is default
bool IsBatchMode() const
returns batch mode
void SetHttpServer(THttpServer *serv)
set http server instance, used for window display
std::string fPageContent
! HTML page content
int fMasterChannel
! used master channel
RWebDisplayArgs & SetWidth(int w=0)
set preferable web window width
void SetDriverData(void *data)
[internal] set web-driver data, used to start window
bool IsInteractiveBrowser() const
returns true if interactive browser window supposed to be started
RWebDisplayArgs & SetY(int y=-1)
set preferable web window y position, negative is default
bool IsHeadless() const
returns headless mode
THttpServer * fServer
! http server which handle all requests
std::shared_ptr< RWebWindow > fMaster
! master window
std::string fRedirectOutput
! filename where browser output should be redirected
RWebDisplayArgs & SetHeight(int h=0)
set preferable web window height
const std::string & GetUrlOpt() const
returns window url options
bool SetSizeAsStr(const std::string &str)
Set size of web browser window as string like "800x600".
@ kOn
web display enable, first try use embed displays like Qt or CEF, then native browsers and at the end ...
@ kDefault
default system web browser, can not be used in batch mode
@ kFirefox
Mozilla Firefox browser.
@ kNative
either Chrome or Firefox - both support major functionality
@ kLocal
either CEF or Qt5 - both runs on local display without real http server
@ kServer
indicates that ROOT runs as server and just printouts window URL, browser should be started by the us...
@ kOff
disable web display, do not start any browser
@ kEmbedded
window will be embedded into other, no extra browser need to be started
@ kCEF
Chromium Embedded Framework - local display with CEF libs.
@ kSafari
Safari browser.
@ kQt5
Qt5 QWebEngine libraries - Chromium code packed in qt5.
@ kQt6
Qt6 QWebEngine libraries - Chromium code packed in qt6.
@ kCustom
custom web browser, execution string should be provided
@ kChrome
Google Chrome browser.
@ kEdge
Microsoft Edge browser (Windows only)
void * GetDriverData() const
[internal] returns web-driver data, used to start window
void SetRedirectOutput(const std::string &fname="")
specify file name to which web browser output should be redirected
void SetHeadless(bool on=true)
set headless mode
const std::string & GetExtraArgs() const
get extra command line arguments for starting web browser command
int GetX() const
set preferable web window x position
bool IsLocalDisplay() const
returns true if local display like CEF or Qt5 QWebEngine should be used
std::string fExtraArgs
! extra arguments which will be append to exec string
const std::string & GetPageContent() const
returns window url
int fY
! custom window y position, negative is default
int fX
! custom window x position, negative is default
RWebDisplayArgs()
Default constructor.
Represents web window, which can be shown in web browser or any other supported environment.
Online http server for arbitrary ROOT application.
Definition THttpServer.h:31
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
ROOT::Experimental::RLogChannel & WebGUILog()
Log channel for WebGUI diagnostics.