]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
7 | * full copyright notice. * | |
8 | **************************************************************************/ | |
9 | ||
10 | #include "AliEveITSModuleStepper.h" | |
11 | #include "AliEveITSDigitsInfo.h" | |
12 | #include "AliEveITSScaledModule.h" | |
13 | ||
14 | #include <TEveManager.h> | |
15 | #include <TEveGedEditor.h> | |
16 | #include <TEveGridStepper.h> | |
17 | #include <TEveGLText.h> | |
18 | #include <TEveTrans.h> | |
19 | ||
20 | #include <TObject.h> | |
21 | #include <TMath.h> | |
22 | ||
23 | #include <TBuffer3D.h> | |
24 | #include <TBuffer3DTypes.h> | |
25 | #include <TVirtualPad.h> | |
26 | #include <TVirtualViewer3D.h> | |
27 | ||
28 | #include <TGLRnrCtx.h> | |
29 | #include <TGLSelectRecord.h> | |
30 | #include <TGLText.h> | |
31 | // #include <FTFont.h> | |
32 | #include <TGLAxis.h> | |
33 | #include <TGLViewer.h> | |
34 | ||
35 | ||
36 | //______________________________________________________________________________ | |
37 | // | |
38 | // Display scaled ITS modules in a paged layout, also providing | |
39 | // GL-overaly control GUI. | |
40 | ||
41 | ||
42 | ClassImp(AliEveITSModuleStepper) | |
43 | ||
44 | AliEveITSModuleStepper::AliEveITSModuleStepper(AliEveITSDigitsInfo* di) : | |
45 | TEveElementList("ITS 2DStore", "AliEveITSModuleStepper", kTRUE), | |
46 | ||
47 | fIDs(), | |
48 | fPosition(0), | |
49 | ||
50 | fDigitsInfo(di), | |
51 | fScaleInfo(0), | |
52 | ||
53 | fSubDet(-1), | |
54 | ||
55 | fStepper(0), | |
56 | fAxis(0), | |
57 | fText(0), | |
58 | fTextSize(0.05), | |
59 | fPagerGap(0.1), | |
60 | fRnrFrame(kFALSE), | |
61 | ||
62 | fExpandCell(0.85), | |
63 | fModuleFrameCol(2), | |
64 | ||
65 | fPaletteOffset(0.2), | |
66 | fPaletteLength(0.6), | |
67 | ||
68 | fWActive(-1), | |
69 | fWWidth(0.025), | |
70 | fWHeight(0.032), | |
71 | fWOff(0.05), | |
72 | fWCol(30), | |
73 | fWActiveCol(45), | |
74 | fFontCol(8) | |
75 | { | |
76 | // Constructor. | |
77 | ||
78 | // override member from base TEveElementList | |
79 | fChildClass = AliEveITSScaledModule::Class(); | |
80 | ||
81 | SetMainColorPtr(&fWCol); | |
82 | ||
83 | fDigitsInfo->IncRefCount(); | |
84 | ||
85 | fStepper = new TEveGridStepper(); | |
86 | fStepper->SetNs(5, 4); | |
87 | ||
88 | fScaleInfo = new AliEveDigitScaleInfo(); | |
89 | fScaleInfo->IncRefCount(); | |
90 | ||
91 | fAxis = new TGLAxis(); | |
92 | fAxis->SetLineColor(4); | |
93 | fAxis->SetTextColor(fFontCol); | |
94 | ||
95 | fText = new TGLText(); | |
96 | fText->SetTextColor(fFontCol); | |
97 | fText->SetGLTextFont(40); | |
98 | fText->SetGLTextAngles(0, 0, 0); | |
99 | fText->SetTextSize(fTextSize); | |
100 | ||
101 | gEve->GetGLViewer()->AddOverlayElement(this); | |
102 | } | |
103 | ||
104 | AliEveITSModuleStepper::~AliEveITSModuleStepper() | |
105 | { | |
106 | // Destructor. | |
107 | ||
108 | gEve->GetGLViewer()->RemoveOverlayElement(this); | |
109 | ||
110 | fScaleInfo->DecRefCount(); | |
111 | fDigitsInfo->DecRefCount(); | |
112 | ||
113 | delete fStepper; | |
114 | ||
115 | delete fAxis; | |
116 | delete fText; | |
117 | } | |
118 | ||
119 | /******************************************************************************/ | |
120 | ||
121 | void AliEveITSModuleStepper::Capacity() | |
122 | { | |
123 | // Make sure we have just enough children (module representations) | |
124 | // to store as many modules as required by the grid-stepper | |
125 | // configuration. | |
126 | ||
127 | Int_t N = fStepper->GetNx()*fStepper->GetNy(); | |
128 | if (N != GetNChildren()) | |
129 | { | |
130 | DestroyElements(); | |
131 | for (Int_t m=0; m<N; m++) | |
132 | { | |
133 | AddElement(new AliEveITSScaledModule(m, fDigitsInfo, fScaleInfo)); | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | /******************************************************************************/ | |
139 | ||
140 | void AliEveITSModuleStepper::SetFirst(Int_t first) | |
141 | { | |
142 | Int_t lastpage = fIDs.size()/Nxy(); | |
143 | if(fIDs.size() % Nxy() ) lastpage++; | |
144 | ||
145 | Int_t firstLastpage = (lastpage - 1)*Nxy(); | |
146 | if(first > firstLastpage) first = firstLastpage; | |
147 | if(first < 0) first = 0; | |
148 | fPosition = first; | |
149 | Apply(); | |
150 | } | |
151 | ||
152 | void AliEveITSModuleStepper::Start() | |
153 | { | |
154 | // Go to first page. | |
155 | ||
156 | fPosition = 0; | |
157 | Apply(); | |
158 | } | |
159 | ||
160 | void AliEveITSModuleStepper::Next() | |
161 | { | |
162 | // Go to next page. | |
163 | ||
164 | SetFirst(fPosition + Nxy()); | |
165 | } | |
166 | ||
167 | void AliEveITSModuleStepper::Previous() | |
168 | { | |
169 | // Go to previous page. | |
170 | ||
171 | SetFirst(fPosition - Nxy()); | |
172 | } | |
173 | ||
174 | void AliEveITSModuleStepper::End() | |
175 | { | |
176 | // Go to last page. | |
177 | ||
178 | Int_t lastpage = fIDs.size()/Nxy(); | |
179 | if (fIDs.size() % Nxy()) lastpage++; | |
180 | fPosition = (lastpage - 1)*Nxy(); | |
181 | ||
182 | fStepper->Reset(); | |
183 | Apply(); | |
184 | } | |
185 | ||
186 | /******************************************************************************/ | |
187 | ||
188 | void AliEveITSModuleStepper::DisplayDet(Int_t det, Int_t layer) | |
189 | { | |
190 | // Select modules to display by sub-det type / layer. | |
191 | ||
192 | fSubDet = det; | |
193 | fIDs.clear(); | |
194 | AliEveITSModuleSelection sel = AliEveITSModuleSelection(); | |
195 | sel.SetType (det); | |
196 | sel.SetLayer(layer); | |
197 | fDigitsInfo->GetModuleIDs(&sel, fIDs); | |
198 | //in reder menu define a space between left and right pager | |
199 | fPagerGap = 1.2*TextLength(Form("%d/%d",GetPages(), GetPages())); | |
200 | Start(); | |
201 | } | |
202 | ||
203 | /******************************************************************************/ | |
204 | ||
205 | void AliEveITSModuleStepper::DisplayTheta(Float_t min, Float_t max) | |
206 | { | |
207 | // Select modules to display by theta range. | |
208 | ||
209 | fIDs.clear(); | |
210 | AliEveITSModuleSelection sel = AliEveITSModuleSelection(); | |
211 | sel.SetThetaRange(min, max); | |
212 | fDigitsInfo->GetModuleIDs(&sel, fIDs); | |
213 | Start(); | |
214 | } | |
215 | ||
216 | /******************************************************************************/ | |
217 | ||
218 | Int_t AliEveITSModuleStepper::GetCurrentPage() | |
219 | { | |
220 | // Get number of current page. | |
221 | ||
222 | Int_t idx = fPosition + 1; | |
223 | Int_t n = idx/Nxy(); | |
224 | if (idx % Nxy()) n++; | |
225 | return n; | |
226 | } | |
227 | ||
228 | /******************************************************************************/ | |
229 | ||
230 | Int_t AliEveITSModuleStepper::GetPages() | |
231 | { | |
232 | // Get number of all pages. | |
233 | ||
234 | Int_t n = fIDs.size()/Nxy(); | |
235 | if(fIDs.size() % Nxy()) n++; | |
236 | return n; | |
237 | } | |
238 | ||
239 | /******************************************************************************/ | |
240 | ||
241 | void AliEveITSModuleStepper::Apply() | |
242 | { | |
243 | // Apply current settings to children modules. | |
244 | ||
245 | // printf("AliEveITSModuleStepper::Apply fPosition %d \n", fPosition); | |
246 | gEve->DisableRedraw(); | |
247 | Capacity(); | |
248 | ||
249 | UInt_t idx = fPosition; | |
250 | for(List_i childit=fChildren.begin(); childit!=fChildren.end(); ++childit) | |
251 | { | |
252 | if(idx < fIDs.size()) | |
253 | { | |
254 | AliEveITSScaledModule* mod = dynamic_cast<AliEveITSScaledModule*>(*childit); | |
255 | mod->SetID(fIDs[idx], kFALSE); | |
256 | TEveTrans& tr = mod->RefHMTrans(); | |
257 | tr.UnitTrans(); | |
258 | tr.RotateLF(3,2,TMath::PiOver2()); | |
259 | tr.RotateLF(1,3,TMath::PiOver2()); | |
260 | ||
261 | // scaling | |
262 | Float_t mz, mx; | |
263 | Float_t* fp = mod->GetFrame()->GetFramePoints(); | |
264 | // switch x,z it will be rotated afterwards | |
265 | mx = -2*fp[0]; | |
266 | mz = -2*fp[2]; | |
267 | ||
268 | // fit width first | |
269 | Double_t sx = fStepper->GetDx(); | |
270 | Double_t sy = (mx*fStepper->GetDx())/mz; | |
271 | if(sy > fStepper->GetDy()) | |
272 | { | |
273 | // printf("fit width \n"); | |
274 | sy = fStepper->GetDy(); | |
275 | sx = (mz*fStepper->GetDx())/mx; | |
276 | } | |
277 | Float_t scale = (fExpandCell*sx)/mz; | |
278 | tr.Scale(scale, scale, scale); | |
279 | ||
280 | Float_t p[3]; | |
281 | fStepper->GetPosition(p); | |
282 | tr.SetPos(p[0]+0.5*fStepper->GetDx(), p[1]+0.5*fStepper->GetDy(), p[2]+0.5*fStepper->GetDz()); | |
283 | ||
284 | if(mod->GetSubDetID() == 2) | |
285 | mod->SetName(Form("SSD %d", idx)); | |
286 | else if(mod->GetSubDetID() == 1) | |
287 | mod->SetName(Form("SDD %d", idx)); | |
288 | else | |
289 | mod->SetName(Form("SPD %d", idx)); | |
290 | mod->SetRnrSelf(kTRUE); | |
291 | mod->UpdateItems(); | |
292 | ||
293 | fStepper->Step(); | |
294 | idx++; | |
295 | } | |
296 | else { | |
297 | (*childit)->SetRnrSelf(kFALSE); | |
298 | } | |
299 | } | |
300 | ||
301 | fStepper->Reset(); | |
302 | ElementChanged(); | |
303 | gEve->EnableRedraw(); | |
304 | } | |
305 | ||
306 | /******************************************************************************/ | |
307 | ||
308 | void AliEveITSModuleStepper::Render(TGLRnrCtx& rnrCtx) | |
309 | { | |
310 | // Render the overlay elements. | |
311 | ||
312 | // render everyting in relative coordinates | |
313 | glMatrixMode(GL_PROJECTION); | |
314 | glPushMatrix(); | |
315 | glLoadIdentity(); | |
316 | if (rnrCtx.Selection()) | |
317 | { | |
318 | // Should be | |
319 | // glLoadMatrix(rnrCtx.GetCamera()->GetProjMBase()); | |
320 | TGLRect rect(*rnrCtx.GetPickRectangle()); | |
321 | rnrCtx.GetCamera()->WindowToViewport(rect); | |
322 | gluPickMatrix(rect.X(), rect.Y(), rect.Width(), rect.Height(), | |
323 | (Int_t*) rnrCtx.GetCamera()->RefViewport().CArr()); | |
324 | } | |
325 | ||
326 | glMatrixMode(GL_MODELVIEW); | |
327 | glPushMatrix(); | |
328 | glLoadIdentity(); | |
329 | ||
330 | GLboolean lightp; | |
331 | glGetBooleanv(GL_LIGHTING, &lightp); | |
332 | if (lightp) glDisable(GL_LIGHTING); | |
333 | ||
334 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
335 | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | |
336 | glDisable(GL_CULL_FACE); | |
337 | glEnable(GL_BLEND); | |
338 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |
339 | RenderMenu(); | |
340 | RenderPalette(fPaletteLength, 1.6*fWWidth, fWHeight*0.6); | |
341 | glPopMatrix(); | |
342 | glPopAttrib(); | |
343 | ||
344 | if (lightp) glEnable(GL_LIGHTING); | |
345 | ||
346 | glMatrixMode(GL_PROJECTION); | |
347 | glPopMatrix(); | |
348 | ||
349 | glMatrixMode(GL_MODELVIEW); | |
350 | RenderCellIDs(); | |
351 | } | |
352 | ||
353 | ||
354 | /******************************************************************************/ | |
355 | // Protected sub-renderers | |
356 | /******************************************************************************/ | |
357 | ||
358 | //______________________________________________________________________________ | |
359 | Float_t AliEveITSModuleStepper::TextLength(const char* txt) | |
360 | { | |
361 | // Calculate length of text txt. | |
362 | ||
363 | Float_t llx, lly, llz, urx, ury, urz; | |
364 | fText->BBox(txt, llx, lly, llz, urx, ury, urz); | |
365 | return (urx-llx)*fTextSize; | |
366 | } | |
367 | ||
368 | //______________________________________________________________________________ | |
369 | void AliEveITSModuleStepper::RenderString(TString string, Int_t id) | |
370 | { | |
371 | // Render text for button id. | |
372 | ||
373 | Float_t txtY = fWHeight*0.5; | |
374 | Float_t txtl = TextLength(string.Data()); | |
375 | ||
376 | if(id > 0) glLoadName(id); | |
377 | if(id>0 && fWActive == id) | |
378 | fText->SetTextColor(fWActiveCol); | |
379 | else | |
380 | fText->SetTextColor(fFontCol); | |
381 | ||
382 | ||
383 | if(id>0) | |
384 | { | |
385 | if(fWActive == id) | |
386 | fText->SetTextColor(fWActiveCol); | |
387 | else | |
388 | fText->SetTextColor(fFontCol); | |
389 | ||
390 | glLoadName(id); | |
391 | Float_t ss = fWWidth*0.4; | |
392 | fText->PaintGLText(ss, txtY, -0.8, string.Data()); | |
393 | // box | |
394 | Float_t bw =2*ss+txtl; | |
395 | RenderFrame(bw,fWHeight*2,id); | |
396 | glTranslatef( bw, 0, 0); | |
397 | } | |
398 | else | |
399 | { | |
400 | fText->SetTextColor(fFontCol); | |
401 | fText->PaintGLText(0, txtY, -0.8, string.Data()); | |
402 | glTranslatef(txtl, 0, 0); | |
403 | } | |
404 | } | |
405 | ||
406 | //______________________________________________________________________________ | |
407 | void AliEveITSModuleStepper::RenderFrame(Float_t dx, Float_t dy, Int_t id) | |
408 | { | |
409 | // Render frame for button id, taking into account if it is currently | |
410 | // below mouse. | |
411 | ||
412 | if (fRnrFrame == kFALSE)return; | |
413 | ||
414 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
415 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |
416 | UChar_t color[4]; | |
417 | if (fWActive == id) | |
418 | TEveUtil::TEveUtil::ColorFromIdx(fWActiveCol, color); | |
419 | else | |
420 | TEveUtil:: TEveUtil::ColorFromIdx(fWCol, color); | |
421 | glColor4ubv(color); | |
422 | ||
423 | glBegin(GL_QUADS); | |
424 | glVertex2f(0, 0); glVertex2f(dx, 0); | |
425 | glVertex2f(dx, dy); glVertex2f(0, dy); | |
426 | glEnd(); | |
427 | glPopAttrib(); | |
428 | } | |
429 | ||
430 | //______________________________________________________________________________ | |
431 | void AliEveITSModuleStepper::RenderSymbol(Float_t dx, Float_t dy, Int_t id) | |
432 | { | |
433 | // Render an overlay / GUI symbol, based on button id: | |
434 | // 1 ~ <, 2 ~ <<, 3 ~ >, 4 ~ >>, 5 ~ ^, 6 ~ v. | |
435 | ||
436 | glLoadName(id); | |
437 | ||
438 | UChar_t color[4]; | |
439 | if (fWActive == id) | |
440 | TEveUtil::TEveUtil::ColorFromIdx(fWActiveCol, color); | |
441 | else | |
442 | TEveUtil::TEveUtil::ColorFromIdx(fWCol, color); | |
443 | glColor4ubv(color); | |
444 | ||
445 | Float_t xs = dx/4, ys = dy/4; | |
446 | if(id == 0) { | |
447 | glBegin(GL_QUADS); | |
448 | glVertex2f(0,ys); glVertex2f(0, ys*3); | |
449 | glVertex2f(dx, ys*3); glVertex2f(dx, ys); | |
450 | glEnd(); | |
451 | return; | |
452 | } | |
453 | ||
454 | glBegin(GL_TRIANGLES); | |
455 | switch (id) { | |
456 | case 1: | |
457 | { | |
458 | // left | |
459 | // glVertex2f(xs*2.5, ys*3); glVertex2f(xs*1.5, ys*2); glVertex2f(xs*2.5, ys); | |
460 | glVertex2f(xs*3, ys*3); glVertex2f(xs*1, ys*2); glVertex2f(xs*3, ys); | |
461 | break; | |
462 | } | |
463 | case 2: | |
464 | { | |
465 | //double left | |
466 | glVertex2f(xs*2, ys*3); glVertex2f(xs, ys*2); glVertex2f(xs*2, ys); | |
467 | glVertex2f(xs*3, ys*3); glVertex2f(xs*2, ys*2); glVertex2f(xs*3, ys); | |
468 | break; | |
469 | } | |
470 | case 3: | |
471 | { | |
472 | // right | |
473 | //glVertex2f(xs*1.5, ys); glVertex2f(xs*2.5, ys*2); glVertex2f(xs*1.5, ys*3); | |
474 | glVertex2f(xs*1, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*1, ys*3); | |
475 | break; | |
476 | } | |
477 | case 4: | |
478 | { | |
479 | // double right | |
480 | glVertex2f(xs, ys); glVertex2f(xs*2, ys*2); glVertex2f(xs, ys*3); | |
481 | glVertex2f(xs*2, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*2, ys*3); | |
482 | break; | |
483 | } | |
484 | case 5: | |
485 | { | |
486 | // up | |
487 | glVertex2f(xs, ys*2.5); glVertex2f(xs*2, ys*3.5); glVertex2f(xs*3, ys*2.5); | |
488 | break; | |
489 | } | |
490 | case 6: | |
491 | { | |
492 | // down | |
493 | glVertex2f(xs, ys*1.5); glVertex2f(xs*2, ys*0.5); glVertex2f(xs*3, ys*1.5); | |
494 | break; | |
495 | } | |
496 | ||
497 | default: | |
498 | break; | |
499 | } | |
500 | glEnd(); | |
501 | glLoadName(0); | |
502 | } | |
503 | ||
504 | //______________________________________________________________________________ | |
505 | void AliEveITSModuleStepper::RenderPalette(Float_t dx, Float_t x, Float_t y) | |
506 | { | |
507 | // Render color palette with number axis. | |
508 | ||
509 | glPushMatrix(); | |
510 | glLoadIdentity(); | |
511 | glTranslatef(1 -x- dx, -1+y*4, 0); | |
512 | AliEveITSModule* qs = dynamic_cast<AliEveITSModule*>(*BeginChildren()); | |
513 | TEveRGBAPalette* p = qs->GetPalette(); | |
514 | glBegin(GL_QUAD_STRIP); | |
515 | glColor4ubv(p->ColorFromValue(p->GetMinVal())); | |
516 | glVertex2f(0, 0); | |
517 | glVertex2f(0, y); | |
518 | if (p->GetMaxVal() > p->GetMinVal() + 1) | |
519 | { | |
520 | Float_t xs = dx/(p->GetMaxVal() - p->GetMinVal()); | |
521 | Float_t x0 = xs; | |
522 | for(Int_t i=p->GetMinVal() + 1; i<p->GetMaxVal(); i++) | |
523 | { | |
524 | glColor4ubv(p->ColorFromValue(i)); | |
525 | glVertex2f(x0, 0); | |
526 | glVertex2f(x0, y); | |
527 | x0+=xs; | |
528 | } | |
529 | } | |
530 | glColor4ubv(p->ColorFromValue(p->GetMaxVal())); | |
531 | glVertex2f(dx, 0); | |
532 | glVertex2f(dx, y); | |
533 | glEnd(); | |
534 | ||
535 | if (p->GetMaxVal() > p->GetMinVal()) | |
536 | { | |
537 | glRotatef(-90,1, 0, 0 ); | |
538 | Double_t v1[3] = {0., 0., 0.}; | |
539 | Double_t v2[3] = {dx, 0, 0.}; | |
540 | fAxis->SetLabelsSize(fTextSize/dx); | |
541 | fAxis->PaintGLAxis(v1, v2, p->GetMinVal(), p->GetMaxVal(), 206); | |
542 | } | |
543 | glPopMatrix(); | |
544 | } | |
545 | ||
546 | //______________________________________________________________________________ | |
547 | void AliEveITSModuleStepper::RenderMenu() | |
548 | { | |
549 | // Render menu: page control, scale control, detector type buttons. | |
550 | ||
551 | Float_t ww = 2*fWWidth; | |
552 | Float_t wh = 2*fWHeight; | |
553 | ||
554 | // transparent bar | |
555 | Float_t a=0.3; | |
556 | glColor4f(a, a, a, a); | |
557 | Float_t H = 1.9*wh*(1+ 2*fWOff); | |
558 | if(1) { | |
559 | glBegin(GL_QUADS); | |
560 | glVertex3f(-1, -1, 0.1); glVertex3f(-1, -1+H, 0.1); | |
561 | glVertex3f(1 , -1+H, 0.1); glVertex3f( 1, -1 , 0.1); | |
562 | glEnd(); | |
563 | } | |
564 | ||
565 | Float_t y_base = -1 + wh*0.35; | |
566 | glTranslatef(-1, y_base, 0.); | |
567 | glPushName(0); | |
568 | // pager | |
569 | glPushMatrix(); | |
570 | glTranslatef(ww, 0, 0.); | |
571 | fText->SetTextSize(fTextSize); | |
572 | Float_t soff = ww*1.3; | |
573 | glTranslatef(0, fWOff*wh, 0); | |
574 | RenderSymbol(ww, wh, 2); | |
575 | RenderFrame(ww,wh,2); | |
576 | glTranslatef(soff, 0, 0); | |
577 | RenderSymbol(ww, wh, 1); | |
578 | RenderFrame(ww,wh,1); | |
579 | glTranslatef(soff, 0, 0); | |
580 | // text info | |
581 | { | |
582 | const char* txt = Form("%d/%d ", GetCurrentPage(), GetPages()); | |
583 | Float_t dx = (fPagerGap - TextLength(txt))*0.5; | |
584 | fText->SetTextColor(fFontCol); | |
585 | fText->PaintGLText(dx, wh*0.25, -0.8, txt); | |
586 | } | |
587 | glTranslatef(fPagerGap, 0, 0); | |
588 | ||
589 | RenderSymbol(ww, wh, 3); | |
590 | RenderFrame(ww,wh,3); | |
591 | glTranslatef(soff, 0, 0); | |
592 | RenderSymbol(ww, wh, 4); | |
593 | RenderFrame(ww,wh,4); | |
594 | glTranslatef(2*ww, 0, 0); | |
595 | glPopMatrix(); | |
596 | ||
597 | // scale info | |
598 | glPushMatrix(); | |
599 | AliEveITSDigitsInfo* di = fDigitsInfo; | |
600 | Int_t scale = fScaleInfo->GetScale() - 1; | |
601 | AliEveITSScaledModule* sm = dynamic_cast<AliEveITSScaledModule*>(*BeginChildren()); | |
602 | Int_t cnx = 0, cnz = 0; | |
603 | switch(sm->GetSubDetID()) | |
604 | { | |
605 | case 0: | |
606 | cnx = di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale]; | |
607 | break; | |
608 | case 1: | |
609 | cnx = di->fSDDScaleX[scale], cnz = di->fSDDScaleZ[scale]; | |
610 | break; | |
611 | case 2: | |
612 | cnx = di->fSSDScale[scale], cnz = 1; | |
613 | break; | |
614 | } | |
615 | glTranslatef(10*ww,0, 0); | |
616 | RenderString(Form("Zoom: ")); | |
617 | glPushMatrix(); | |
618 | glTranslatef(0, 0.2*wh, 0); | |
619 | RenderSymbol(ww, wh*0.9, 5); | |
620 | glTranslatef(0, 0.4*wh, 0); | |
621 | RenderFrame(ww, wh*0.5, 5); | |
622 | glPopMatrix(); | |
623 | RenderSymbol(ww, wh*0.9, 6); | |
624 | RenderFrame(ww, wh*0.5, 6); | |
625 | glTranslatef(ww, 0, 0); | |
626 | RenderString(Form("%dx%d ", cnx, cnz)); | |
627 | glPopMatrix(); | |
628 | ||
629 | //choose detector | |
630 | glPushMatrix(); | |
631 | glTranslatef(18*ww, 0, 0); | |
632 | Float_t bs = ww*0.2; | |
633 | RenderString("SPD", 8); | |
634 | glTranslatef(bs, 0, 0); | |
635 | RenderString("SDD", 9); | |
636 | glTranslatef(bs, 0, 0); | |
637 | RenderString("SSD", 10); | |
638 | glPopMatrix(); | |
639 | ||
640 | glPopName(); | |
641 | } | |
642 | ||
643 | //______________________________________________________________________________ | |
644 | void AliEveITSModuleStepper::RenderCellIDs() | |
645 | { | |
646 | // Render module-ids under their cells. | |
647 | ||
648 | fText->SetTextSize(fStepper->GetDy()*0.1); | |
649 | fText->SetTextColor(fFontCol); | |
650 | Double_t x, y, z; | |
651 | Double_t sx, sy, sz; | |
652 | UInt_t idx = fPosition; | |
653 | for (List_i childit=fChildren.begin(); childit!=fChildren.end(); ++childit) | |
654 | { | |
655 | if(idx < fIDs.size()) | |
656 | { | |
657 | AliEveITSScaledModule* mod = dynamic_cast<AliEveITSScaledModule*>(*childit); | |
658 | TEveTrans& tr = mod->RefHMTrans(); | |
659 | TString name = Form("%d",mod->GetID()); | |
660 | tr.GetPos(x,y,z); | |
661 | x += fStepper->GetDx()*0.5; | |
662 | y -= fStepper->GetDy()*0.5; | |
663 | z += 0.4; // !!! MT hack - cross check with overlay rendering. | |
664 | Float_t llx, lly, llz, urx, ury, urz; | |
665 | fText->BBox(name, llx, lly, llz, urx, ury, urz); | |
666 | tr.GetScale(sx, sy, sz); | |
667 | fText->PaintGLText(x-(urx-llx)*sx, y, z, name); | |
668 | idx++; | |
669 | } | |
670 | } | |
671 | } | |
672 | ||
673 | ||
674 | /******************************************************************************/ | |
675 | // Virtual event handlers from TGLOverlayElement | |
676 | /******************************************************************************/ | |
677 | ||
678 | //______________________________________________________________________________ | |
679 | Bool_t AliEveITSModuleStepper::Handle(TGLRnrCtx & /*rnrCtx*/, | |
680 | TGLOvlSelectRecord & rec, | |
681 | Event_t * event) | |
682 | { | |
683 | // Handle overlay event. | |
684 | // Return TRUE if event was handled. | |
685 | ||
686 | switch (event->fType) | |
687 | { | |
688 | case kMotionNotify: | |
689 | { | |
690 | Int_t item = rec.GetN() < 2 ? -1 : (Int_t)rec.GetItem(1); | |
691 | if (fWActive != item) { | |
692 | fWActive = item; | |
693 | return kTRUE; | |
694 | } else { | |
695 | return kFALSE; | |
696 | } | |
697 | break; | |
698 | } | |
699 | case kButtonPress: | |
700 | { | |
701 | if (event->fCode != kButton1) { | |
702 | return kFALSE; | |
703 | } | |
704 | switch (rec.GetItem(1)) | |
705 | { | |
706 | case 1: | |
707 | Previous(); | |
708 | break; | |
709 | case 2: | |
710 | Start(); | |
711 | break; | |
712 | case 3: | |
713 | Next(); | |
714 | break; | |
715 | case 4: | |
716 | End(); | |
717 | break; | |
718 | case 5: | |
719 | { | |
720 | AliEveDigitScaleInfo* si = fScaleInfo; | |
721 | if(si->GetScale() < 5) | |
722 | { | |
723 | si->ScaleChanged(si->GetScale() + 1); | |
724 | ElementChanged(kTRUE, kTRUE); | |
725 | } | |
726 | break; | |
727 | } | |
728 | case 6: | |
729 | { | |
730 | AliEveDigitScaleInfo* si = fScaleInfo; | |
731 | if(si->GetScale() > 1) | |
732 | { | |
733 | si->ScaleChanged(si->GetScale() - 1); | |
734 | ElementChanged(kTRUE, kTRUE); | |
735 | } | |
736 | break; | |
737 | } | |
738 | case 7: | |
739 | gEve->GetEditor()->DisplayElement(*BeginChildren()); | |
740 | break; | |
741 | ||
742 | case 8: | |
743 | DisplayDet(0, -1); | |
744 | break; | |
745 | case 9: | |
746 | DisplayDet(1, -1); | |
747 | break; | |
748 | case 10: | |
749 | DisplayDet(2, -1); | |
750 | break; | |
751 | default: | |
752 | break; | |
753 | } | |
754 | return kTRUE; | |
755 | break; | |
756 | } | |
757 | default: | |
758 | break; | |
759 | } // end switch | |
760 | return kFALSE; | |
761 | } | |
762 | ||
763 | //______________________________________________________________________________ | |
764 | Bool_t AliEveITSModuleStepper::MouseEnter(TGLOvlSelectRecord& /*rec*/) | |
765 | { | |
766 | // Mouse has entered overlay area. | |
767 | ||
768 | return kTRUE; | |
769 | } | |
770 | ||
771 | //______________________________________________________________________________ | |
772 | void AliEveITSModuleStepper::MouseLeave() | |
773 | { | |
774 | // Mouse has left overlay area. | |
775 | ||
776 | fWActive = -1; | |
777 | } |