ROOT
master
Reference Guide
Loading...
Searching...
No Matches
boxset_cones.C File Reference
Tutorials
»
Visualisation tutorials
»
Event display for ROOT 7 tutorials
Detailed Description
Demonstrates usage of 'cone' mode in
REveBoxSet
class.
using namespace
ROOT::Experimental
;
REveBoxSet
*elliptic_boxset_cones(
Float_t
x
= 0,
Float_t
y
= 0,
Float_t
z = 0,
Int_t
num = 100)
{
auto
eveMng
=
REveManager::Create
();
using namespace
TMath
;
REveManager::Create
();
auto
lines =
new
REveStraightLineSet
(
"StraightLines"
);
lines->SetLineColor(
kYellow
);
lines->SetLineWidth(2);
TRandom
r
(0);
auto
cones =
new
REveBoxSet
(
"EllipticConeSet"
);
bool
valIsColor =
true
;
cones->Reset(
REveBoxSet::kBT_InstancedScaledRotated
, valIsColor, 64);
cones->SetPickable(
kTRUE
);
Float_t
a
= 40;
// max distance between cones
REveVector
dir, pos;
Float_t
theta, phi,
height
, rad;
for
(
Int_t
i = 0; i < num; ++i) {
theta =
r
.Uniform(0,
TMath::Pi
());
phi =
r
.Uniform(-
TMath::Pi
(),
TMath::Pi
());
height
=
r
.Uniform(5, 15);
rad =
r
.Uniform(3, 5);
dir.
Set
(
Cos
(phi) *
Cos
(theta),
Sin
(phi) *
Cos
(theta),
Sin
(theta));
dir *=
height
;
pos.
Set
(
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
));
cones->AddEllipticCone(pos, dir, rad, 0.5 * rad,
r
.Uniform(0, 360));
if
(i % 2 == 0)
cones->DigitColor(
kRed
);
else
cones->DigitColor(
kGreen
);
// draw axis line 30% longer than cone height
REveVector
end = pos + dir * 1.3f;
lines->AddLine(pos.
fX
, pos.
fY
, pos.
fZ
, end.
fX
, end.
fY
, end.
fZ
);
}
// by default cone cap not drawn
if
(
r
.Integer(2) > 0)
cones->SetDrawConeCap(
kTRUE
);
cones->RefitPlex();
REveTrans
&t = cones->RefMainTrans();
t.SetPos(
x
,
y
, z);
cones->SetPickable(1);
cones->SetAlwaysSecSelect(1);
eveMng
->GetEventScene()->AddElement(cones);
eveMng
->GetEventScene()->AddElement(lines);
REveViewer
*
v
= (
REveViewer
*)
eveMng
->GetViewers()->FirstChild();
v
->SetAxesType(
REveViewer::kAxesOrigin
);
eveMng
->Show();
return
cones;
}
REveBoxSet
*boxset_cones(
Float_t
x
= 0,
Float_t
y
= 0,
Float_t
z = 0,
Int_t
num = 100)
{
auto
eveMng
=
REveManager::Create
();
using namespace
TMath
;
auto
lines =
new
REveStraightLineSet
(
"StraightLines"
);
lines->SetLineColor(
kYellow
);
lines->SetLineWidth(2);
TRandom
r
(0);
auto
pal =
new
REveRGBAPalette
(0, 500);
auto
cones =
new
REveBoxSet
(
"ConeSet"
);
cones->SetPalette(pal);
bool
valIsColor =
false
;
cones->Reset(
REveBoxSet::kBT_InstancedScaledRotated
, valIsColor, 64);
Float_t
a
= 40;
// max distance between cones
REveVector
dir, pos;
Float_t
theta, phi,
height
, rad;
for
(
Int_t
i = 0; i < num; ++i) {
theta =
r
.Uniform(0,
TMath::Pi
());
phi =
r
.Uniform(-
TMath::Pi
(),
TMath::Pi
());
height
=
r
.Uniform(5, 15);
rad =
r
.Uniform(3, 5);
dir.
Set
(
Cos
(phi) *
Cos
(theta),
Sin
(phi) *
Cos
(theta),
Sin
(theta));
dir *=
height
;
pos.
Set
(
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
));
cones->AddCone(pos, dir, rad);
cones->DigitValue(
r
.Uniform(0, 500));
// draw axis line 30% longer than cone height
REveVector
end = pos + dir * 1.3f;
lines->AddLine(pos.
fX
, pos.
fY
, pos.
fZ
, end.
fX
, end.
fY
, end.
fZ
);
}
cones->SetPickable(1);
cones->SetAlwaysSecSelect(1);
// by default cone cap not drawn
if
(
r
.Integer(2) > 0)
cones->SetDrawConeCap(
kTRUE
);
cones->RefitPlex();
REveTrans
&t = cones->RefMainTrans();
t.SetPos(
x
,
y
, z);
eveMng
->GetEventScene()->AddElement(cones);
eveMng
->GetEventScene()->AddElement(lines);
eveMng
->GetEventScene()->AddElement(pal);
eveMng
->Show();
return
cones;
}
a
#define a(i)
Definition
RSha256.hxx:99
Int_t
int Int_t
Signed integer 4 bytes (int)
Definition
RtypesCore.h:59
Float_t
float Float_t
Float 4 bytes (float)
Definition
RtypesCore.h:71
kTRUE
constexpr Bool_t kTRUE
Definition
RtypesCore.h:107
kRed
@ kRed
Definition
Rtypes.h:67
kGreen
@ kGreen
Definition
Rtypes.h:67
kYellow
@ kYellow
Definition
Rtypes.h:67
r
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
Definition
TGWin32VirtualXProxy.cxx:168
height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Definition
TGWin32VirtualXProxy.cxx:164
REveBoxSet
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
REveRGBAPalette
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
REveTrans
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
REveViewer
Eve representation of a GL view.
ROOT::Experimental::REveBoxSet::kBT_InstancedScaledRotated
@ kBT_InstancedScaledRotated
Definition
REveBoxSet.hxx:36
ROOT::Experimental::REveManager::Create
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
Definition
REveManager.cxx:683
ROOT::Experimental::REveStraightLineSet
REveStraightLineSet Set of straight lines with optional markers along the lines.
Definition
REveStraightLineSet.hxx:42
ROOT::Experimental::REveVectorT::fX
TT fX
Definition
REveVector.hxx:31
ROOT::Experimental::REveVectorT::fZ
TT fZ
Definition
REveVector.hxx:31
ROOT::Experimental::REveVectorT::fY
TT fY
Definition
REveVector.hxx:31
ROOT::Experimental::REveVectorT::Set
void Set(const Float_t *v)
Definition
REveVector.hxx:80
ROOT::Experimental::REveViewer::kAxesOrigin
@ kAxesOrigin
Definition
REveViewer.hxx:50
TRandom
This is the base class for the ROOT Random number generators.
Definition
TRandom.h:27
eveMng
ROOT::Experimental::REveManager * eveMng
Definition
collection_proxies.C:55
y
Double_t y[n]
Definition
legend1.C:17
x
Double_t x[n]
Definition
legend1.C:17
ROOT::Experimental
Namespace for ROOT features in testing.
Definition
TROOT.h:100
ROOT::Experimental::REveVector
REveVectorT< Float_t > REveVector
Definition
REveVector.hxx:119
TMath
TMath.
Definition
TMathBase.h:35
TMath::Cos
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition
TMath.h:605
TMath::Pi
constexpr Double_t Pi()
Definition
TMath.h:40
TMath::Sin
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition
TMath.h:599
v
@ v
Definition
rootcling_impl.cxx:3554
Author
Alja Mrak-Tadel
Definition in file
boxset_cones.C
.
tutorials
visualisation
eve7
boxset_cones.C
ROOTmaster - Reference Guide Generated on Tue May 19 2026 19:40:28 (GVA Time) using Doxygen 1.13.2