]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/TrackGL.cxx
Record changes.
[u/mrichter/AliRoot.git] / EVE / Reve / TrackGL.cxx
1 // $Header$
2
3 #include "TrackGL.h"
4 #include <Reve/Track.h>
5
6 #include <TGLDrawFlags.h>
7
8 #ifdef WIN32
9 #include "Windows4root.h"
10 #endif
11 #include <GL/gl.h>
12 #include <GL/glu.h>
13
14 using namespace Reve;
15
16 //______________________________________________________________________
17 // TrackGL
18 //
19
20 ClassImp(TrackGL)
21
22 TrackGL::TrackGL() : LineGL()
23 {
24   // fCached = false; // Disable display list.
25 }
26
27 TrackGL::~TrackGL()
28 {}
29
30 /**************************************************************************/
31
32 Bool_t TrackGL::SetModel(TObject* obj)
33 {
34   if(LineGL::SetModel(obj) == kFALSE) return kFALSE;
35   if(SetModelCheckClass(obj, Track::Class())) {
36     fTrack = dynamic_cast<Track*>(obj);
37     return kTRUE;
38   }
39   return kFALSE;
40 }
41 /**************************************************************************/
42
43 void TrackGL::ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*)
44 {
45   // Processes secondary selection from TGLViewer.
46   // Calls TPointSet3D::PointSelected(Int_t) with index of selected
47   // point as an argument.
48
49   Int_t n = ptr[0];
50   printf("TrackGL::ProcessSelection %d names on the stack (z1=%g, z2=%g).\n",
51          n, Float_t(ptr[1])/0x7fffffff, Float_t(ptr[2])/0x7fffffff);
52   ptr += 3;
53   printf("  Names: ");
54   for (Int_t j=0; j<n; ++j, ++ptr) printf ("%d ", *ptr);
55   printf("\n");
56
57   ((Track*)fM)->CtrlClicked((Track*)fM);
58 }
59
60 /**************************************************************************/
61 void TrackGL::DirectDraw(const TGLDrawFlags & flags) const
62 {
63   // Render line and path marks
64
65   LineGL::DirectDraw(flags);
66
67   if ( ! fTrack->fPathMarks.empty()){
68
69     TrackRnrStyle* rs = fTrack->GetRnrStyle();
70     Int_t  style = rs->fPMStyle;
71
72     UChar_t color[4];
73     ColorFromIdx(rs->fPMColor, color);
74     glColor4ubv(color);
75     
76     glPushAttrib(GL_POINT_BIT | GL_LINE_BIT | GL_ENABLE_BIT);
77     glDisable(GL_LIGHTING);
78
79     Int_t ms = rs->fPMStyle;
80     // points
81     if (ms != 2 && ms != 3 && ms != 5 && ms != 28) 
82     {
83       Float_t size = 5*rs->fPMSize;
84       if (style == 4 || style == 20 || style == 24) 
85       {
86         if (style == 4 || style == 24)
87           glEnable(GL_BLEND);
88         glEnable(GL_POINT_SMOOTH);
89       } 
90       else 
91       {
92         glDisable(GL_POINT_SMOOTH);
93         if      (style == 1) size = 1;
94         else if (style == 6) size = 2;
95         else if (style == 7) size = 3;
96       }
97       glPointSize(size);
98
99       glBegin(GL_POINTS);
100       Bool_t accept;
101       std::vector<PathMark*>& pm = fTrack->fPathMarks;
102       for(std::vector<PathMark*>::iterator i=pm.begin(); i!=pm.end(); ++i) 
103       {
104         accept = kFALSE;
105         switch((*i)->type)
106         {
107           case(PathMark::Daughter):
108             if(rs->fRnrDaughters) accept = kTRUE;
109             break;
110           case(PathMark::Reference):
111             if(rs->fRnrReferences) accept = kTRUE;
112             break;
113           case(PathMark::Decay):
114             if(rs->fRnrDecay) accept = kTRUE;
115             break;
116         } 
117         if(accept)
118         {
119           if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && ((*i)->V.Perp() < rs->fMaxR))
120             glVertex3f((*i)->V.x, (*i)->V.y,(*i)->V.z);
121         }
122       } 
123       glEnd();
124     } // end render points
125     else 
126     {
127       // crosses
128       if ( style== 28) 
129       {
130         glEnable(GL_BLEND);
131         glEnable(GL_LINE_SMOOTH);
132         glLineWidth(2);
133       } 
134       else 
135       {
136         glDisable(GL_LINE_SMOOTH);
137       }
138
139       glBegin(GL_LINES);
140       Bool_t accept;
141       Float_t d = 2* rs->fPMSize;
142       Float_t p[3];
143       std::vector<PathMark*>& pm = fTrack->fPathMarks;     
144       for(std::vector<PathMark*>::iterator i=pm.begin(); i!=pm.end(); ++i) 
145       {
146         accept = kFALSE;
147         switch((*i)->type)
148         {
149           case(PathMark::Daughter):
150             if(rs->fRnrDaughters) accept = kTRUE;
151             break;
152           case(PathMark::Reference):
153             if(rs->fRnrReferences) accept = kTRUE;
154             break;
155           case(PathMark::Decay):
156             if(rs->fRnrDecay) accept = kTRUE;
157             break;
158         } 
159         if(accept)
160         {
161           if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && ((*i)->V.Perp() < rs->fMaxR))
162           {
163             p[0] = (*i)->V.x; p[1] = (*i)->V.y; p[2] = (*i)->V.z;
164             glVertex3f(p[0]-d, p[1], p[2]); glVertex3f(p[0]+d, p[1], p[2]);
165             glVertex3f(p[0], p[1]-d, p[2]); glVertex3f(p[0], p[1]+d, p[2]);
166             glVertex3f(p[0], p[1], p[2]-d); glVertex3f(p[0], p[1], p[2]+d);
167           }
168         }
169       } 
170       glEnd();
171     } // end render corsses
172     glPopAttrib();
173   } //if PM not empty
174 }