Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RWebDisplayHandle.hxx
Go to the documentation of this file.
1// Author: Sergey Linev <s.linev@gsi.de>
2// Date: 2018-10-17
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_RWebDisplayHandle
14#define ROOT7_RWebDisplayHandle
15
17
18#include <string>
19#include <map>
20#include <memory>
21#include <vector>
22
23namespace ROOT {
24
26
27 std::string fUrl; ///!< URL used to launch display
28
29 std::string fContent; ///!< page content
30
31protected:
32
33 class Creator {
34 public:
35 virtual std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) = 0;
36 virtual bool IsActive() const { return true; }
37 virtual ~Creator() = default;
38 };
39
40 class BrowserCreator : public Creator {
41 protected:
42 std::string fProg; ///< browser executable
43 std::string fExec; ///< standard execute line
44 std::string fHeadlessExec; ///< headless execute line
45 std::string fBatchExec; ///< batch execute line
46 void TestProg(const std::string &nexttry, bool check_std_paths = false);
47 virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &) {}
48 virtual std::string MakeProfile(std::string &, bool) { return ""; }
49 public:
50 BrowserCreator(bool custom = true, const std::string &exec = "");
51 std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args) override;
52 ~BrowserCreator() override = default;
53 };
54
56 public:
58 ~SafariCreator() override = default;
59 bool IsActive() const override;
60 };
61
63 bool fEdge{false};
64 std::string fEnvPrefix; // rc parameters prefix
65 int fChromeVersion{-1}; // major version in chrome browser
66 public:
67 ChromeCreator(bool is_edge = false);
68 ~ChromeCreator() override = default;
69 bool IsActive() const override { return !fProg.empty(); }
70 void ProcessGeometry(std::string &, const RWebDisplayArgs &) override;
71 std::string MakeProfile(std::string &exec, bool) override;
72 };
73
75 public:
77 ~FirefoxCreator() override = default;
78 bool IsActive() const override { return !fProg.empty(); }
79 void ProcessGeometry(std::string &, const RWebDisplayArgs &) override;
80 std::string MakeProfile(std::string &exec, bool batch) override;
81 };
82
83 static std::map<std::string, std::unique_ptr<Creator>> &GetMap();
84
85 static std::unique_ptr<Creator> &FindCreator(const std::string &name, const std::string &libname = "");
86
88
89public:
90
91 /// constructor
92 RWebDisplayHandle(const std::string &url) : fUrl(url) {}
93
94 /// required virtual destructor for correct cleanup at the end
95 virtual ~RWebDisplayHandle() = default;
96
97 /// returns url of start web display
98 const std::string &GetUrl() const { return fUrl; }
99
100 /// set content
101 void SetContent(const std::string &cont) { fContent = cont; }
102 /// get content
103 const std::string &GetContent() const { return fContent; }
104
105 /// resize web window - if possible
106 virtual bool Resize(int, int) { return false; }
107
108 static bool NeedHttpServer(const RWebDisplayArgs &args);
109
110 static std::unique_ptr<RWebDisplayHandle> Display(const RWebDisplayArgs &args);
111
112 static bool DisplayUrl(const std::string &url);
113
114 static bool CanProduceImages(const std::string &browser = "");
115
116 static std::string GetImageFormat(const std::string &fname);
117
118 static bool ProduceImage(const std::string &fname, const std::string &json, int width = 800, int height = 600, const char *batch_file = nullptr);
119
120 static bool ProduceImages(const std::string &fname, const std::vector<std::string> &jsons, const std::vector<int> &widths, const std::vector<int> &heights, const char *batch_file = nullptr);
121
122 static std::vector<std::string> ProduceImagesNames(const std::string &fname, unsigned nfiles = 1);
123
124 static bool ProduceImages(const std::vector<std::string> &fnames, const std::vector<std::string> &jsons, const std::vector<int> &widths, const std::vector<int> &heights, const char *batch_file = nullptr);
125
126};
127
128} // namespace ROOT
129
130#endif
nlohmann::json json
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
char name[80]
Definition TGX11.cxx:110
Holds different arguments for starting browser with RWebDisplayHandle::Display() method.
std::string fBatchExec
batch execute line
std::string fHeadlessExec
headless execute line
std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args) override
Display given URL in web browser.
virtual void ProcessGeometry(std::string &, const RWebDisplayArgs &)
std::string fExec
standard execute line
void TestProg(const std::string &nexttry, bool check_std_paths=false)
Check if browser executable exists and can be used.
virtual std::string MakeProfile(std::string &, bool)
void ProcessGeometry(std::string &, const RWebDisplayArgs &) override
Replace $geometry placeholder with geometry settings Also RWebDisplayArgs::GetExtraArgs() are appende...
std::string MakeProfile(std::string &exec, bool) override
Handle profile argument.
virtual std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)=0
std::string MakeProfile(std::string &exec, bool batch) override
Create Firefox profile to run independent browser window.
void ProcessGeometry(std::string &, const RWebDisplayArgs &) override
Process window geometry for Firefox.
bool IsActive() const override
Returns true if it can be used.
Handle of created web-based display Depending from type of web display, holds handle of started brows...
const std::string & GetContent() const
get content
static std::map< std::string, std::unique_ptr< Creator > > & GetMap()
Static holder of registered creators of web displays.
static bool CheckIfCanProduceImages(RWebDisplayArgs &args)
Checks if configured browser can be used for image production.
static bool ProduceImages(const std::string &fname, const std::vector< std::string > &jsons, const std::vector< int > &widths, const std::vector< int > &heights, const char *batch_file=nullptr)
Produce image file(s) using JSON data as source Invokes JSROOT drawing functionality in headless brow...
static std::vector< std::string > ProduceImagesNames(const std::string &fname, unsigned nfiles=1)
Produce vector of file names for specified file pattern Depending from supported file forma.
static std::string GetImageFormat(const std::string &fname)
Detect image format There is special handling of ".screenshot.pdf" and ".screenshot....
virtual ~RWebDisplayHandle()=default
required virtual destructor for correct cleanup at the end
void SetContent(const std::string &cont)
set content
const std::string & GetUrl() const
returns url of start web display
RWebDisplayHandle(const std::string &url)
constructor
static bool ProduceImage(const std::string &fname, const std::string &json, int width=800, int height=600, const char *batch_file=nullptr)
Produce image file using JSON data as source Invokes JSROOT drawing functionality in headless browser...
static bool CanProduceImages(const std::string &browser="")
Returns true if image production for specified browser kind is supported If browser not specified - u...
static bool NeedHttpServer(const RWebDisplayArgs &args)
Check if http server required for display.
virtual bool Resize(int, int)
resize web window - if possible
static bool DisplayUrl(const std::string &url)
Display provided url in configured web browser.
std::string fContent
!< URL used to launch display
static std::unique_ptr< RWebDisplayHandle > Display(const RWebDisplayArgs &args)
Create web display.
static std::unique_ptr< Creator > & FindCreator(const std::string &name, const std::string &libname="")
Search for specific browser creator If not found, try to add one.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...