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