]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/NLTTrackGL.cxx
First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / EVE / Reve / NLTTrackGL.cxx
1 // $Header$
2
3 #include "NLTTrackGL.h"
4 #include <Reve/NLTTrack.h>
5 #include <Reve/NLTProjector.h>
6 #include <Reve/GLUtilNS.h>
7
8 #include <TGLRnrCtx.h>
9 #include <TGLIncludes.h>
10
11 using namespace Reve;
12
13 //______________________________________________________________________
14 // NLTTrackGL
15 //
16
17 ClassImp(NLTTrackGL)
18
19 NLTTrackGL::NLTTrackGL() : TrackGL(), fM(0)
20 {
21   // fDLCache = kFALSE; // Disable display list.
22 }
23
24 NLTTrackGL::~NLTTrackGL()
25 {}
26
27 /**************************************************************************/
28
29 Bool_t NLTTrackGL::SetModel(TObject* obj, const Option_t* /*opt*/)
30 {
31   if(TrackGL::SetModel(obj) == kFALSE) return kFALSE;
32   if(SetModelCheckClass(obj, NLTTrack::Class())) {
33     fM = dynamic_cast<NLTTrack*>(obj);
34     return kTRUE;
35   }
36   return kFALSE;
37 }
38
39 /**************************************************************************/
40
41 void NLTTrackGL::DirectDraw(TGLRnrCtx & rnrCtx) const
42 {
43   // printf("NLTTrackGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
44   if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine || fM->Size() == 0)
45     return;
46
47   // lines
48   Int_t start = 0;
49   Float_t* p = fM->GetP();
50   for (std::vector<Int_t>::iterator bpi = fM->fBreakPoints.begin();
51        bpi != fM->fBreakPoints.end(); ++bpi)
52   {
53     Int_t size = *bpi - start;
54     if (fM->fRnrLine)   GLUtilNS::RenderLine(*fM, p, size);
55     if (fM->fRnrPoints) GLUtilNS::RenderPolyMarkers(*fM, p, size);
56     p     += 3*size;
57     start +=   size;
58   }
59
60   // path-marks
61   std::vector<PathMark*>& pm = fM->fPathMarks;
62   TrackRnrStyle& RS = *fM->GetRnrStyle();
63   if(pm.size())
64   {
65     Float_t* pnts = new Float_t[3*pm.size()]; // maximum
66     Int_t N = 0;
67     Bool_t accept;
68     for(std::vector<PathMark*>::iterator i=pm.begin(); i!=pm.end(); ++i) 
69     {
70       accept = kFALSE;
71       switch((*i)->type)
72       {
73         case(PathMark::Daughter):
74           if(RS.fRnrDaughters) accept = kTRUE;
75           break;
76         case(PathMark::Reference):
77           if(RS.fRnrReferences) accept = kTRUE;
78           break;
79         case(PathMark::Decay):
80           if(RS.fRnrDecay) accept = kTRUE;
81           break;
82       } 
83       if(accept)
84       {
85         if((TMath::Abs((*i)->V.z) < RS.fMaxZ) && ((*i)->V.Perp() < RS.fMaxR))
86         {
87           pnts[3*N  ] =(*i)->V.x;
88           pnts[3*N+1] =(*i)->V.y; 
89           pnts[3*N+2] =(*i)->V.z;
90           fM->fProjection->ProjectPoint(pnts[3*N  ], pnts[3*N+1], pnts[3*N+2]);
91           N++;
92         }
93       }
94     } 
95     GLUtilNS::RenderPolyMarkers(RS.fPMAtt, pnts, N);
96     delete [] pnts;
97   }
98
99   // fist vertex
100   if(RS.fRnrFV && fTrack->GetLastPoint())
101     GLUtilNS::RenderPolyMarkers(RS.fFVAtt, fTrack->GetP(), 1);
102 }