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>
20 //______________________________________________________________________________
22 // GL renderer for AliEveTPCSector3D.
24 ClassImp(AliEveTPCSector3DGL)
26 AliEveTPCSector3DGL::AliEveTPCSector3DGL() :
28 fSector(0), fBoxRnr(0),
33 // fDLCache = false; // Disable display list.
36 AliEveTPCSector3DGL::~AliEveTPCSector3DGL()
43 /******************************************************************************/
45 //______________________________________________________________________________
46 Short_t AliEveTPCSector3DGL::QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
48 // Factor in scene/viewer LOD and quantize.
50 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
55 return (Short_t)(10 * TMath::Nint(0.1*lod));
58 /******************************************************************************/
60 Bool_t AliEveTPCSector3DGL::SetModel(TObject* obj, const Option_t* /*opt*/)
64 if(SetModelCheckClass(obj, AliEveTPCSector3D::Class())) {
65 fSector = (AliEveTPCSector3D*) fExternalObj;
67 fBoxRnr = new TEveBoxSetGL;
68 fBoxRnr->SetModel(&fSector->fBoxSet);
75 void AliEveTPCSector3DGL::SetBBox()
79 SetAxisAlignedBBox(((AliEveTPCSector3D*)fExternalObj)->AssertBBox());
82 /******************************************************************************/
84 void AliEveTPCSector3DGL::DirectDraw(TGLRnrCtx & rnrCtx) const
88 // printf("AliEveTPCSector3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
90 if(fRTS < fSector->fRTS) {
91 fSector->UpdateBoxesAndPoints();
95 if (rnrCtx.SecSelection()) glPushName(0);
97 Bool_t hasData = (fSector->GetSectorData() != 0);
101 if (rnrCtx.SecSelection()) glLoadName(9999);
102 fBoxRnr->Render(rnrCtx);
105 glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
106 glDisable(GL_LIGHTING);
109 if(hasData && fSector->fPointSetOn)
112 glEnable(GL_POINT_SMOOTH);
113 glPointSize(fSector->fPointSize);
115 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
116 glEnableClientState(GL_VERTEX_ARRAY);
118 const TEvePointSetArray& psa = fSector->fPointSetArray;
119 for(Int_t b=0; b<psa.GetNBins(); ++b)
121 TEvePointSet* ps = psa.GetBin(b);
124 TEveUtil::TEveUtil::ColorFromIdx(ps->GetMarkerColor(), col);
127 if (rnrCtx.SecSelection()) glLoadName(b + 1);
128 glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
129 glDrawArrays(GL_POINTS, 0, ps->Size());
136 if(fSector->fRnrFrame && ! rnrCtx.SecSelection())
138 TEveUtil::TEveUtil::ColorFromIdx(fSector->fFrameColor, col);
142 DrawSegmentFrame(AliEveTPCSectorData::GetInnSeg(), 0, 2);
143 if(fSector->fRnrOut1)
144 DrawSegmentFrame(AliEveTPCSectorData::GetOut1Seg(), 2, 1);
145 if(fSector->fRnrOut2)
146 DrawSegmentFrame(AliEveTPCSectorData::GetOut2Seg(), 2, 2);
152 void AliEveTPCSector3DGL::DrawSegmentFrame(const AliEveTPCSectorData::SegmentInfo& s,
153 Int_t botExtraPads, Int_t topExtraPads) const
155 // Draw frame of given segment.
157 Float_t xl, xh, yl, yh, zl, zh;
158 xl = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
159 xh = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads);
161 yh = yl + s.GetNRows()*s.GetPadHeight();
163 zh = AliEveTPCSectorData::GetZLength();
165 glBegin(GL_LINE_LOOP);
166 glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl);
167 glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl);
169 glBegin(GL_LINE_LOOP);
170 glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh);
171 glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh);
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);
181 /******************************************************************************/
182 /******************************************************************************/
184 //______________________________________________________________________________
185 void AliEveTPCSector3DGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
187 // Processes secondary selection from TGLViewer.
188 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
189 // point as an argument.
191 if (rec.GetN() < 3) return;
193 if (rec.GetItem(1) == 9999)
195 printf("TPC3D Box selected idx=%u\n", rec.GetItem(2));
199 const TEvePointSetArray& psa = fSector->fPointSetArray;
201 if (rec.GetItem(1) > 0 && rec.GetItem(1) <= (UInt_t) psa.GetNBins())
203 // TEvePointSet& ps = * psa.GetBin(rec.GetItem(1) - 1);
204 printf("TPC3D Point selected, bin=%u, idx=%u\n", rec.GetItem(1) - 1, rec.GetItem(2));