]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSector3DGL.cxx
Fix effc++ warnings.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSector3DGL.cxx
1 // $Header$
2
3 #include "TPCSector3DGL.h"
4 #include <Alieve/TPCSector3D.h>
5
6 #include <Reve/BoxSetGL.h>
7
8 #include <TGLDrawFlags.h>
9
10 #ifdef WIN32
11 #include "Windows4root.h"
12 #endif
13 #include <GL/gl.h>
14 #include <GL/glu.h>
15
16 using namespace Reve;
17 using namespace Alieve;
18
19 //______________________________________________________________________
20 // TPCSector3DGL
21 //
22
23 ClassImp(TPCSector3DGL)
24
25 TPCSector3DGL::TPCSector3DGL() :
26   TGLObject(),
27   fSector(0), fBoxRnr(0),
28   fRTS(0)
29 {
30   // fCached = false; // Disable display list.
31 }
32
33 TPCSector3DGL::~TPCSector3DGL()
34 {
35   delete fBoxRnr;
36 }
37
38 /**************************************************************************/
39
40 Bool_t TPCSector3DGL::SetModel(TObject* obj)
41 {
42 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
43   if(set_model(obj, "Alieve::TPCSector3D")) {
44 #elif ROOT_VERSION_CODE <= ROOT_VERSION(5,13,0)
45   if(SetModelCheckClass(obj, "Alieve::TPCSector3D")) {
46 #else
47   if(SetModelCheckClass(obj, Alieve::TPCSector3D::Class())) {
48 #endif
49     fSector = (TPCSector3D*) fExternalObj;
50     if(fBoxRnr == 0) {
51       fBoxRnr = new BoxSetGL;
52       fBoxRnr->SetModel(&fSector->fBoxSet);
53     }
54     return kTRUE;
55   }
56   return kFALSE;
57 }
58
59 void TPCSector3DGL::SetBBox()
60 {
61 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2)
62   set_axis_aligned_bbox(((TPCSector3D*)fExternalObj)->AssertBBox());
63 #else
64   SetAxisAlignedBBox(((TPCSector3D*)fExternalObj)->AssertBBox());
65 #endif
66 }
67
68 /**************************************************************************/
69
70 void TPCSector3DGL::DirectDraw(const TGLDrawFlags & flags) const
71 {
72   // printf("TPCSector3DGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
73
74   if(fRTS < fSector->fRTS) {
75     fSector->UpdateBoxes();
76     fRTS = fSector->fRTS;
77   }  
78
79   Bool_t hasData = (fSector->GetSectorData() != 0);
80
81   if(hasData)
82     fBoxRnr->Render(flags);
83
84   glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
85   glDisable(GL_LIGHTING);
86   UChar_t col[4];
87
88   if(hasData && fSector->fPointSetOn) {
89     glEnable(GL_BLEND);
90     glEnable(GL_POINT_SMOOTH);
91     glPointSize(fSector->fPointSize);
92
93     glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
94     glEnableClientState(GL_VERTEX_ARRAY);
95
96     const Reve::PointSetArray& psa = fSector->fPointSetArray;
97     for(Int_t b=0; b<psa.GetNBins(); ++b) {
98       Reve::PointSet* ps = psa.GetBin(b);
99       if(ps->Size() > 0) {
100         ColorFromIdx(ps->GetMarkerColor(), col);
101         glColor4ubv(col);
102
103         glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
104         glDrawArrays(GL_POINTS, 0, ps->Size());
105       }
106     }
107
108     glPopClientAttrib();
109   }
110
111   if(fSector->fRnrFrame) {
112     ColorFromIdx(fSector->fFrameColor, col);
113     glColor4ubv(col);
114
115     if(fSector->fRnrInn)
116       DrawSegmentFrame(TPCSectorData::GetInnSeg(),  0, 2);
117     if(fSector->fRnrOut1)
118       DrawSegmentFrame(TPCSectorData::GetOut1Seg(), 2, 1);
119     if(fSector->fRnrOut2)
120       DrawSegmentFrame(TPCSectorData::GetOut2Seg(), 2, 2);
121   }
122
123   glPopAttrib();
124 }
125
126 void TPCSector3DGL::DrawSegmentFrame(const TPCSectorData::SegmentInfo& s,
127                                      Int_t botExtraPads, Int_t topExtraPads) const
128 {
129   Float_t xl, xh, yl, yh, zl, zh;
130   xl = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
131   xh = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetLastRow())  + topExtraPads);
132   yl = s.GetRLow();
133   yh = yl + s.GetNRows()*s.GetPadHeight();
134   zl = 0;
135   zh = TPCSectorData::GetZLength();
136
137   glBegin(GL_LINE_LOOP);
138   glVertex3f( xl, yl, zl);  glVertex3f( xh, yh, zl);
139   glVertex3f(-xh, yh, zl);  glVertex3f(-xl, yl, zl);
140   glEnd();
141   glBegin(GL_LINE_LOOP);
142   glVertex3f( xl, yl, zh);  glVertex3f( xh, yh, zh);
143   glVertex3f(-xh, yh, zh);  glVertex3f(-xl, yl, zh);
144   glEnd();
145   glBegin(GL_LINES);
146   glVertex3f( xl, yl, zl);  glVertex3f( xl, yl, zh);
147   glVertex3f( xh, yh, zl);  glVertex3f( xh, yh, zh);
148   glVertex3f(-xh, yh, zl);  glVertex3f(-xh, yh, zh);
149   glVertex3f(-xl, yl, zl);  glVertex3f(-xl, yl, zh);
150   glEnd();
151 }