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