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