17
17
#include < ROOT/RNTupleDrawVisitor.hxx>
18
18
#include < ROOT/RNTupleDescriptor.hxx>
19
19
#include < ROOT/RNTupleReader.hxx>
20
+ #include < ROOT/RTreeMapPainter.hxx>
21
+ #include < ROOT/RNTupleInspector.hxx>
20
22
21
23
#include < TBrowser.h>
22
24
#include < TObject.h>
@@ -91,6 +93,32 @@ class RFieldBrowsable final : public TObject {
91
93
const char *GetTitle () const final { return fTypeName .c_str (); }
92
94
};
93
95
96
+ class RVisualizationBrowsable : public TObject {
97
+ private:
98
+ std::unique_ptr<ROOT::Experimental::RNTupleInspector> fInspector ;
99
+ std::unique_ptr<ROOT::Experimental::RTreeMapPainter> fTreeMap ;
100
+
101
+ public:
102
+ RVisualizationBrowsable (const ROOT::RNTuple &ntuple)
103
+ : fInspector (ROOT::Experimental::RNTupleInspector::Create(ntuple))
104
+ {
105
+ }
106
+ void Browse (TBrowser *b) final
107
+ {
108
+ if (!b || !gPad )
109
+ return ;
110
+ gPad ->GetListOfPrimitives ()->Clear ();
111
+ fTreeMap = ROOT::Experimental::RTreeMapPainter::ImportRNTuple (*fInspector );
112
+ fTreeMap ->Paint (" " );
113
+ gPad ->Update ();
114
+ }
115
+
116
+ const char *GetIconName () const final { return " RNTuple-visualization" ; }
117
+ bool IsFolder () const final { return false ; }
118
+ const char *GetName () const final { return " Visualization" ; }
119
+ const char *GetTitle () const final { return " TreeMap visualization of RNTuple structure and disk usage" ; }
120
+ };
121
+
94
122
} // anonymous namespace
95
123
96
124
void ROOT::Internal::BrowseRNTuple (const void *ntuple, TBrowser *b)
@@ -100,6 +128,7 @@ void ROOT::Internal::BrowseRNTuple(const void *ntuple, TBrowser *b)
100
128
101
129
std::shared_ptr<ROOT::RNTupleReader> reader = RNTupleReader::Open (*static_cast <const ROOT::RNTuple *>(ntuple));
102
130
const auto &desc = reader->GetDescriptor ();
131
+ b->Add (new RVisualizationBrowsable (*static_cast <const ROOT::RNTuple *>(ntuple)), " Visualization" );
103
132
for (const auto &f : desc.GetTopLevelFields ()) {
104
133
b->Add (new RFieldBrowsable (reader, f.GetId ()), f.GetFieldName ().c_str ());
105
134
}
0 commit comments