]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
fafff680 | 2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007 |
d810d0de | 3 | |
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
37b09b91 | 9 | |
eadce74d | 10 | #include <Riostream.h> |
11 | ||
37b09b91 | 12 | #include <TMath.h> |
13 | ||
d810d0de | 14 | #include "AliEveMUONChamberGL.h" |
3626c858 | 15 | |
cb4245bb | 16 | #include <EveDet/AliEveMUONChamber.h> |
17 | #include <EveDet/AliEveMUONChamberData.h> | |
3626c858 | 18 | |
84aff7a4 | 19 | #include <TEveQuadSetGL.h> |
19208112 | 20 | #include <TGLRnrCtx.h> |
21 | #include <TGLIncludes.h> | |
d810d0de | 22 | |
3626c858 | 23 | |
57ffa5fb | 24 | //______________________________________________________________________________ |
d810d0de | 25 | // AliEveMUONChamberGL |
3626c858 | 26 | // |
27 | ||
d810d0de | 28 | ClassImp(AliEveMUONChamberGL) |
3626c858 | 29 | |
57ffa5fb | 30 | //______________________________________________________________________________ |
d810d0de | 31 | AliEveMUONChamberGL::AliEveMUONChamberGL() : |
3626c858 | 32 | TGLObject(), |
33 | fChamber(0), | |
c76ea574 | 34 | fQS1(), fQS2(), |
3626c858 | 35 | fRTS(0) |
36 | { | |
37 | // | |
38 | // constructor | |
39 | // | |
40 | ||
41 | } | |
42 | ||
57ffa5fb | 43 | //______________________________________________________________________________ |
d810d0de | 44 | AliEveMUONChamberGL::~AliEveMUONChamberGL() |
3626c858 | 45 | { |
46 | // | |
47 | // destructor | |
48 | // | |
49 | ||
50 | } | |
51 | ||
57ffa5fb | 52 | //______________________________________________________________________________ |
d810d0de | 53 | Bool_t AliEveMUONChamberGL::SetModel(TObject* obj, const Option_t* /*opt*/) |
3626c858 | 54 | { |
55 | // | |
56 | // ... | |
57 | // | |
58 | ||
d810d0de | 59 | if(SetModelCheckClass(obj, AliEveMUONChamber::Class())) { |
51346b82 | 60 | |
d810d0de | 61 | fChamber = (AliEveMUONChamber*) fExternalObj; |
84aff7a4 | 62 | fQS1.SetModel(&fChamber->fQuadSet1); |
63 | fQS2.SetModel(&fChamber->fQuadSet2); | |
3626c858 | 64 | return kTRUE; |
65 | ||
66 | } | |
67 | ||
68 | return kFALSE; | |
69 | ||
70 | } | |
71 | ||
57ffa5fb | 72 | //______________________________________________________________________________ |
d810d0de | 73 | void AliEveMUONChamberGL::SetBBox() |
3626c858 | 74 | { |
75 | // | |
76 | // ... | |
77 | // | |
78 | ||
d810d0de | 79 | SetAxisAlignedBBox(((AliEveMUONChamber*)fExternalObj)->AssertBBox()); |
3626c858 | 80 | |
81 | } | |
82 | ||
57ffa5fb | 83 | //______________________________________________________________________________ |
d810d0de | 84 | void AliEveMUONChamberGL::DirectDraw(TGLRnrCtx& rnrCtx) const |
3626c858 | 85 | { |
86 | // | |
87 | // Actual GL drawing. | |
88 | // | |
89 | ||
90 | glDisable(GL_LIGHTING); | |
91 | ||
92 | //Double_t width = 10; | |
93 | //glOrtho(-width,+width,-width,+width,-width,+width); | |
94 | ||
95 | if(fRTS < fChamber->fRTS) { | |
96 | fChamber->UpdateQuads(); | |
97 | fRTS = fChamber->fRTS; | |
98 | } | |
51346b82 | 99 | |
3626c858 | 100 | Bool_t hasData = (fChamber->GetChamberData() != 0); |
51346b82 | 101 | |
3626c858 | 102 | if(hasData) { |
103 | ||
84aff7a4 | 104 | DrawQuads(rnrCtx); |
eadce74d | 105 | DrawPoints(); |
51346b82 | 106 | |
3626c858 | 107 | } |
108 | ||
109 | DrawChamberFrame(); | |
110 | ||
111 | } | |
112 | ||
57ffa5fb | 113 | //______________________________________________________________________________ |
d810d0de | 114 | void AliEveMUONChamberGL::DrawQuads(TGLRnrCtx& rnrCtx) const |
3626c858 | 115 | { |
116 | // | |
117 | // draw the digits as GL_QUADS | |
118 | // | |
119 | ||
120 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
121 | ||
122 | glDisable(GL_LIGHTING); | |
123 | glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | |
124 | glEnable(GL_COLOR_MATERIAL); | |
125 | glDisable(GL_CULL_FACE); | |
126 | ||
127 | //Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c); | |
128 | ||
129 | glPolygonMode(GL_FRONT, GL_FILL); | |
130 | glPolygonMode(GL_BACK, GL_LINE); | |
131 | ||
84aff7a4 | 132 | fQS1.DirectDraw(rnrCtx); |
3626c858 | 133 | |
134 | glPolygonMode(GL_FRONT, GL_LINE); | |
135 | glPolygonMode(GL_BACK, GL_FILL); | |
136 | ||
84aff7a4 | 137 | fQS2.DirectDraw(rnrCtx); |
3626c858 | 138 | |
139 | glPopAttrib(); | |
140 | ||
141 | } | |
142 | ||
57ffa5fb | 143 | //______________________________________________________________________________ |
d810d0de | 144 | void AliEveMUONChamberGL::DrawPoints() const |
eadce74d | 145 | { |
146 | // | |
147 | // draw the clusters as GL_QUADS | |
148 | // | |
149 | ||
150 | Float_t x, y, z; | |
151 | ||
152 | glDisable(GL_LIGHTING); | |
153 | glLineWidth(1.0); | |
154 | ||
155 | glColor3f(1.0,1.0,1.0); | |
51346b82 | 156 | |
eadce74d | 157 | glBegin(GL_LINES); |
51346b82 | 158 | |
eadce74d | 159 | // clusters |
160 | ||
161 | Int_t clsSize = fChamber->fClusterSize; | |
162 | ||
163 | if (clsSize > 1) { | |
164 | ||
165 | for (Int_t i = 0; i < fChamber->fPointSet1.GetN(); i++) { | |
51346b82 | 166 | |
eadce74d | 167 | fChamber->fPointSet1.GetPoint(i,x,y,z); |
168 | ||
169 | glVertex3f(x-clsSize,y+clsSize,z); | |
170 | glVertex3f(x+clsSize,y-clsSize,z); | |
51346b82 | 171 | |
eadce74d | 172 | glVertex3f(x-clsSize,y-clsSize,z); |
173 | glVertex3f(x+clsSize,y+clsSize,z); | |
51346b82 | 174 | |
eadce74d | 175 | } |
51346b82 | 176 | |
eadce74d | 177 | } |
178 | ||
179 | // hits | |
180 | ||
181 | Int_t hitSize = fChamber->fHitSize; | |
182 | ||
183 | if (hitSize > 1) { | |
184 | ||
185 | for (Int_t i = 0; i < fChamber->fPointSet2.GetN(); i++) { | |
51346b82 | 186 | |
eadce74d | 187 | fChamber->fPointSet2.GetPoint(i,x,y,z); |
51346b82 | 188 | |
eadce74d | 189 | glVertex3f(x-hitSize,y,z); |
190 | glVertex3f(x+hitSize,y,z); | |
51346b82 | 191 | |
eadce74d | 192 | glVertex3f(x,y-hitSize,z); |
193 | glVertex3f(x,y+hitSize,z); | |
51346b82 | 194 | |
eadce74d | 195 | } |
51346b82 | 196 | |
eadce74d | 197 | } |
198 | ||
199 | glEnd(); | |
51346b82 | 200 | |
eadce74d | 201 | } |
202 | ||
57ffa5fb | 203 | //______________________________________________________________________________ |
d810d0de | 204 | void AliEveMUONChamberGL::DrawChamberFrame() const |
3626c858 | 205 | { |
206 | // | |
207 | // draw the chamber frame as GL_LINE_LOOP | |
51346b82 | 208 | // |
3626c858 | 209 | |
d810d0de | 210 | AliEveMUONChamberData* chamberData = fChamber->GetChamberData(); |
3626c858 | 211 | Int_t nDetElem = chamberData->GetNDetElem(); |
212 | Float_t *frameCoord; | |
213 | Float_t xOrig, yOrig, xRad, yRad, x, y, z; | |
214 | ||
215 | UChar_t pix[4]; | |
216 | pix[0] = 255; | |
217 | pix[1] = 0; | |
218 | pix[2] = 0; | |
219 | pix[3] = 255; | |
220 | ||
221 | glColor4ubv(pix); | |
51346b82 | 222 | |
3626c858 | 223 | for (Int_t id = 0; id < nDetElem; id++) { |
224 | ||
225 | frameCoord = chamberData->GetFrameCoord(id); | |
226 | ||
227 | if (fChamber->GetID() < 4) { | |
228 | ||
229 | xOrig = frameCoord[0]; | |
230 | yOrig = frameCoord[1]; | |
231 | xRad = frameCoord[2]; | |
232 | yRad = frameCoord[3]; | |
233 | z = frameCoord[4]; | |
51346b82 | 234 | |
fafff680 | 235 | if (fChamber->GetID() < 2) { |
236 | xRad += TMath::Sign(15.0,(Double_t)xRad); | |
237 | yRad += TMath::Sign(15.0,(Double_t)yRad); | |
238 | } else { | |
239 | xRad += TMath::Sign( 5.0,(Double_t)xRad); | |
240 | yRad += TMath::Sign( 5.0,(Double_t)yRad); | |
241 | } | |
3626c858 | 242 | |
243 | glBegin(GL_LINE_LOOP); | |
244 | ||
245 | glVertex3f(xOrig,yOrig,z); | |
51346b82 | 246 | |
3626c858 | 247 | Int_t nstep = 100; |
248 | Float_t dstep = TMath::Pi()/2.0 / (Float_t)nstep; | |
249 | Float_t d; | |
250 | for (Int_t istep = 0; istep < nstep; istep++) { | |
251 | ||
252 | d = istep * dstep; | |
253 | x = xOrig + xRad * TMath::Cos(d); | |
254 | y = yOrig + yRad * TMath::Sin(d); | |
255 | ||
256 | glVertex3f(x,y,z); | |
257 | ||
258 | } | |
51346b82 | 259 | |
3626c858 | 260 | glVertex3f(xOrig,yOrig,z); |
261 | ||
262 | glEnd(); | |
263 | ||
264 | } else { | |
265 | ||
266 | glBegin(GL_LINE_LOOP); | |
267 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
268 | glVertex3f(frameCoord[0],frameCoord[3],frameCoord[4]); | |
269 | glVertex3f(frameCoord[2],frameCoord[3],frameCoord[4]); | |
270 | glVertex3f(frameCoord[2],frameCoord[1],frameCoord[4]); | |
271 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
272 | glEnd(); | |
273 | ||
274 | } | |
275 | ||
276 | } | |
277 | ||
278 | } |