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