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