Logo ROOT  
Reference Guide
RWebDisplayArgs.hxx
Go to the documentation of this file.
1 /// \file ROOT/RWebDisplayArgs.hxx
2 /// \ingroup WebGui ROOT7
3 /// \author Sergey Linev <s.linev@gsi.de>
4 /// \date 2018-10-24
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
16 #ifndef ROOT7_RWebDisplayArgs
17 #define ROOT7_RWebDisplayArgs
18 
19 #include <string>
20 #include <memory>
21 
22 class THttpServer;
23 
24 namespace ROOT {
25 namespace Experimental {
26 
27 class RWebWindow;
28 
30 
31 friend class RWebWindow;
32 
33 public:
34  enum EBrowserKind {
35  kChrome, ///< Google Chrome browser
36  kFirefox, ///< Mozilla Firefox browser
37  kNative, ///< either Chrome or Firefox - both support major functionality
38  kCEF, ///< Chromium Embedded Framework - local display with CEF libs
39  kQt5, ///< QWebEngine libraries - Chrome code packed in qt5
40  kLocal, ///< either CEF or Qt5 - both runs on local display without real http server
41  kStandard, ///< standard system web browser, not recognized by ROOT, without batch mode
42  kEmbedded, ///< window will be embedded into other, no extra browser need to be started
43  kCustom ///< custom web browser, execution string should be provided
44  };
45 
46 protected:
47  EBrowserKind fKind{kNative}; ///<! id of web browser used for display
48  std::string fUrl; ///<! URL to display
49  std::string fExtraArgs; ///<! extra arguments which will be append to exec string
50  std::string fPageContent; ///<! HTML page content
51  std::string fRedirectOutput; ///<! filename where browser output should be redirected
52  bool fHeadless{false}; ///<! is browser runs in headless mode
53  bool fStandalone{true}; ///<! indicates if browser should run isolated from other browser instances
54  THttpServer *fServer{nullptr}; ///<! http server which handle all requests
55  int fWidth{0}; ///<! custom window width, when not specified - used RWebWindow geometry
56  int fHeight{0}; ///<! custom window height, when not specified - used RWebWindow geometry
57  int fX{-1}; ///<! custom window x position, negative is default
58  int fY{-1}; ///<! custom window y position, negative is default
59  std::string fUrlOpt; ///<! extra URL options, which are append to window URL
60  std::string fExec; ///<! string to run browser, used with kCustom type
61  void *fDriverData{nullptr}; ///<! special data delivered to driver, can be used for QWebEngine
62 
63  std::shared_ptr<RWebWindow> fMaster; ///<! master window
64  int fMasterChannel{-1}; ///<! used master channel
65 
66  bool SetSizeAsStr(const std::string &str);
67  bool SetPosAsStr(const std::string &str);
68 
69 public:
71 
72  RWebDisplayArgs(const std::string &browser);
73 
74  RWebDisplayArgs(const char *browser);
75 
76  RWebDisplayArgs(int width, int height, int x = -1, int y = -1, const std::string &browser = "");
77 
78  RWebDisplayArgs(std::shared_ptr<RWebWindow> master, int channel = -1);
79 
80  virtual ~RWebDisplayArgs();
81 
82  RWebDisplayArgs &SetBrowserKind(const std::string &kind);
83  /// set browser kind, see EBrowserKind for allowed values
84  RWebDisplayArgs &SetBrowserKind(EBrowserKind kind) { fKind = kind; return *this; }
85  /// returns configured browser kind, see EBrowserKind for supported values
86  EBrowserKind GetBrowserKind() const { return fKind; }
87  std::string GetBrowserName() const;
88 
89  void SetMasterWindow(std::shared_ptr<RWebWindow> master, int channel = -1);
90 
91  /// returns true if local display like CEF or Qt5 QWebEngine should be used
92  bool IsLocalDisplay() const
93  {
94  return (GetBrowserKind() == kLocal) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5);
95  }
96 
97  /// returns true if browser supports headless (batch) mode, used for image production
98  bool IsSupportHeadless() const
99  {
100  return (GetBrowserKind() == kNative) || (GetBrowserKind() == kChrome) || (GetBrowserKind() == kCEF) || (GetBrowserKind() == kQt5);
101  }
102 
103  /// set window url
104  RWebDisplayArgs &SetUrl(const std::string &url) { fUrl = url; return *this; }
105  /// returns window url
106  const std::string &GetUrl() const { return fUrl; }
107 
108  /// set window url
109  RWebDisplayArgs &SetPageContent(const std::string &cont) { fPageContent = cont; return *this; }
110  /// returns window url
111  const std::string &GetPageContent() const { return fPageContent; }
112 
113  /// Set standalone mode for running browser, default on
114  /// When disabled, normal browser window (or just tab) will be started
115  void SetStandalone(bool on = true) { fStandalone = on; }
116  /// Return true if browser should runs in standalone mode
117  bool IsStandalone() const { return fStandalone; }
118 
119  /// set window url options
120  RWebDisplayArgs &SetUrlOpt(const std::string &opt) { fUrlOpt = opt; return *this; }
121  /// returns window url options
122  const std::string &GetUrlOpt() const { return fUrlOpt; }
123 
124  /// append extra url options, add "&" as separator if required
125  void AppendUrlOpt(const std::string &opt);
126 
127  /// returns window url with append options
128  std::string GetFullUrl() const;
129 
130  /// set headless mode
131  void SetHeadless(bool on = true) { fHeadless = on; }
132  /// returns headless mode
133  bool IsHeadless() const { return fHeadless; }
134 
135  /// set preferable web window width
136  RWebDisplayArgs &SetWidth(int w = 0) { fWidth = w; return *this; }
137  /// set preferable web window height
138  RWebDisplayArgs &SetHeight(int h = 0) { fHeight = h; return *this; }
139  RWebDisplayArgs &SetSize(int w, int h) { fWidth = w; fHeight = h; return *this; }
140 
141  /// set preferable web window x position, negative is default
142  RWebDisplayArgs &SetX(int x = -1) { fX = x; return *this; }
143  /// set preferable web window y position, negative is default
144  RWebDisplayArgs &SetY(int y = -1) { fY = y; return *this; }
145  RWebDisplayArgs &SetPos(int x = -1, int y = -1) { fX = x; fY = y; return *this; }
146 
147  /// returns preferable web window width
148  int GetWidth() const { return fWidth; }
149  /// returns preferable web window height
150  int GetHeight() const { return fHeight; }
151  /// set preferable web window x position
152  int GetX() const { return fX; }
153  /// set preferable web window y position
154  int GetY() const { return fY; }
155 
156  void SetExtraArgs(const std::string &args) { fExtraArgs = args; }
157  const std::string &GetExtraArgs() const { return fExtraArgs; }
158 
159  void SetRedirectOutput(const std::string &fname = "") { fRedirectOutput = fname; }
160  const std::string &GetRedirectOutput() const { return fRedirectOutput; }
161 
162  /// set custom executable to start web browser
163  void SetCustomExec(const std::string &exec);
164  /// returns custom executable to start web browser
165  std::string GetCustomExec() const;
166 
167  /// set http server instance, used for window display
168  void SetHttpServer(THttpServer *serv) { fServer = serv; }
169  /// returns http server instance, used for window display
170  THttpServer *GetHttpServer() const { return fServer; }
171 
172  /// [internal] set web-driver data, used to start window
173  void SetDriverData(void *data) { fDriverData = data; }
174  /// [internal] returns web-driver data, used to start window
175  void *GetDriverData() const { return fDriverData; }
176 };
177 
178 }
179 }
180 
181 #endif
ROOT::Experimental::RWebDisplayArgs::fDriverData
void * fDriverData
! special data delivered to driver, can be used for QWebEngine
Definition: RWebDisplayArgs.hxx:61
ROOT::Experimental::RWebDisplayArgs::fUrl
std::string fUrl
! URL to display
Definition: RWebDisplayArgs.hxx:48
ROOT::Experimental::RWebDisplayArgs::GetBrowserName
std::string GetBrowserName() const
Returns configured browser name.
Definition: RWebDisplayArgs.cxx:201
ROOT::Experimental::RWebDisplayArgs::SetBrowserKind
RWebDisplayArgs & SetBrowserKind(EBrowserKind kind)
set browser kind, see EBrowserKind for allowed values
Definition: RWebDisplayArgs.hxx:84
ROOT::Experimental::RWebDisplayArgs::GetFullUrl
std::string GetFullUrl() const
returns window url with append options
Definition: RWebDisplayArgs.cxx:248
ROOT::Experimental::RWebDisplayArgs::kFirefox
@ kFirefox
Mozilla Firefox browser.
Definition: RWebDisplayArgs.hxx:36
ROOT::Experimental::RWebDisplayArgs::fHeight
int fHeight
! custom window height, when not specified - used RWebWindow geometry
Definition: RWebDisplayArgs.hxx:56
ROOT::Experimental::RWebDisplayArgs::SetHttpServer
void SetHttpServer(THttpServer *serv)
set http server instance, used for window display
Definition: RWebDisplayArgs.hxx:168
ROOT::Experimental::RWebDisplayArgs::IsLocalDisplay
bool IsLocalDisplay() const
returns true if local display like CEF or Qt5 QWebEngine should be used
Definition: RWebDisplayArgs.hxx:92
ROOT::Experimental::RWebDisplayArgs::fHeadless
bool fHeadless
! is browser runs in headless mode
Definition: RWebDisplayArgs.hxx:52
ROOT::Experimental::RWebDisplayArgs::kLocal
@ kLocal
either CEF or Qt5 - both runs on local display without real http server
Definition: RWebDisplayArgs.hxx:40
ROOT::Experimental::RWebDisplayArgs::GetBrowserKind
EBrowserKind GetBrowserKind() const
returns configured browser kind, see EBrowserKind for supported values
Definition: RWebDisplayArgs.hxx:86
ROOT::Experimental::RWebDisplayArgs::kEmbedded
@ kEmbedded
window will be embedded into other, no extra browser need to be started
Definition: RWebDisplayArgs.hxx:42
ROOT::Experimental::RWebDisplayArgs::GetRedirectOutput
const std::string & GetRedirectOutput() const
Definition: RWebDisplayArgs.hxx:160
ROOT::Experimental::RWebDisplayArgs::GetUrlOpt
const std::string & GetUrlOpt() const
returns window url options
Definition: RWebDisplayArgs.hxx:122
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
ROOT::Experimental::RWebDisplayArgs::SetDriverData
void SetDriverData(void *data)
[internal] set web-driver data, used to start window
Definition: RWebDisplayArgs.hxx:173
ROOT::Experimental::RWebDisplayArgs::kStandard
@ kStandard
standard system web browser, not recognized by ROOT, without batch mode
Definition: RWebDisplayArgs.hxx:41
ROOT::Experimental::RWebDisplayArgs::SetBrowserKind
RWebDisplayArgs & SetBrowserKind(const std::string &kind)
Set browser kind as string argument Recognized values: chrome - use Google Chrome web browser,...
Definition: RWebDisplayArgs.cxx:142
ROOT::Experimental::RWebDisplayArgs::SetMasterWindow
void SetMasterWindow(std::shared_ptr< RWebWindow > master, int channel=-1)
Assign window and channel id where other window will be embed.
Definition: RWebDisplayArgs.cxx:223
ROOT::Experimental::RWebDisplayArgs::SetExtraArgs
void SetExtraArgs(const std::string &args)
Definition: RWebDisplayArgs.hxx:156
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Experimental::RWebDisplayArgs::fPageContent
std::string fPageContent
! HTML page content
Definition: RWebDisplayArgs.hxx:50
ROOT::Experimental::RWebDisplayArgs
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
Definition: RWebDisplayArgs.hxx:29
ROOT::Experimental::RWebDisplayArgs::GetDriverData
void * GetDriverData() const
[internal] returns web-driver data, used to start window
Definition: RWebDisplayArgs.hxx:175
ROOT::Experimental::RWebDisplayArgs::SetPageContent
RWebDisplayArgs & SetPageContent(const std::string &cont)
set window url
Definition: RWebDisplayArgs.hxx:109
ROOT::Experimental::RWebDisplayArgs::SetPos
RWebDisplayArgs & SetPos(int x=-1, int y=-1)
Definition: RWebDisplayArgs.hxx:145
ROOT::Experimental::RWebDisplayArgs::GetX
int GetX() const
set preferable web window x position
Definition: RWebDisplayArgs.hxx:152
ROOT::Experimental::RWebDisplayArgs::SetHeadless
void SetHeadless(bool on=true)
set headless mode
Definition: RWebDisplayArgs.hxx:131
ROOT::Experimental::RWebDisplayArgs::GetWidth
int GetWidth() const
returns preferable web window width
Definition: RWebDisplayArgs.hxx:148
ROOT::Experimental::RWebDisplayArgs::IsHeadless
bool IsHeadless() const
returns headless mode
Definition: RWebDisplayArgs.hxx:133
ROOT::Experimental::RWebDisplayArgs::RWebDisplayArgs
RWebDisplayArgs()
Default constructor - browser kind configured from gROOT->GetWebDisplay()
Definition: RWebDisplayArgs.cxx:31
ROOT::Experimental::RWebDisplayArgs::kCustom
@ kCustom
custom web browser, execution string should be provided
Definition: RWebDisplayArgs.hxx:43
ROOT::Experimental::RWebDisplayArgs::SetStandalone
void SetStandalone(bool on=true)
Set standalone mode for running browser, default on When disabled, normal browser window (or just tab...
Definition: RWebDisplayArgs.hxx:115
ROOT::Experimental::RWebDisplayArgs::SetRedirectOutput
void SetRedirectOutput(const std::string &fname="")
Definition: RWebDisplayArgs.hxx:159
ROOT::Experimental::RWebDisplayArgs::kNative
@ kNative
either Chrome or Firefox - both support major functionality
Definition: RWebDisplayArgs.hxx:37
ROOT::Experimental::RWebDisplayArgs::fY
int fY
! custom window y position, negative is default
Definition: RWebDisplayArgs.hxx:58
ROOT::Experimental::RWebDisplayArgs::fRedirectOutput
std::string fRedirectOutput
! filename where browser output should be redirected
Definition: RWebDisplayArgs.hxx:51
ROOT::Experimental::RWebDisplayArgs::SetUrl
RWebDisplayArgs & SetUrl(const std::string &url)
set window url
Definition: RWebDisplayArgs.hxx:104
ROOT::Experimental::RWebDisplayArgs::IsStandalone
bool IsStandalone() const
Return true if browser should runs in standalone mode.
Definition: RWebDisplayArgs.hxx:117
ROOT::Experimental::RWebDisplayArgs::~RWebDisplayArgs
virtual ~RWebDisplayArgs()
Destructor.
Definition: RWebDisplayArgs.cxx:76
ROOT::Experimental::RWebDisplayArgs::EBrowserKind
EBrowserKind
Definition: RWebDisplayArgs.hxx:34
THttpServer
Definition: THttpServer.h:31
ROOT::Experimental::RWebDisplayArgs::kQt5
@ kQt5
QWebEngine libraries - Chrome code packed in qt5.
Definition: RWebDisplayArgs.hxx:39
ROOT::Experimental::RWebDisplayArgs::IsSupportHeadless
bool IsSupportHeadless() const
returns true if browser supports headless (batch) mode, used for image production
Definition: RWebDisplayArgs.hxx:98
ROOT::Experimental::RWebDisplayArgs::SetWidth
RWebDisplayArgs & SetWidth(int w=0)
set preferable web window width
Definition: RWebDisplayArgs.hxx:136
h
#define h(i)
Definition: RSha256.hxx:106
ROOT::Experimental::RWebDisplayArgs::GetHttpServer
THttpServer * GetHttpServer() const
returns http server instance, used for window display
Definition: RWebDisplayArgs.hxx:170
ROOT::Experimental::RWebDisplayArgs::fServer
THttpServer * fServer
! http server which handle all requests
Definition: RWebDisplayArgs.hxx:54
ROOT::Experimental::RWebDisplayArgs::SetX
RWebDisplayArgs & SetX(int x=-1)
set preferable web window x position, negative is default
Definition: RWebDisplayArgs.hxx:142
ROOT::Experimental::RWebDisplayArgs::fExtraArgs
std::string fExtraArgs
! extra arguments which will be append to exec string
Definition: RWebDisplayArgs.hxx:49
ROOT::Experimental::RWebDisplayArgs::SetPosAsStr
bool SetPosAsStr(const std::string &str)
Set position of web browser window as string like "100,100".
Definition: RWebDisplayArgs.cxx:108
ROOT::Experimental::RWebDisplayArgs::fMasterChannel
int fMasterChannel
! used master channel
Definition: RWebDisplayArgs.hxx:64
ROOT::Experimental::RWebDisplayArgs::GetHeight
int GetHeight() const
returns preferable web window height
Definition: RWebDisplayArgs.hxx:150
ROOT::Experimental::RWebDisplayArgs::fKind
EBrowserKind fKind
! id of web browser used for display
Definition: RWebDisplayArgs.hxx:47
ROOT::Experimental::RWebDisplayArgs::GetUrl
const std::string & GetUrl() const
returns window url
Definition: RWebDisplayArgs.hxx:106
y
Double_t y[n]
Definition: legend1.C:17
ROOT::Experimental::RWebDisplayArgs::SetHeight
RWebDisplayArgs & SetHeight(int h=0)
set preferable web window height
Definition: RWebDisplayArgs.hxx:138
ROOT::Experimental::RWebWindow
Represents web window, which can be shown in web browser or any other supported environment.
Definition: RWebWindow.hxx:56
ROOT::Experimental::RWebDisplayArgs::GetExtraArgs
const std::string & GetExtraArgs() const
Definition: RWebDisplayArgs.hxx:157
ROOT::Experimental::RWebDisplayArgs::fStandalone
bool fStandalone
! indicates if browser should run isolated from other browser instances
Definition: RWebDisplayArgs.hxx:53
ROOT::Experimental::RWebDisplayArgs::fUrlOpt
std::string fUrlOpt
! extra URL options, which are append to window URL
Definition: RWebDisplayArgs.hxx:59
ROOT::Experimental::RWebDisplayArgs::SetY
RWebDisplayArgs & SetY(int y=-1)
set preferable web window y position, negative is default
Definition: RWebDisplayArgs.hxx:144
ROOT::Experimental::RWebDisplayArgs::kCEF
@ kCEF
Chromium Embedded Framework - local display with CEF libs.
Definition: RWebDisplayArgs.hxx:38
ROOT::Experimental::RWebDisplayArgs::GetPageContent
const std::string & GetPageContent() const
returns window url
Definition: RWebDisplayArgs.hxx:111
ROOT::Experimental::RWebDisplayArgs::kChrome
@ kChrome
Google Chrome browser.
Definition: RWebDisplayArgs.hxx:35
ROOT::Experimental::RWebDisplayArgs::SetSizeAsStr
bool SetSizeAsStr(const std::string &str)
Set size of web browser window as string like "800x600".
Definition: RWebDisplayArgs.cxx:84
ROOT::Experimental::RWebDisplayArgs::fMaster
std::shared_ptr< RWebWindow > fMaster
! master window
Definition: RWebDisplayArgs.hxx:63
ROOT::Experimental::RWebDisplayArgs::fWidth
int fWidth
! custom window width, when not specified - used RWebWindow geometry
Definition: RWebDisplayArgs.hxx:55
ROOT::Experimental::RWebDisplayArgs::SetUrlOpt
RWebDisplayArgs & SetUrlOpt(const std::string &opt)
set window url options
Definition: RWebDisplayArgs.hxx:120
ROOT::Experimental::RWebDisplayArgs::SetSize
RWebDisplayArgs & SetSize(int w, int h)
Definition: RWebDisplayArgs.hxx:139
ROOT::Experimental::RWebDisplayArgs::fX
int fX
! custom window x position, negative is default
Definition: RWebDisplayArgs.hxx:57
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::RWebDisplayArgs::fExec
std::string fExec
! string to run browser, used with kCustom type
Definition: RWebDisplayArgs.hxx:60
ROOT::Experimental::RWebDisplayArgs::GetCustomExec
std::string GetCustomExec() const
returns custom executable to start web browser
Definition: RWebDisplayArgs.cxx:279
ROOT::Experimental::RWebDisplayArgs::AppendUrlOpt
void AppendUrlOpt(const std::string &opt)
append extra url options, add "&" as separator if required
Definition: RWebDisplayArgs.cxx:234
ROOT::Experimental::RWebDisplayArgs::GetY
int GetY() const
set preferable web window y position
Definition: RWebDisplayArgs.hxx:154
ROOT::Experimental::RWebDisplayArgs::SetCustomExec
void SetCustomExec(const std::string &exec)
set custom executable to start web browser
Definition: RWebDisplayArgs.cxx:270