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 <Alieve/AliEveTPCSector3D.h>
13 #include <TEveBoxSetGL.h>
15 #include <TGLIncludes.h>
16 #include <TGLRnrCtx.h>
17 #include <TGLSelectRecord.h>
20 //______________________________________________________________________
21 // AliEveTPCSector3DGL
24 ClassImp(AliEveTPCSector3DGL)
26 AliEveTPCSector3DGL::AliEveTPCSector3DGL() :
28 fSector(0), fBoxRnr(0),
31 // fDLCache = false; // Disable display list.
34 AliEveTPCSector3DGL::~AliEveTPCSector3DGL()
39 /**************************************************************************/
41 //______________________________________________________________________________
42 Short_t AliEveTPCSector3DGL::QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
44 // Factor in scene/viewer LOD and quantize.
46 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
51 return (Short_t)(10 * TMath::Nint(0.1*lod));
54 /**************************************************************************/
56 Bool_t AliEveTPCSector3DGL::SetModel(TObject* obj, const Option_t* /*opt*/)
58 if(SetModelCheckClass(obj, AliEveTPCSector3D::Class())) {
59 fSector = (AliEveTPCSector3D*) fExternalObj;
61 fBoxRnr = new TEveBoxSetGL;
62 fBoxRnr->SetModel(&fSector->fBoxSet);
69 void AliEveTPCSector3DGL::SetBBox()
71 SetAxisAlignedBBox(((AliEveTPCSector3D*)fExternalObj)->AssertBBox());
74 /**************************************************************************/
76 void AliEveTPCSector3DGL::DirectDraw(TGLRnrCtx & rnrCtx) const
78 // printf("AliEveTPCSector3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
80 if(fRTS < fSector->fRTS) {
81 fSector->UpdateBoxes();
85 if (rnrCtx.SecSelection()) glPushName(0);
87 Bool_t hasData = (fSector->GetSectorData() != 0);
91 if (rnrCtx.SecSelection()) glLoadName(9999);
92 fBoxRnr->Render(rnrCtx);
95 glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
96 glDisable(GL_LIGHTING);
99 if(hasData && fSector->fPointSetOn)
102 glEnable(GL_POINT_SMOOTH);
103 glPointSize(fSector->fPointSize);
105 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
106 glEnableClientState(GL_VERTEX_ARRAY);
108 const TEvePointSetArray& psa = fSector->fPointSetArray;
109 for(Int_t b=0; b<psa.GetNBins(); ++b)
111 TEvePointSet* ps = psa.GetBin(b);
114 TEveUtil::TEveUtil::ColorFromIdx(ps->GetMarkerColor(), col);
117 if (rnrCtx.SecSelection()) glLoadName(b + 1);
118 glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
119 glDrawArrays(GL_POINTS, 0, ps->Size());
126 if(fSector->fRnrFrame && ! rnrCtx.SecSelection())
128 TEveUtil::TEveUtil::ColorFromIdx(fSector->fFrameColor, col);
132 DrawSegmentFrame(AliEveTPCSectorData::GetInnSeg(), 0, 2);
133 if(fSector->fRnrOut1)
134 DrawSegmentFrame(AliEveTPCSectorData::GetOut1Seg(), 2, 1);
135 if(fSector->fRnrOut2)
136 DrawSegmentFrame(AliEveTPCSectorData::GetOut2Seg(), 2, 2);
142 void AliEveTPCSector3DGL::DrawSegmentFrame(const AliEveTPCSectorData::SegmentInfo& s,
143 Int_t botExtraPads, Int_t topExtraPads) const
145 Float_t xl, xh, yl, yh, zl, zh;
146 xl = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
147 xh = 0.5*s.GetPadWidth()*(AliEveTPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads);
149 yh = yl + s.GetNRows()*s.GetPadHeight();
151 zh = AliEveTPCSectorData::GetZLength();
153 glBegin(GL_LINE_LOOP);
154 glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl);
155 glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl);
157 glBegin(GL_LINE_LOOP);
158 glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh);
159 glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh);
162 glVertex3f( xl, yl, zl); glVertex3f( xl, yl, zh);
163 glVertex3f( xh, yh, zl); glVertex3f( xh, yh, zh);
164 glVertex3f(-xh, yh, zl); glVertex3f(-xh, yh, zh);
165 glVertex3f(-xl, yl, zl); glVertex3f(-xl, yl, zh);
169 /**************************************************************************/
170 /**************************************************************************/
172 //______________________________________________________________________________
173 void AliEveTPCSector3DGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
175 // Processes secondary selection from TGLViewer.
176 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
177 // point as an argument.
179 if (rec.GetN() < 3) return;
181 if (rec.GetItem(1) == 9999)
183 printf("TPC3D Box selected idx=%u\n", rec.GetItem(2));
187 const TEvePointSetArray& psa = fSector->fPointSetArray;
189 if (rec.GetItem(1) > 0 && rec.GetItem(1) <= (UInt_t) psa.GetNBins())
191 // TEvePointSet& ps = * psa.GetBin(rec.GetItem(1) - 1);
192 printf("TPC3D Point selected, bin=%u, idx=%u\n", rec.GetItem(1) - 1, rec.GetItem(2));