]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveJetPlaneGL.cxx
Coverity
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveJetPlaneGL.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveJetPlaneGL.h"
11 #include "AliEveJetPlane.h"
12
13 #include <TGLRnrCtx.h>
14 #include <TGLSelectRecord.h>
15 #include <TGLIncludes.h>
16
17 #include "TGLUtil.h"
18 #include "TGLAxis.h"
19
20 #include <TColor.h>
21 #include <TStyle.h>
22 #include <TROOT.h>
23
24 //==============================================================================
25 //==============================================================================
26 // AliEveJetPlaneGL
27 //==============================================================================
28
29 //______________________________________________________________________________
30 //
31 // GL renderer for AliEveJetPlane.
32
33 ClassImp(AliEveJetPlaneGL)
34
35 AliEveJetPlaneGL::AliEveJetPlaneGL() : TGLObject(), fM(0)
36 {
37   // Constructor.
38
39   fDLCache = kFALSE; // Disable display list -- axis pain.
40 }
41
42 /******************************************************************************/
43
44 Bool_t AliEveJetPlaneGL::SetModel(TObject* obj, const Option_t* /*opt*/)
45 {
46   // Set model object.
47
48   if (SetModelCheckClass(obj, AliEveJetPlane::Class())) {
49     fM = dynamic_cast<AliEveJetPlane*>(obj);
50     return kTRUE;
51   }
52   return kFALSE;
53 }
54
55 void AliEveJetPlaneGL::SetBBox()
56 {
57   // Set bounding box.
58
59   SetAxisAlignedBBox(((AliEveJetPlane*)fExternalObj)->AssertBBox());
60 }
61
62 /******************************************************************************/
63
64 void AliEveJetPlaneGL::DirectDraw(TGLRnrCtx& rnrCtx) const
65 {
66   // Render the object.
67
68   Float_t minEta = (fM->fMinEta)*(fM->fEtaScale);
69   Float_t maxEta = (fM->fMaxEta)*(fM->fEtaScale);
70   Float_t minPhi = (fM->fMinPhi)*(fM->fPhiScale) - 350;
71   Float_t maxPhi = (fM->fMaxPhi)*(fM->fPhiScale) - 350;
72   Float_t phiCoord, etaCoord, dPhi, dEta;
73
74   // Show frame for Eta-Phi coordinates
75
76   glBegin(GL_LINE_LOOP);
77   glVertex3f(minEta, minPhi, 0);
78   glVertex3f(maxEta, minPhi, 0);
79   glVertex3f(maxEta, maxPhi, 0);
80   glVertex3f(minEta, maxPhi, 0);
81   glEnd();
82
83   if (rnrCtx.Selection() == kFALSE && rnrCtx.Highlight() == kFALSE)
84   {
85
86     // Show grid in Eta-Phi coordinates
87
88     dPhi = (maxPhi-minPhi)/(fM->fNPhiDiv - 1);
89     dEta = (maxEta-minEta)/(fM->fNEtaDiv - 1);
90
91     for (Int_t count = 1; count < fM->fNPhiDiv-1; ++count)
92     {
93       phiCoord = minPhi + count*dPhi;
94       glBegin(GL_LINES);
95       glVertex3f( minEta, phiCoord, 0);
96       glVertex3f( maxEta, phiCoord, 0);
97       glEnd();
98     }
99
100     for (Int_t count = 1; count < fM->fNEtaDiv-1; ++count)
101     {
102       etaCoord = minEta + count*dEta;
103       glBegin(GL_LINES);
104       glVertex3f(etaCoord, minPhi, 0);
105       glVertex3f(etaCoord, maxPhi, 0);
106       glEnd();
107     }
108
109     // Show axis tick marks and labels
110
111     {
112       TGLCapabilitySwitch lightsOff(GL_LIGHTING, false);
113
114       TGLAxis ap;
115       ap.SetLineColor(fM->fGridColor);
116       ap.SetTextColor(fM->fGridColor);
117       TGLVector3 start, end;
118
119       start.Set(minEta, minPhi, 0);
120       end.Set(maxEta, minPhi, 0);
121       ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinEta, fM->fMaxEta, 205);
122
123       start.Set(maxEta, minPhi, 0);
124       end.Set(maxEta, maxPhi, 0);
125       ap.PaintGLAxis(start.CArr(), end.CArr(), fM->fMinPhi, fM->fMaxPhi, 205);
126     }
127
128   }
129 }