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