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