19using namespace std::string_literals;
105 if (cl && (bmap.find(cl) != bmap.end()))
118 if (cl && (bmap.find(cl) != bmap.end()))
131 if (cl && (bmap.find(cl) != bmap.end()))
149 const std::string &browselib,
const std::string &draw6lib,
150 const std::string &draw7lib,
const std::string &drawopt)
154 if (!clname.empty() && (bmap.find(clname) != bmap.end()))
157 std::string blib = browselib;
158 bool can_have_childs = !browselib.empty();
159 if ((blib ==
"dflt") || (blib ==
"TObject")) blib =
"";
161 bmap.emplace(clname,
StructClass{
this, can_have_childs, iconname, blib, draw6lib, draw7lib, drawopt});
171 if (iter != bmap.end())
174 if (!cl.
name.empty()) {
175 for (
auto &elem : bmap)
176 if (cl.
name.compare(0, elem.first.length(), elem.first) == 0)
179 auto bases =
const_cast<TClass *
>(cl.
cl)->GetListOfBases();
180 const TClass *basecl = bases && (bases->GetSize() > 0) ?
dynamic_cast<TBaseClass *
>(bases->First())->GetClassPointer() :
nullptr;
199 return fmap.find(
extension) != fmap.end();
211 if (iter != fmap.end())
212 return iter->second.func(fullname);
220template<
class Map_t,
class Func_t>
229 auto iter = fmap.find(testcl);
230 if (iter != fmap.end())
231 if (!check_func || check_func(iter->second.func))
236 testcl = bases && (bases->GetSize() > 0) ?
dynamic_cast<TBaseClass *
>(bases->First())->GetClassPointer() :
nullptr;
239 for (
auto &entry : fmap) {
240 if (!entry.first)
continue;
241 std::string
name = entry.first->GetName();
247 if (check_func(entry.second.func))
253 if (test_all && check_func) {
254 for (
auto &entry : fmap)
255 if (!entry.first && check_func(entry.second.func))
268 std::shared_ptr<RElement> res;
270 if (!
object)
return res;
274 return (res || !
object) ? true :
false;
278 if (ScanProviderMap<BrowseMap_t,BrowseFunc_t>(
GetBrowseMap(),
object->GetClass(),
false, browse_func))
282 if (!entry.dummy() && !entry.browselib.empty())
286 ScanProviderMap<BrowseMap_t,BrowseFunc_t>(
GetBrowseMap(),
object->GetClass(),
true, browse_func);
299 if (entry.browselib.empty())
317 if (!
object || !
object->GetClass())
321 return func(subpad,
object, opt);
324 if (ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(),
object->GetClass(),
false, draw_func))
328 if (!entry.dummy() && !entry.draw6lib.empty())
331 return ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(),
object->GetClass(),
true, draw_func);
338bool RProvider::Draw7(std::shared_ptr<ROOT::Experimental::RPadBase> &subpad, std::unique_ptr<RHolder> &
object,
const std::string &opt)
340 if (!
object || !
object->GetClass())
344 return func(subpad,
object, opt);
347 if (ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(),
object->GetClass(),
false, draw_func))
351 if (!entry.dummy() && !entry.draw7lib.empty())
354 return ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(),
object->GetClass(),
true, draw_func);
363 if (!entry.iconname.empty())
364 return entry.iconname;
366 return is_folder ?
"sap-icon://folder-blank"s :
"sap-icon://electronic-medical-record"s;
405 return !entry.dummy() && !entry.can_have_childs;
413 if (ScanProviderMap<Draw6Map_t,Draw6Func_t>(
GetDraw6Map(), arg))
427 if (ScanProviderMap<Draw7Map_t,Draw7Func_t>(
GetDraw7Map(), arg))
445 RegisterClass(
"ROOT::Experimental::RH1D",
"sap-icon://bar-chart",
"",
"",
"libROOTHistDrawProvider");
446 RegisterClass(
"ROOT::Experimental::RH2D",
"sap-icon://pixelate",
"",
"",
"libROOTHistDrawProvider");
447 RegisterClass(
"ROOT::Experimental::RH3D",
"sap-icon://product",
"",
"",
"libROOTHistDrawProvider");
448 RegisterClass(
"ROOT::Experimental::RCanvas",
"sap-icon://business-objects-experience",
"",
"",
"libROOTHistDrawProvider");
449 RegisterClass(
"ROOT::Experimental::RNTuple",
"sap-icon://table-chart",
"libROOTNTupleBrowseProvider",
"libROOTNTupleDraw6Provider",
"libROOTNTupleDraw7Provider");
#define R__LOG_ERROR(...)
RDefaultProvider newRDefaultProvider
bool ScanProviderMap(Map_t &fmap, const RProvider::ClassArg &cl, bool test_all=false, std::function< bool(Func_t &)> check_func=nullptr)
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 TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
R__EXTERN TSystem * gSystem
const TClass * GetClass() const
const std::string & GetName() const
Provider of different browsing methods for supported classes.
void RegisterDraw7(const TClass *cl, Draw7Func_t func)
static std::shared_ptr< RElement > BrowseNTuple(const std::string &tuplename, const std::string &filename)
Start browsing of RNTuple.
void RegisterClass(const std::string &clname, const std::string &iconname, const std::string &browselib="", const std::string &draw6lib="", const std::string &draw7lib="", const std::string &drawopt="")
std::function< bool(std::shared_ptr< ROOT::Experimental::RPadBase > &, std::unique_ptr< RHolder > &, const std::string &)> Draw7Func_t
static bool CanDraw6(const ClassArg &)
Return true if provided class can be drawn on the TCanvas.
static ClassMap_t & GetClassMap()
static bool SetClassDrawOption(const ClassArg &, const std::string &)
Set draw option for the class Return true if entry for the class exists.
static FileMap_t & GetFileMap()
void RegisterDraw6(const TClass *cl, Draw6Func_t func)
static std::shared_ptr< RElement > Browse(std::unique_ptr< RHolder > &obj)
Create browsable element for the object Created element may take ownership over the object.
static bool CanDraw7(const ClassArg &)
Return true if provided class can be drawn on the RCanvas.
static BrowseNTupleFunc_t gNTupleFunc
static bool Draw6(TVirtualPad *subpad, std::unique_ptr< RHolder > &obj, const std::string &opt="")
Invoke drawing of object on TCanvas sub-pad All existing providers are checked, first checked are cla...
virtual ~RProvider()
Automatically unregister provider from all maps.
std::multimap< std::string, StructClass > ClassMap_t
static std::string GetClassIcon(const ClassArg &, bool=false)
Return icon name for the given class - either class name or TClass *.
std::multimap< std::string, StructFile > FileMap_t
static bool Draw7(std::shared_ptr< ROOT::Experimental::RPadBase > &subpad, std::unique_ptr< RHolder > &obj, const std::string &opt="")
Invoke drawing of object on RCanvas sub-pad All existing providers are checked, first checked are cla...
void RegisterFile(const std::string &extension, FileFunc_t func)
static bool IsFileFormatSupported(const std::string &extension)
static Draw7Map_t & GetDraw7Map()
std::function< std::shared_ptr< RElement >(const std::string &, const std::string &)> BrowseNTupleFunc_t
std::function< std::shared_ptr< RElement >(std::unique_ptr< RHolder > &)> BrowseFunc_t
std::multimap< const TClass *, StructBrowse > BrowseMap_t
void RegisterBrowse(const TClass *cl, BrowseFunc_t func)
void RegisterNTupleFunc(BrowseNTupleFunc_t func)
std::function< std::shared_ptr< RElement >(const std::string &)> FileFunc_t
static bool CanHaveChilds(const ClassArg &)
Return true if provided class can have childs.
std::function< bool(TVirtualPad *, std::unique_ptr< RHolder > &, const std::string &)> Draw6Func_t
static BrowseMap_t & GetBrowseMap()
static StructClass & GetClassEntry(const ClassArg &)
static std::shared_ptr< RElement > OpenFile(const std::string &extension, const std::string &fullname)
std::multimap< const TClass *, StructDraw7 > Draw7Map_t
static Draw6Map_t & GetDraw6Map()
static bool NotShowChilds(const ClassArg &)
Check if showing of sub-elements was disabled.
static std::string GetClassDrawOption(const ClassArg &)
Return configured draw option for the class.
void CleanThis(Map_t &fmap)
std::multimap< const TClass *, StructDraw6 > Draw6Map_t
Each class (see TClass) has a linked list of its base class(es).
TClass instances represent classes, structs and namespaces in the ROOT type system.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
const char * GetName() const override
Returns name of object.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
RLogChannel & BrowsableLog()
Log channel for Browsable diagnostics.