Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RBrowserWidget.cxx
Go to the documentation of this file.
1// Author: Sergey Linev <S.Linev@gsi.de>
2// Date: 2021-01-22
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-2021, 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#include "RBrowserWidget.hxx"
14
15#include <algorithm>
16
17#include "TSystem.h"
18#include "TBufferJSON.h"
19
20using namespace std::string_literals;
21using namespace ROOT;
22
23///////////////////////////////////////////////////////////////
24/// Returns string which can be send to browser client to set/change
25/// title of the widget tab
26
28{
29 std::vector<std::string> args = { GetName(), GetTitle(), Browsable::RElement::GetPathAsString(GetPath()) };
30
31 return "SET_TITLE:"s + TBufferJSON::ToJSON(&args).Data();
32}
33
34///////////////////////////////////////////////////////////////
35/// Constructor
36
38{
39 GetMap().emplace(kind, this);
40}
41
42///////////////////////////////////////////////////////////////
43/// Destructor
44
46{
47 auto &map = GetMap();
48 auto iter = std::find_if(map.begin(), map.end(),
49 [this](const ProvidersMap_t::value_type &pair) { return this == pair.second; });
50
51 if (iter != map.end())
52 map.erase(iter);
53}
54
55///////////////////////////////////////////////////////////////
56/// Returns static map of existing providers
57
63
64///////////////////////////////////////////////////////////////
65/// Returns provider for specified kind
66
68{
69 auto &map = GetMap();
70 auto iter = map.find(kind);
71 if (iter == map.end()) {
72 // try to load necessary libraries
73 if (kind == "geom"s)
74 gSystem->Load("libROOTBrowserGeomWidget");
75 else if (kind == "tree"s)
76 gSystem->Load("libROOTBrowserTreeWidget");
77 else if (kind == "tcanvas"s)
78 gSystem->Load("libROOTBrowserTCanvasWidget");
79 else if (kind == "rcanvas"s)
80 gSystem->Load("libROOTBrowserRCanvasWidget");
81 iter = map.find(kind);
82 if (iter == map.end())
83 return nullptr;
84 }
85 return iter->second;
86}
87
88
89///////////////////////////////////////////////////////////////
90/// Create specified widget
91
92std::shared_ptr<RBrowserWidget> RBrowserWidgetProvider::CreateWidget(const std::string &kind, const std::string &name)
93{
94 auto provider = GetProvider(kind);
95
96 return provider ? provider->Create(name) : nullptr;
97}
98
99///////////////////////////////////////////////////////////////
100/// Create specified widget for existing object
101
102std::shared_ptr<RBrowserWidget> RBrowserWidgetProvider::CreateWidgetFor(const std::string &kind, const std::string &name, std::shared_ptr<Browsable::RElement> &element)
103{
104 auto provider = GetProvider(kind);
105
106 return provider ? provider->CreateFor(name, element) : nullptr;
107}
108
109///////////////////////////////////////////////////////////////
110/// Check if catch window can be identified and normal widget can be created
111/// Used for TCanvas created in macro and catch by RBrowser
112
113std::shared_ptr<RBrowserWidget> RBrowserWidgetProvider::DetectCatchedWindow(const std::string &kind, RWebWindow &win)
114{
115 auto provider = GetProvider(kind);
116
117 return provider ? provider->DetectWindow(win) : nullptr;
118}
119
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
char name[80]
Definition TGX11.cxx:110
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
static std::string GetPathAsString(const RElementPath_t &path)
Converts element path back to string.
Definition RElement.cxx:160
std::map< std::string, RBrowserWidgetProvider * > ProvidersMap_t
static RBrowserWidgetProvider * GetProvider(const std::string &kind)
Returns provider for specified kind.
static std::shared_ptr< RBrowserWidget > DetectCatchedWindow(const std::string &kind, RWebWindow &win)
Check if catch window can be identified and normal widget can be created Used for TCanvas created in ...
static std::shared_ptr< RBrowserWidget > CreateWidgetFor(const std::string &kind, const std::string &name, std::shared_ptr< Browsable::RElement > &element)
Create specified widget for existing object.
static std::shared_ptr< RBrowserWidget > CreateWidget(const std::string &kind, const std::string &name)
Create specified widget.
static ProvidersMap_t & GetMap()
Returns static map of existing providers.
virtual ~RBrowserWidgetProvider()
Destructor.
RBrowserWidgetProvider(const std::string &kind)
Constructor.
const Browsable::RElementPath_t & GetPath() const
virtual std::string GetTitle()
const std::string & GetName() const
std::string SendWidgetTitle()
Returns string which can be send to browser client to set/change title of the widget tab.
Represents web window, which can be shown in web browser or any other supported environment.
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
Definition TBufferJSON.h:75
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1869
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...