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