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
13
14//------------------------------------------------------------------------------
15
17{
19
20 TRandom r(0);
21
22 TEveRGBAPalette *pal = new TEveRGBAPalette(0, 130);
24 box->SetAAQuadXY(-10, -10, 0, 20, 20);
25 box->SetFrameColor(kGray);
26
27 TEveQuadSet *q = new TEveQuadSet("RectangleXY");
28 q->SetOwnIds(kTRUE);
29 q->SetPalette(pal);
30 q->SetFrame(box);
32 for (Int_t i = 0; i < num; ++i) {
33 q->AddQuad(r.Uniform(-10, 9), r.Uniform(-10, 9), 0, r.Uniform(0.2, 1), r.Uniform(0.2, 1));
34 q->QuadValue(r.Uniform(0, 130));
35 q->QuadId(new TNamed(Form("QuadIdx %d", i), "TNamed assigned to a quad as an indentifier."));
36 }
37 q->RefitPlex();
38
39 TEveTrans &t = q->RefMainTrans();
40 t.RotateLF(1, 3, 0.5 * TMath::Pi());
41 t.SetPos(x, y, z);
42
45 TGLCameraOverlay *co = v->GetCameraOverlay();
46 co->SetShowOrthographic(kTRUE);
47 co->SetOrthographicMode(TGLCameraOverlay::kGridFront);
48
49 // Uncomment these two lines to get internal highlight / selection.
50 // q->SetPickable(1);
51 // q->SetAlwaysSecSelect(1);
52
53 TEveRGBAPaletteOverlay *po = new TEveRGBAPaletteOverlay(pal, 0.55, 0.1, 0.4, 0.05);
56
57 // To set user-interface (GUI + overlay) to display real values
58 // mapped with a linear function: r = 0.1 * i + 0;
59 // pal->SetUIDoubleRep(kTRUE, 0.1, 0);
60
61 if (registerSet) {
64 }
65
66 Info("quadset", "use alt-left-mouse to select individual digits.");
67
68 return q;
69}
70
71TEveQuadSet *quadset_emc(Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t num = 100)
72{
74
75 TRandom r(0);
76
77 TEveQuadSet *q = new TEveQuadSet("EMC Supermodule");
78 q->SetOwnIds(kTRUE);
80 q->SetDefWidth(8);
81 q->SetDefHeight(8);
82
83 for (Int_t i = 0; i < num; ++i) {
84 q->AddQuad(r.Uniform(-100, 100), r.Uniform(-100, 100));
85 q->QuadValue(r.Uniform(0, 130));
86 q->QuadId(new TNamed(Form("Cell %d", i), "Dong!"));
87 }
88 q->RefitPlex();
89
90 TEveTrans &t = q->RefMainTrans();
91 t.SetPos(x, y, z);
92
94 gEve->Redraw3D();
95
96 return q;
97}
98
100{
102
103 TRandom rnd(0);
104
105 Float_t R = 10, dW = 1, dH = .5;
106
108 {
109 Float_t frame[3 * 36];
110 Float_t *p = frame;
111 for (Int_t i = 0; i < 36; ++i, p += 3) {
112 p[0] = 11 * TMath::Cos(TMath::TwoPi() * i / 36);
113 p[1] = 11 * TMath::Sin(TMath::TwoPi() * i / 36);
114 p[2] = 0;
115 }
116 box->SetQuadByPoints(frame, 36);
117 }
118 box->SetFrameColor(kGray);
119
120 TEveQuadSet *q = new TEveQuadSet("Pepe");
121 q->SetFrame(box);
123
124 for (Float_t r = R; r > 2; r *= 0.8) {
125 Int_t maxI = 2.0 * TMath::Pi() * r / 2;
126 for (Int_t i = 0; i < maxI; ++i) {
127 Float_t x = r * TMath::Cos(TMath::TwoPi() * i / maxI);
128 Float_t y = r * TMath::Sin(TMath::TwoPi() * i / maxI);
129 q->AddHexagon(x, y, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
130 q->QuadValue(rnd.Uniform(0, 130));
131 }
132 }
133 q->RefitPlex();
134
135 TEveTrans &t = q->RefMainTrans();
136 t.RotateLF(1, 3, 0.5 * TMath::Pi());
137
138 gEve->AddElement(q);
139 gEve->Redraw3D();
140
141 return q;
142}
143
145{
147
148 TRandom r(0);
149
150 {
151 TEveQuadSet *q = new TEveQuadSet("HexagonXY");
153 for (Int_t i = 0; i < num; ++i) {
154 q->AddHexagon(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1));
155 q->QuadValue(r.Uniform(0, 120));
156 }
157 q->RefitPlex();
158
159 TEveTrans &t = q->RefMainTrans();
160 t.SetPos(x, y, z);
161
162 if (registerSet) {
163 gEve->AddElement(q);
164 gEve->Redraw3D();
165 }
166 }
167
168 {
169 TEveQuadSet *q = new TEveQuadSet("HexagonYX");
171 for (Int_t i = 0; i < num; ++i) {
172 q->AddHexagon(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1));
173 q->QuadValue(r.Uniform(0, 120));
174 }
175 q->RefitPlex();
176
177 TEveTrans &t = q->RefMainTrans();
178 t.SetPos(x, y, z);
179
180 if (registerSet) {
181 gEve->AddElement(q);
182 gEve->Redraw3D();
183 }
184
185 return q;
186 }
187}
188
190{
192
193 TRandom r(0);
194
195 TEveQuadSet *q = new TEveQuadSet("HexagonXY");
196
197 {
198
199 q->SetOwnIds(kTRUE);
201 for (Int_t i = 0; i < num; ++i) {
202 q->AddHexagon(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1));
203 q->QuadValue(r.Uniform(0, 120));
204 q->QuadId(new TNamed(Form("Quad with idx=%d", i), "This title is not confusing."));
205 }
206 q->RefitPlex();
207
208 TEveTrans &t = q->RefMainTrans();
209 t.SetPos(x, y, z);
210
211 if (registerSet) {
212 gEve->AddElement(q);
213 gEve->Redraw3D();
214 }
215 }
216
218
219 // With the following you get per digit highlight with tooltip.
220 // q->SetPickable(1);
221 // q->SetAlwaysSecSelect(1);
222 // Otherwise you need to Alt - left click to get info printout.
223
224 return q;
225}
226
227void quadset_hierarchy(Int_t n = 4)
228{
230
231 TEveRGBAPalette *pal = new TEveRGBAPalette(20, 100);
232 pal->SetLimits(0, 120);
233
235 box->SetAABox(-10, -10, -10, 20, 20, 20);
236 box->SetFrameColor(33);
237
238 TEveElementList *l = new TEveElementList("Parent/Dir");
239 l->SetTitle("Tooltip");
240 // l->SetMainColor(3);
241 gEve->AddElement(l);
242
243 for (Int_t i = 0; i < n; ++i) {
244 TEveQuadSet *qs = quadset_hexid(0, 0, 50 * i, 50, kFALSE);
245 qs->SetPalette(pal);
246 qs->SetFrame(box);
247 l->AddElement(qs);
248 }
249
250 gEve->Redraw3D();
251}
252
253//------------------------------------------------------------------------------
254
256{
257 printf("dump_digit_set_hit - 0x%lx, id=%d, obj=0x%lx\n", (ULong_t)ds, idx, (ULong_t)obj);
258}
259
261{
262 // This gets called for tooltip if the following is set:
263 // q->SetPickable(1);
264 // q->SetAlwaysSecSelect(1);
265
266 return TString::Format("callback tooltip for '%s' - 0x%lx, id=%d\n", ds->GetElementName(), (ULong_t)ds, idx);
267}
268
270{
271 ds->SetCallbackFoo(quadset_callback);
272 ds->SetTooltipCBFoo(quadset_tooltip_callback);
273}
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kGray
Definition Rtypes.h:65
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEveManager * gEve
winID h TVirtualViewer3D TVirtualGLPainter p
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
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
Base-class for storage of digit collections; provides transformation matrix (TEveTrans),...
A list of TEveElements.
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.
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...
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.
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:139
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:2378
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
std::ostream & Info()
Definition hadd.cxx:163
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)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
constexpr Double_t Pi()
Definition TMath.h:37
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592
constexpr Double_t TwoPi()
Definition TMath.h:44
TLine l
Definition textangle.C:4