Logo ROOT  
Reference Guide
rpave.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_rcanvas
3///
4/// This macro draw different variants of RPave on the RCanvas.
5/// Also usage of custom font is demonstrated.
6///
7/// \macro_image (rcanvas_js)
8/// \macro_code
9///
10/// \date 2020-06-18
11/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
12/// \author Sergey Linev <s.linev@gsi.de>
13
14/*************************************************************************
15 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
16 * All rights reserved. *
17 * *
18 * For the licensing terms see $ROOTSYS/LICENSE. *
19 * For the list of contributors see $ROOTSYS/README/CREDITS. *
20 *************************************************************************/
21
22#include "ROOT/RCanvas.hxx"
23#include "ROOT/RPave.hxx"
24#include "ROOT/RPaveText.hxx"
25#include "ROOT/RFont.hxx"
26
27using namespace ROOT::Experimental;
28
29void rpave()
30{
31 // Create a canvas to be displayed.
32 auto canvas = RCanvas::Create("RPave example");
33
34 // this pave should be in top left corner
35 auto pave = canvas->Draw<RPave>();
36 pave->fill.color = RColor::kBlue;
37 pave->fill.style = RAttrFill::k3001;
38 pave->border.color = RColor::kGreen;
39 pave->border.width = 3;
40 pave->corner = RPave::kTopLeft;
41 pave->offsetX = pave->offsetY = 0.05_normal;
42 pave->width = 0.3_normal;
43 pave->height = 0.3_normal;
44
45 // this second pave in the bottom left corner
46 auto pave2 = canvas->Draw<RPave>();
47 pave2->fill.color = RColor::kRed;
48 pave2->fill.style = RAttrFill::k3002;
49 pave2->corner = RPave::kBottomLeft;
50 pave2->offsetX = pave2->offsetY = 0.05_normal;
51 pave2->width = 0.3_normal;
52 pave2->height = 0.3_normal;
53
54 auto text = canvas->Draw<RPaveText>();
55 text->AddLine("This is RPaveText");
56 text->AddLine("It can have several lines");
57 text->AddLine("It should be in top right corner");
58 text->fill.color = RColor::kYellow;
59 text->fill.style = RAttrFill::k3003;
60 text->corner = RPave::kTopRight;
61 text->offsetX = text->offsetY = 0.05_normal;
62 text->width = 0.4_normal;
63 text->height = 0.3_normal;
64
65 std::string fname = __FILE__;
66 auto pos = fname.find("rpave.cxx");
67 if (pos > 0) { fname.resize(pos); fname.append("comic.woff2"); }
68 else fname = "comic.woff2";
69 canvas->Draw<RFont>("CustomFont", fname);
70
71 auto text2 = canvas->Draw<RPaveText>();
72 text2->AddLine("RPaveText with custom font");
73 text2->AddLine("It loaded from comic.woff2 file");
74 text2->AddLine("One also can provide valid URL");
75 text2->fill.color = RColor::kGreen;
76 text2->fill.style = RAttrFill::k3004;
77 text2->corner = RPave::kBottomRight;
78 text2->offsetX = text2->offsetY = 0.05_normal;
79 text2->width = 0.4_normal;
80 text2->height = 0.3_normal;
81 text2->text.font.family = "CustomFont";
82
83 canvas->SetSize(1000, 700);
84 canvas->Show();
85}
@ kTopLeft
Definition: GuiTypes.h:372
@ kBottomRight
Definition: GuiTypes.h:372
@ kTopRight
Definition: GuiTypes.h:372
@ kBottomLeft
Definition: GuiTypes.h:372
@ kRed
Definition: Rtypes.h:66
@ kGreen
Definition: Rtypes.h:66
@ kBlue
Definition: Rtypes.h:66
@ kYellow
Definition: Rtypes.h:66
RAttrValue< RColor > color
! fill color
Definition: RAttrFill.hxx:43
Base class for paves with text, statistic, legends, placed relative to RFrame position and adjustable...
Definition: RPave.hxx:32
RAttrFill fill
! fill attributes
Definition: RPave.hxx:48
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
TText * text