]>
Commit | Line | Data |
---|---|---|
31eaa632 | 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 | ||
5d470a90 | 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 | ||
495f908e | 43 | void TrackGL::ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*) |
31eaa632 | 44 | { |
495f908e | 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); | |
5d470a90 | 58 | } |
59 | ||
60 | /**************************************************************************/ | |
61 | void TrackGL::DirectDraw(const TGLDrawFlags & flags) const | |
62 | { | |
85b3ce77 | 63 | // Render line and path marks |
64 | ||
5d470a90 | 65 | LineGL::DirectDraw(flags); |
85b3ce77 | 66 | |
5d470a90 | 67 | if ( ! fTrack->fPathMarks.empty()){ |
68 | ||
69 | TrackRnrStyle* rs = fTrack->GetRnrStyle(); | |
5d470a90 | 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; | |
85b3ce77 | 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 | { | |
5d470a90 | 86 | if (style == 4 || style == 24) |
87 | glEnable(GL_BLEND); | |
88 | glEnable(GL_POINT_SMOOTH); | |
85b3ce77 | 89 | } |
90 | else | |
91 | { | |
5d470a90 | 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; | |
85b3ce77 | 105 | switch((*i)->type) |
106 | { | |
5d470a90 | 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 | } | |
85b3ce77 | 117 | if(accept) |
118 | { | |
c06d7ff5 | 119 | if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && ((*i)->V.Perp() < rs->fMaxR)) |
5d470a90 | 120 | glVertex3f((*i)->V.x, (*i)->V.y,(*i)->V.z); |
5d470a90 | 121 | } |
122 | } | |
123 | glEnd(); | |
124 | } // end render points | |
85b3ce77 | 125 | else |
126 | { | |
127 | // crosses | |
128 | if ( style== 28) | |
129 | { | |
5d470a90 | 130 | glEnable(GL_BLEND); |
131 | glEnable(GL_LINE_SMOOTH); | |
132 | glLineWidth(2); | |
85b3ce77 | 133 | } |
134 | else | |
135 | { | |
5d470a90 | 136 | glDisable(GL_LINE_SMOOTH); |
137 | } | |
138 | ||
139 | glBegin(GL_LINES); | |
140 | Bool_t accept; | |
85b3ce77 | 141 | Float_t d = 2* rs->fPMSize; |
5d470a90 | 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; | |
85b3ce77 | 147 | switch((*i)->type) |
148 | { | |
5d470a90 | 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 | } | |
85b3ce77 | 159 | if(accept) |
160 | { | |
c06d7ff5 | 161 | if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && ((*i)->V.Perp() < rs->fMaxR)) |
85b3ce77 | 162 | { |
5d470a90 | 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 | |
5d470a90 | 172 | glPopAttrib(); |
173 | } //if PM not empty | |
31eaa632 | 174 | } |