3 #include "TPCSector3DGL.h"
4 #include <Alieve/TPCSector3D.h>
6 #include <TEveBoxSetGL.h>
8 #include <TGLIncludes.h>
10 #include <TGLSelectRecord.h>
11 using namespace Alieve;
13 //______________________________________________________________________
17 ClassImp(TPCSector3DGL)
19 TPCSector3DGL::TPCSector3DGL() :
21 fSector(0), fBoxRnr(0),
24 // fDLCache = false; // Disable display list.
27 TPCSector3DGL::~TPCSector3DGL()
32 /**************************************************************************/
34 //______________________________________________________________________________
35 Short_t TPCSector3DGL::QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
37 // Factor in scene/viewer LOD and quantize.
39 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
44 return (Short_t)(10 * TMath::Nint(0.1*lod));
47 /**************************************************************************/
49 Bool_t TPCSector3DGL::SetModel(TObject* obj, const Option_t* /*opt*/)
51 if(SetModelCheckClass(obj, Alieve::TPCSector3D::Class())) {
52 fSector = (TPCSector3D*) fExternalObj;
54 fBoxRnr = new TEveBoxSetGL;
55 fBoxRnr->SetModel(&fSector->fBoxSet);
62 void TPCSector3DGL::SetBBox()
64 SetAxisAlignedBBox(((TPCSector3D*)fExternalObj)->AssertBBox());
67 /**************************************************************************/
69 void TPCSector3DGL::DirectDraw(TGLRnrCtx & rnrCtx) const
71 // printf("TPCSector3DGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
73 if(fRTS < fSector->fRTS) {
74 fSector->UpdateBoxes();
78 if (rnrCtx.SecSelection()) glPushName(0);
80 Bool_t hasData = (fSector->GetSectorData() != 0);
84 if (rnrCtx.SecSelection()) glLoadName(9999);
85 fBoxRnr->Render(rnrCtx);
88 glPushAttrib(GL_CURRENT_BIT | GL_POINT_BIT | GL_ENABLE_BIT);
89 glDisable(GL_LIGHTING);
92 if(hasData && fSector->fPointSetOn)
95 glEnable(GL_POINT_SMOOTH);
96 glPointSize(fSector->fPointSize);
98 glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
99 glEnableClientState(GL_VERTEX_ARRAY);
101 const TEvePointSetArray& psa = fSector->fPointSetArray;
102 for(Int_t b=0; b<psa.GetNBins(); ++b)
104 TEvePointSet* ps = psa.GetBin(b);
107 TEveUtil::ColorFromIdx(ps->GetMarkerColor(), col);
110 if (rnrCtx.SecSelection()) glLoadName(b + 1);
111 glVertexPointer(3, GL_FLOAT, 0, ps->GetP());
112 glDrawArrays(GL_POINTS, 0, ps->Size());
119 if(fSector->fRnrFrame && ! rnrCtx.SecSelection())
121 TEveUtil::ColorFromIdx(fSector->fFrameColor, col);
125 DrawSegmentFrame(TPCSectorData::GetInnSeg(), 0, 2);
126 if(fSector->fRnrOut1)
127 DrawSegmentFrame(TPCSectorData::GetOut1Seg(), 2, 1);
128 if(fSector->fRnrOut2)
129 DrawSegmentFrame(TPCSectorData::GetOut2Seg(), 2, 2);
135 void TPCSector3DGL::DrawSegmentFrame(const TPCSectorData::SegmentInfo& s,
136 Int_t botExtraPads, Int_t topExtraPads) const
138 Float_t xl, xh, yl, yh, zl, zh;
139 xl = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetFirstRow()) + botExtraPads);
140 xh = 0.5*s.GetPadWidth()*(TPCSectorData::GetNPadsInRow(s.GetLastRow()) + topExtraPads);
142 yh = yl + s.GetNRows()*s.GetPadHeight();
144 zh = TPCSectorData::GetZLength();
146 glBegin(GL_LINE_LOOP);
147 glVertex3f( xl, yl, zl); glVertex3f( xh, yh, zl);
148 glVertex3f(-xh, yh, zl); glVertex3f(-xl, yl, zl);
150 glBegin(GL_LINE_LOOP);
151 glVertex3f( xl, yl, zh); glVertex3f( xh, yh, zh);
152 glVertex3f(-xh, yh, zh); glVertex3f(-xl, yl, zh);
155 glVertex3f( xl, yl, zl); glVertex3f( xl, yl, zh);
156 glVertex3f( xh, yh, zl); glVertex3f( xh, yh, zh);
157 glVertex3f(-xh, yh, zl); glVertex3f(-xh, yh, zh);
158 glVertex3f(-xl, yl, zl); glVertex3f(-xl, yl, zh);
162 /**************************************************************************/
163 /**************************************************************************/
165 //______________________________________________________________________________
166 void TPCSector3DGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
168 // Processes secondary selection from TGLViewer.
169 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
170 // point as an argument.
172 if (rec.GetN() < 3) return;
174 if (rec.GetItem(1) == 9999)
176 printf("TPC3D Box selected idx=%u\n", rec.GetItem(2));
180 const TEvePointSetArray& psa = fSector->fPointSetArray;
182 if (rec.GetItem(1) > 0 && rec.GetItem(1) <= (UInt_t) psa.GetNBins())
184 // TEvePointSet& ps = * psa.GetBin(rec.GetItem(1) - 1);
185 printf("TPC3D Point selected, bin=%u, idx=%u\n", rec.GetItem(1) - 1, rec.GetItem(2));