Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
boxset_cones.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of 'cone' mode in REveBoxSet class.
4///
5/// \image html eve_boxset_cones.png
6/// \macro_code
7///
8/// \author Alja Mrak-Tadel
9
10using namespace ROOT::Experimental;
11
13{
14 auto eveMng = REveManager::Create();
15
16 using namespace TMath;
17
18 REveManager::Create();
19
20 auto lines = new REveStraightLineSet("StraightLines");
21 lines->SetLineColor(kYellow);
22 lines->SetLineWidth(2);
23
24 TRandom r(0);
25
26 auto cones = new REveBoxSet("EllipticConeSet");
27 bool valIsColor = true;
28 cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
29
30 cones->SetPickable(kTRUE);
31
32 Float_t a = 40; // max distance between cones
33 REveVector dir, pos;
34 Float_t theta, phi, height, rad;
35 for (Int_t i = 0; i < num; ++i) {
36 theta = r.Uniform(0, TMath::Pi());
37 phi = r.Uniform(-TMath::Pi(), TMath::Pi());
38 height = r.Uniform(5, 15);
39 rad = r.Uniform(3, 5);
40 dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
41 dir *= height;
42 pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
43
44 cones->AddEllipticCone(pos, dir, rad, 0.5 * rad, r.Uniform(0, 360));
45 if (i % 2 == 0)
46 cones->DigitColor(kRed);
47 else
48 cones->DigitColor(kGreen);
49 // draw axis line 30% longer than cone height
50 REveVector end = pos + dir * 1.3f;
51 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
52 }
53
54 // by default cone cap not drawn
55 if (r.Integer(2) > 0)
56 cones->SetDrawConeCap(kTRUE);
57
58 cones->RefitPlex();
59 REveTrans &t = cones->RefMainTrans();
60 t.SetPos(x, y, z);
61 cones->SetPickable(1);
62 cones->SetAlwaysSecSelect(1);
63
66
68 v->SetAxesType(REveViewer::kAxesOrigin);
69
70 eveMng->Show();
71 return cones;
72}
73
74REveBoxSet *boxset_cones(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100)
75{
76 auto eveMng = REveManager::Create();
77
78 using namespace TMath;
79
80 auto lines = new REveStraightLineSet("StraightLines");
81 lines->SetLineColor(kYellow);
82 lines->SetLineWidth(2);
83
84 TRandom r(0);
85 auto pal = new REveRGBAPalette(0, 500);
86 auto cones = new REveBoxSet("ConeSet");
87 cones->SetPalette(pal);
88 bool valIsColor = false;
89 cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
90
91 Float_t a = 40; // max distance between cones
92 REveVector dir, pos;
93 Float_t theta, phi, height, rad;
94 for (Int_t i = 0; i < num; ++i) {
95 theta = r.Uniform(0, TMath::Pi());
96 phi = r.Uniform(-TMath::Pi(), TMath::Pi());
97 height = r.Uniform(5, 15);
98 rad = r.Uniform(3, 5);
99 dir.Set(Cos(phi) * Cos(theta), Sin(phi) * Cos(theta), Sin(theta));
100 dir *= height;
101 pos.Set(r.Uniform(-a, a), r.Uniform(-a, a), r.Uniform(-a, a));
102
103 cones->AddCone(pos, dir, rad);
104 cones->DigitValue(r.Uniform(0, 500));
105
106 // draw axis line 30% longer than cone height
107 REveVector end = pos + dir * 1.3f;
108 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
109 }
110
111 cones->SetPickable(1);
112 cones->SetAlwaysSecSelect(1);
113 // by default cone cap not drawn
114 if (r.Integer(2) > 0)
115 cones->SetDrawConeCap(kTRUE);
116
117 cones->RefitPlex();
118 REveTrans &t = cones->RefMainTrans();
119 t.SetPos(x, y, z);
120
124 eveMng->Show();
125
126 return cones;
127}
#define a(i)
Definition RSha256.hxx:99
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Eve representation of a GL view.
virtual void AddElement(REveElement *el)
Add el to the list of children.
REveElement * FirstChild() const
Returns the first child element or 0 if the list is empty.
REveScene * GetEventScene() const
REveViewerList * GetViewers() const
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveStraightLineSet Set of straight lines with optional markers along the lines.
void Set(const Float_t *v)
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
ROOT::Experimental::REveManager * eveMng
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMath.
Definition TMathBase.h:35
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592