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