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
12REveBoxSet* elliptic_boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
13 Int_t num=100)
14{
15 auto eveMng = REveManager::Create();
16
17 using namespace TMath;
18
19 REveManager::Create();
20
21 auto lines = new REveStraightLineSet("StraightLines");
22 lines->SetLineColor(kYellow);
23 lines->SetLineWidth(2);
24
25 TRandom r(0);
26
27 auto cones = new REveBoxSet("EllipticConeSet");
28 bool valIsColor = true;
29 cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
30
31 cones->SetPickable(kTRUE);
32
33 Float_t a = 40; // max distance between cones
34 REveVector dir, pos;
35 Float_t theta, phi, height, rad;
36 for (Int_t i=0; i<num; ++i) {
37 theta = r.Uniform(0,TMath::Pi());
38 phi = r.Uniform (-TMath::Pi(), TMath::Pi());
39 height = r.Uniform(5, 15);
40 rad = r.Uniform(3, 5);
41 dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
42 dir *= height;
43 pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
44
45 cones->AddEllipticCone(pos, dir, rad, 0.5*rad, r.Uniform(0,360));
46 if (i %2 == 0)
47 cones->DigitColor(kRed);
48 else
49 cones->DigitColor(kGreen);
50 // draw axis line 30% longer than cone height
51 REveVector end = pos + dir*1.3f;
52 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
53 }
54
55 // by default cone cap not drawn
56 if (r.Integer(2)>0) 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
74
75REveBoxSet* boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0,
76 Int_t num=100)
77{
78 auto eveMng = REveManager::Create();
79
80 using namespace TMath;
81
82 auto lines = new REveStraightLineSet("StraightLines");
83 lines->SetLineColor(kYellow);
84 lines->SetLineWidth(2);
85
86 TRandom r(0);
87 auto pal = new REveRGBAPalette(0, 500);
88 auto cones = new REveBoxSet("ConeSet");
89 cones->SetPalette(pal);
90 bool valIsColor = false;
91 cones->Reset(REveBoxSet::kBT_InstancedScaledRotated, valIsColor, 64);
92
93 Float_t a = 40; // max distance between cones
94 REveVector dir, pos;
95 Float_t theta, phi, height, rad;
96 for (Int_t i=0; i<num; ++i) {
97 theta = r.Uniform(0,TMath::Pi());
98 phi = r.Uniform (-TMath::Pi(), TMath::Pi());
99 height = r.Uniform(5, 15);
100 rad = r.Uniform(3, 5);
101 dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
102 dir *= height;
103 pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a));
104
105 cones->AddCone(pos, dir, rad);
106 cones->DigitValue(r.Uniform(0, 500));
107
108 // draw axis line 30% longer than cone height
109 REveVector end = pos + dir*1.3f;
110 lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ);
111 }
112
113 cones->SetPickable(1);
114 cones->SetAlwaysSecSelect(1);
115 // by default cone cap not drawn
116 if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE);
117
118 cones->RefitPlex();
119 REveTrans& t = cones->RefMainTrans();
120 t.SetPos(x, y, z);
121
125 eveMng->Show();
126
127 return cones;
128}
#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:100
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kYellow
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 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:594
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:588