]>
Commit | Line | Data |
---|---|---|
37b09b91 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
eadce74d | 18 | #include <Riostream.h> |
19 | ||
37b09b91 | 20 | #include <TMath.h> |
21 | ||
3626c858 | 22 | #include "MUONChamberGL.h" |
23 | ||
24 | #include <Alieve/MUONChamber.h> | |
25 | #include <Alieve/MUONChamberData.h> | |
26 | ||
27 | #include <TGLDrawFlags.h> | |
28 | #include <Reve/QuadSetGL.h> | |
29 | #include <GL/gl.h> | |
30 | #include <GL/glu.h> | |
31 | ||
32 | using namespace Reve; | |
33 | using namespace Alieve; | |
34 | ||
35 | //______________________________________________________________________ | |
36 | // MUONChamberGL | |
37 | // | |
38 | ||
39 | ClassImp(MUONChamberGL) | |
40 | ||
41 | //______________________________________________________________________ | |
42 | MUONChamberGL::MUONChamberGL() : | |
43 | TGLObject(), | |
44 | fChamber(0), | |
45 | fRTS(0) | |
46 | { | |
47 | // | |
48 | // constructor | |
49 | // | |
50 | ||
51 | } | |
52 | ||
53 | //______________________________________________________________________ | |
54 | MUONChamberGL::~MUONChamberGL() | |
55 | { | |
56 | // | |
57 | // destructor | |
58 | // | |
59 | ||
60 | } | |
61 | ||
62 | //______________________________________________________________________ | |
63 | Bool_t MUONChamberGL::SetModel(TObject* obj) | |
64 | { | |
65 | // | |
66 | // ... | |
67 | // | |
68 | ||
69 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
70 | if(set_model(obj, "Alieve::MUONChamber")) { | |
71 | #elif ROOT_VERSION_CODE <= ROOT_VERSION(5,13,0) | |
72 | if(SetModelCheckClass(obj, "Alieve::MUONChamber")) { | |
73 | #else | |
74 | if(SetModelCheckClass(obj, Alieve::MUONChamber::Class())) { | |
75 | #endif | |
76 | ||
77 | fChamber = (MUONChamber*) fExternalObj; | |
78 | ||
79 | return kTRUE; | |
80 | ||
81 | } | |
82 | ||
83 | return kFALSE; | |
84 | ||
85 | } | |
86 | ||
87 | //______________________________________________________________________ | |
88 | void MUONChamberGL::SetBBox() | |
89 | { | |
90 | // | |
91 | // ... | |
92 | // | |
93 | ||
94 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
95 | set_axis_aligned_bbox(((MUONChamber*)fExternalObj)->AssertBBox()); | |
96 | #else | |
97 | SetAxisAlignedBBox(((MUONChamber*)fExternalObj)->AssertBBox()); | |
98 | #endif | |
99 | ||
100 | } | |
101 | ||
102 | //______________________________________________________________________ | |
103 | void MUONChamberGL::DirectDraw(const TGLDrawFlags& /*flags*/) const | |
104 | { | |
105 | // | |
106 | // Actual GL drawing. | |
107 | // | |
108 | ||
109 | glDisable(GL_LIGHTING); | |
110 | ||
111 | //Double_t width = 10; | |
112 | //glOrtho(-width,+width,-width,+width,-width,+width); | |
113 | ||
114 | if(fRTS < fChamber->fRTS) { | |
115 | fChamber->UpdateQuads(); | |
116 | fRTS = fChamber->fRTS; | |
117 | } | |
118 | ||
119 | Bool_t hasData = (fChamber->GetChamberData() != 0); | |
120 | ||
121 | if(hasData) { | |
122 | ||
123 | DrawQuads(); | |
eadce74d | 124 | DrawPoints(); |
3626c858 | 125 | |
126 | } | |
127 | ||
128 | DrawChamberFrame(); | |
129 | ||
130 | } | |
131 | ||
132 | //______________________________________________________________________ | |
133 | void MUONChamberGL::DrawQuads() const | |
134 | { | |
135 | // | |
136 | // draw the digits as GL_QUADS | |
137 | // | |
138 | ||
139 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
140 | ||
141 | glDisable(GL_LIGHTING); | |
142 | glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | |
143 | glEnable(GL_COLOR_MATERIAL); | |
144 | glDisable(GL_CULL_FACE); | |
145 | ||
146 | //Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c); | |
147 | ||
148 | glPolygonMode(GL_FRONT, GL_FILL); | |
149 | glPolygonMode(GL_BACK, GL_LINE); | |
150 | ||
151 | glBegin(GL_QUADS); | |
152 | for(std::vector<Quad>::iterator q=fChamber->fQuadSet1.Quads().begin(); q!=fChamber->fQuadSet1.Quads().end(); ++q) { | |
153 | UChar_t* c = (UChar_t*) &q->color; | |
154 | glColor4ubv(c); | |
155 | glVertex3fv(q->vertices); | |
156 | glVertex3fv(q->vertices + 3); | |
157 | glVertex3fv(q->vertices + 6); | |
158 | glVertex3fv(q->vertices + 9); | |
159 | } | |
160 | glEnd(); | |
161 | ||
162 | glPolygonMode(GL_FRONT, GL_LINE); | |
163 | glPolygonMode(GL_BACK, GL_FILL); | |
164 | ||
165 | glBegin(GL_QUADS); | |
166 | for(std::vector<Quad>::iterator q=fChamber->fQuadSet2.Quads().begin(); q!=fChamber->fQuadSet2.Quads().end(); ++q) { | |
167 | UChar_t* c = (UChar_t*) &q->color; | |
168 | glColor4ubv(c); | |
169 | glVertex3fv(q->vertices); | |
170 | glVertex3fv(q->vertices + 3); | |
171 | glVertex3fv(q->vertices + 6); | |
172 | glVertex3fv(q->vertices + 9); | |
173 | } | |
174 | glEnd(); | |
175 | ||
176 | glPopAttrib(); | |
177 | ||
178 | } | |
179 | ||
eadce74d | 180 | //______________________________________________________________________ |
181 | void MUONChamberGL::DrawPoints() const | |
182 | { | |
183 | // | |
184 | // draw the clusters as GL_QUADS | |
185 | // | |
186 | ||
187 | Float_t x, y, z; | |
188 | ||
189 | glDisable(GL_LIGHTING); | |
190 | glLineWidth(1.0); | |
191 | ||
192 | glColor3f(1.0,1.0,1.0); | |
193 | ||
194 | glBegin(GL_LINES); | |
195 | ||
196 | // clusters | |
197 | ||
198 | Int_t clsSize = fChamber->fClusterSize; | |
199 | ||
200 | if (clsSize > 1) { | |
201 | ||
202 | for (Int_t i = 0; i < fChamber->fPointSet1.GetN(); i++) { | |
203 | ||
204 | fChamber->fPointSet1.GetPoint(i,x,y,z); | |
205 | ||
206 | glVertex3f(x-clsSize,y+clsSize,z); | |
207 | glVertex3f(x+clsSize,y-clsSize,z); | |
208 | ||
209 | glVertex3f(x-clsSize,y-clsSize,z); | |
210 | glVertex3f(x+clsSize,y+clsSize,z); | |
211 | ||
212 | } | |
213 | ||
214 | } | |
215 | ||
216 | // hits | |
217 | ||
218 | Int_t hitSize = fChamber->fHitSize; | |
219 | ||
220 | if (hitSize > 1) { | |
221 | ||
222 | for (Int_t i = 0; i < fChamber->fPointSet2.GetN(); i++) { | |
223 | ||
224 | fChamber->fPointSet2.GetPoint(i,x,y,z); | |
225 | ||
226 | glVertex3f(x-hitSize,y,z); | |
227 | glVertex3f(x+hitSize,y,z); | |
228 | ||
229 | glVertex3f(x,y-hitSize,z); | |
230 | glVertex3f(x,y+hitSize,z); | |
231 | ||
232 | } | |
233 | ||
234 | } | |
235 | ||
236 | glEnd(); | |
237 | ||
238 | } | |
239 | ||
3626c858 | 240 | //______________________________________________________________________ |
241 | void MUONChamberGL::DrawChamberFrame() const | |
242 | { | |
243 | // | |
244 | // draw the chamber frame as GL_LINE_LOOP | |
245 | // | |
246 | ||
247 | MUONChamberData* chamberData = fChamber->GetChamberData(); | |
248 | Int_t nDetElem = chamberData->GetNDetElem(); | |
249 | Float_t *frameCoord; | |
250 | Float_t xOrig, yOrig, xRad, yRad, x, y, z; | |
251 | ||
252 | UChar_t pix[4]; | |
253 | pix[0] = 255; | |
254 | pix[1] = 0; | |
255 | pix[2] = 0; | |
256 | pix[3] = 255; | |
257 | ||
258 | glColor4ubv(pix); | |
259 | ||
260 | for (Int_t id = 0; id < nDetElem; id++) { | |
261 | ||
262 | frameCoord = chamberData->GetFrameCoord(id); | |
263 | ||
264 | if (fChamber->GetID() < 4) { | |
265 | ||
266 | xOrig = frameCoord[0]; | |
267 | yOrig = frameCoord[1]; | |
268 | xRad = frameCoord[2]; | |
269 | yRad = frameCoord[3]; | |
270 | z = frameCoord[4]; | |
271 | ||
272 | xRad += 0.0; | |
273 | yRad += 0.0; | |
274 | ||
275 | glBegin(GL_LINE_LOOP); | |
276 | ||
277 | glVertex3f(xOrig,yOrig,z); | |
278 | ||
279 | Int_t nstep = 100; | |
280 | Float_t dstep = TMath::Pi()/2.0 / (Float_t)nstep; | |
281 | Float_t d; | |
282 | for (Int_t istep = 0; istep < nstep; istep++) { | |
283 | ||
284 | d = istep * dstep; | |
285 | x = xOrig + xRad * TMath::Cos(d); | |
286 | y = yOrig + yRad * TMath::Sin(d); | |
287 | ||
288 | glVertex3f(x,y,z); | |
289 | ||
290 | } | |
291 | ||
292 | glVertex3f(xOrig,yOrig,z); | |
293 | ||
294 | glEnd(); | |
295 | ||
296 | } else { | |
297 | ||
298 | glBegin(GL_LINE_LOOP); | |
299 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
300 | glVertex3f(frameCoord[0],frameCoord[3],frameCoord[4]); | |
301 | glVertex3f(frameCoord[2],frameCoord[3],frameCoord[4]); | |
302 | glVertex3f(frameCoord[2],frameCoord[1],frameCoord[4]); | |
303 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
304 | glEnd(); | |
305 | ||
306 | } | |
307 | ||
308 | } | |
309 | ||
310 | } |