]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliDisplay.cxx
Removal of useless dependencies via forward declarations
[u/mrichter/AliRoot.git] / STEER / AliDisplay.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
94de3818 18Revision 1.9 2000/07/13 16:19:09 fca
19Mainly coding conventions + some small bug fixes
20
ef42d733 21Revision 1.8 2000/07/11 18:24:59 fca
22Coding convention corrections + few minor bug fixes
23
aee8290b 24Revision 1.7 1999/11/10 07:37:06 fca
25Pads do not inherit editability from canvas any more
26
38b32e9f 27Revision 1.6 1999/11/09 07:38:52 fca
28Changes for compatibility with version 2.23 of ROOT
29
084c1b4a 30Revision 1.5 1999/09/29 09:24:29 fca
31Introduction of the Copyright and cvs Log
32
4c039060 33*/
34
fe4da5cc 35
36//////////////////////////////////////////////////////////////////////////
37// //
38// AliDisplay //
39// //
40// Utility class to display ALICE outline, tracks, hits,.. //
41// //
42//////////////////////////////////////////////////////////////////////////
43
44#include <TROOT.h>
45#include <TTree.h>
46#include <TButton.h>
47#include <TCanvas.h>
48#include <TView.h>
49#include <TText.h>
50#include <TPolyMarker3D.h>
51#include <TPaveLabel.h>
52#include <TPaveText.h>
53#include <TList.h>
54#include <TDiamond.h>
55#include <TNode.h>
56#include <TArc.h>
57#include <TTUBE.h>
58#include <TSlider.h>
59#include <TSliderBox.h>
60#include <TGaxis.h>
084c1b4a 61#include <TVirtualX.h>
fe4da5cc 62#include <TMath.h>
63#include <X3DBuffer.h>
64
65#include "AliRun.h"
66#include "AliDetector.h"
67#include "AliDisplay.h"
68#include "AliPoints.h"
1578254f 69#include "TParticle.h"
94de3818 70#include "AliGeometry.h"
71#include "TGeometry.h"
fe4da5cc 72
aee8290b 73static const Float_t kptcutmax = 2;
74static const Float_t ketacutmax = 1.5;
fe4da5cc 75
76ClassImp(AliDisplay)
77
78
79//_____________________________________________________________________________
80AliDisplay::AliDisplay()
81{
aee8290b 82 //
83 // Default constructor
84 //
85 fCanvas = 0;
fe4da5cc 86}
87
88//_____________________________________________________________________________
89AliDisplay::AliDisplay(Int_t size)
90{
91// Create an event display object.
92// A canvas named "edisplay" is created with a vertical size in pixels
93//
94// A QUICK Overview of the Event Display functions
95// ===============================================
96//
97// The event display can ve invoked by executing the macro "display.C"
98// A canvas like in the picture below will appear.
99//
100// On the left side of the canvas, the following buttons appear:
101// *Next* to move to the next event
102// *Previous* to move to the previous event
103// *Top View* to display a top view of the current event
104// *Side View* to display a side view of the current event
105// *Front View* to display a front view of the current event
106// *All Views* to display front/side/top/30-30 views of the current event
107// *OpenGL* to use OpenGl to view the current event.
108// Note that OpenGL cannot be used across the network.
109// Before using OpenGL, load the GL libraries
110// by executing the macro GL.C (in $ROOTSYS/macros/GL.C.
111// Once in GL, click the HELP button of the GL canvas.
112// *X3D* to use X3D to view the current event (Unix only).
113// Once in X3D, type M to see the list of all possible options.
114// for example type J to zoom, K to unzoom
115// use the mouse to rotate.
116// *Pick* Select this option to be able to point on a track with the
117// mouse. Once on the track, use the right button to select
118// an action. For example, select SetMarkerAttributes to
119// change the marker type/color/size for the track.
120// *Zoom* Select this option (default) if you want to zoom.
121// To zoom, simply select the selected area with the left button.
122// *UnZoom* To revert to the previous picture size.
123//
124// slider R On the left side, the vertical slider can be used to
125// set the default picture size.
126// slider pcut At the top of the canvas, a slider can be used to change
127// the momentum cut (or range) to display tracks.
128// slider eta On the right side of the canvas, a vertical slider can be used
129// to specify a rapidity range for the tracks.
130//
131// When you are in Zoom mode, you can click on the black part of the canvas
132// to select special options with the right mouse button.
133// This will display a pop-up menu with items like:
134// *Disable detector*
135// *Enable detector*, etc.
136// For example select "Disable detector". You get a dialog box.
137// Diable detector TRD for example.
138//
139// When you are in pick mode, you can "Inspect" the object pointed by the mouse.
140// When you are on a track, select the menu item "InspectParticle"
141// to display the current particle attributes.
142//
143// You can activate the Root browser by selecting the Inspect menu
144// in the canvas tool bar menu. Then select "Start Browser"
145// This will open a new canvas with the browser. At this point, you may want
146// to display some histograms (from the Trees). Go to the "File" menu
147// of the browser and click on "New canvas".
148// In the browser, click on item "ROOT files" in the left pane.
149// Click on galice.root.
150// Click on TH
151// Click on TPC for example
152// Click on any variable (eg TPC.fX) to histogram the variable.
153//
154// If you are lost, you can click on HELP in any Root canvas or browser.
155//Begin_Html
156/*
1439f98e 157<img src="picts/alidisplay.gif">
fe4da5cc 158*/
159//End_Html
160
161 fPad = 0;
162 gAlice->SetDisplay(this);
163
164 // Initialize display default parameters
165 SetRange();
166 SetPTcut();
167
168 // Set front view by default
169 fTheta = 0;
170 fPhi = -90;
171 fPsi = 0;
172 fDrawAllViews = kFALSE;
173 fDrawHits = kTRUE;
174 fDrawParticles = kTRUE;
175 fZoomMode = 1;
176 fZooms = 0;
177 fHitsCuts = 0;
178
179 // Create display canvas
180 Int_t ysize = size;
181 if (ysize < 100) ysize = 750;
182 Int_t xsize = Int_t(size*830./ysize);
183 fCanvas = new TCanvas("Canvas", "ALICE Event Display",14,47,xsize,ysize);
fe4da5cc 184 fCanvas->ToggleEventStatus();
185
186 // Create main display pad
187 fPad = new TPad("viewpad", "Alice display",0.15,0,0.97,0.96);
188 fPad->Draw();
189 fPad->Modified();
190 fPad->SetFillColor(1);
191 fPad->SetBorderSize(2);
192
193 // Create user interface control pad
194 DisplayButtons();
195 fCanvas->cd();
196
197 // Create Range and mode pad
198 Float_t dxtr = 0.15;
199 Float_t dytr = 0.45;
200 fTrigPad = new TPad("trigger", "range and mode pad",0,0,dxtr,dytr);
38b32e9f 201 fTrigPad->SetEditable(kFALSE);
fe4da5cc 202 fTrigPad->Draw();
203 fTrigPad->cd();
204 fTrigPad->SetFillColor(22);
205 fTrigPad->SetBorderSize(2);
206 fRangeSlider = new TSlider("range","range",0.7,0.42,0.9,0.98);
207 fRangeSlider->SetObject(this);
208 char pickmode[] = "gAlice->Display()->SetPickMode()";
209 Float_t db = 0.09;
210 fPickButton = new TButton("Pick",pickmode,0.05,0.32,0.65,0.32+db);
211 fPickButton->SetFillColor(38);
212 fPickButton->Draw();
213 char zoommode[] = "gAlice->Display()->SetZoomMode()";
214 fZoomButton = new TButton("Zoom",zoommode,0.05,0.21,0.65,0.21+db);
215 fZoomButton->SetFillColor(38);
216 fZoomButton->Draw();
217 fArcButton = new TArc(.8,fZoomButton->GetYlowNDC()+0.5*db,0.33*db);
218 fArcButton->SetFillColor(kGreen);
219 fArcButton->Draw();
220 char butUnzoom[] = "gAlice->Display()->UnZoom()";
221 TButton *button = new TButton("UnZoom",butUnzoom,0.05,0.05,0.95,0.15);
222 button->SetFillColor(38);
223 button->Draw();
224 AppendPad(); // append display object as last object to force selection
225
226 // Create momentum cut slider pad
227 fCanvas->cd();
228 fCutPad = new TPad("cutSlider", "pcut slider pad",dxtr,.96,1,1);
229 fCutPad->Draw();
230 fCutPad->cd();
231 fCutPad->SetFillColor(22);
232 fCutPad->SetBorderSize(2);
233 fCutSlider = new TSlider("pcut","Momentum cut",0,0,1,1);
aee8290b 234 fCutSlider->SetRange(fPTcut/kptcutmax,1);
fe4da5cc 235 fCutSlider->SetObject(this);
236 fCutSlider->SetFillColor(45);
237 TSliderBox *sbox = (TSliderBox*)fCutSlider->GetListOfPrimitives()->First();
238 sbox->SetFillColor(46);
239 fCutSlider->cd();
aee8290b 240 TGaxis *cutaxis = new TGaxis(0.02,0.8,0.98,0.8,0,kptcutmax,510,"");
fe4da5cc 241 cutaxis->SetLabelSize(0.5);
242 cutaxis->SetTitleSize(0.6);
243 cutaxis->SetTitleOffset(0.5);
244 cutaxis->SetTitle("pcut . ");
245 fCutSlider->GetListOfPrimitives()->AddFirst(cutaxis);
246
247 // Create rapidity cut slider pad
248 fCanvas->cd();
249 fEtaPad = new TPad("EtaSlider", "Eta slider pad",0.97,0,1,0.96);
250 fEtaPad->Draw();
251 fEtaPad->cd();
252 fEtaPad->SetFillColor(22);
253 fEtaPad->SetBorderSize(2);
254 fEtaSlider = new TSlider("etacut","Rapidity cut",0,0,1,1);
255 fEtaSlider->SetObject(this);
256 fEtaSlider->SetFillColor(45);
257 TSliderBox *sbox2 = (TSliderBox*)fEtaSlider->GetListOfPrimitives()->First();
258 sbox2->SetFillColor(46);
259 fEtaSlider->cd();
aee8290b 260 TGaxis *etaaxis = new TGaxis(0.9,0.02,0.9,0.98,-ketacutmax,ketacutmax,510,"");
fe4da5cc 261 etaaxis->SetLabelSize(0.5);
262 etaaxis->SetTitleSize(0.6);
263 etaaxis->SetTitleOffset(0.2);
264 cutaxis->SetTitle("Etacut . ");
265 fEtaSlider->GetListOfPrimitives()->AddFirst(etaaxis);
266 fCanvas->cd();
267
268
269 fCanvas->cd();
270 fCanvas->Update();
271}
272
273
aee8290b 274//_____________________________________________________________________________
275AliDisplay::AliDisplay(const AliDisplay &disp)
276{
277 //
278 // Copy constructor
279 //
280 disp.Copy(*this);
281}
282
fe4da5cc 283//_____________________________________________________________________________
284AliDisplay::~AliDisplay()
285{
aee8290b 286 //
287 // Destructor
288 //
fe4da5cc 289}
290
291//_____________________________________________________________________________
292void AliDisplay::Clear(Option_t *)
293{
294// Delete graphics temporary objects
295}
296
aee8290b 297//_____________________________________________________________________________
298void AliDisplay::Copy(AliDisplay &disp) const
299{
300 //
301 // Copy *this onto disp -- not implemented
302 //
303 Fatal("Copy","Not implemented~\n");
304}
305
fe4da5cc 306//----------------------------------------------------------------------------
307void AliDisplay::ShowTrack(Int_t idx) {
aee8290b 308 AliDetector *mTPC=(AliDetector*)gAlice->GetModule("TPC");
309 TObjArray *points=mTPC->Points();
fe4da5cc 310 int ntracks=points->GetEntriesFast();
311 for (int track=0;track<ntracks;track++) {
312 AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
313 if (!pm) continue;
314 if (idx == pm->GetIndex()) {
315 pm->SetMarkerColor(2);
316 pm->SetMarkerStyle(22);
317 pm->Draw("same");
318// fPad->Update();
319// fPad->Modified();
320 TClonesArray *particles=gAlice->Particles();
1578254f 321 TParticle *p = (TParticle*)particles->UncheckedAt(idx);
fe4da5cc 322 printf("\nTrack index %d\n",idx);
1578254f 323 printf("Particle ID %d\n",p->GetPdgCode());
324 printf("Parent %d\n",p->GetFirstMother());
325 printf("First child %d\n",p->GetFirstDaughter());
326 printf("Px,Py,Pz %f %f %f\n",p->Px(),p->Py(),p->Pz());
fe4da5cc 327 return;
328 }
329 }
330}
331
332//----------------------------------------------------------------------------
333void AliDisplay::HideTrack(Int_t idx) {
ef42d733 334 //
335 // Hide track on display
336 //
aee8290b 337 AliDetector *mTPC=(AliDetector*)gAlice->GetModule("TPC");
338 TObjArray *points=mTPC->Points();
fe4da5cc 339 int ntracks=points->GetEntriesFast();
340 for (int track=0;track<ntracks;track++) {
341 AliPoints *pm = (AliPoints*)points->UncheckedAt(track);
342 if (!pm) continue;
343 if (idx == pm->GetIndex()) {
344 pm->SetMarkerColor(5);
345 pm->SetMarkerStyle(1);
346 pm->Draw("same");
347// fPad->Update();
348// fPad->Modified();
349 return;
350 }
351 }
352}
353
354//_____________________________________________________________________________
355void AliDisplay::DisableDetector(const char *name)
356{
357// Disable detector name from graphics views
358
8494b010 359 AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
360 if (!module) return;
361 module->Disable();
fe4da5cc 362 Draw();
363}
364
365//_____________________________________________________________________________
366void AliDisplay::DisplayButtons()
367{
368// Create the user interface buttons
369
370 fButtons = new TPad("buttons", "newpad",0,0.45,0.15,1);
38b32e9f 371 fButtons->SetEditable(kFALSE);
fe4da5cc 372 fButtons->Draw();
373 fButtons->SetFillColor(38);
374 fButtons->SetBorderSize(2);
375 fButtons->cd();
376
377 Int_t butcolor = 33;
378 Float_t dbutton = 0.08;
379 Float_t y = 0.96;
380 Float_t dy = 0.014;
381 Float_t x0 = 0.05;
382 Float_t x1 = 0.95;
383
384 TButton *button;
385 char but1[] = "gAlice->Display()->ShowNextEvent(1)";
386 button = new TButton("Next",but1,x0,y-dbutton,x1,y);
387 button->SetFillColor(38);
388 button->Draw();
389
390 y -= dbutton +dy;
391 char but2[] = "gAlice->Display()->ShowNextEvent(-1)";
392 button = new TButton("Previous",but2,x0,y-dbutton,x1,y);
393 button->SetFillColor(38);
394 button->Draw();
395
396 y -= dbutton +dy;
397 char but3[] = "gAlice->Display()->SetView(90,-90,90)";
398 button = new TButton("Top View",but3,x0,y-dbutton,x1,y);
399 button->SetFillColor(butcolor);
400 button->Draw();
401
402 y -= dbutton +dy;
403 char but4[] = "gAlice->Display()->SetView(90,0,-90)";
404 button = new TButton("Side View",but4,x0,y-dbutton,x1,y);
405 button->SetFillColor(butcolor);
406 button->Draw();
407
408 y -= dbutton +dy;
409 char but5[] = "gAlice->Display()->SetView(0,-90,0)";
410 button = new TButton("Front View",but5,x0,y-dbutton,x1,y);
411 button->SetFillColor(butcolor);
412 button->Draw();
413
414 y -= dbutton +dy;
415 char but6[] = "gAlice->Display()->DrawAllViews()";
416 button = new TButton("All Views",but6,x0,y-dbutton,x1,y);
417 button->SetFillColor(butcolor);
418 button->Draw();
419
420 y -= dbutton +dy;
421 char but7[] = "gAlice->Display()->DrawViewGL()";
422 button = new TButton("OpenGL",but7,x0,y-dbutton,x1,y);
423 button->SetFillColor(38);
424 button->Draw();
425
426 y -= dbutton +dy;
427 char but8[] = "gAlice->Display()->DrawViewX3D()";
428 button = new TButton("X3D",but8,x0,y-dbutton,x1,y);
429 button->SetFillColor(38);
430 button->Draw();
431
432 // display logo
433 TDiamond *diamond = new TDiamond(0.05,0.015,0.95,0.22);
434 diamond->SetFillColor(50);
435 diamond->SetTextAlign(22);
436 diamond->SetTextColor(5);
437 diamond->SetTextSize(0.11);
438 diamond->Draw();
439 diamond->AddText(".. ");
440 diamond->AddText("ROOT");
441 diamond->AddText("ALICE");
442 diamond->AddText("... ");
443 diamond->AddText(" ");
444}
445
446//______________________________________________________________________________
447Int_t AliDisplay::DistancetoPrimitive(Int_t px, Int_t)
448{
449// Compute distance from point px,py to objects in event
450
451 gPad->SetCursor(kCross);
452
453 if (gPad == fTrigPad) return 9999;
454 if (gPad == fCutPad) return 9999;
455 if (gPad == fEtaPad) return 9999;
456
aee8290b 457 const Int_t kbig = 9999;
458 Int_t dist = kbig;
fe4da5cc 459 Float_t xmin = gPad->GetX1();
460 Float_t xmax = gPad->GetX2();
461 Float_t dx = 0.02*(xmax - xmin);
462 Float_t x = gPad->AbsPixeltoX(px);
463 if (x < xmin+dx || x > xmax-dx) return dist;
464
465 if (fZoomMode) return 0;
466 else return 7;
467}
468
469//_____________________________________________________________________________
470void AliDisplay::Draw(Option_t *)
471{
472// Display current event
473
474 if (fDrawAllViews) {
475 DrawAllViews();
476 return;
477 }
478
479 fPad->cd();
480
481 DrawView(fTheta, fPhi, fPsi);
482
483 // Display the event number and title
484 fPad->cd();
485 DrawTitle();
486}
487
488//_____________________________________________________________________________
489void AliDisplay::DrawAllViews()
490{
491// Draw front,top,side and 30 deg views
492
493 fDrawAllViews = kTRUE;
494 fPad->cd();
495 fPad->SetFillColor(15);
496 fPad->Clear();
497 fPad->Divide(2,2);
498
499 // draw 30 deg view
500 fPad->cd(1);
501 DrawView(30, 30, 0);
502 DrawTitle();
503
504 // draw front view
505 fPad->cd(2);
506 DrawView(0, -90,0);
507 DrawTitle("Front");
508
509 // draw top view
510 fPad->cd(3);
511 DrawView(90, -90, 90);
512 DrawTitle("Top");
513
514 // draw side view
515 fPad->cd(4);
516 DrawView(90, 0, -90);
517 DrawTitle("Side");
518
519 fPad->cd(2);
520}
521
522//_____________________________________________________________________________
523void AliDisplay::DrawHits()
524{
525// Draw hits for all ALICE detectors
526
527 Float_t cutmin, cutmax, etamin, etamax, pmom, smin, smax, eta, theta, r;
528 Float_t *pxyz;
529 Int_t ntracks,track;
1578254f 530 TParticle *particle;
fe4da5cc 531 TObjArray *points;
532 AliPoints *pm;
533
534 //Get cut slider
535 smax = fCutSlider->GetMaximum();
536 smin = fCutSlider->GetMinimum();
aee8290b 537 cutmin = kptcutmax*smin;
538 if (smax < 0.98) cutmax = kptcutmax*smax;
fe4da5cc 539 else cutmax = 100000;
540
541 //Get eta slider
542 smax = fEtaSlider->GetMaximum();
543 smin = fEtaSlider->GetMinimum();
aee8290b 544 etamin = ketacutmax*(2*smin-1);
545 etamax = ketacutmax*(2*smax-1);
fe4da5cc 546 if (smin < 0.02) etamin = -1000;
547 if (smax > 0.98) etamax = 1000;
548
8494b010 549 TIter next(gAlice->Modules());
550 AliModule *module;
fe4da5cc 551 fHitsCuts = 0;
8494b010 552 while((module = (AliModule*)next())) {
553 if (!module->IsActive()) continue;
554 points = module->Points();
fe4da5cc 555 if (!points) continue;
556 ntracks = points->GetEntriesFast();
557 for (track=0;track<ntracks;track++) {
558 pm = (AliPoints*)points->UncheckedAt(track);
559 if (!pm) continue;
560 particle = pm->GetParticle();
561 if (!particle) continue;
1578254f 562 pmom = particle->P();
fe4da5cc 563 if (pmom < cutmin) continue;
564 if (pmom > cutmax) continue;
565 // as a first approximation, take eta of first point
566 pxyz = pm->GetP();
567 r = TMath::Sqrt(pxyz[0]*pxyz[0] + pxyz[1]*pxyz[1]);
568 theta = TMath::ATan2(r,TMath::Abs(pxyz[2]));
569 if(theta) eta = -TMath::Log(TMath::Tan(0.5*theta)); else eta = 1e10;
570 if (pxyz[2] < 0) eta = -eta;
571 if (eta < etamin || eta > etamax) continue;
572 pm->Draw();
573 fHitsCuts += pm->GetN();
574 }
575 }
576}
577
578//_____________________________________________________________________________
579void AliDisplay::DrawTitle(Option_t *option)
580{
581// Draw the event title
582
583 Float_t xmin = gPad->GetX1();
584 Float_t xmax = gPad->GetX2();
585 Float_t ymin = gPad->GetY1();
586 Float_t ymax = gPad->GetY2();
587 Float_t dx = xmax-xmin;
588 Float_t dy = ymax-ymin;
589
590 if (strlen(option) == 0) {
591 TPaveText *title = new TPaveText(xmin +0.01*dx, ymax-0.09*dy, xmin +0.5*dx, ymax-0.01*dy);
592 title->SetBit(kCanDelete);
593 title->SetFillColor(42);
594 title->Draw();
595 char ptitle[100];
596 sprintf(ptitle,"Alice event: %d, Run:%d",gAlice->GetHeader()->GetEvent(), gAlice->GetHeader()->GetRun());
597 title->AddText(ptitle);
598 Int_t nparticles = gAlice->Particles()->GetEntriesFast();
599 sprintf(ptitle,"Nparticles = %d Nhits = %d",nparticles, fHitsCuts);
600 title->AddText(ptitle);
601 } else {
602 TPaveLabel *label = new TPaveLabel(xmin +0.01*dx, ymax-0.07*dy, xmin +0.2*dx, ymax-0.01*dy,option);
603 label->SetBit(kCanDelete);
604 label->SetFillColor(42);
605 label->Draw();
606 }
607}
608
609//_____________________________________________________________________________
610void AliDisplay::DrawView(Float_t theta, Float_t phi, Float_t psi)
611{
612// Draw a view of ALICE
613
614 gPad->SetCursor(kWatch);
615 gPad->SetFillColor(1);
616 gPad->Clear();
617
618 Int_t iret;
619 TView *view = new TView(1);
620 Float_t range = fRrange*fRangeSlider->GetMaximum();
621 view->SetRange(-range,-range,-range,range, range, range);
622 fZoomX0[0] = -1;
623 fZoomY0[0] = -1;
624 fZoomX1[0] = 1;
625 fZoomY1[0] = 1;
626 fZooms = 0;
627
628 // Display Alice Geometry
629 gAlice->GetGeometry()->Draw("same");
630
631 //Loop on all detectors to add their products to the pad
632 DrawHits();
633
634 // add itself to the list (must be last)
635 AppendPad();
636
637 view->SetView(phi, theta, psi, iret);
638}
639
640//_____________________________________________________________________________
641void AliDisplay::DrawViewGL()
642{
643// Draw current view using OPENGL
644
645 TPad *pad = (TPad*)gPad->GetPadSave();
646 pad->cd();
647 TView *view = pad->GetView();
648 if (!view) return;
649 pad->x3d("OPENGL");
650}
651
652//_____________________________________________________________________________
653void AliDisplay::DrawViewX3D()
654{
655// Draw current view using X3D
656
657 TPad *pad = (TPad*)gPad->GetPadSave();
658 pad->cd();
659 TView *view = pad->GetView();
660 if (!view) return;
661 pad->x3d();
662}
663
664//_____________________________________________________________________________
665void AliDisplay::EnableDetector(const char *name)
666{
667// Enable detector name in graphics views
668
8494b010 669 AliModule *module = (AliModule*)gAlice->Modules()->FindObject(name);
670 if (!module) return;
671 module->Enable();
fe4da5cc 672 Draw();
673}
674
675//______________________________________________________________________________
676void AliDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
677{
678// Execute action corresponding to the mouse event
679
680 static Float_t x0, y0, x1, y1;
681
682 static Int_t pxold, pyold;
683 static Int_t px0, py0;
684 static Int_t linedrawn;
685 Float_t temp;
686
687 if (px == 0 && py == 0) { //when called by sliders
688 if (event == kButton1Up) {
689 Draw();
690 }
691 return;
692 }
693 if (!fZoomMode && gPad->GetView()) {
694 gPad->GetView()->ExecuteRotateView(event, px, py);
695 return;
696 }
697
698 // something to zoom ?
699// fPad->SetCursor(kCross);
700 gPad->SetCursor(kCross);
701
702 switch (event) {
703
704 case kButton1Down:
084c1b4a 705 gVirtualX->SetLineColor(-1);
fe4da5cc 706 gPad->TAttLine::Modify(); //Change line attributes only if necessary
707 x0 = gPad->AbsPixeltoX(px);
708 y0 = gPad->AbsPixeltoY(py);
709 px0 = px; py0 = py;
710 pxold = px; pyold = py;
711 linedrawn = 0;
712 return;
713
714 case kButton1Motion:
084c1b4a 715 if (linedrawn) gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
fe4da5cc 716 pxold = px;
717 pyold = py;
718 linedrawn = 1;
084c1b4a 719 gVirtualX->DrawBox(px0, py0, pxold, pyold, TVirtualX::kHollow);
fe4da5cc 720 return;
721
722 case kButton1Up:
723 gPad->GetCanvas()->FeedbackMode(kFALSE);
724 if (px == px0) return;
725 if (py == py0) return;
726 x1 = gPad->AbsPixeltoX(px);
727 y1 = gPad->AbsPixeltoY(py);
728
729 if (x1 < x0) {temp = x0; x0 = x1; x1 = temp;}
730 if (y1 < y0) {temp = y0; y0 = y1; y1 = temp;}
731 gPad->Range(x0,y0,x1,y1);
732 if (fZooms < kMAXZOOMS-1) {
733 fZooms++;
734 fZoomX0[fZooms] = x0;
735 fZoomY0[fZooms] = y0;
736 fZoomX1[fZooms] = x1;
737 fZoomY1[fZooms] = y1;
738 }
739 gPad->Modified(kTRUE);
740 return;
741 }
742
743}
744
745//___________________________________________
746void AliDisplay::LoadPoints()
747{
748// Read hits info and store x,y,z info in arrays fPoints
749// Loop on all detectors
750
751 gAlice->ResetPoints();
8494b010 752 TIter next(gAlice->Modules());
753 AliModule *module;
fe4da5cc 754 Int_t ntracks = gAlice->GetNtrack();
755 for (Int_t track=0; track<ntracks;track++) {
756 gAlice->ResetHits();
757 gAlice->TreeH()->GetEvent(track);
8494b010 758 while((module = (AliModule*)next())) {
759 module->LoadPoints(track);
fe4da5cc 760 }
761 next.Reset();
762 }
763}
764
765//_____________________________________________________________________________
766void AliDisplay::Paint(Option_t *)
767{
768// Paint miscellaneous items
769
770}
771
772//_____________________________________________________________________________
773void AliDisplay::SetPickMode()
774{
ef42d733 775 //
776 // Set Pick Mode -- disable zoom
777 //
fe4da5cc 778 fZoomMode = 0;
779
780 fArcButton->SetY1(fPickButton->GetYlowNDC()+0.5*fPickButton->GetHNDC());
781 fTrigPad->Modified();
782}
783
784//_____________________________________________________________________________
785void AliDisplay::SetZoomMode()
786{
ef42d733 787 //
788 // Set Zoom Mode -- disable pick
789 //
fe4da5cc 790 fZoomMode = 1;
791
792 fArcButton->SetY1(fZoomButton->GetYlowNDC()+0.5*fZoomButton->GetHNDC());
793 fTrigPad->Modified();
794}
795
796//_____________________________________________________________________________
797void AliDisplay::SetPTcut(Float_t ptcut)
798{
ef42d733 799 //
800 // Set Pt Cut
801 //
fe4da5cc 802 fPTcut = ptcut;
803
804 if (!fPad) return;
805 fPad->Clear();
806 Draw();
807}
808
809//_____________________________________________________________________________
810void AliDisplay::SetRange(Float_t rrange, Float_t zrange)
811{
812// Set view range along R and Z
813 fRrange = rrange;
814 fZrange = zrange;
815
816 if (!fPad) return;
817 fPad->Clear();
818 Draw();
819}
820
821//_____________________________________________________________________________
822void AliDisplay::SetView(Float_t theta, Float_t phi, Float_t psi)
823{
824// change viewing angles for current event
825
826 fPad->cd();
827 fDrawAllViews = kFALSE;
828 fPhi = phi;
829 fTheta = theta;
830 fPsi = psi;
831 Int_t iret = 0;
832
833 TView *view = gPad->GetView();
834 if (view) view->SetView(fPhi, fTheta, fPsi, iret);
835 else Draw();
836
837 gPad->Modified();
838}
839
840//_____________________________________________________________________________
841void AliDisplay::ShowNextEvent(Int_t delta)
842{
843// Display (current event_number+delta)
844// delta = 1 shown next event
845// delta = -1 show previous event
846
847 if (delta) {
848 gAlice->Clear();
aee8290b 849 Int_t currentEvent = gAlice->GetHeader()->GetEvent();
850 Int_t newEvent = currentEvent + delta;
851 gAlice->GetEvent(newEvent);
fe4da5cc 852 if (!gAlice->TreeH()) return;
853 }
854 LoadPoints();
855 fPad->cd();
856 Draw();
857}
858
859//______________________________________________________________________________
860void AliDisplay::UnZoom()
861{
aee8290b 862 //
863 // Resets ZOOM
864 //
865 if (fZooms <= 0) return;
866 fZooms--;
867 TPad *pad = (TPad*)gPad->GetPadSave();
868 pad->Range(fZoomX0[fZooms],fZoomY0[fZooms], fZoomX1[fZooms],fZoomY1[fZooms]);
869 pad->Modified();
870}
871
872//_____________________________________________________________________________
873AliDisplay & AliDisplay::operator=(const AliDisplay &disp)
874{
875 //
876 // Assignment operator
877 //
878 disp.Copy(*this);
879 return (*this);
fe4da5cc 880}