Two new items for context menu: PrintPathMarks and ImportDaughters.
[u/mrichter/AliRoot.git] / EVE / Reve / TrackGL.cxx
CommitLineData
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
14using namespace Reve;
15
16//______________________________________________________________________
17// TrackGL
18//
19
20ClassImp(TrackGL)
21
22TrackGL::TrackGL() : LineGL()
23{
24 // fCached = false; // Disable display list.
25}
26
27TrackGL::~TrackGL()
28{}
29
30/**************************************************************************/
31
5d470a90 32Bool_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 43void 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/**************************************************************************/
61void TrackGL::DirectDraw(const TGLDrawFlags & flags) const
62{
63 LineGL::DirectDraw(flags);
64 // render path marks
65 if ( ! fTrack->fPathMarks.empty()){
66
67 TrackRnrStyle* rs = fTrack->GetRnrStyle();
68 Float_t size = 5*rs->fPMSize;
69 Int_t style = rs->fPMStyle;
70
71 UChar_t color[4];
72 ColorFromIdx(rs->fPMColor, color);
73 glColor4ubv(color);
74
75 glPushAttrib(GL_POINT_BIT | GL_LINE_BIT | GL_ENABLE_BIT);
76 glDisable(GL_LIGHTING);
77
78 Int_t ms = rs->fPMStyle;
79 // render points
80 if (ms != 2 && ms != 3 && ms != 5 && ms != 28) {
81 if (style == 4 || style == 20 || style == 24) {
82 if (style == 4 || style == 24)
83 glEnable(GL_BLEND);
84 glEnable(GL_POINT_SMOOTH);
85 } else {
86 glDisable(GL_POINT_SMOOTH);
87 if (style == 1) size = 1;
88 else if (style == 6) size = 2;
89 else if (style == 7) size = 3;
90 }
91 glPointSize(size);
92
93 glBegin(GL_POINTS);
94 Bool_t accept;
95 std::vector<PathMark*>& pm = fTrack->fPathMarks;
96 for(std::vector<PathMark*>::iterator i=pm.begin(); i!=pm.end(); ++i)
97 {
98 accept = kFALSE;
99 switch((*i)->type){
100 case(PathMark::Daughter):
101 if(rs->fRnrDaughters) accept = kTRUE;
102 break;
103 case(PathMark::Reference):
104 if(rs->fRnrReferences) accept = kTRUE;
105 break;
106 case(PathMark::Decay):
107 if(rs->fRnrDecay) accept = kTRUE;
108 break;
109 }
110 if(accept){
111 if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && (*i)->V.Perp() < rs->fMaxR*rs->fMaxR){
112 glVertex3f((*i)->V.x, (*i)->V.y,(*i)->V.z);
113 }
114 }
115 }
116 glEnd();
117 } // end render points
118 else {
119 // render crosses
120 if ( style== 28) {
121 glEnable(GL_BLEND);
122 glEnable(GL_LINE_SMOOTH);
123 glLineWidth(2);
124 } else {
125 glDisable(GL_LINE_SMOOTH);
126 }
127
128 glBegin(GL_LINES);
129 Bool_t accept;
130 Float_t d = size;
131 Float_t p[3];
132 std::vector<PathMark*>& pm = fTrack->fPathMarks;
133 for(std::vector<PathMark*>::iterator i=pm.begin(); i!=pm.end(); ++i)
134 {
135 accept = kFALSE;
136 switch((*i)->type){
137 case(PathMark::Daughter):
138 if(rs->fRnrDaughters) accept = kTRUE;
139 break;
140 case(PathMark::Reference):
141 if(rs->fRnrReferences) accept = kTRUE;
142 break;
143 case(PathMark::Decay):
144 if(rs->fRnrDecay) accept = kTRUE;
145 break;
146 }
147 if(accept){
148 // check RS boundraries
149 if((TMath::Abs((*i)->V.z) < rs->fMaxZ) && (*i)->V.Perp() < rs->fMaxR*rs->fMaxR){
150 p[0] = (*i)->V.x; p[1] = (*i)->V.y; p[2] = (*i)->V.z;
151 glVertex3f(p[0]-d, p[1], p[2]); glVertex3f(p[0]+d, p[1], p[2]);
152 glVertex3f(p[0], p[1]-d, p[2]); glVertex3f(p[0], p[1]+d, p[2]);
153 glVertex3f(p[0], p[1], p[2]-d); glVertex3f(p[0], p[1], p[2]+d);
154 }
155 }
156 }
157 glEnd();
158 } // end render corsses
495f908e 159
5d470a90 160 glPopAttrib();
161 } //if PM not empty
31eaa632 162}