Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RTreeMapPainter.cxx
Go to the documentation of this file.
1/// \file RTreeMapPainter.cxx
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
17
18#include <TCanvas.h>
19#include <TPad.h>
20#include <TBox.h>
21#include <TLatex.h>
22#include <TColor.h>
23
24#include <cmath>
25
27{
28 if (!gPad)
29 return;
30 gPad->Clear();
31 gPad->Range(0, 0, 1, 1);
32 gPad->cd();
33 gPad->SetEditable(kFALSE);
34 DrawTreeMap(fNodes[0], Rect(Vec2(0.025, 0.05), Vec2(0.825, 0.9)), 0);
35 DrawLegend();
36}
37
39{
40 auto box = new TBox(rect.fBottomLeft.x, rect.fBottomLeft.y, rect.fTopRight.x, rect.fTopRight.y);
41 box->SetFillColor(TColor::GetColor(color.r, color.g, color.b, color.a));
42 box->SetLineColor(kGray);
43 box->SetLineWidth(std::ceil(borderWidth));
44 gPad->Add(box, "l");
45}
46
47void ROOT::Experimental::RTreeMapPainter::AddText(const Vec2 &pos, const std::string &content, float size,
48 const RGBColor &color, bool alignCenter) const
49{
50 auto t = new TLatex(pos.x, pos.y, content.c_str());
51 t->SetTextFont(42);
52 t->SetTextSize(size);
53 t->SetTextAlign((alignCenter) ? 22 : 13);
54 t->SetTextColor(TColor::GetColor(color.r, color.g, color.b, color.a));
55 gPad->Add(t);
56}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
@ kGray
Definition Rtypes.h:66
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
#define gPad
void DrawLegend() const
Logic for drawing the legend of leaf types.
void DrawTreeMap(const Node &elem, Rect rect, int depth) const
Logic for drawing the entirety of the treemap.
void Paint(Option_t *opt) override
This method must be overridden if a class wants to paint itself.
void AddText(const Vec2 &pos, const std::string &content, float size, const RGBColor &color=RGBColor(0, 0, 0), bool alignCenter=false) const final
Logic for drawing a text on TVirtualPad.
void AddBox(const Rect &rect, const RGBColor &color, float borderWidth) const final
Logic for drawing a box on TVirtualPad.
Create a Box.
Definition TBox.h:22
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1927
To draw Mathematical Formula.
Definition TLatex.h:18
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1