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