From 91d77d8d6cdf8c1fd5058b9e8f62d5a81fe4b418 Mon Sep 17 00:00:00 2001 From: Patryk Pilichowski Date: Thu, 25 Sep 2025 21:15:36 +0200 Subject: [PATCH] [gui] Add browsable RNTupleItem --- gui/browsable/CMakeLists.txt | 1 + gui/browsable/inc/LinkDef.h | 1 + .../inc/ROOT/Browsable/RNTupleItem.hxx | 56 +++++++++++++++++++ gui/browsable/src/RNTupleBrowseProvider.cxx | 17 +++--- 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 gui/browsable/inc/ROOT/Browsable/RNTupleItem.hxx diff --git a/gui/browsable/CMakeLists.txt b/gui/browsable/CMakeLists.txt index 3f1cdeed9a7dc..568c45e32b1d9 100644 --- a/gui/browsable/CMakeLists.txt +++ b/gui/browsable/CMakeLists.txt @@ -26,6 +26,7 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTBrowsable ROOT/Browsable/TObjectElement.hxx ROOT/Browsable/TObjectHolder.hxx ROOT/Browsable/TObjectItem.hxx + ROOT/Browsable/RNTupleItem.hxx SOURCES src/RElement.cxx src/RGroup.cxx diff --git a/gui/browsable/inc/LinkDef.h b/gui/browsable/inc/LinkDef.h index fc4fd589bb8a3..f46cbb166711d 100644 --- a/gui/browsable/inc/LinkDef.h +++ b/gui/browsable/inc/LinkDef.h @@ -30,5 +30,6 @@ #pragma link C++ class ROOT::Browsable::RItem+; #pragma link C++ class ROOT::Browsable::RSysFileItem+; +#pragma link C++ class ROOT::Browsable::RNTupleItem+; #endif diff --git a/gui/browsable/inc/ROOT/Browsable/RNTupleItem.hxx b/gui/browsable/inc/ROOT/Browsable/RNTupleItem.hxx new file mode 100644 index 0000000000000..48df2eeb2b01e --- /dev/null +++ b/gui/browsable/inc/ROOT/Browsable/RNTupleItem.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT7_Browsable_RNTupleItem +#define ROOT7_Browsable_RNTupleItem + +#include + +namespace ROOT { +namespace Browsable { + +/** \class RNTupleItem +\ingroup rbrowser +\brief Representation of an RNTuple item in the browser +\author Patryk Tymoteusz Pilichowski +*/ + +class RNTupleItem : public RItem { +public: + enum ECategory { + kField, + kVisualization + }; + + RNTupleItem() = default; + RNTupleItem(const std::string &_name, int _nchilds = 0, const std::string &_icon = "", ECategory _category = kField) + : RItem(_name, _nchilds, _icon), category(_category) + { + } + // must be here, one needs virtual table for correct streaming of sub-classes + virtual ~RNTupleItem() = default; + + bool IsVisualization() const { return category == kVisualization; } + bool IsField() const { return category == kField; } + + bool Compare(const RItem *b, const std::string &s) const override + { + auto tuple_b = dynamic_cast(b); + if (tuple_b != nullptr && (IsVisualization() || tuple_b->IsVisualization())) + return IsVisualization(); + return RItem::Compare(b, s); + } + +protected: + ECategory category{kField}; +}; + +} // namespace Browsable +} // namespace ROOT + +#endif diff --git a/gui/browsable/src/RNTupleBrowseProvider.cxx b/gui/browsable/src/RNTupleBrowseProvider.cxx index e7f203c67d206..04c71fb039455 100644 --- a/gui/browsable/src/RNTupleBrowseProvider.cxx +++ b/gui/browsable/src/RNTupleBrowseProvider.cxx @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -76,7 +77,7 @@ class RTreeMapElement : public RElement { /** Create item with TreeMap icon */ std::unique_ptr CreateItem() const override { - auto item = std::make_unique(GetName(), 0, "sap-icon://Chart-Tree-Map"); + auto item = std::make_unique(GetName(), 0, "sap-icon://Chart-Tree-Map"); item->SetTitle(GetTitle()); return item; } @@ -132,7 +133,8 @@ class RVisualizationElement : public RElement { /** Create item with visualization folder icon */ std::unique_ptr CreateItem() const override { - auto item = std::make_unique(GetName(), 1, "sap-icon://show"); + auto item = + std::make_unique(GetName(), 1, "sap-icon://show", RNTupleItem::ECategory::kVisualization); item->SetTitle(GetTitle()); return item; } @@ -184,7 +186,7 @@ class RVisualizationIterator : public RLevelIter { std::unique_ptr CreateItem() override { if (fCounter == 0) { - auto item = std::make_unique("TreeMap", 0, "sap-icon://Chart-Tree-Map"); + auto item = std::make_unique("TreeMap", 0, "sap-icon://Chart-Tree-Map"); item->SetTitle("TreeMap visualization of RNTuple structure and disk usage"); return item; } @@ -306,7 +308,7 @@ class RNTupleElement : public RElement { std::unique_ptr CreateItem() const override { - auto item = std::make_unique(GetName(), -1, "sap-icon://table-chart"); + auto item = std::make_unique(GetName(), -1, "sap-icon://table-chart"); item->SetTitle(GetTitle()); return item; } @@ -382,7 +384,8 @@ class RNTupleIterator : public RLevelIter { std::unique_ptr CreateItem() override { if (fHasVisualization && fCounter == 0) { - auto item = std::make_unique("Visualization", 1, "sap-icon://show"); + auto item = std::make_unique("Visualization", 1, "sap-icon://show", + RNTupleItem::ECategory::kVisualization); item->SetTitle("Visualization tools and options for RNTuple data"); return item; } @@ -396,8 +399,8 @@ class RNTupleIterator : public RLevelIter { const auto &field = fNtplReader->GetDescriptor().GetFieldDescriptor(fProvidedFieldIds[fieldIndex]); - auto item = - std::make_unique(field.GetFieldName(), nchilds, nchilds > 0 ? "sap-icon://split" : "sap-icon://e-care"); + auto item = std::make_unique(field.GetFieldName(), nchilds, + nchilds > 0 ? "sap-icon://split" : "sap-icon://e-care"); item->SetTitle("RField name "s + field.GetFieldName() + " type "s + field.GetTypeName()); return item;