Logo ROOT  
Reference Guide
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,
11 Int_t num=100, Bool_t registerSet=kTRUE)
12{
14
15 TRandom r(0);
16
17 auto pal = new TEveRGBAPalette(0, 130);
18
19 auto frm = new TEveFrameBox();
20 frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
21 frm->SetFrameColor(kCyan);
22 frm->SetBackColorRGBA(120,120,120,20);
23 frm->SetDrawBack(kTRUE);
24
25 auto q = new TEveBoxSet("BoxSet");
26 q->SetPalette(pal);
27 q->SetFrame(frm);
28 q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
29 for (Int_t i=0; i<num; ++i) {
30 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
31 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
32 q->DigitValue(r.Uniform(0, 130));
33 }
34 q->RefitPlex();
35
36 TEveTrans& t = q->RefMainTrans();
37 t.SetPos(x, y, z);
38
39 // Uncomment these two lines to get internal highlight / selection.
40 // q->SetPickable(1);
41 // q->SetAlwaysSecSelect(1);
42
43 if (registerSet)
44 {
47 }
48
49 return q;
50}
51
52TEveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
53 Int_t num=100, Bool_t registerSet=kTRUE)
54{
56
57 TRandom r(0);
58
59 auto q = new TEveBoxSet("BoxSet");
60 q->Reset(TEveBoxSet::kBT_AABox, kTRUE, 64);
61 for (Int_t i=0; i<num; ++i) {
62 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
63 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
64 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
65 r.Uniform(20, 255), r.Uniform(20, 255));
66 }
67 q->RefitPlex();
68
69 TEveTrans& t = q->RefMainTrans();
70 t.SetPos(x, y, z);
71
72 if (registerSet)
73 {
76 }
77
78 return q;
79}
80
81TEveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
82 Int_t num=100, Bool_t registerSet=kTRUE)
83{
85
86 TRandom r(0);
87
88 auto q = new TEveBoxSet("BoxSet");
89 q->UseSingleColor();
90 q->SetMainColor(kCyan-2);
91 q->SetMainTransparency(50);
92 q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
93 for (Int_t i=0; i<num; ++i) {
94 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
95 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
96 }
97 q->RefitPlex();
98
99 TEveTrans& t = q->RefMainTrans();
100 t.SetPos(x, y, z);
101
102 if (registerSet) {
103 gEve->AddElement(q);
105 }
106
107 return q;
108}
109
110TEveBoxSet* boxset_freebox(Int_t num=100, Bool_t registerSet=kTRUE)
111{
113
114 TRandom r(0);
115
116 auto pal = new TEveRGBAPalette(0, 130);
117
118 auto q = new TEveBoxSet("BoxSet");
119 q->SetPalette(pal);
120 q->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64);
121
122#define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
123
124 Float_t verts[24];
125 for (Int_t i=0; i<num; ++i) {
126 Float_t x = RND_BOX(10);
127 Float_t y = RND_BOX(10);
128 Float_t z = RND_BOX(10);
129 Float_t a = r.Uniform(0.2, 0.5);
130 Float_t d = 0.05;
131 Float_t verts[24] = {
132 x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
133 x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
134 x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
135 x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
136 x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d),
137 x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
138 x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
139 x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
140 q->AddBox(verts);
141 q->DigitValue(r.Uniform(0, 130));
142 }
143 q->RefitPlex();
144
145#undef RND_BOX
146
147 // Uncomment these two lines to get internal highlight / selection.
148 // q->SetPickable(1);
149 // q->SetAlwaysSecSelect(1);
150
151 if (registerSet) {
152 gEve->AddElement(q);
154 }
155
156 return q;
157}
158
159TEveBoxSet* boxset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
160 Int_t num=100, Bool_t registerSet=kTRUE)
161{
163
164 TRandom r(0);
165
166 auto q = new TEveBoxSet("BoxSet");
167 q->Reset(TEveBoxSet::kBT_Hex, kTRUE, 64);
168
169 for (Int_t i=0; i<num; ++i) {
170 q->AddHex(TEveVector(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10)),
171 r.Uniform(0.2, 1), r.Uniform(0, 60), r.Uniform(0.2, 5));
172 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
173 r.Uniform(20, 255), r.Uniform(20, 255));
174 }
175 q->RefitPlex();
176
177 q->SetPickable(true);
178 q->SetAlwaysSecSelect(true);
179
180 TEveTrans& t = q->RefMainTrans();
181 t.SetPos(x, y, z);
182
183 if (registerSet)
184 {
185 gEve->AddElement(q);
187 }
188
189 return q;
190}
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
@ kCyan
Definition: Rtypes.h:64
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
TEveVectorT< Float_t > TEveVector
Definition: TEveVector.h:122
float * q
Definition: THbookFile.cxx:87
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.
Definition: TEveFrameBox.h:19
void AddElement(TEveElement *element, TEveElement *parent=0)
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)
Definition: TEveManager.h:168
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).
Definition: TEveTrans.cxx:507
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
auto * a
Definition: textangle.C:12