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