Skip to content

Commit 91d77d8

Browse files
[gui] Add browsable RNTupleItem
1 parent 7e0fcc8 commit 91d77d8

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

gui/browsable/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTBrowsable
2626
ROOT/Browsable/TObjectElement.hxx
2727
ROOT/Browsable/TObjectHolder.hxx
2828
ROOT/Browsable/TObjectItem.hxx
29+
ROOT/Browsable/RNTupleItem.hxx
2930
SOURCES
3031
src/RElement.cxx
3132
src/RGroup.cxx

gui/browsable/inc/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030

3131
#pragma link C++ class ROOT::Browsable::RItem+;
3232
#pragma link C++ class ROOT::Browsable::RSysFileItem+;
33+
#pragma link C++ class ROOT::Browsable::RNTupleItem+;
3334

3435
#endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*************************************************************************
2+
* Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
3+
* All rights reserved. *
4+
* *
5+
* For the licensing terms see $ROOTSYS/LICENSE. *
6+
* For the list of contributors see $ROOTSYS/README/CREDITS. *
7+
*************************************************************************/
8+
9+
#ifndef ROOT7_Browsable_RNTupleItem
10+
#define ROOT7_Browsable_RNTupleItem
11+
12+
#include <ROOT/Browsable/RItem.hxx>
13+
14+
namespace ROOT {
15+
namespace Browsable {
16+
17+
/** \class RNTupleItem
18+
\ingroup rbrowser
19+
\brief Representation of an RNTuple item in the browser
20+
\author Patryk Tymoteusz Pilichowski
21+
*/
22+
23+
class RNTupleItem : public RItem {
24+
public:
25+
enum ECategory {
26+
kField,
27+
kVisualization
28+
};
29+
30+
RNTupleItem() = default;
31+
RNTupleItem(const std::string &_name, int _nchilds = 0, const std::string &_icon = "", ECategory _category = kField)
32+
: RItem(_name, _nchilds, _icon), category(_category)
33+
{
34+
}
35+
// must be here, one needs virtual table for correct streaming of sub-classes
36+
virtual ~RNTupleItem() = default;
37+
38+
bool IsVisualization() const { return category == kVisualization; }
39+
bool IsField() const { return category == kField; }
40+
41+
bool Compare(const RItem *b, const std::string &s) const override
42+
{
43+
auto tuple_b = dynamic_cast<const RNTupleItem *>(b);
44+
if (tuple_b != nullptr && (IsVisualization() || tuple_b->IsVisualization()))
45+
return IsVisualization();
46+
return RItem::Compare(b, s);
47+
}
48+
49+
protected:
50+
ECategory category{kField};
51+
};
52+
53+
} // namespace Browsable
54+
} // namespace ROOT
55+
56+
#endif

gui/browsable/src/RNTupleBrowseProvider.cxx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ROOT/Browsable/RProvider.hxx>
1111
#include <ROOT/Browsable/RLevelIter.hxx>
1212
#include <ROOT/Browsable/RItem.hxx>
13+
#include <ROOT/Browsable/RNTupleItem.hxx>
1314

1415
#include <ROOT/RNTupleReader.hxx>
1516
#include <ROOT/RNTupleBrowseUtils.hxx>
@@ -76,7 +77,7 @@ class RTreeMapElement : public RElement {
7677
/** Create item with TreeMap icon */
7778
std::unique_ptr<RItem> CreateItem() const override
7879
{
79-
auto item = std::make_unique<RItem>(GetName(), 0, "sap-icon://Chart-Tree-Map");
80+
auto item = std::make_unique<RNTupleItem>(GetName(), 0, "sap-icon://Chart-Tree-Map");
8081
item->SetTitle(GetTitle());
8182
return item;
8283
}
@@ -132,7 +133,8 @@ class RVisualizationElement : public RElement {
132133
/** Create item with visualization folder icon */
133134
std::unique_ptr<RItem> CreateItem() const override
134135
{
135-
auto item = std::make_unique<RItem>(GetName(), 1, "sap-icon://show");
136+
auto item =
137+
std::make_unique<RNTupleItem>(GetName(), 1, "sap-icon://show", RNTupleItem::ECategory::kVisualization);
136138
item->SetTitle(GetTitle());
137139
return item;
138140
}
@@ -184,7 +186,7 @@ class RVisualizationIterator : public RLevelIter {
184186
std::unique_ptr<RItem> CreateItem() override
185187
{
186188
if (fCounter == 0) {
187-
auto item = std::make_unique<RItem>("TreeMap", 0, "sap-icon://Chart-Tree-Map");
189+
auto item = std::make_unique<RNTupleItem>("TreeMap", 0, "sap-icon://Chart-Tree-Map");
188190
item->SetTitle("TreeMap visualization of RNTuple structure and disk usage");
189191
return item;
190192
}
@@ -306,7 +308,7 @@ class RNTupleElement : public RElement {
306308

307309
std::unique_ptr<RItem> CreateItem() const override
308310
{
309-
auto item = std::make_unique<RItem>(GetName(), -1, "sap-icon://table-chart");
311+
auto item = std::make_unique<RNTupleItem>(GetName(), -1, "sap-icon://table-chart");
310312
item->SetTitle(GetTitle());
311313
return item;
312314
}
@@ -382,7 +384,8 @@ class RNTupleIterator : public RLevelIter {
382384
std::unique_ptr<RItem> CreateItem() override
383385
{
384386
if (fHasVisualization && fCounter == 0) {
385-
auto item = std::make_unique<RItem>("Visualization", 1, "sap-icon://show");
387+
auto item = std::make_unique<RNTupleItem>("Visualization", 1, "sap-icon://show",
388+
RNTupleItem::ECategory::kVisualization);
386389
item->SetTitle("Visualization tools and options for RNTuple data");
387390
return item;
388391
}
@@ -396,8 +399,8 @@ class RNTupleIterator : public RLevelIter {
396399

397400
const auto &field = fNtplReader->GetDescriptor().GetFieldDescriptor(fProvidedFieldIds[fieldIndex]);
398401

399-
auto item =
400-
std::make_unique<RItem>(field.GetFieldName(), nchilds, nchilds > 0 ? "sap-icon://split" : "sap-icon://e-care");
402+
auto item = std::make_unique<RNTupleItem>(field.GetFieldName(), nchilds,
403+
nchilds > 0 ? "sap-icon://split" : "sap-icon://e-care");
401404

402405
item->SetTitle("RField name "s + field.GetFieldName() + " type "s + field.GetTypeName());
403406
return item;

0 commit comments

Comments
 (0)