ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  gStyle->SetPalette(1, 0);
17 
18  TEveRGBAPalette *pal = new TEveRGBAPalette(0, 130);
19  TEveFrameBox *box = new TEveFrameBox();
20  box->SetAAQuadXY(-10, -10, 0, 20, 20);
21  box->SetFrameColor(kGray);
22 
23  TEveQuadSet* q = new TEveQuadSet("RectangleXY");
24  q->SetOwnIds(kTRUE);
25  q->SetPalette(pal);
26  q->SetFrame(box);
28  for (Int_t i=0; i<num; ++i)
29  {
30  q->AddQuad(r.Uniform(-10, 9), r.Uniform(-10, 9), 0,
31  r.Uniform(0.2, 1), r.Uniform(0.2, 1));
32  q->QuadValue(r.Uniform(0, 130));
33  q->QuadId(new TNamed(Form("QuadIdx %d", i),
34  "TNamed assigned to a quad as an indentifier."));
35  }
36  q->RefitPlex();
37 
38  TEveTrans& t = q->RefMainTrans();
39  t.RotateLF(1, 3, 0.5*TMath::Pi());
40  t.SetPos(x, y, z);
41 
47 
48  // Uncomment these two lines to get internal highlight / selection.
49  // q->SetPickable(1);
50  // q->SetAlwaysSecSelect(1);
51 
52  TEveRGBAPaletteOverlay *po = new TEveRGBAPaletteOverlay(pal, 0.55, 0.1, 0.4, 0.05);
53  v = gEve->GetDefaultGLViewer();
54  v->AddOverlayElement(po);
55 
56  // To set user-interface (GUI + overlay) to display real values
57  // mapped with a linear function: r = 0.1 * i + 0;
58  // pal->SetUIDoubleRep(kTRUE, 0.1, 0);
59 
60  if (registerSet)
61  {
62  gEve->AddElement(q);
64  }
65 
66  Info("quadset", "use alt-left-mouse to select individual digits.");
67 
68  return q;
69 }
70 
71 TEveQuadSet* 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  gStyle->SetPalette(1, 0);
77 
78  TEveQuadSet* q = new TEveQuadSet("EMC Supermodule");
79  q->SetOwnIds(kTRUE);
81  q->SetDefWidth(8);
82  q->SetDefHeight(8);
83 
84  for (Int_t i=0; i<num; ++i)
85  {
86  q->AddQuad(r.Uniform(-100, 100), r.Uniform(-100, 100));
87  q->QuadValue(r.Uniform(0, 130));
88  q->QuadId(new TNamed(Form("Cell %d", i), "Dong!"));
89  }
90  q->RefitPlex();
91 
92  TEveTrans& t = q->RefMainTrans();
93  t.SetPos(x, y, z);
94 
95  gEve->AddElement(q);
96  gEve->Redraw3D();
97 
98  return q;
99 }
100 
101 TEveQuadSet* quadset_circ()
102 {
104 
105  TRandom rnd(0);
106  gStyle->SetPalette(1, 0);
107 
108  Float_t R = 10, dW = 1, dH = .5;
109 
110  TEveFrameBox *box = new TEveFrameBox();
111  {
112  Float_t frame[3*36];
113  Float_t *p = frame;
114  for (Int_t i = 0; i < 36; ++i, p += 3) {
115  p[0] = 11 * TMath::Cos(TMath::TwoPi()*i/36);
116  p[1] = 11 * TMath::Sin(TMath::TwoPi()*i/36);
117  p[2] = 0;
118  }
119  box->SetQuadByPoints(frame, 36);
120  }
121  box->SetFrameColor(kGray);
122 
123  TEveQuadSet* q = new TEveQuadSet("Pepe");
124  q->SetFrame(box);
126 
127  for (Float_t r = R; r > 2; r *= 0.8)
128  {
129  Int_t maxI = 2.0*TMath::Pi()*r / 2;
130  for (Int_t i = 0; i < maxI; ++i)
131  {
132  Float_t x = r * TMath::Cos(TMath::TwoPi()*i/maxI);
133  Float_t y = r * TMath::Sin(TMath::TwoPi()*i/maxI);
134  q->AddHexagon(x, y, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
135  q->QuadValue(rnd.Uniform(0, 130));
136  }
137  }
138  q->RefitPlex();
139 
140  TEveTrans& t = q->RefMainTrans();
141  t.RotateLF(1, 3, 0.5*TMath::Pi());
142 
143  gEve->AddElement(q);
144  gEve->Redraw3D();
145 
146  return q;
147 }
148 
149 TEveQuadSet* quadset_hex(Float_t x=0, Float_t y=0, Float_t z=0,
150  Int_t num=100, Bool_t registerSet=kTRUE)
151 {
153 
154  TRandom r(0);
155  gStyle->SetPalette(1, 0);
156 
157  {
158  TEveQuadSet* q = new TEveQuadSet("HexagonXY");
160  for (Int_t i=0; i<num; ++i)
161  {
162  q->AddHexagon(r.Uniform(-10, 10),
163  r.Uniform(-10, 10),
164  r.Uniform(-10, 10),
165  r.Uniform(0.2, 1));
166  q->QuadValue(r.Uniform(0, 120));
167  }
168  q->RefitPlex();
169 
170  TEveTrans& t = q->RefMainTrans();
171  t.SetPos(x, y, z);
172 
173  if (registerSet)
174  {
175  gEve->AddElement(q);
176  gEve->Redraw3D();
177  }
178  }
179 
180  {
181  TEveQuadSet* q = new TEveQuadSet("HexagonYX");
183  for (Int_t i=0; i<num; ++i)
184  {
185  q->AddHexagon(r.Uniform(-10, 10),
186  r.Uniform(-10, 10),
187  r.Uniform(-10, 10),
188  r.Uniform(0.2, 1));
189  q->QuadValue(r.Uniform(0, 120));
190  }
191  q->RefitPlex();
192 
193  TEveTrans& t = q->RefMainTrans();
194  t.SetPos(x, y, z);
195 
196  if (registerSet)
197  {
198  gEve->AddElement(q);
199  gEve->Redraw3D();
200  }
201 
202  return q;
203  }
204 }
205 
206 TEveQuadSet* quadset_hexid(Float_t x=0, Float_t y=0, Float_t z=0,
207  Int_t num=100, Bool_t registerSet=kTRUE)
208 {
210 
211  TRandom r(0);
212  gStyle->SetPalette(1, 0);
213 
214  TEveQuadSet* q = new TEveQuadSet("HexagonXY");
215 
216  {
217 
218  q->SetOwnIds(kTRUE);
220  for (Int_t i=0; i<num; ++i)
221  {
222  q->AddHexagon(r.Uniform(-10, 10),
223  r.Uniform(-10, 10),
224  r.Uniform(-10, 10),
225  r.Uniform(0.2, 1));
226  q->QuadValue(r.Uniform(0, 120));
227  q->QuadId(new TNamed(Form("Quad with idx=%d", i),
228  "This title is not confusing."));
229  }
230  q->RefitPlex();
231 
232  TEveTrans& t = q->RefMainTrans();
233  t.SetPos(x, y, z);
234 
235  if (registerSet)
236  {
237  gEve->AddElement(q);
238  gEve->Redraw3D();
239  }
240  }
241 
242  // This show another way of getting notified about
243  // secondary selection hit. The callback function and the
244  // setting of it must be done in compiled code.
245  gROOT->ProcessLine(".L quadset_callback.cxx+");
247 
248  return q;
249 }
250 
251 void quadset_hierarchy(Int_t n=4)
252 {
254 
255  gStyle->SetPalette(1, 0);
256 
257  TEveRGBAPalette* pal = new TEveRGBAPalette(20, 100);
258  pal->SetLimits(0, 120);
259 
260  TEveFrameBox* box = new TEveFrameBox();
261  box->SetAABox(-10, -10, -10, 20, 20, 20);
262  box->SetFrameColor(33);
263 
264  TEveElementList* l = new TEveElementList("Parent/Dir");
265  l->SetTitle("Tooltip");
266  // l->SetMainColor(3);
267  gEve->AddElement(l);
268 
269  for (Int_t i=0; i<n; ++i)
270  {
271  TEveQuadSet* qs = quadset_hexid(0, 0, 50*i, 50, kFALSE);
272  qs->SetPalette(pal);
273  qs->SetFrame(box);
274  l->AddElement(qs);
275  }
276 
277  gEve->Redraw3D();
278 }
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
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
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:344
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 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.
TGLCameraOverlay * GetCameraOverlay() const
Definition: TGLViewer.h:281
void SetFrameColor(Color_t ci)
Set color of the frame.
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
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
Float_t z[5]
Definition: Ifit.C:16
void SetFrame(TEveFrameBox *b)
Set TEveFrameBox pointer.
ROOT::R::TRInterface & r
Definition: Object.C:4
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
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)
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.
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.
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1779
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
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="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
const Int_t n
Definition: legend1.C:16
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445
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