Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-14 10:31:21

0001 /// \file ROOT/RTreeMapPainter.hxx
0002 /// \ingroup TreeMap ROOT7
0003 /// \author Patryk Tymoteusz Pilichowski <patryk.tymoteusz.pilichowski@cern.ch>
0004 /// \date 2025-08-21
0005 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
0006 /// is welcome!
0007 
0008 /*************************************************************************
0009  * Copyright (C) 1995-2025, Rene Brun and Fons Rademakers.               *
0010  * All rights reserved.                                                  *
0011  *                                                                       *
0012  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0013  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0014  *************************************************************************/
0015 
0016 #ifndef TTREEMAP_HXX
0017 #define TTREEMAP_HXX
0018 
0019 #include "RTreeMapBase.hxx"
0020 
0021 #include "TROOT.h"
0022 #include "TObject.h"
0023 #include "TCanvas.h"
0024 #include "TPad.h"
0025 
0026 #include <vector>
0027 
0028 namespace ROOT::Experimental {
0029 // clang-format off
0030 /**
0031 \class ROOT::Experimental::RTreeMapPainter
0032 \ingroup TreeMap
0033 \brief Logic for drawing a treemap on a TVirtualPad
0034 
0035 One can visualize an RNTuple in a TCanvas as a treemap like this:
0036 ~~~ {.cpp}
0037 auto tm = ROOT::Experimental::CreateTreeMapFromRNTuple("file.root", "ntuple_name");
0038 auto c = new TCanvas("c_tm","TreeMap");
0039 c->Add(tm.release());
0040 ~~~
0041 */
0042 // clang-format on
0043 class RTreeMapPainter final : public ROOT::Experimental::RTreeMapBase, public TObject {
0044 public:
0045    struct Node final : public ROOT::Experimental::RTreeMapBase::Node, public TObject {
0046    public:
0047       ClassDefOverride(Node, 1);
0048    };
0049    RTreeMapPainter() = default;
0050    void Paint(Option_t *opt) override;
0051 
0052    ClassDefOverride(RTreeMapPainter, 1);
0053 
0054    ~RTreeMapPainter() override = default;
0055 
0056 private:
0057    /////////////////////////////////////////////////////////////////////////////
0058    /// \brief Logic for drawing a box on TVirtualPad
0059    void AddBox(const Rect &rect, const RGBColor &color, float borderWidth) const final;
0060 
0061    /////////////////////////////////////////////////////////////////////////////
0062    /// \brief Logic for drawing a text on TVirtualPad
0063    void AddText(const Vec2 &pos, const std::string &content, float size, const RGBColor &color = RGBColor(0, 0, 0),
0064                 bool alignCenter = false) const final;
0065 };
0066 } // namespace ROOT::Experimental
0067 #endif