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 {
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 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() && ((GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) || (GetBrowserKind() == kEdge)
104 }
105
106 /// returns true if local display like CEF or Qt5 QWebEngine should be used
107 bool IsLocalDisplay() const
108 {
109 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
110 }
111
112 /// returns true if browser supports headless mode
113 bool IsSupportHeadless() const
114 {
115 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kDefault) ||
117 (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5) || (GetBrowserKind() == kQt6);
118 }
119
120 /// set window url
121 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
122 /// returns window url
123 const std::string &GetUrl() const { return fUrl; }
124
125 /// set widget kind
126 RWebDisplayArgs &SetWidgetKind(const std::string &kind) { fWidgetKind = kind; return *this; }
127 /// returns widget kind
128 const std::string &GetWidgetKind() const { return fWidgetKind; }
129
130 /// set window url
131 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
132 /// returns window url
133 const std::string &GetPageContent() const { return fPageContent; }
134
135 /// Set standalone mode for running browser, default on
136 /// When disabled, normal browser window (or just tab) will be started
137 void SetStandalone(bool on = true) { fStandalone = on; }
138 /// Return true if browser should runs in standalone mode
139 bool IsStandalone() const { return fStandalone; }
140
141 /// set window url options
142 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
143 /// returns window url options
144 const std::string &GetUrlOpt() const { return fUrlOpt; }
145
146 /// append extra url options, add "&" as separator if required
147 void AppendUrlOpt(const std::string &opt);
148
149 /// returns window url with append options
150 std::string GetFullUrl() const;
151
152 /// set batch mode
153 void SetBatchMode(bool on = true) { fBatchMode = on; }
154 /// returns batch mode
155 bool IsBatchMode() const { return fBatchMode; }
156
157 /// set headless mode
158 void SetHeadless(bool on = true) { fHeadless = on; }
159 /// returns headless mode
160 bool IsHeadless() const { return fHeadless; }
161
162 /// set preferable web window width
163 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
164 /// set preferable web window height
165 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
166 /// set preferable web window width and height
167 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
168
169 /// set preferable web window x position, negative is default
170 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
171 /// set preferable web window y position, negative is default
172 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
173 /// set preferable web window x and y position, negative is default
174 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
175
176 /// returns preferable web window width
177 int GetWidth() const { return fWidth; }
178 /// returns preferable web window height
179 int GetHeight() const { return fHeight; }
180 /// set preferable web window x position
181 int GetX() const { return fX; }
182 /// set preferable web window y position
183 int GetY() const { return fY; }
184
185 /// set extra command line arguments for starting web browser command
186 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
187 /// get extra command line arguments for starting web browser command
188 const std::string &GetExtraArgs() const { return fExtraArgs; }
189
190 /// specify file name to which web browser output should be redirected
191 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
192 /// get file name to which web browser output should be redirected
193 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
194
195 /// set custom executable to start web browser
196 void SetCustomExec(const std::string &exec);
197 /// returns custom executable to start web browser
198 std::string GetCustomExec() const;
199
200 /// set http server instance, used for window display
201 void SetHttpServer(THttpServer *serv) { fServer = serv; }
202 /// returns http server instance, used for window display
203 THttpServer *GetHttpServer() const { return fServer; }
204
205 /// [internal] set web-driver data, used to start window
207 /// [internal] returns web-driver data, used to start window
208 void *GetDriverData() const { return fDriverData; }
209
210 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "", unsigned qtversion = 0x50000);
211};
212
213}
214}
215
216#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
unsigned fMasterConnection
! used master connection
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 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
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.
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
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...
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.
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.