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