]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTPCSector3DGL.cxx
From Massimo: remove usage of AliITSgeom, use AliITSgeomTGeo instead.
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCSector3DGL.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
dcb55984 3
d810d0de 4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
9
10#include "AliEveTPCSector3DGL.h"
cb4245bb 11#include <EveDet/AliEveTPCSector3D.h>
dcb55984 12
84aff7a4 13#include <TEveBoxSetGL.h>
dcb55984 14
19208112 15#include <TGLIncludes.h>
32e219c2 16#include <TGLRnrCtx.h>
17#include <TGLSelectRecord.h>
d810d0de 18
dcb55984 19
57ffa5fb 20//______________________________________________________________________________
dcb55984 21//
a97abca8 22// GL renderer for AliEveTPCSector3D.
dcb55984 23
d810d0de 24ClassImp(AliEveTPCSector3DGL)
dcb55984 25
d810d0de 26AliEveTPCSector3DGL::AliEveTPCSector3DGL() :
265ecb21 27 TGLObject(),
28 fSector(0), fBoxRnr(0),
29 fRTS(0)
dcb55984 30{
a97abca8 31 // Constructor.
32
19208112 33 // fDLCache = false; // Disable display list.
dcb55984 34}
35
d810d0de 36AliEveTPCSector3DGL::~AliEveTPCSector3DGL()
dcb55984 37{
a97abca8 38 // Destructor.
39
dcb55984 40 delete fBoxRnr;
41}
42
57ffa5fb 43/******************************************************************************/
dcb55984 44
32e219c2 45//______________________________________________________________________________
d810d0de 46Short_t AliEveTPCSector3DGL::QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
32e219c2 47{
48 // Factor in scene/viewer LOD and quantize.
49
50 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
51
52 if (lod >= 100)
53 return 100;
54 else
55 return (Short_t)(10 * TMath::Nint(0.1*lod));
56}
57
57ffa5fb 58/******************************************************************************/
32e219c2 59
d810d0de 60Bool_t AliEveTPCSector3DGL::SetModel(TObject* obj, const Option_t* /*opt*/)
dcb55984 61{
a97abca8 62 // Set model object.
63
d810d0de 64 if(SetModelCheckClass(obj, AliEveTPCSector3D::Class())) {
65 fSector = (AliEveTPCSector3D*) fExternalObj;
dcb55984 66 if(fBoxRnr == 0) {
84aff7a4 67 fBoxRnr = new TEveBoxSetGL;
dcb55984 68 fBoxRnr->SetModel(&fSector->fBoxSet);
69 }
70 return kTRUE;
71 }
72 return kFALSE;
73}
74
d810d0de 75void AliEveTPCSector3DGL::SetBBox()
dcb55984 76{
a97abca8 77 // Set bounding-box.
78
d810d0de 79 SetAxisAlignedBBox(((AliEveTPCSector3D*)fExternalObj)->AssertBBox());
dcb55984 80}
81
57ffa5fb 82/******************************************************************************/
dcb55984 83
d810d0de 84void AliEveTPCSector3DGL::DirectDraw(TGLRnrCtx & rnrCtx) const
dcb55984 85{
a97abca8 86 // Render object.
87
d810d0de 88 // printf("AliEveTPCSector3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
dcb55984 89
7b7bcadc 90 if(fRTS < fSector->fRTS) {
a97abca8 91 fSector->UpdateBoxesAndPoints();
7b7bcadc 92 fRTS = fSector->fRTS;
51346b82 93 }
7b7bcadc 94
32e219c2 95 if (rnrCtx.SecSelection()) glPushName(0);
96
7b7bcadc 97 Bool_t hasData = (fSector->GetSectorData() != 0);
98
99 if(hasData)
32e219c2 100 {
101 if (rnrCtx.SecSelection()) glLoadName(9999);
19208112 102 fBoxRnr->Render(rnrCtx);
32e219c2 103 }
dcb55984 104
6a3de3d4 105 glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
106 glDisable(GL_LIGHTING);
107 UChar_t col[4];
9a7ad6a0 108
32e219c2 109 if(hasData && fSector->fPointSetOn)
110 {
9a7ad6a0 111 glEnable(GL_BLEND);
112 glEnable(GL_POINT_SMOOTH);
6a3de3d4 113 glPointSize(fSector->fPointSize);
9a7ad6a0 114
115 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
116 glEnableClientState(GL_VERTEX_ARRAY);
117
84aff7a4 118 const TEvePointSetArray& psa = fSector->fPointSetArray;
32e219c2 119 for(Int_t b=0; b<psa.GetNBins(); ++b)
120 {
84aff7a4 121 TEvePointSet* ps = psa.GetBin(b);
32e219c2 122 if(ps->Size() > 0)
123 {
d810d0de 124 TEveUtil::TEveUtil::ColorFromIdx(ps->GetMarkerColor(), col);
7b7bcadc 125 glColor4ubv(col);
9a7ad6a0 126
32e219c2 127 if (rnrCtx.SecSelection()) glLoadName(b + 1);
f80216f6 128 glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
7b7bcadc 129 glDrawArrays(GL_POINTS, 0, ps->Size());
f80216f6 130 }
9a7ad6a0 131 }
132
133 glPopClientAttrib();
9a7ad6a0 134 }
135
32e219c2 136 if(fSector->fRnrFrame && ! rnrCtx.SecSelection())
137 {
d810d0de 138 TEveUtil::TEveUtil::ColorFromIdx(fSector->fFrameColor, col);
dcb55984 139 glColor4ubv(col);
140
141 if(fSector->fRnrInn)
d810d0de 142 DrawSegmentFrame(AliEveTPCSectorData::GetInnSeg(), 0, 2);
dcb55984 143 if(fSector->fRnrOut1)
d810d0de 144 DrawSegmentFrame(AliEveTPCSectorData::GetOut1Seg(), 2, 1);
dcb55984 145 if(fSector->fRnrOut2)
d810d0de 146 DrawSegmentFrame(AliEveTPCSectorData::GetOut2Seg(), 2, 2);
dcb55984 147 }
6a3de3d4 148
149 glPopAttrib();
dcb55984 150}
151
d810d0de 152void AliEveTPCSector3DGL::DrawSegmentFrame(const AliEveTPCSectorData::SegmentInfo& s,
a97abca8 153 Int_t botExtraPads, Int_t topExtraPads) const
dcb55984 154{
a97abca8 155 // Draw frame of given segment.
156
dcb55984 157 Float_t xl, xh, yl, yh, zl, zh;
d810d0de 158 xl = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
159 xh = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads);
dcb55984 160 yl = s.GetRLow();
161 yh = yl + s.GetNRows()*s.GetPadHeight();
6a3de3d4 162 zl = 0;
d810d0de 163 zh = AliEveTPCSectorData::GetZLength();
dcb55984 164
165 glBegin(GL_LINE_LOOP);
166 glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl);
167 glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl);
168 glEnd();
169 glBegin(GL_LINE_LOOP);
170 glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh);
171 glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh);
172 glEnd();
173 glBegin(GL_LINES);
174 glVertex3f( xl, yl, zl); glVertex3f( xl, yl, zh);
175 glVertex3f( xh, yh, zl); glVertex3f( xh, yh, zh);
176 glVertex3f(-xh, yh, zl); glVertex3f(-xh, yh, zh);
177 glVertex3f(-xl, yl, zl); glVertex3f(-xl, yl, zh);
178 glEnd();
179}
32e219c2 180
57ffa5fb 181/******************************************************************************/
182/******************************************************************************/
32e219c2 183
184//______________________________________________________________________________
d810d0de 185void AliEveTPCSector3DGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
32e219c2 186{
187 // Processes secondary selection from TGLViewer.
188 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
189 // point as an argument.
190
191 if (rec.GetN() < 3) return;
192
193 if (rec.GetItem(1) == 9999)
194 {
195 printf("TPC3D Box selected idx=%u\n", rec.GetItem(2));
196 return;
197 }
198
84aff7a4 199 const TEvePointSetArray& psa = fSector->fPointSetArray;
32e219c2 200
201 if (rec.GetItem(1) > 0 && rec.GetItem(1) <= (UInt_t) psa.GetNBins())
202 {
84aff7a4 203 // TEvePointSet& ps = * psa.GetBin(rec.GetItem(1) - 1);
32e219c2 204 printf("TPC3D Point selected, bin=%u, idx=%u\n", rec.GetItem(1) - 1, rec.GetItem(2));
205 return;
206 }
207}