Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
box.cxx
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_v7
3 ///
4 /// This ROOT 7 example demonstrates how to create a ROOT 7 canvas (RCanvas) and
5 /// draw ROOT 7 boxes in it (RBox). It generates a set of boxes using the
6 /// "normal" coordinates' system.
7 ///
8 /// \macro_image
9 /// \macro_code
10 ///
11 /// \date 2018-10-10
12 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
13 /// is welcome!
14 /// \author Olivier Couet
15 
16 #include "ROOT/RCanvas.hxx"
17 #include "ROOT/RColor.hxx"
18 #include "ROOT/RBox.hxx"
19 #include <ROOT/RPadPos.hxx>
20 
21 void box()
22 {
23  using namespace ROOT::Experimental;
24 
25  // Create a canvas to be displayed.
26  auto canvas = RCanvas::Create("Canvas Title");
27 
28  auto Box1 = canvas->Draw<RBox>(RPadPos(0.1_normal, 0.3_normal), RPadPos(0.3_normal,0.6_normal));
29  RColor Color1(255, 0, 0, 0.5); // 50% opaque
30  RColor Color2(0, 0, 255, 0.3); // 30% opaque
31 
32  Box1->AttrBox().AttrBorder().SetColor(Color1).SetWidth(5);
33  Box1->AttrBox().AttrFill().SetColor(RColor::kRed);
34 
35  auto Box2 = canvas->Draw<RBox>(RPadPos(0.4_normal, 0.2_normal), RPadPos(0.6_normal,0.7_normal));
36  Box2->AttrBox().AttrBorder().SetColor(Color2).SetStyle(2).SetWidth(3);
37  Box2->AttrBox().AttrFill().SetColor(RColor::kGreen);
38 
39  auto Box3 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.4_normal), RPadPos(0.9_normal,0.6_normal));
40  Box3->AttrBox().AttrBorder().SetWidth(3);
41  Box3->AttrBox().AttrFill().SetColor(RColor::kBlue);
42 
43  auto Box4 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.7_normal), RPadPos(0.9_normal,0.9_normal));
44  //OptsBox4->SetFillStyle(0);
45  //OptsBox4->SetRoundWidth(50);
46  //OptsBox4->SetRoundHeight(25);
47  Box4->AttrBox().AttrBorder().SetWidth(3);
48 
49  auto Box5 = canvas->Draw<RBox>(RPadPos(0.7_normal, 0.1_normal), RPadPos(0.9_normal,0.3_normal));
50  //OptsBox5->SetFillStyle(0);
51  //OptsBox5->SetRoundWidth(25);
52  //OptsBox5->SetRoundHeight(50);
53  Box5->AttrBox().AttrBorder().SetWidth(3);
54 
55  canvas->Show();
56 }