Logo ROOT  
Reference Guide
boxset.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage of REveBoxSet class.
4///
5/// \image html eve_boxset.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10#include "TRandom.h"
11#include <ROOT/REveElement.hxx>
12#include <ROOT/REveScene.hxx>
13#include <ROOT/REveManager.hxx>
14#include <ROOT/REveBoxSet.hxx>
15
16using namespace ROOT::Experimental;
17
18
19REveBoxSet* boxset(Int_t num=100)
20{
21 auto eveMng = REveManager::Create();
22
23 TRandom r(0);
24
25 auto pal = new REveRGBAPalette(0, 130);
26
27 auto q = new REveBoxSet("BoxSet");
28 q->SetPalette(pal);
29 q->Reset(REveBoxSet::kBT_FreeBox, kFALSE, 64);
30
31#define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
32
33 Float_t verts[24];
34 for (Int_t i=0; i<num; ++i) {
35 Float_t x = RND_BOX(10);
36 Float_t y = RND_BOX(10);
37 Float_t z = RND_BOX(10);
38 Float_t a = r.Uniform(0.2, 0.5);
39 Float_t d = 0.05;
40 Float_t verts[24] = {
41 x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
42 x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
43 x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
44 x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
45 x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d),
46 x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
47 x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
48 x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
49 q->AddBox(verts);
50 q->DigitValue(r.Uniform(0, 130));
51 }
52 q->RefitPlex();
53
54#undef RND_BOX
55
56 // Uncomment these two lines to get internal highlight / selection.
57 q->SetPickable(1);
58 q->SetAlwaysSecSelect(1);
59
61
62 eveMng->Show();
63 return q;
64}
65
66REveBoxSet* boxset_axisaligned(Float_t x=0, Float_t y=0, Float_t z=0,
67 Int_t num=100, Bool_t registerSet=kTRUE)
68{
69 auto eveMng = REveManager::Create();
70
71 TRandom r(0);
72
73 auto pal = new REveRGBAPalette(0, 130);
74
75 auto frm = new REveFrameBox();
76 frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
77 frm->SetFrameColor(kCyan);
78 frm->SetBackColorRGBA(120,120,120,20);
79 frm->SetDrawBack(kTRUE);
80
81 auto q = new REveBoxSet("BoxSet");
82 q->SetPalette(pal);
83 q->SetFrame(frm);
84 q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
85 for (Int_t i=0; i<num; ++i) {
86 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
87 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
88 q->DigitValue(r.Uniform(0, 130));
89 }
90 q->RefitPlex();
91
92 REveTrans& t = q->RefMainTrans();
93 t.SetPos(x, y, z);
94
95 // Uncomment these two lines to get internal highlight / selection.
96 q->SetPickable(1);
97 q->SetAlwaysSecSelect(1);
98
99 if (registerSet)
100 {
102 eveMng->Show();
103 }
104
105 return q;
106}
107
108REveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
109 Int_t num=100, Bool_t registerSet=kTRUE)
110{
111 auto eveMng = REveManager::Create();
112
113 TRandom r(0);
114
115 auto q = new REveBoxSet("BoxSet");
116 q->Reset(REveBoxSet::kBT_AABox, kTRUE, 64);
117 for (Int_t i=0; i<num; ++i) {
118 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
119 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
120 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
121 r.Uniform(20, 255), r.Uniform(20, 255));
122 }
123 q->RefitPlex();
124
125 REveTrans& t = q->RefMainTrans();
126 t.SetPos(x, y, z);
127
128 if (registerSet)
129 {
131 eveMng->Show();
132 }
133
134 return q;
135}
136
137REveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
138 Int_t num=100, Bool_t registerSet=kTRUE)
139{
140 auto eveMng = REveManager::Create();
141
142 TRandom r(0);
143
144 auto q = new REveBoxSet("BoxSet");
145 q->UseSingleColor();
146 q->SetMainColorPtr(new Color_t);
147 q->SetMainColor(kRed);
148 q->SetMainTransparency(50);
149 q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
150
151 for (Int_t i=0; i<num; ++i) {
152 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
153 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
154 }
155 q->RefitPlex();
156
157 REveTrans& t = q->RefMainTrans();
158 t.SetPos(x, y, z);
159
160 if (registerSet) {
162 eveMng->Show();
163 }
164
165 return q;
166}
167
168/*
169REveBoxSet* boxset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
170 Int_t num=100, Bool_t registerSet=kTRUE)
171{
172 auto eveMng = REveManager::Create();
173
174 TRandom r(0);
175
176 auto q = new REveBoxSet("BoxSet");
177 q->Reset(REveBoxSet::kBT_Hex, kTRUE, 64);
178
179 for (Int_t i=0; i<num; ++i) {
180 q->AddHex(REveVector(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10)),
181 r.Uniform(0.2, 1), r.Uniform(0, 60), r.Uniform(0.2, 5));
182 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
183 r.Uniform(20, 255), r.Uniform(20, 255));
184 }
185 q->RefitPlex();
186
187 q->SetPickable(true);
188 q->SetAlwaysSecSelect(true);
189
190 REveTrans& t = q->RefMainTrans();
191 t.SetPos(x, y, z);
192
193 if (registerSet)
194 {
195 eveMng->GetEventScene()->AddElement(q);
196 eveMng->Show();
197 }
198
199 return q;
200}
201*/
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
const Bool_t kFALSE
Definition: RtypesCore.h:90
short Color_t
Definition: RtypesCore.h:81
const Bool_t kTRUE
Definition: RtypesCore.h:89
@ kRed
Definition: Rtypes.h:64
@ kCyan
Definition: Rtypes.h:64
float * q
Definition: THbookFile.cxx:87
virtual void AddElement(REveElement *el)
Add el to the list of children.
REveScene * GetEventScene() const
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: REveTrans.cxx:508
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
REX::REveManager * eveMng
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
auto * a
Definition: textangle.C:12