Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
quadset.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstates usage of 2D digit class TEveQuadSet.
4///
5/// \image html eve_quadset.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10void quadset_callback(TEveDigitSet* ds, Int_t idx, TObject* obj);
11TString quadset_tooltip_callback(TEveDigitSet* ds, Int_t idx);
12void quadset_set_callback(TEveDigitSet* ds);
13
14//------------------------------------------------------------------------------
15
16TEveQuadSet* quadset(Float_t x=0, Float_t y=0, Float_t z=0,
17 Int_t num=100, Bool_t registerSet=kTRUE)
18{
20
21 TRandom r(0);
22
23 TEveRGBAPalette *pal = new TEveRGBAPalette(0, 130);
25 box->SetAAQuadXY(-10, -10, 0, 20, 20);
26 box->SetFrameColor(kGray);
27
28 TEveQuadSet* q = new TEveQuadSet("RectangleXY");
29 q->SetOwnIds(kTRUE);
30 q->SetPalette(pal);
31 q->SetFrame(box);
33 for (Int_t i=0; i<num; ++i)
34 {
35 q->AddQuad(r.Uniform(-10, 9), r.Uniform(-10, 9), 0,
36 r.Uniform(0.2, 1), r.Uniform(0.2, 1));
37 q->QuadValue(r.Uniform(0, 130));
38 q->QuadId(new TNamed(Form("QuadIdx %d", i),
39 "TNamed assigned to a quad as an indentifier."));
40 }
41 q->RefitPlex();
42
43 TEveTrans& t = q->RefMainTrans();
44 t.RotateLF(1, 3, 0.5*TMath::Pi());
45 t.SetPos(x, y, z);
46
49 TGLCameraOverlay* co = v->GetCameraOverlay();
52
53 // Uncomment these two lines to get internal highlight / selection.
54 // q->SetPickable(1);
55 // q->SetAlwaysSecSelect(1);
56
57 TEveRGBAPaletteOverlay *po = new TEveRGBAPaletteOverlay(pal, 0.55, 0.1, 0.4, 0.05);
60
61 // To set user-interface (GUI + overlay) to display real values
62 // mapped with a linear function: r = 0.1 * i + 0;
63 // pal->SetUIDoubleRep(kTRUE, 0.1, 0);
64
65 if (registerSet)
66 {
69 }
70
71 Info("quadset", "use alt-left-mouse to select individual digits.");
72
73 return q;
74}
75
76TEveQuadSet* quadset_emc(Float_t x=0, Float_t y=0, Float_t z=0, Int_t num=100)
77{
79
80 TRandom r(0);
81
82 TEveQuadSet* q = new TEveQuadSet("EMC Supermodule");
83 q->SetOwnIds(kTRUE);
85 q->SetDefWidth(8);
86 q->SetDefHeight(8);
87
88 for (Int_t i=0; i<num; ++i)
89 {
90 q->AddQuad(r.Uniform(-100, 100), r.Uniform(-100, 100));
91 q->QuadValue(r.Uniform(0, 130));
92 q->QuadId(new TNamed(Form("Cell %d", i), "Dong!"));
93 }
94 q->RefitPlex();
95
96 TEveTrans& t = q->RefMainTrans();
97 t.SetPos(x, y, z);
98
100 gEve->Redraw3D();
101
102 return q;
103}
104
105TEveQuadSet* quadset_circ()
106{
108
109 TRandom rnd(0);
110
111 Float_t R = 10, dW = 1, dH = .5;
112
114 {
115 Float_t frame[3*36];
116 Float_t *p = frame;
117 for (Int_t i = 0; i < 36; ++i, p += 3) {
118 p[0] = 11 * TMath::Cos(TMath::TwoPi()*i/36);
119 p[1] = 11 * TMath::Sin(TMath::TwoPi()*i/36);
120 p[2] = 0;
121 }
122 box->SetQuadByPoints(frame, 36);
123 }
124 box->SetFrameColor(kGray);
125
126 TEveQuadSet* q = new TEveQuadSet("Pepe");
127 q->SetFrame(box);
129
130 for (Float_t r = R; r > 2; r *= 0.8)
131 {
132 Int_t maxI = 2.0*TMath::Pi()*r / 2;
133 for (Int_t i = 0; i < maxI; ++i)
134 {
135 Float_t x = r * TMath::Cos(TMath::TwoPi()*i/maxI);
136 Float_t y = r * TMath::Sin(TMath::TwoPi()*i/maxI);
137 q->AddHexagon(x, y, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
138 q->QuadValue(rnd.Uniform(0, 130));
139 }
140 }
141 q->RefitPlex();
142
143 TEveTrans& t = q->RefMainTrans();
144 t.RotateLF(1, 3, 0.5*TMath::Pi());
145
146 gEve->AddElement(q);
147 gEve->Redraw3D();
148
149 return q;
150}
151
152TEveQuadSet* quadset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
153 Int_t num=100, Bool_t registerSet=kTRUE)
154{
156
157 TRandom r(0);
158
159 {
160 TEveQuadSet* q = new TEveQuadSet("HexagonXY");
162 for (Int_t i=0; i<num; ++i)
163 {
164 q->AddHexagon(r.Uniform(-10, 10),
165 r.Uniform(-10, 10),
166 r.Uniform(-10, 10),
167 r.Uniform(0.2, 1));
168 q->QuadValue(r.Uniform(0, 120));
169 }
170 q->RefitPlex();
171
172 TEveTrans& t = q->RefMainTrans();
173 t.SetPos(x, y, z);
174
175 if (registerSet)
176 {
177 gEve->AddElement(q);
178 gEve->Redraw3D();
179 }
180 }
181
182 {
183 TEveQuadSet* q = new TEveQuadSet("HexagonYX");
185 for (Int_t i=0; i<num; ++i)
186 {
187 q->AddHexagon(r.Uniform(-10, 10),
188 r.Uniform(-10, 10),
189 r.Uniform(-10, 10),
190 r.Uniform(0.2, 1));
191 q->QuadValue(r.Uniform(0, 120));
192 }
193 q->RefitPlex();
194
195 TEveTrans& t = q->RefMainTrans();
196 t.SetPos(x, y, z);
197
198 if (registerSet)
199 {
200 gEve->AddElement(q);
201 gEve->Redraw3D();
202 }
203
204 return q;
205 }
206}
207
208TEveQuadSet* quadset_hexid(Float_t x=0, Float_t y=0, Float_t z=0,
209 Int_t num=100, Bool_t registerSet=kTRUE)
210{
212
213 TRandom r(0);
214
215 TEveQuadSet* q = new TEveQuadSet("HexagonXY");
216
217 {
218
219 q->SetOwnIds(kTRUE);
221 for (Int_t i=0; i<num; ++i)
222 {
223 q->AddHexagon(r.Uniform(-10, 10),
224 r.Uniform(-10, 10),
225 r.Uniform(-10, 10),
226 r.Uniform(0.2, 1));
227 q->QuadValue(r.Uniform(0, 120));
228 q->QuadId(new TNamed(Form("Quad with idx=%d", i),
229 "This title is not confusing."));
230 }
231 q->RefitPlex();
232
233 TEveTrans& t = q->RefMainTrans();
234 t.SetPos(x, y, z);
235
236 if (registerSet)
237 {
238 gEve->AddElement(q);
239 gEve->Redraw3D();
240 }
241 }
242
243 quadset_set_callback(q);
244
245 // With the following you get per digit highlight with tooltip.
246 //q->SetPickable(1);
247 //q->SetAlwaysSecSelect(1);
248 // Otherwise you need to Alt - left click to get info printout.
249
250 return q;
251}
252
253void quadset_hierarchy(Int_t n=4)
254{
256
257
258 TEveRGBAPalette* pal = new TEveRGBAPalette(20, 100);
259 pal->SetLimits(0, 120);
260
262 box->SetAABox(-10, -10, -10, 20, 20, 20);
263 box->SetFrameColor(33);
264
265 TEveElementList* l = new TEveElementList("Parent/Dir");
266 l->SetTitle("Tooltip");
267 // l->SetMainColor(3);
268 gEve->AddElement(l);
269
270 for (Int_t i=0; i<n; ++i)
271 {
272 TEveQuadSet* qs = quadset_hexid(0, 0, 50*i, 50, kFALSE);
273 qs->SetPalette(pal);
274 qs->SetFrame(box);
275 l->AddElement(qs);
276 }
277
278 gEve->Redraw3D();
279}
280
281//------------------------------------------------------------------------------
282
283void quadset_callback(TEveDigitSet* ds, Int_t idx, TObject* obj)
284{
285 printf("dump_digit_set_hit - 0x%lx, id=%d, obj=0x%lx\n",
286 (ULong_t) ds, idx, (ULong_t) obj);
287}
288
289TString quadset_tooltip_callback(TEveDigitSet* ds, Int_t idx)
290{
291 // This gets called for tooltip if the following is set:
292 // q->SetPickable(1);
293 // q->SetAlwaysSecSelect(1);
294
295 return TString::Format("callback tooltip for '%s' - 0x%lx, id=%d\n",
296 ds->GetElementName(), (ULong_t) ds, idx);
297}
298
299void quadset_set_callback(TEveDigitSet* ds)
300{
301 ds->SetCallbackFoo(quadset_callback);
302 ds->SetTooltipCBFoo(quadset_tooltip_callback);
303}
ROOT::R::TRInterface & r
Definition Object.C:4
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:101
unsigned long ULong_t
Definition RtypesCore.h:55
bool Bool_t
Definition RtypesCore.h:63
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:100
@ kGray
Definition Rtypes.h:65
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:220
R__EXTERN TEveManager * gEve
float * q
char * Form(const char *fmt,...)
Base-class for storage of digit collections; provides transformation matrix (TEveTrans),...
void SetPalette(TEveRGBAPalette *p)
Set TEveRGBAPalette pointer.
void SetCallbackFoo(Callback_foo f)
void SetTooltipCBFoo(TooltipCB_foo f)
void SetFrame(TEveFrameBox *b)
Set TEveFrameBox pointer.
A list of TEveElements.
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
Description of a 2D or 3D frame that can be used to visually group a set of objects.
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
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)
Supports various internal formats that result in rendering of a set of planar (lines,...
Definition TEveQuadSet.h:20
@ kQT_RectangleXZFixedDimY
Definition TEveQuadSet.h:38
Description of TEveRGBAPaletteOverlay.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition TEveTrans.h:27
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
A GL overlay element which displays camera furstum.
void SetShowOrthographic(Bool_t x)
void SetOrthographicMode(EMode m)
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition TGLViewer.h:55
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ,...
@ kCameraOrthoZOY
Definition TGLViewer.h:62
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
Basic string class.
Definition TString.h:136
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:2336
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Double_t Cos(Double_t)
Definition TMath.h:593
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Definition TMath.h:589
constexpr Double_t TwoPi()
Definition TMath.h:44
auto * l
Definition textangle.C:4