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