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