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 kFirefox, ///< Mozilla Firefox browser
38 kNative, ///< either Chrome or Firefox - both support major functionality
39 kCEF, ///< Chromium Embedded Framework - local display with CEF libs
40 kQt5, ///< QWebEngine libraries - Chrome code packed in qt5
41 kLocal, ///< either CEF or Qt5 - both runs on local display without real http server
42 kStandard, ///< standard system web browser, not recognized by ROOT, without batch mode
43 kEmbedded, ///< window will be embedded into other, no extra browser need to be started
44 kCustom ///< custom web browser, execution string should be provided
45 };
46
47protected:
48 EBrowserKind fKind{kNative}; ///<! id of web browser used for display
49 std::string fUrl; ///<! URL to display
50 std::string fExtraArgs; ///<! extra arguments which will be append to exec string
51 std::string fPageContent; ///<! HTML page content
52 std::string fRedirectOutput; ///<! filename where browser output should be redirected
53 bool fHeadless{false}; ///<! is browser runs in headless mode
54 bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
55 THttpServer *fServer{nullptr}; ///<! http server which handle all requests
56 int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
57 int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
58 int fX{-1}; ///<! custom window x position, negative is default
59 int fY{-1}; ///<! custom window y position, negative is default
60 std::string fUrlOpt; ///<! extra URL options, which are append to window URL
61 std::string fExec; ///<! string to run browser, used with kCustom type
62 void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
63
64 std::shared_ptr<RWebWindow> fMaster; ///<! master window
65 int fMasterChannel{-1}; ///<! used master channel
66
67 bool SetSizeAsStr(const std::string &str);
68 bool SetPosAsStr(const std::string &str);
69
70public:
72
73 RWebDisplayArgs(const std::string &browser);
74
75 RWebDisplayArgs(const char *browser);
76
77 RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
78
79 RWebDisplayArgs(std::shared_ptr<RWebWindow> master, int channel = -1);
80
81 virtual ~RWebDisplayArgs();
82
83 RWebDisplayArgs &SetBrowserKind(const std::string &kind);
84 /// set browser kind, see EBrowserKind for allowed values
85 RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
86 /// returns configured browser kind, see EBrowserKind for supported values
87 EBrowserKind GetBrowserKind() const { return fKind; }
88 std::string GetBrowserName() const;
89
90 void SetMasterWindow(std::shared_ptr<RWebWindow> master, int channel = -1);
91
92 /// returns true if local display like CEF or Qt5 QWebEngine should be used
93 bool IsLocalDisplay() const
94 {
95 return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5);
96 }
97
98 /// returns true if browser supports headless (batch) mode, used for image production
99 bool IsSupportHeadless() const
100 {
101 return (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5);
102 }
103
104 /// set window url
105 RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
106 /// returns window url
107 const std::string &GetUrl() const { return fUrl; }
108
109 /// set window url
110 RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
111 /// returns window url
112 const std::string &GetPageContent() const { return fPageContent; }
113
114 /// Set standalone mode for running browser, default on
115 /// When disabled, normal browser window (or just tab) will be started
116 void SetStandalone(bool on = true) { fStandalone = on; }
117 /// Return true if browser should runs in standalone mode
118 bool IsStandalone() const { return fStandalone; }
119
120 /// set window url options
121 RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
122 /// returns window url options
123 const std::string &GetUrlOpt() const { return fUrlOpt; }
124
125 /// append extra url options, add "&" as separator if required
126 void AppendUrlOpt(const std::string &opt);
127
128 /// returns window url with append options
129 std::string GetFullUrl() const;
130
131 /// set headless mode
132 void SetHeadless(bool on = true) { fHeadless = on; }
133 /// returns headless mode
134 bool IsHeadless() const { return fHeadless; }
135
136 /// set preferable web window width
137 RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
138 /// set preferable web window height
139 RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
140 RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
141
142 /// set preferable web window x position, negative is default
143 RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
144 /// set preferable web window y position, negative is default
145 RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
146 RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
147
148 /// returns preferable web window width
149 int GetWidth() const { return fWidth; }
150 /// returns preferable web window height
151 int GetHeight() const { return fHeight; }
152 /// set preferable web window x position
153 int GetX() const { return fX; }
154 /// set preferable web window y position
155 int GetY() const { return fY; }
156
157 void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
158 const std::string &GetExtraArgs() const { return fExtraArgs; }
159
160 void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
161 const std::string &GetRedirectOutput() const { return fRedirectOutput; }
162
163 /// set custom executable to start web browser
164 void SetCustomExec(const std::string &exec);
165 /// returns custom executable to start web browser
166 std::string GetCustomExec() const;
167
168 /// set http server instance, used for window display
169 void SetHttpServer(THttpServer *serv) { fServer = serv; }
170 /// returns http server instance, used for window display
171 THttpServer *GetHttpServer() const { return fServer; }
172
173 /// [internal] set web-driver data, used to start window
174 void SetDriverData(void *data) { fDriverData = data; }
175 /// [internal] returns web-driver data, used to start window
176 void *GetDriverData() const { return fDriverData; }
177
178 static std::string GetQt5EmbedQualifier(const void *qparent, const std::string &urlopt = "");
179};
180
181}
182}
183
184#endif
#define h(i)
Definition RSha256.hxx:106
include TDocParser_001 C image html pict1_TDocParser_001 png width
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 (batch) mode, used for image production
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)
const std::string & GetUrlOpt() const
returns window url options
RWebDisplayArgs & SetUrl(const std::string &url)
set window url
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)
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...
int GetHeight() const
returns preferable web window height
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
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
RWebDisplayArgs & SetBrowserKind(const std::string &kind)
Set browser kind as string argument Recognized values: chrome - use Google Chrome web browser,...
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="")
@ kFirefox
Mozilla Firefox browser.
@ kCEF
Chromium Embedded Framework - local display with CEF libs.
@ 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
@ kLocal
either CEF or Qt5 - both runs on local display without real http server
@ kStandard
standard system web browser, not recognized by ROOT, without batch mode
@ kQt5
QWebEngine libraries - Chrome 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
void SetDriverData(void *data)
[internal] set web-driver data, used to start window
RWebDisplayArgs & SetSize(int w, int h)
const std::string & GetUrl() const
returns window url
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
RWebDisplayArgs()
Default constructor - browser kind configured from gROOT->GetWebDisplay()
Represents web window, which can be shown in web browser or any other supported environment.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
RLogChannel & WebGUILog()
Log channel for WebGUI diagnostics.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...