Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RTreeMapBase.hxx
Go to the documentation of this file.
1/// \file ROOT/RTreeMapBase.hxx
2/// \ingroup TreeMap ROOT7
3/// \author Patryk Tymoteusz Pilichowski <patryk.tymoteusz.pilichowski@cern.ch>
4/// \date 2025-08-21
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef RTREEMAPBASE_HXX
17#define RTREEMAPBASE_HXX
18
19#include <cstdint>
20#include <string>
21#include <vector>
22
23namespace ROOT::Experimental {
24
25// clang-format off
26/**
27\class ROOT::Experimental::RTreeMapBase
28\ingroup TreeMap
29\brief Base logic for drawing a treemap visualization
30
31A treemap can be used for analyzing a hierarchical data structure whose elements have a certain size. It visualizes this
32hierarchical data as nested rectangles which allows for easy comparison of proportions within categories, but
33also the whole structure. The squarification algorithm is used to make these rectangles as close to squares as
34possible for visual clarity.
35
36Furthermore, we assume that each node has a type and that the size of a non-leaf node equals to the total size of its children. This
37allows for drawing a legend of types of leaf nodes, and see which types occupy how much of the total space.
38
39Note: this visualization class/technique is independent/unrelated to `TTree`.
40*/
41// clang-format on
43public:
44 struct Node {
45 std::string fName, fType;
46 uint64_t fSize;
47 uint64_t fChildrenIdx;
48 uint64_t fNChildren;
49 Node() = default;
50 Node(const std::string &name, const std::string &type, uint64_t size, uint64_t childrenIdx, uint64_t nChildren)
52 {
53 }
54 };
55
56 struct Vec2 {
57 float x, y;
58 Vec2(float xArg, float yArg) : x(xArg), y(yArg) {}
59 };
64 struct RGBColor {
65 uint8_t r, g, b, a;
66 RGBColor(uint8_t rArg, uint8_t gArg, uint8_t bArg, uint8_t aArg = 255) : r(rArg), g(gArg), b(bArg), a(aArg) {}
67 };
68 std::vector<Node> fNodes;
69 RTreeMapBase() = default;
70 virtual ~RTreeMapBase() = default;
71
72protected:
73 /////////////////////////////////////////////////////////////////////////////
74 /// \brief Logic for drawing the entirety of the treemap.
75 void DrawTreeMap(const Node &elem, Rect rect, int depth) const;
76
77 /////////////////////////////////////////////////////////////////////////////
78 /// \brief Logic for drawing the legend of leaf types
79 void DrawLegend() const;
80
81 /////////////////////////////////////////////////////////////////////////////
82 /// \brief Logic for drawing a box
83 virtual void AddBox(const Rect &rect, const RGBColor &color, float borderWidth = 0.15f) const = 0;
84
85 /////////////////////////////////////////////////////////////////////////////
86 /// \brief Logic for drawing a text
87 virtual void AddText(const Vec2 &pos, const std::string &content, float size,
88 const RGBColor &color = RGBColor(0, 0, 0), bool alignCenter = false) const = 0;
89};
90} // namespace ROOT::Experimental
91#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 rect
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 Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
Base logic for drawing a treemap visualization.
virtual void AddText(const Vec2 &pos, const std::string &content, float size, const RGBColor &color=RGBColor(0, 0, 0), bool alignCenter=false) const =0
Logic for drawing a text.
void DrawLegend() const
Logic for drawing the legend of leaf types.
virtual void AddBox(const Rect &rect, const RGBColor &color, float borderWidth=0.15f) const =0
Logic for drawing a box.
void DrawTreeMap(const Node &elem, Rect rect, int depth) const
Logic for drawing the entirety of the treemap.
Node(const std::string &name, const std::string &type, uint64_t size, uint64_t childrenIdx, uint64_t nChildren)
RGBColor(uint8_t rArg, uint8_t gArg, uint8_t bArg, uint8_t aArg=255)
Rect(const Vec2 &bottomLeftArg, const Vec2 &topRightArg)