Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
boxset.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of TEveBoxSet class.
4///
5/// \image html eve_boxset.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10TEveBoxSet *boxset(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100, Bool_t registerSet = kTRUE)
11{
13
14 TRandom r(0);
15
16 auto pal = new TEveRGBAPalette(0, 130);
17
18 auto frm = new TEveFrameBox();
19 frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
20 frm->SetFrameColor(kCyan);
21 frm->SetBackColorRGBA(120, 120, 120, 20);
22 frm->SetDrawBack(kTRUE);
23
24 auto q = new TEveBoxSet("BoxSet");
25 q->SetPalette(pal);
26 q->SetFrame(frm);
27 q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
28 for (Int_t i = 0; i < num; ++i) {
29 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1), r.Uniform(0.2, 1),
30 r.Uniform(0.2, 1));
31 q->DigitValue(r.Uniform(0, 130));
32 }
33 q->RefitPlex();
34
35 TEveTrans &t = q->RefMainTrans();
36 t.SetPos(x, y, z);
37
38 // Uncomment these two lines to get internal highlight / selection.
39 q->SetPickable(1);
40 q->SetAlwaysSecSelect(1);
41
42 if (registerSet) {
45 }
46
47 return q;
48}
49
51{
53
54 TRandom r(0);
55
56 auto q = new TEveBoxSet("BoxSet");
57 q->Reset(TEveBoxSet::kBT_AABox, kTRUE, 64);
58 for (Int_t i = 0; i < num; ++i) {
59 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1), r.Uniform(0.2, 1),
60 r.Uniform(0.2, 1));
61 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255));
62 }
63 q->RefitPlex();
64
65 TEveTrans &t = q->RefMainTrans();
66 t.SetPos(x, y, z);
67
68 if (registerSet) {
71 }
72
73 return q;
74}
75
78{
80
81 TRandom r(0);
82
83 auto q = new TEveBoxSet("BoxSet");
84 q->UseSingleColor();
85 q->SetMainColor(kCyan - 2);
86 q->SetMainTransparency(50);
87 q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
88 for (Int_t i = 0; i < num; ++i) {
89 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1), r.Uniform(0.2, 1),
90 r.Uniform(0.2, 1));
91 }
92 q->RefitPlex();
93
94 TEveTrans &t = q->RefMainTrans();
95 t.SetPos(x, y, z);
96
97 if (registerSet) {
100 }
101
102 return q;
103}
104
106{
108
109 TRandom r(0);
110
111 auto pal = new TEveRGBAPalette(0, 130);
112
113 auto q = new TEveBoxSet("BoxSet");
114 q->SetPalette(pal);
115 q->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
116
117#define RND_BOX(x) (Float_t) r.Uniform(-(x), (x))
118
119 Float_t verts[24];
120 for (Int_t i = 0; i < num; ++i) {
121 Float_t x = RND_BOX(10);
122 Float_t y = RND_BOX(10);
123 Float_t z = RND_BOX(10);
124 Float_t a = r.Uniform(0.2, 0.5);
125 Float_t d = 0.05;
126 Float_t verts[24] = {x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d), x - a + RND_BOX(d),
127 y + a + RND_BOX(d), z - a + RND_BOX(d), x + a + RND_BOX(d), y + a + RND_BOX(d),
128 z - a + RND_BOX(d), x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
129 x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d), x - a + RND_BOX(d),
130 y + a + RND_BOX(d), z + a + RND_BOX(d), x + a + RND_BOX(d), y + a + RND_BOX(d),
131 z + a + RND_BOX(d), x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d)};
132 q->AddBox(verts);
133 q->DigitValue(r.Uniform(0, 130));
134 }
135 q->RefitPlex();
136
137#undef RND_BOX
138
139 // Uncomment these two lines to get internal highlight / selection.
140 q->SetPickable(1);
141 q->SetAlwaysSecSelect(1);
142
143 if (registerSet) {
144 gEve->AddElement(q);
146 }
147
148 return q;
149}
150
152{
154
155 TRandom r(0);
156
157 auto q = new TEveBoxSet("BoxSet");
158 q->Reset(TEveBoxSet::kBT_Hex, kTRUE, 64);
159
160 for (Int_t i = 0; i < num; ++i) {
161 q->AddHex(TEveVector(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10)), r.Uniform(0.2, 1),
162 r.Uniform(0, 60), r.Uniform(0.2, 5));
163 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255), r.Uniform(20, 255));
164 }
165 q->RefitPlex();
166
167 q->SetPickable(true);
168 q->SetAlwaysSecSelect(true);
169
170 TEveTrans &t = q->RefMainTrans();
171 t.SetPos(x, y, z);
172
173 if (registerSet) {
174 gEve->AddElement(q);
176 }
177
178 return q;
179}
#define d(i)
Definition RSha256.hxx:102
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kCyan
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEveManager * gEve
TEveVectorT< Float_t > TEveVector
Definition TEveVector.h:123
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
float * q
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
Definition TEveBoxSet.h:22
Description of a 2D or 3D frame that can be used to visually group a set of objects.
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
Add an element.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
#define RND_BOX(x)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17