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 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
19std::string customTooltip(const ROOT::Experimental::REveDigitSet *digitSet, int n)
20{
21 auto d = digitSet->GetDigit(n);
22 return TString::Format("Custom tooltip:\n value %d idx %d\n", d->fValue, n).Data();
23}
24
25REveBoxSet* boxset(Int_t num=100)
26{
27 auto eveMng = REveManager::Create();
28
29 TRandom r(0);
30
31 auto pal = new REveRGBAPalette(0, 130);
32 pal->SetMin(80);
33
34
35 auto q = new REveBoxSet("BoxSet");
36 q->SetPalette(pal);
37 q->Reset(REveBoxSet::kBT_FreeBox, kFALSE, 64);
38
39#define RND_BOX(x) (Float_t)r.Uniform(-(x), (x))
40
41 const float R = 500;
42 const float A = 40;
43 const float D = 1;
44 for (int i = 0; i < num; ++i) {
45 float x = RND_BOX(R);
46 float y = RND_BOX(R);
47 float z = RND_BOX(R);
48 float a = r.Uniform(0.2*A, A);
49 float d = D;
50 float verts[24] = {
51 x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
52 x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
53 x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d),
54 x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d),
55 x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d),
56 x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
57 x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d),
58 x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) };
59 q->AddBox(verts);
60 q->DigitValue(r.Uniform(0, 130));
61 }
62 q->RefitPlex();
63
64#undef RND_BOX
65
66 // Uncomment these two lines to get internal highlight / selection.
67 q->SetPickable(1);
68 q->SetAlwaysSecSelect(1);
69
70 q->SetTooltipCBFoo(customTooltip);
71
73
74 eveMng->Show();
75 return q;
76}
77
78REveBoxSet* boxset_axisaligned(Float_t x=0, Float_t y=0, Float_t z=0,
79 Int_t num=100, Bool_t registerSet=kTRUE)
80{
81 auto eveMng = REveManager::Create();
82
83 TRandom r(0);
84
85 auto pal = new REveRGBAPalette(0, 130);
86
87 auto frm = new REveFrameBox();
88 frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12);
89 frm->SetFrameColor(kCyan);
90 frm->SetBackColorRGBA(120,120,120,20);
91 frm->SetDrawBack(kTRUE);
92
93 auto q = new REveBoxSet("BoxSet");
94 q->SetPalette(pal);
95 q->SetFrame(frm);
96 q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
97 for (Int_t i=0; i<num; ++i) {
98 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
99 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
100 q->DigitValue(r.Uniform(0, 130));
101 }
102 q->RefitPlex();
103
104 REveTrans& t = q->RefMainTrans();
105 t.SetPos(x, y, z);
106
107 // Uncomment these two lines to get internal highlight / selection.
108 q->SetPickable(1);
109 q->SetAlwaysSecSelect(1);
110
111 if (registerSet)
112 {
114 eveMng->Show();
115 }
116
117 return q;
118}
119
120REveBoxSet* boxset_colisval(Float_t x=0, Float_t y=0, Float_t z=0,
121 Int_t num=100, Bool_t registerSet=kTRUE)
122{
123 auto eveMng = REveManager::Create();
124
125 TRandom r(0);
126
127 auto q = new REveBoxSet("BoxSet");
128 q->Reset(REveBoxSet::kBT_AABox, kTRUE, 64);
129 for (Int_t i=0; i<num; ++i) {
130 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
131 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
132 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
133 r.Uniform(20, 255), r.Uniform(20, 255));
134 }
135 q->RefitPlex();
136
137 REveTrans& t = q->RefMainTrans();
138 t.SetPos(x, y, z);
139
140 if (registerSet)
141 {
143 eveMng->Show();
144 }
145
146 return q;
147}
148
149REveBoxSet* boxset_single_color(Float_t x=0, Float_t y=0, Float_t z=0,
150 Int_t num=100, Bool_t registerSet=kTRUE)
151{
152 auto eveMng = REveManager::Create();
153
154 TRandom r(0);
155
156 auto q = new REveBoxSet("BoxSet");
157 q->UseSingleColor();
158 q->SetMainColorPtr(new Color_t);
159 q->SetMainColor(kRed);
160 q->SetMainTransparency(50);
161 q->Reset(REveBoxSet::kBT_AABox, kFALSE, 64);
162
163 for (Int_t i=0; i<num; ++i) {
164 q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10),
165 r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1));
166 }
167 q->RefitPlex();
168
169 REveTrans& t = q->RefMainTrans();
170 t.SetPos(x, y, z);
171
172 if (registerSet) {
174 eveMng->Show();
175 }
176
177 return q;
178}
179
180
181REveBoxSet* boxset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
182 Int_t num=100, Bool_t registerSet=kTRUE)
183{
184 auto eveMng = REveManager::Create();
185
186 TRandom r(0);
187
188 auto q = new REveBoxSet("BoxSet");
189 q->Reset(REveBoxSet::kBT_Hex, kTRUE, 64);
190
191 for (Int_t i=0; i<num; ++i) {
192 q->AddHex(REveVector(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10)),
193 r.Uniform(0.2, 1), r.Uniform(0, 60), r.Uniform(0.2, 5));
194 q->DigitColor(r.Uniform(20, 255), r.Uniform(20, 255),
195 r.Uniform(20, 255), r.Uniform(20, 255));
196 }
197 q->RefitPlex();
198
199 q->SetPickable(true);
200 q->SetAlwaysSecSelect(true);
201
202 REveTrans& t = q->RefMainTrans();
203 t.SetPos(x, y, z);
204
205 if (registerSet)
206 {
208 eveMng->Show();
209 }
210
211 return q;
212}
213
#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
short Color_t
Definition RtypesCore.h:92
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
@ kRed
Definition Rtypes.h:66
@ kCyan
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
float * q
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
Description of a 2D or 3D frame that can be used to visually group a set of objects.
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...
DigitBase_t * GetDigit(Int_t n) const
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.
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
const char * Data() const
Definition TString.h:380
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
ROOT::Experimental::REveManager * eveMng
#define RND_BOX(x)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16