27using namespace std::string_literals;
64 std::shared_ptr<TObjectElement> telem = std::dynamic_pointer_cast<TObjectElement>(
fElements[
fCounter]);
65 return telem ? telem->IsFolder() :
false;
71 std::shared_ptr<TObjectElement> elem = std::dynamic_pointer_cast<TObjectElement>(
fElements[
fCounter]);
73 if (!elem)
return nullptr;
75 auto cl = elem->GetClass();
77 auto nchilds = elem->GetNumChilds();
78 if ((nchilds == 0) && elem->IsFolder()) nchilds = -1;
80 auto item = std::make_unique<TObjectItem>(elem->GetName(), nchilds);
82 item->SetClassName(cl ? cl->GetName() :
"");
86 item->SetTitle(elem->GetTitle());
88 auto sz = elem->GetSize();
90 item->SetSize(std::to_string(sz));
101 bool Find(
const std::string &
name,
int indx = -1)
override
133 std::unique_ptr<RHolder> holder = std::make_unique<TObjectHolder>(obj);
138 std::shared_ptr<TObjectElement> telem = std::dynamic_pointer_cast<TObjectElement>(elem);
139 if (telem) telem->SetName(
name);
172 std::string
GetItemName()
const override {
return (*fIter)->GetName(); }
177 return obj ? obj->
IsFolder() :
false;
184 if (!obj)
return nullptr;
186 auto item = std::make_unique<TObjectItem>(obj->
GetName(), obj->
IsFolder() ? -1 : 0);
194 if (obj->IsA() == TColor::Class()) {
195 if (item->GetName().empty())
196 item->SetName(
"Color"s + std::to_string(
static_cast<TColor *
>(obj)->
GetNumber()));
205 std::unique_ptr<RHolder> holder = std::make_unique<TObjectHolder>(*
fIter,
kFALSE);
232 return std::make_unique<TCollectionIter>(folder->GetListOfFolders());
261 if (coll && (coll->GetSize() > 0))
262 return std::make_unique<TCollectionIter>(coll);
270 return coll ? coll->
GetSize() : 0;
297 else if (
fName.empty())
333 auto iter = std::make_unique<TObjectLevelIter>();
346 if (dupl || (iter->NumElements() == 0))
return nullptr;
367 return fObj ?
fObj->IsA() :
nullptr;
378 std::string clname = cl->GetName();
380 if ((
"TGeoManager"s == cl->GetName()) || (
"TGeoVolume"s == cl->GetName()) || (clname.compare(0, 8,
"TGeoNode"s) == 0))
return kActGeom;
393 if (!cl)
return false;
395 std::string clname = cl->GetName();
404 case kActGeom:
return (
"TGeoManager"s == clname) || (
"TGeoVolume"s == clname) || (clname.compare(0, 8,
"TGeoNode"s) == 0);
405 default:
return false;
416 return std::make_unique<TCollectionIter>(coll);
433 void RegisterTObject(
const std::string &clname,
const std::string &iconname,
bool can_browse =
false,
int can_draw = 3)
435 RegisterClass(clname, iconname, can_browse ?
"dflt"s :
""s,
436 can_draw & 1 ?
"libROOTObjectDraw6Provider"s :
""s,
437 can_draw & 2 ?
"libROOTObjectDraw7Provider"s :
""s);
442 RegisterClass(
"TTree",
"sap-icon://tree",
"libROOTBranchBrowseProvider");
443 RegisterClass(
"TNtuple",
"sap-icon://tree",
"libROOTBranchBrowseProvider");
444 RegisterClass(
"TBranchElement",
"sap-icon://e-care",
"libROOTBranchBrowseProvider",
"libROOTLeafDraw6Provider",
"libROOTLeafDraw7Provider");
445 RegisterClass(
"TLeaf",
"sap-icon://e-care",
""s,
"libROOTLeafDraw6Provider",
"libROOTLeafDraw7Provider");
446 RegisterClass(
"TBranch",
"sap-icon://e-care",
"libROOTBranchBrowseProvider"s,
"libROOTLeafDraw6Provider",
"libROOTLeafDraw7Provider");
447 RegisterClass(
"TVirtualBranchBrowsable",
"sap-icon://e-care",
""s,
"libROOTLeafDraw6Provider",
"libROOTLeafDraw7Provider");
448 RegisterClass(
"TColor",
"sap-icon://palette");
449 RegisterClass(
"TStyle",
"sap-icon://badge");
451 RegisterTObject(
"TDirectory",
"sap-icon://folder-blank",
true, 0);
452 RegisterTObject(
"TH1",
"sap-icon://bar-chart");
453 RegisterTObject(
"TH2",
"sap-icon://pixelate");
454 RegisterTObject(
"TH3",
"sap-icon://product");
455 RegisterTObject(
"TProfile",
"sap-icon://vertical-bar-chart");
456 RegisterTObject(
"TGraph",
"sap-icon://line-chart");
457 RegisterTObject(
"TCanvas",
"sap-icon://business-objects-experience",
false, 1);
458 RegisterTObject(
"TASImage",
"sap-icon://picture",
false, 1);
460 RegisterTObject(
"THStack",
"sap-icon://multiple-bar-chart");
461 RegisterTObject(
"TMultiGraph",
"sap-icon://multiple-line-chart");
463 RegisterTObject(
"TCollection",
"sap-icon://list",
true, 0);
464 RegisterTObject(
"TGeoManager",
"sap-icon://overview-chart",
true, 0);
465 RegisterTObject(
"TGeoVolume",
"sap-icon://product",
true, 0);
466 RegisterTObject(
"TGeoNode",
"sap-icon://product",
true, 0);
468 RegisterBrowse(TFolder::Class(), [](std::unique_ptr<RHolder> &
object) -> std::shared_ptr<RElement> {
469 return std::make_shared<TFolderElement>(
object);
472 RegisterBrowse(TCollection::Class(), [](std::unique_ptr<RHolder> &
object) -> std::shared_ptr<RElement> {
473 return std::make_shared<TCollectionElement>(
object);
476 RegisterBrowse(
nullptr, [](std::unique_ptr<RHolder> &
object) -> std::shared_ptr<RElement> {
478 return std::make_shared<TObjectElement>(
object);
RTObjectProvider newRTObjectProvider
EActionKind
Possible actions on double-click.
@ kActEdit
can provide data for text editor
@ kActCanvas
indicate that it is canvas and should be drawn directly
@ kActBrowse
just browse (expand) item
@ kActGeom
can be shown in geometry viewer
@ kActDraw7
can be drawn inside ROOT7 canvas
@ kActImage
can be shown in image viewer, can provide image
@ kActDraw6
can be drawn inside ROOT6 canvas
Iterator over single level hierarchy like any array, keys list, ...
virtual bool Find(const std::string &name, int indx=-1)
Find item with specified name Default implementation, should work for all If index specified,...
Provider of different browsing methods for supported classes.
static bool CanDraw6(const ClassArg &)
Return true if provided class can be drawn on the TCanvas.
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 std::string GetClassIcon(const ClassArg &, bool=false)
Return icon name for the given class - either class name or TClass *.
static bool CanHaveChilds(const ClassArg &)
Return true if provided class can have childs.
Access to TObject basic properties for RBrowsable.
std::unique_ptr< RHolder > GetObject() override
Return copy of TObject holder - if possible.
const TClass * GetClass() const
Returns class for contained object.
std::unique_ptr< RHolder > fObject
TObjectElement(TObject *obj, const std::string &name="")
Constructor with plain TObject* as argument - ownership is not defined.
bool IsCapable(EActionKind) const override
Check object capability.
static std::unique_ptr< RLevelIter > GetCollectionIter(const TCollection *)
Creates iterator for TCollection object.
bool IsFolder() const
Returns IsFolder of contained TObject.
std::string GetTitle() const override
Title of TObject.
std::unique_ptr< RLevelIter > GetChildsIter() override
Create iterator for childs elements if any.
EActionKind GetDefaultAction() const override
Provides default action which can be performed with the object.
std::string GetName() const override
Name of TObject.
Provider for all known TObject-based classes.
void RegisterTObject(const std::string &clname, const std::string &iconname, bool can_browse=false, int can_draw=3)
ABC describing GUI independent browser implementation protocol.
Using a TBrowser one can browse all ROOT objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Browsable element for TCollection.
int GetNumChilds() override
Returns number of childs By default creates iterator and iterates over all items.
std::unique_ptr< RLevelIter > GetChildsIter() override
Create iterator for childs elements if any.
TCollectionElement(std::unique_ptr< RHolder > &obj)
Iterator over elements in TCollection.
std::unique_ptr< RItem > CreateItem() override
Create item for current TObject.
TCollectionIter(const TFolder *f)
bool CanItemHaveChilds() const override
Returns true if current item can have childs.
bool Next() override
Shift to next entry.
virtual ~TCollectionIter()=default
TCollectionIter(const TCollection *coll)
std::shared_ptr< RElement > GetElement() override
Returns full information for current element.
std::string GetItemName() const override
Returns current entry name
Collection abstract base class.
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
The color creation and management class.
Browsable element for TFolder.
TFolderElement(std::unique_ptr< RHolder > &obj)
std::unique_ptr< RLevelIter > GetChildsIter() override
Create iterator for childs elements if any.
int GetNumChilds() override
Returns number of childs By default creates iterator and iterates over all items.
A TFolder object is a collection of objects and folders.
TCollection * GetListOfFolders() const
bool fDuplicated
! is object was duplicated?
virtual ~TMyBrowserImp()=default
TObjectLevelIter * fIter
! back-reference on iterator
void Add(TObject *obj, const char *name, Int_t) override
const TObject * fBrowseObj
! object which wil be browsed
bool IsDuplicated() const
TMyBrowserImp(TObjectLevelIter *iter, TObject *obj)
virtual void Copy(TObject &named) const
Copy this to obj.
Iterator over list of elements, designed for support TBrowser usage.
std::unique_ptr< RItem > CreateItem() override
Create element for the browser.
std::vector< std::shared_ptr< RElement > > fElements
bool CanItemHaveChilds() const override
Returns true if current item can have childs.
std::string GetItemName() const override
Returns current entry name
void AddElement(std::shared_ptr< RElement > &&elem)
bool Next() override
Shift to next entry.
std::shared_ptr< RElement > GetElement() override
Returns full information for current element.
bool Find(const std::string &name, int indx=-1) override
Find item with specified name Default implementation, should work for all If index specified,...
virtual ~TObjectLevelIter()=default
Mother of all ROOT objects.
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
virtual const char * GetName() const
Returns name of object.
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual const char * GetTitle() const
Returns title of object.