]>
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 | //______________________________________________________________________________ |
82b3616d | 37 | // |
698e2c9b | 38 | // Display scaled ITS modules in a paged layout, also providing |
39 | // GL-overaly control GUI. | |
40 | ||
82b3616d | 41 | |
d810d0de | 42 | ClassImp(AliEveITSModuleStepper) |
82b3616d | 43 | |
d810d0de | 44 | AliEveITSModuleStepper::AliEveITSModuleStepper(AliEveITSDigitsInfo* di) : |
45 | TEveElementList("ITS 2DStore", "AliEveITSModuleStepper", kTRUE), | |
32e219c2 | 46 | |
c76ea574 | 47 | fIDs(), |
51346b82 | 48 | fPosition(0), |
49 | ||
32e219c2 | 50 | fDigitsInfo(di), |
51 | fScaleInfo(0), | |
52 | ||
53 | fSubDet(-1), | |
09edeb17 | 54 | |
32e219c2 | 55 | fStepper(0), |
56 | fAxis(0), | |
57 | fText(0), | |
58 | fTextSize(0.05), | |
59 | fPagerGap(0.1), | |
60 | fRnrFrame(kFALSE), | |
09edeb17 | 61 | |
32e219c2 | 62 | fExpandCell(0.85), |
63 | fModuleFrameCol(2), | |
09edeb17 | 64 | |
32e219c2 | 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) | |
82b3616d | 75 | { |
698e2c9b | 76 | // Constructor. |
77 | ||
84aff7a4 | 78 | // override member from base TEveElementList |
d810d0de | 79 | fChildClass = AliEveITSScaledModule::Class(); |
32e219c2 | 80 | |
81 | SetMainColorPtr(&fWCol); | |
82 | ||
83 | fDigitsInfo->IncRefCount(); | |
84 | ||
84aff7a4 | 85 | fStepper = new TEveGridStepper(); |
32e219c2 | 86 | fStepper->SetNs(5, 4); |
87 | ||
d810d0de | 88 | fScaleInfo = new AliEveDigitScaleInfo(); |
32e219c2 | 89 | fScaleInfo->IncRefCount(); |
64c42545 | 90 | |
32e219c2 | 91 | fAxis = new TGLAxis(); |
92 | fAxis->SetLineColor(4); | |
93 | fAxis->SetTextColor(fFontCol); | |
09edeb17 | 94 | |
32e219c2 | 95 | fText = new TGLText(); |
96 | fText->SetTextColor(fFontCol); | |
97 | fText->SetGLTextFont(40); | |
98 | fText->SetGLTextAngles(0, 0, 0); | |
99 | fText->SetTextSize(fTextSize); | |
100 | ||
84aff7a4 | 101 | gEve->GetGLViewer()->AddOverlayElement(this); |
82b3616d | 102 | } |
103 | ||
d810d0de | 104 | AliEveITSModuleStepper::~AliEveITSModuleStepper() |
82b3616d | 105 | { |
698e2c9b | 106 | // Destructor. |
107 | ||
84aff7a4 | 108 | gEve->GetGLViewer()->RemoveOverlayElement(this); |
32e219c2 | 109 | |
110 | fScaleInfo->DecRefCount(); | |
111 | fDigitsInfo->DecRefCount(); | |
112 | ||
82b3616d | 113 | delete fStepper; |
32e219c2 | 114 | |
115 | delete fAxis; | |
116 | delete fText; | |
82b3616d | 117 | } |
118 | ||
57ffa5fb | 119 | /******************************************************************************/ |
d7e36bcf | 120 | |
d810d0de | 121 | void AliEveITSModuleStepper::Capacity() |
82b3616d | 122 | { |
698e2c9b | 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 | ||
84aff7a4 | 127 | Int_t N = fStepper->GetNx()*fStepper->GetNy(); |
128 | if (N != GetNChildren()) | |
82b3616d | 129 | { |
32e219c2 | 130 | DestroyElements(); |
51346b82 | 131 | for (Int_t m=0; m<N; m++) |
32e219c2 | 132 | { |
d810d0de | 133 | AddElement(new AliEveITSScaledModule(m, fDigitsInfo, fScaleInfo)); |
32e219c2 | 134 | } |
82b3616d | 135 | } |
82b3616d | 136 | } |
137 | ||
57ffa5fb | 138 | /******************************************************************************/ |
d7e36bcf | 139 | |
d810d0de | 140 | void AliEveITSModuleStepper::SetFirst(Int_t first) |
09edeb17 | 141 | { |
142 | Int_t lastpage = fIDs.size()/Nxy(); | |
51346b82 | 143 | if(fIDs.size() % Nxy() ) lastpage++; |
144 | ||
698e2c9b | 145 | Int_t firstLastpage = (lastpage - 1)*Nxy(); |
146 | if(first > firstLastpage) first = firstLastpage; | |
09edeb17 | 147 | if(first < 0) first = 0; |
148 | fPosition = first; | |
09edeb17 | 149 | Apply(); |
150 | } | |
151 | ||
d810d0de | 152 | void AliEveITSModuleStepper::Start() |
82b3616d | 153 | { |
698e2c9b | 154 | // Go to first page. |
155 | ||
09edeb17 | 156 | fPosition = 0; |
82b3616d | 157 | Apply(); |
158 | } | |
159 | ||
d810d0de | 160 | void AliEveITSModuleStepper::Next() |
82b3616d | 161 | { |
698e2c9b | 162 | // Go to next page. |
163 | ||
32e219c2 | 164 | SetFirst(fPosition + Nxy()); |
09edeb17 | 165 | } |
166 | ||
d810d0de | 167 | void AliEveITSModuleStepper::Previous() |
09edeb17 | 168 | { |
698e2c9b | 169 | // Go to previous page. |
170 | ||
32e219c2 | 171 | SetFirst(fPosition - Nxy()); |
09edeb17 | 172 | } |
173 | ||
d810d0de | 174 | void AliEveITSModuleStepper::End() |
51346b82 | 175 | { |
698e2c9b | 176 | // Go to last page. |
177 | ||
09edeb17 | 178 | Int_t lastpage = fIDs.size()/Nxy(); |
698e2c9b | 179 | if (fIDs.size() % Nxy()) lastpage++; |
180 | fPosition = (lastpage - 1)*Nxy(); | |
09edeb17 | 181 | |
51346b82 | 182 | fStepper->Reset(); |
82b3616d | 183 | Apply(); |
184 | } | |
185 | ||
57ffa5fb | 186 | /******************************************************************************/ |
d7e36bcf | 187 | |
d810d0de | 188 | void AliEveITSModuleStepper::DisplayDet(Int_t det, Int_t layer) |
32e219c2 | 189 | { |
698e2c9b | 190 | // Select modules to display by sub-det type / layer. |
191 | ||
32e219c2 | 192 | fSubDet = det; |
193 | fIDs.clear(); | |
d810d0de | 194 | AliEveITSModuleSelection sel = AliEveITSModuleSelection(); |
51346b82 | 195 | sel.SetType (det); |
196 | sel.SetLayer(layer); | |
32e219c2 | 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 | ||
57ffa5fb | 203 | /******************************************************************************/ |
32e219c2 | 204 | |
d810d0de | 205 | void AliEveITSModuleStepper::DisplayTheta(Float_t min, Float_t max) |
32e219c2 | 206 | { |
698e2c9b | 207 | // Select modules to display by theta range. |
208 | ||
32e219c2 | 209 | fIDs.clear(); |
d810d0de | 210 | AliEveITSModuleSelection sel = AliEveITSModuleSelection(); |
51346b82 | 211 | sel.SetThetaRange(min, max); |
32e219c2 | 212 | fDigitsInfo->GetModuleIDs(&sel, fIDs); |
213 | Start(); | |
214 | } | |
215 | ||
57ffa5fb | 216 | /******************************************************************************/ |
32e219c2 | 217 | |
d810d0de | 218 | Int_t AliEveITSModuleStepper::GetCurrentPage() |
32e219c2 | 219 | { |
698e2c9b | 220 | // Get number of current page. |
221 | ||
222 | Int_t idx = fPosition + 1; | |
223 | Int_t n = idx/Nxy(); | |
224 | if (idx % Nxy()) n++; | |
32e219c2 | 225 | return n; |
226 | } | |
227 | ||
57ffa5fb | 228 | /******************************************************************************/ |
32e219c2 | 229 | |
d810d0de | 230 | Int_t AliEveITSModuleStepper::GetPages() |
32e219c2 | 231 | { |
698e2c9b | 232 | // Get number of all pages. |
233 | ||
51346b82 | 234 | Int_t n = fIDs.size()/Nxy(); |
235 | if(fIDs.size() % Nxy()) n++; | |
32e219c2 | 236 | return n; |
237 | } | |
51346b82 | 238 | |
57ffa5fb | 239 | /******************************************************************************/ |
32e219c2 | 240 | |
d810d0de | 241 | void AliEveITSModuleStepper::Apply() |
82b3616d | 242 | { |
698e2c9b | 243 | // Apply current settings to children modules. |
244 | ||
d810d0de | 245 | // printf("AliEveITSModuleStepper::Apply fPosition %d \n", fPosition); |
84aff7a4 | 246 | gEve->DisableRedraw(); |
32e219c2 | 247 | Capacity(); |
09edeb17 | 248 | |
249 | UInt_t idx = fPosition; | |
32e219c2 | 250 | for(List_i childit=fChildren.begin(); childit!=fChildren.end(); ++childit) |
82b3616d | 251 | { |
51346b82 | 252 | if(idx < fIDs.size()) |
82b3616d | 253 | { |
d810d0de | 254 | AliEveITSScaledModule* mod = dynamic_cast<AliEveITSScaledModule*>(*childit); |
51346b82 | 255 | mod->SetID(fIDs[idx], kFALSE); |
84aff7a4 | 256 | TEveTrans& tr = mod->RefHMTrans(); |
32e219c2 | 257 | tr.UnitTrans(); |
258 | tr.RotateLF(3,2,TMath::PiOver2()); | |
51346b82 | 259 | tr.RotateLF(1,3,TMath::PiOver2()); |
82b3616d | 260 | |
51346b82 | 261 | // scaling |
32e219c2 | 262 | Float_t mz, mx; |
d7e36bcf | 263 | Float_t* fp = mod->GetFrame()->GetFramePoints(); |
264 | // switch x,z it will be rotated afterwards | |
32e219c2 | 265 | mx = -2*fp[0]; |
266 | mz = -2*fp[2]; | |
d7e36bcf | 267 | |
32e219c2 | 268 | // fit width first |
84aff7a4 | 269 | Double_t sx = fStepper->GetDx(); |
270 | Double_t sy = (mx*fStepper->GetDx())/mz; | |
271 | if(sy > fStepper->GetDy()) | |
82b3616d | 272 | { |
32e219c2 | 273 | // printf("fit width \n"); |
84aff7a4 | 274 | sy = fStepper->GetDy(); |
275 | sx = (mz*fStepper->GetDx())/mx; | |
82b3616d | 276 | } |
32e219c2 | 277 | Float_t scale = (fExpandCell*sx)/mz; |
278 | tr.Scale(scale, scale, scale); | |
64c42545 | 279 | |
32e219c2 | 280 | Float_t p[3]; |
281 | fStepper->GetPosition(p); | |
84aff7a4 | 282 | tr.SetPos(p[0]+0.5*fStepper->GetDx(), p[1]+0.5*fStepper->GetDy(), p[2]+0.5*fStepper->GetDz()); |
51346b82 | 283 | |
d7e36bcf | 284 | if(mod->GetSubDetID() == 2) |
b3ffcccb | 285 | mod->SetName(Form("SSD %d", idx)); |
d7e36bcf | 286 | else if(mod->GetSubDetID() == 1) |
b3ffcccb | 287 | mod->SetName(Form("SDD %d", idx)); |
d7e36bcf | 288 | else |
b3ffcccb | 289 | mod->SetName(Form("SPD %d", idx)); |
32e219c2 | 290 | mod->SetRnrSelf(kTRUE); |
d7e36bcf | 291 | mod->UpdateItems(); |
292 | ||
09edeb17 | 293 | fStepper->Step(); |
294 | idx++; | |
82b3616d | 295 | } |
296 | else { | |
297 | (*childit)->SetRnrSelf(kFALSE); | |
298 | } | |
299 | } | |
09edeb17 | 300 | |
32e219c2 | 301 | fStepper->Reset(); |
302 | ElementChanged(); | |
84aff7a4 | 303 | gEve->EnableRedraw(); |
82b3616d | 304 | } |
09edeb17 | 305 | |
57ffa5fb | 306 | /******************************************************************************/ |
09edeb17 | 307 | |
d810d0de | 308 | void AliEveITSModuleStepper::Render(TGLRnrCtx& rnrCtx) |
09edeb17 | 309 | { |
698e2c9b | 310 | // Render the overlay elements. |
311 | ||
32e219c2 | 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 | } | |
51346b82 | 325 | |
32e219c2 | 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); | |
51346b82 | 338 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
32e219c2 | 339 | RenderMenu(); |
340 | RenderPalette(fPaletteLength, 1.6*fWWidth, fWHeight*0.6); | |
341 | glPopMatrix(); | |
342 | glPopAttrib(); | |
51346b82 | 343 | |
32e219c2 | 344 | if (lightp) glEnable(GL_LIGHTING); |
345 | ||
346 | glMatrixMode(GL_PROJECTION); | |
347 | glPopMatrix(); | |
348 | ||
349 | glMatrixMode(GL_MODELVIEW); | |
350 | RenderCellIDs(); | |
09edeb17 | 351 | } |
352 | ||
32e219c2 | 353 | |
57ffa5fb | 354 | /******************************************************************************/ |
32e219c2 | 355 | // Protected sub-renderers |
57ffa5fb | 356 | /******************************************************************************/ |
09edeb17 | 357 | |
57ffa5fb | 358 | //______________________________________________________________________________ |
d810d0de | 359 | Float_t AliEveITSModuleStepper::TextLength(const char* txt) |
09edeb17 | 360 | { |
698e2c9b | 361 | // Calculate length of text txt. |
362 | ||
32e219c2 | 363 | Float_t llx, lly, llz, urx, ury, urz; |
364 | fText->BBox(txt, llx, lly, llz, urx, ury, urz); | |
365 | return (urx-llx)*fTextSize; | |
09edeb17 | 366 | } |
367 | ||
57ffa5fb | 368 | //______________________________________________________________________________ |
d810d0de | 369 | void AliEveITSModuleStepper::RenderString(TString string, Int_t id) |
09edeb17 | 370 | { |
698e2c9b | 371 | // Render text for button id. |
372 | ||
32e219c2 | 373 | Float_t txtY = fWHeight*0.5; |
374 | Float_t txtl = TextLength(string.Data()); | |
09edeb17 | 375 | |
32e219c2 | 376 | if(id > 0) glLoadName(id); |
377 | if(id>0 && fWActive == id) | |
378 | fText->SetTextColor(fWActiveCol); | |
51346b82 | 379 | else |
32e219c2 | 380 | fText->SetTextColor(fFontCol); |
09edeb17 | 381 | |
51346b82 | 382 | |
32e219c2 | 383 | if(id>0) |
51346b82 | 384 | { |
385 | if(fWActive == id) | |
32e219c2 | 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 | } | |
51346b82 | 398 | else |
32e219c2 | 399 | { |
400 | fText->SetTextColor(fFontCol); | |
401 | fText->PaintGLText(0, txtY, -0.8, string.Data()); | |
402 | glTranslatef(txtl, 0, 0); | |
403 | } | |
404 | } | |
09edeb17 | 405 | |
57ffa5fb | 406 | //______________________________________________________________________________ |
d810d0de | 407 | void AliEveITSModuleStepper::RenderFrame(Float_t dx, Float_t dy, Int_t id) |
32e219c2 | 408 | { |
698e2c9b | 409 | // Render frame for button id, taking into account if it is currently |
410 | // below mouse. | |
411 | ||
412 | if (fRnrFrame == kFALSE)return; | |
32e219c2 | 413 | |
414 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
415 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |
416 | UChar_t color[4]; | |
84aff7a4 | 417 | if (fWActive == id) |
d810d0de | 418 | TEveUtil::TEveUtil::ColorFromIdx(fWActiveCol, color); |
51346b82 | 419 | else |
d810d0de | 420 | TEveUtil:: TEveUtil::ColorFromIdx(fWCol, color); |
32e219c2 | 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(); | |
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 | ||
438 | UChar_t color[4]; | |
84aff7a4 | 439 | if (fWActive == id) |
d810d0de | 440 | TEveUtil::TEveUtil::ColorFromIdx(fWActiveCol, color); |
51346b82 | 441 | else |
d810d0de | 442 | TEveUtil::TEveUtil::ColorFromIdx(fWCol, color); |
32e219c2 | 443 | glColor4ubv(color); |
444 | ||
445 | Float_t xs = dx/4, ys = dy/4; | |
446 | if(id == 0) { | |
447 | glBegin(GL_QUADS); | |
51346b82 | 448 | glVertex2f(0,ys); glVertex2f(0, ys*3); |
32e219c2 | 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 | } | |
51346b82 | 496 | |
32e219c2 | 497 | default: |
498 | break; | |
499 | } | |
500 | glEnd(); | |
501 | glLoadName(0); | |
502 | } | |
09edeb17 | 503 | |
57ffa5fb | 504 | //______________________________________________________________________________ |
d810d0de | 505 | void AliEveITSModuleStepper::RenderPalette(Float_t dx, Float_t x, Float_t y) |
09edeb17 | 506 | { |
698e2c9b | 507 | // Render color palette with number axis. |
508 | ||
32e219c2 | 509 | glPushMatrix(); |
510 | glLoadIdentity(); | |
511 | glTranslatef(1 -x- dx, -1+y*4, 0); | |
d810d0de | 512 | AliEveITSModule* qs = dynamic_cast<AliEveITSModule*>(*BeginChildren()); |
84aff7a4 | 513 | TEveRGBAPalette* p = qs->GetPalette(); |
32e219c2 | 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; | |
51346b82 | 522 | for(Int_t i=p->GetMinVal() + 1; i<p->GetMaxVal(); i++) |
32e219c2 | 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(); | |
09edeb17 | 534 | |
32e219c2 | 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); | |
09edeb17 | 542 | } |
32e219c2 | 543 | glPopMatrix(); |
09edeb17 | 544 | } |
545 | ||
57ffa5fb | 546 | //______________________________________________________________________________ |
d810d0de | 547 | void AliEveITSModuleStepper::RenderMenu() |
32e219c2 | 548 | { |
698e2c9b | 549 | // Render menu: page control, scale control, detector type buttons. |
550 | ||
32e219c2 | 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); | |
51346b82 | 560 | glVertex3f(-1, -1, 0.1); glVertex3f(-1, -1+H, 0.1); |
32e219c2 | 561 | glVertex3f(1 , -1+H, 0.1); glVertex3f( 1, -1 , 0.1); |
562 | glEnd(); | |
563 | } | |
09edeb17 | 564 | |
32e219c2 | 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 | |
51346b82 | 581 | { |
32e219c2 | 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); | |
51346b82 | 595 | glPopMatrix(); |
32e219c2 | 596 | |
597 | // scale info | |
598 | glPushMatrix(); | |
d810d0de | 599 | AliEveITSDigitsInfo* di = fDigitsInfo; |
32e219c2 | 600 | Int_t scale = fScaleInfo->GetScale() - 1; |
d810d0de | 601 | AliEveITSScaledModule* sm = dynamic_cast<AliEveITSScaledModule*>(*BeginChildren()); |
32e219c2 | 602 | Int_t cnx = 0, cnz = 0; |
603 | switch(sm->GetSubDetID()) | |
604 | { | |
51346b82 | 605 | case 0: |
32e219c2 | 606 | cnx = di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale]; |
607 | break; | |
51346b82 | 608 | case 1: |
32e219c2 | 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; | |
51346b82 | 633 | RenderString("SPD", 8); |
32e219c2 | 634 | glTranslatef(bs, 0, 0); |
51346b82 | 635 | RenderString("SDD", 9); |
32e219c2 | 636 | glTranslatef(bs, 0, 0); |
637 | RenderString("SSD", 10); | |
638 | glPopMatrix(); | |
639 | ||
640 | glPopName(); | |
641 | } | |
09edeb17 | 642 | |
57ffa5fb | 643 | //______________________________________________________________________________ |
d810d0de | 644 | void AliEveITSModuleStepper::RenderCellIDs() |
09edeb17 | 645 | { |
698e2c9b | 646 | // Render module-ids under their cells. |
647 | ||
84aff7a4 | 648 | fText->SetTextSize(fStepper->GetDy()*0.1); |
32e219c2 | 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 | { | |
51346b82 | 655 | if(idx < fIDs.size()) |
656 | { | |
d810d0de | 657 | AliEveITSScaledModule* mod = dynamic_cast<AliEveITSScaledModule*>(*childit); |
84aff7a4 | 658 | TEveTrans& tr = mod->RefHMTrans(); |
32e219c2 | 659 | TString name = Form("%d",mod->GetID()); |
660 | tr.GetPos(x,y,z); | |
84aff7a4 | 661 | x += fStepper->GetDx()*0.5; |
662 | y -= fStepper->GetDy()*0.5; | |
32e219c2 | 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 | } | |
09edeb17 | 671 | } |
32e219c2 | 672 | |
673 | ||
57ffa5fb | 674 | /******************************************************************************/ |
32e219c2 | 675 | // Virtual event handlers from TGLOverlayElement |
57ffa5fb | 676 | /******************************************************************************/ |
09edeb17 | 677 | |
57ffa5fb | 678 | //______________________________________________________________________________ |
d810d0de | 679 | Bool_t AliEveITSModuleStepper::Handle(TGLRnrCtx & /*rnrCtx*/, |
698e2c9b | 680 | TGLOvlSelectRecord & rec, |
681 | Event_t * event) | |
09edeb17 | 682 | { |
32e219c2 | 683 | // Handle overlay event. |
684 | // Return TRUE if event was handled. | |
685 | ||
686 | switch (event->fType) | |
51346b82 | 687 | { |
32e219c2 | 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 | { | |
d810d0de | 720 | AliEveDigitScaleInfo* si = fScaleInfo; |
51346b82 | 721 | if(si->GetScale() < 5) |
32e219c2 | 722 | { |
51346b82 | 723 | si->ScaleChanged(si->GetScale() + 1); |
32e219c2 | 724 | ElementChanged(kTRUE, kTRUE); |
725 | } | |
726 | break; | |
727 | } | |
728 | case 6: | |
729 | { | |
d810d0de | 730 | AliEveDigitScaleInfo* si = fScaleInfo; |
51346b82 | 731 | if(si->GetScale() > 1) |
32e219c2 | 732 | { |
51346b82 | 733 | si->ScaleChanged(si->GetScale() - 1); |
32e219c2 | 734 | ElementChanged(kTRUE, kTRUE); |
735 | } | |
736 | break; | |
737 | } | |
738 | case 7: | |
84aff7a4 | 739 | gEve->GetEditor()->DisplayElement(*BeginChildren()); |
32e219c2 | 740 | break; |
741 | ||
742 | case 8: | |
743 | DisplayDet(0, -1); | |
744 | break; | |
51346b82 | 745 | case 9: |
32e219c2 | 746 | DisplayDet(1, -1); |
747 | break; | |
51346b82 | 748 | case 10: |
32e219c2 | 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; | |
09edeb17 | 761 | } |
32e219c2 | 762 | |
57ffa5fb | 763 | //______________________________________________________________________________ |
d810d0de | 764 | Bool_t AliEveITSModuleStepper::MouseEnter(TGLOvlSelectRecord& /*rec*/) |
32e219c2 | 765 | { |
698e2c9b | 766 | // Mouse has entered overlay area. |
767 | ||
32e219c2 | 768 | return kTRUE; |
769 | } | |
770 | ||
57ffa5fb | 771 | //______________________________________________________________________________ |
d810d0de | 772 | void AliEveITSModuleStepper::MouseLeave() |
32e219c2 | 773 | { |
698e2c9b | 774 | // Mouse has left overlay area. |
32e219c2 | 775 | |
776 | fWActive = -1; | |
51346b82 | 777 | } |