Logo ROOT   6.08/07
Reference Guide
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 
10 TEveQuadSet* quadset(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  TEveRGBAPalette *pal = new TEveRGBAPalette(0, 130);
18  TEveFrameBox *box = new TEveFrameBox();
19  box->SetAAQuadXY(-10, -10, 0, 20, 20);
20  box->SetFrameColor(kGray);
21 
22  TEveQuadSet* q = new TEveQuadSet("RectangleXY");
23  q->SetOwnIds(kTRUE);
24  q->SetPalette(pal);
25  q->SetFrame(box);
27  for (Int_t i=0; i<num; ++i)
28  {
29  q->AddQuad(r.Uniform(-10, 9), r.Uniform(-10, 9), 0,
30  r.Uniform(0.2, 1), r.Uniform(0.2, 1));
31  q->QuadValue(r.Uniform(0, 130));
32  q->QuadId(new TNamed(Form("QuadIdx %d", i),
33  "TNamed assigned to a quad as an indentifier."));
34  }
35  q->RefitPlex();
36 
37  TEveTrans& t = q->RefMainTrans();
38  t.RotateLF(1, 3, 0.5*TMath::Pi());
39  t.SetPos(x, y, z);
40 
46 
47  // Uncomment these two lines to get internal highlight / selection.
48  // q->SetPickable(1);
49  // q->SetAlwaysSecSelect(1);
50 
51  TEveRGBAPaletteOverlay *po = new TEveRGBAPaletteOverlay(pal, 0.55, 0.1, 0.4, 0.05);
52  v = gEve->GetDefaultGLViewer();
53  v->AddOverlayElement(po);
54 
55  // To set user-interface (GUI + overlay) to display real values
56  // mapped with a linear function: r = 0.1 * i + 0;
57  // pal->SetUIDoubleRep(kTRUE, 0.1, 0);
58 
59  if (registerSet)
60  {
61  gEve->AddElement(q);
63  }
64 
65  Info("quadset", "use alt-left-mouse to select individual digits.");
66 
67  return q;
68 }
69 
70 TEveQuadSet* quadset_emc(Float_t x=0, Float_t y=0, Float_t z=0, Int_t num=100)
71 {
73 
74  TRandom r(0);
75 
76  TEveQuadSet* q = new TEveQuadSet("EMC Supermodule");
77  q->SetOwnIds(kTRUE);
79  q->SetDefWidth(8);
80  q->SetDefHeight(8);
81 
82  for (Int_t i=0; i<num; ++i)
83  {
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 
93  gEve->AddElement(q);
94  gEve->Redraw3D();
95 
96  return q;
97 }
98 
99 TEveQuadSet* quadset_circ()
100 {
102 
103  TRandom rnd(0);
104 
105  Float_t R = 10, dW = 1, dH = .5;
106 
107  TEveFrameBox *box = new TEveFrameBox();
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  {
126  Int_t maxI = 2.0*TMath::Pi()*r / 2;
127  for (Int_t i = 0; i < maxI; ++i)
128  {
129  Float_t x = r * TMath::Cos(TMath::TwoPi()*i/maxI);
130  Float_t y = r * TMath::Sin(TMath::TwoPi()*i/maxI);
131  q->AddHexagon(x, y, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
132  q->QuadValue(rnd.Uniform(0, 130));
133  }
134  }
135  q->RefitPlex();
136 
137  TEveTrans& t = q->RefMainTrans();
138  t.RotateLF(1, 3, 0.5*TMath::Pi());
139 
140  gEve->AddElement(q);
141  gEve->Redraw3D();
142 
143  return q;
144 }
145 
146 TEveQuadSet* quadset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
147  Int_t num=100, Bool_t registerSet=kTRUE)
148 {
150 
151  TRandom r(0);
152 
153  {
154  TEveQuadSet* q = new TEveQuadSet("HexagonXY");
156  for (Int_t i=0; i<num; ++i)
157  {
158  q->AddHexagon(r.Uniform(-10, 10),
159  r.Uniform(-10, 10),
160  r.Uniform(-10, 10),
161  r.Uniform(0.2, 1));
162  q->QuadValue(r.Uniform(0, 120));
163  }
164  q->RefitPlex();
165 
166  TEveTrans& t = q->RefMainTrans();
167  t.SetPos(x, y, z);
168 
169  if (registerSet)
170  {
171  gEve->AddElement(q);
172  gEve->Redraw3D();
173  }
174  }
175 
176  {
177  TEveQuadSet* q = new TEveQuadSet("HexagonYX");
179  for (Int_t i=0; i<num; ++i)
180  {
181  q->AddHexagon(r.Uniform(-10, 10),
182  r.Uniform(-10, 10),
183  r.Uniform(-10, 10),
184  r.Uniform(0.2, 1));
185  q->QuadValue(r.Uniform(0, 120));
186  }
187  q->RefitPlex();
188 
189  TEveTrans& t = q->RefMainTrans();
190  t.SetPos(x, y, z);
191 
192  if (registerSet)
193  {
194  gEve->AddElement(q);
195  gEve->Redraw3D();
196  }
197 
198  return q;
199  }
200 }
201 
202 TEveQuadSet* quadset_hexid(Float_t x=0, Float_t y=0, Float_t z=0,
203  Int_t num=100, Bool_t registerSet=kTRUE)
204 {
206 
207  TRandom r(0);
208 
209  TEveQuadSet* q = new TEveQuadSet("HexagonXY");
210 
211  {
212 
213  q->SetOwnIds(kTRUE);
215  for (Int_t i=0; i<num; ++i)
216  {
217  q->AddHexagon(r.Uniform(-10, 10),
218  r.Uniform(-10, 10),
219  r.Uniform(-10, 10),
220  r.Uniform(0.2, 1));
221  q->QuadValue(r.Uniform(0, 120));
222  q->QuadId(new TNamed(Form("Quad with idx=%d", i),
223  "This title is not confusing."));
224  }
225  q->RefitPlex();
226 
227  TEveTrans& t = q->RefMainTrans();
228  t.SetPos(x, y, z);
229 
230  if (registerSet)
231  {
232  gEve->AddElement(q);
233  gEve->Redraw3D();
234  }
235  }
236 
237  // This show another way of getting notified about
238  // secondary selection hit. The callback function and the
239  // setting of it must be done in compiled code.
240  gROOT->ProcessLine(".L quadset_callback.cxx+");
242 
243  return q;
244 }
245 
246 void quadset_hierarchy(Int_t n=4)
247 {
249 
250 
251  TEveRGBAPalette* pal = new TEveRGBAPalette(20, 100);
252  pal->SetLimits(0, 120);
253 
254  TEveFrameBox* box = new TEveFrameBox();
255  box->SetAABox(-10, -10, -10, 20, 20, 20);
256  box->SetFrameColor(33);
257 
258  TEveElementList* l = new TEveElementList("Parent/Dir");
259  l->SetTitle("Tooltip");
260  // l->SetMainColor(3);
261  gEve->AddElement(l);
262 
263  for (Int_t i=0; i<n; ++i)
264  {
265  TEveQuadSet* qs = quadset_hexid(0, 0, 50*i, 50, kFALSE);
266  qs->SetPalette(pal);
267  qs->SetFrame(box);
268  l->AddElement(qs);
269  }
270 
271  gEve->Redraw3D();
272 }
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
A GL overlay element which displays camera furstum.
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
float Float_t
Definition: RtypesCore.h:53
void SetDefWidth(Float_t v)
Definition: TEveQuadSet.h:92
void AddHexagon(Float_t a, Float_t b, Float_t z, Float_t r)
Add a hexagon with given center (a,b,c) and radius.
Definition: Rtypes.h:60
#define gROOT
Definition: TROOT.h:364
void AddQuad(Float_t *verts)
Description of TEveRGBAPaletteOverlay.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Description of a 2D or 3D frame that can be used to visually group a set of objects.
Definition: TEveFrameBox.h:18
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
void QuadId(TObject *id)
Definition: TEveQuadSet.h:113
A list of TEveElements.
Definition: TEveElement.h:459
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
void SetFrameColor(Color_t ci)
Set color of the frame.
Double_t x[n]
Definition: legend1.C:17
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:31
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void Info(const char *location, const char *msgfmt,...)
void SetDefHeight(Float_t v)
Definition: TEveQuadSet.h:93
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Double_t TwoPi()
Definition: TMath.h:45
void SetFrame(TEveFrameBox *b)
Set TEveFrameBox pointer.
TRandom2 r(17)
SVector< double, 2 > v
Definition: Dict.h:5
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
TGLCameraOverlay * GetCameraOverlay() const
Definition: TGLViewer.h:281
void SetOwnIds(Bool_t o)
Definition: TEveDigitSet.h:121
char * Form(const char *fmt,...)
void SetQuadByPoints(const Float_t *pointArr, Int_t nPoints)
Setup frame with explicitly given corner coordinates.
void quadset_set_callback(TEveDigitSet *ds)
TLine * l
Definition: textangle.C:4
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
virtual void AddElement(TEveElement *el)
Add el to the list of children.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
Double_t Cos(Double_t)
Definition: TMath.h:424
void SetOrthographicMode(EMode m)
Double_t Pi()
Definition: TMath.h:44
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
void QuadValue(Int_t value)
Definition: TEveQuadSet.h:110
void SetPalette(TEveRGBAPalette *p)
Set TEveRGBAPalette pointer.
void RefitPlex()
Instruct underlying memory allocator to regroup itself into a contiguous memory chunk.
Double_t y[n]
Definition: legend1.C:17
void SetCurrentCamera(ECameraType camera)
Set current active camera - &#39;cameraType&#39; one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1786
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:606
void SetAAQuadXY(Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dy)
Setup for axis-aligned rectangle with one corner at x, y, z and given sizes in x (dx) and y (dy)...
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: TEveTrans.cxx:375
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
Double_t Sin(Double_t)
Definition: TMath.h:421
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
void Reset(EQuadType_e quadType, Bool_t valIsCol, Int_t chunkSize)
Clear the quad-set and reset the basic parameters.
void SetAABox(Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dy, Float_t dz)
Setup for axis-aligned box with one corner at x, y, z and given sizes in x (dx), y (dy) and z (dz)...
const Bool_t kTRUE
Definition: Rtypes.h:91
float * q
Definition: THbookFile.cxx:87
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Int_t n
Definition: legend1.C:16
TRandom3 R
a TMatrixD.
Definition: testIO.cxx:28
void SetShowOrthographic(Bool_t x)
Supports various internal formats that result in rendering of a set of planar (lines, rectangles, hexagons with shared normal) objects.
Definition: TEveQuadSet.h:19