2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #include "AliEveTPCSector3DGL.h"
11 #include <EveDet/AliEveTPCSector3D.h>
13 #include <TEveBoxSetGL.h>
15 #include <TGLIncludes.h>
16 #include <TGLRnrCtx.h>
17 #include <TGLSelectRecord.h>
19 //______________________________________________________________________________
21 // GL renderer for AliEveTPCSector3D.
23 ClassImp(AliEveTPCSector3DGL)
25 AliEveTPCSector3DGL::AliEveTPCSector3DGL() :
27 fSector(0), fBoxRnr(0),
32 fDLCache = false; // Disable display list.
35 AliEveTPCSector3DGL::~AliEveTPCSector3DGL()
42 /******************************************************************************/
44 //______________________________________________________________________________
45 Short_t AliEveTPCSector3DGL::QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
47 // Factor in scene/viewer LOD and quantize.
49 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
54 return (Short_t)(10 * TMath::Nint(0.1*lod));
57 /******************************************************************************/
59 Bool_t AliEveTPCSector3DGL::SetModel(TObject* obj, const Option_t* /*opt*/)
63 if(SetModelCheckClass(obj, AliEveTPCSector3D::Class())) {
64 fSector = (AliEveTPCSector3D*) fExternalObj;
66 fBoxRnr = new TEveBoxSetGL;
67 fBoxRnr->SetModel(&fSector->fBoxSet);
74 void AliEveTPCSector3DGL::SetBBox()
78 SetAxisAlignedBBox(((AliEveTPCSector3D*)fExternalObj)->AssertBBox());
81 /******************************************************************************/
83 void AliEveTPCSector3DGL::DirectDraw(TGLRnrCtx & rnrCtx) const
87 // printf("AliEveTPCSector3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
89 if(fRTS < fSector->fRTS) {
90 fSector->UpdateBoxesAndPoints();
94 if (rnrCtx.SecSelection()) glPushName(0);
96 Bool_t hasData = (fSector->GetSectorData() != 0);
100 if (rnrCtx.SecSelection()) glLoadName(9999);
101 fBoxRnr->Render(rnrCtx);
104 glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
105 glDisable(GL_LIGHTING);
107 if(hasData && fSector->fPointSetOn)
110 glEnable(GL_POINT_SMOOTH);
111 glPointSize(fSector->fPointSize);
113 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
114 glEnableClientState(GL_VERTEX_ARRAY);
116 const TEvePointSetArray& psa = fSector->fPointSetArray;
117 for(Int_t b=0; b<psa.GetNBins(); ++b)
119 TEvePointSet* ps = psa.GetBin(b);
122 TGLUtil::Color(ps->GetMarkerColor());
124 if (rnrCtx.SecSelection()) glLoadName(b + 1);
125 glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
126 glDrawArrays(GL_POINTS, 0, ps->Size());
133 if(fSector->fRnrFrame && ! rnrCtx.SecSelection())
135 TGLUtil::Color(fSector->fFrameColor);
138 DrawSegmentFrame(AliEveTPCSectorData::GetInnSeg(), 0, 2);
139 if(fSector->fRnrOut1)
140 DrawSegmentFrame(AliEveTPCSectorData::GetOut1Seg(), 2, 1);
141 if(fSector->fRnrOut2)
142 DrawSegmentFrame(AliEveTPCSectorData::GetOut2Seg(), 2, 2);
148 void AliEveTPCSector3DGL::DrawSegmentFrame(const AliEveTPCSectorData::SegmentInfo& s,
149 Int_t botExtraPads, Int_t topExtraPads) const
151 // Draw frame of given segment.
153 Float_t xl, xh, yl, yh, zl, zh;
154 xl = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
155 xh = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads);
157 yh = yl + s.GetNRows()*s.GetPadHeight();
159 zh = AliEveTPCSectorData::GetZLength();
161 glBegin(GL_LINE_LOOP);
162 glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl);
163 glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl);
165 glBegin(GL_LINE_LOOP);
166 glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh);
167 glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh);
170 glVertex3f( xl, yl, zl); glVertex3f( xl, yl, zh);
171 glVertex3f( xh, yh, zl); glVertex3f( xh, yh, zh);
172 glVertex3f(-xh, yh, zl); glVertex3f(-xh, yh, zh);
173 glVertex3f(-xl, yl, zl); glVertex3f(-xl, yl, zh);
177 /******************************************************************************/
178 /******************************************************************************/
180 //______________________________________________________________________________
181 void AliEveTPCSector3DGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
183 // Processes secondary selection from TGLViewer.
184 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
185 // point as an argument.
187 if (rec.GetN() < 3) return;
189 if (rec.GetItem(1) == 9999)
191 printf("TPC3D Box selected idx=%u\n", rec.GetItem(2));
195 const TEvePointSetArray& psa = fSector->fPointSetArray;
197 if (rec.GetItem(1) > 0 && rec.GetItem(1) <= (UInt_t) psa.GetNBins())
199 // TEvePointSet& ps = * psa.GetBin(rec.GetItem(1) - 1);
200 printf("TPC3D Point selected, bin=%u, idx=%u\n", rec.GetItem(1) - 1, rec.GetItem(2));