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