]>
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 | ||
18 | #include <TMath.h> | |
19 | ||
3626c858 | 20 | #include "MUONChamberGL.h" |
21 | ||
22 | #include <Alieve/MUONChamber.h> | |
23 | #include <Alieve/MUONChamberData.h> | |
24 | ||
25 | #include <TGLDrawFlags.h> | |
26 | #include <Reve/QuadSetGL.h> | |
27 | #include <GL/gl.h> | |
28 | #include <GL/glu.h> | |
29 | ||
30 | using namespace Reve; | |
31 | using namespace Alieve; | |
32 | ||
33 | //______________________________________________________________________ | |
34 | // MUONChamberGL | |
35 | // | |
36 | ||
37 | ClassImp(MUONChamberGL) | |
38 | ||
39 | //______________________________________________________________________ | |
40 | MUONChamberGL::MUONChamberGL() : | |
41 | TGLObject(), | |
42 | fChamber(0), | |
43 | fRTS(0) | |
44 | { | |
45 | // | |
46 | // constructor | |
47 | // | |
48 | ||
49 | } | |
50 | ||
51 | //______________________________________________________________________ | |
52 | MUONChamberGL::~MUONChamberGL() | |
53 | { | |
54 | // | |
55 | // destructor | |
56 | // | |
57 | ||
58 | } | |
59 | ||
60 | //______________________________________________________________________ | |
61 | Bool_t MUONChamberGL::SetModel(TObject* obj) | |
62 | { | |
63 | // | |
64 | // ... | |
65 | // | |
66 | ||
67 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
68 | if(set_model(obj, "Alieve::MUONChamber")) { | |
69 | #elif ROOT_VERSION_CODE <= ROOT_VERSION(5,13,0) | |
70 | if(SetModelCheckClass(obj, "Alieve::MUONChamber")) { | |
71 | #else | |
72 | if(SetModelCheckClass(obj, Alieve::MUONChamber::Class())) { | |
73 | #endif | |
74 | ||
75 | fChamber = (MUONChamber*) fExternalObj; | |
76 | ||
77 | return kTRUE; | |
78 | ||
79 | } | |
80 | ||
81 | return kFALSE; | |
82 | ||
83 | } | |
84 | ||
85 | //______________________________________________________________________ | |
86 | void MUONChamberGL::SetBBox() | |
87 | { | |
88 | // | |
89 | // ... | |
90 | // | |
91 | ||
92 | #if ROOT_VERSION_CODE <= ROOT_VERSION(5,11,2) | |
93 | set_axis_aligned_bbox(((MUONChamber*)fExternalObj)->AssertBBox()); | |
94 | #else | |
95 | SetAxisAlignedBBox(((MUONChamber*)fExternalObj)->AssertBBox()); | |
96 | #endif | |
97 | ||
98 | } | |
99 | ||
100 | //______________________________________________________________________ | |
101 | void MUONChamberGL::DirectDraw(const TGLDrawFlags& /*flags*/) const | |
102 | { | |
103 | // | |
104 | // Actual GL drawing. | |
105 | // | |
106 | ||
107 | glDisable(GL_LIGHTING); | |
108 | ||
109 | //Double_t width = 10; | |
110 | //glOrtho(-width,+width,-width,+width,-width,+width); | |
111 | ||
112 | if(fRTS < fChamber->fRTS) { | |
113 | fChamber->UpdateQuads(); | |
114 | fRTS = fChamber->fRTS; | |
115 | } | |
116 | ||
117 | Bool_t hasData = (fChamber->GetChamberData() != 0); | |
118 | ||
119 | if(hasData) { | |
120 | ||
121 | DrawQuads(); | |
122 | ||
123 | } | |
124 | ||
125 | DrawChamberFrame(); | |
126 | ||
127 | } | |
128 | ||
129 | //______________________________________________________________________ | |
130 | void MUONChamberGL::DrawQuads() const | |
131 | { | |
132 | // | |
133 | // draw the digits as GL_QUADS | |
134 | // | |
135 | ||
136 | glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); | |
137 | ||
138 | glDisable(GL_LIGHTING); | |
139 | glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | |
140 | glEnable(GL_COLOR_MATERIAL); | |
141 | glDisable(GL_CULL_FACE); | |
142 | ||
143 | //Float_t c[4]; glGetFloatv(GL_CURRENT_COLOR, c); | |
144 | ||
145 | glPolygonMode(GL_FRONT, GL_FILL); | |
146 | glPolygonMode(GL_BACK, GL_LINE); | |
147 | ||
148 | glBegin(GL_QUADS); | |
149 | for(std::vector<Quad>::iterator q=fChamber->fQuadSet1.Quads().begin(); q!=fChamber->fQuadSet1.Quads().end(); ++q) { | |
150 | UChar_t* c = (UChar_t*) &q->color; | |
151 | glColor4ubv(c); | |
152 | glVertex3fv(q->vertices); | |
153 | glVertex3fv(q->vertices + 3); | |
154 | glVertex3fv(q->vertices + 6); | |
155 | glVertex3fv(q->vertices + 9); | |
156 | } | |
157 | glEnd(); | |
158 | ||
159 | glPolygonMode(GL_FRONT, GL_LINE); | |
160 | glPolygonMode(GL_BACK, GL_FILL); | |
161 | ||
162 | glBegin(GL_QUADS); | |
163 | for(std::vector<Quad>::iterator q=fChamber->fQuadSet2.Quads().begin(); q!=fChamber->fQuadSet2.Quads().end(); ++q) { | |
164 | UChar_t* c = (UChar_t*) &q->color; | |
165 | glColor4ubv(c); | |
166 | glVertex3fv(q->vertices); | |
167 | glVertex3fv(q->vertices + 3); | |
168 | glVertex3fv(q->vertices + 6); | |
169 | glVertex3fv(q->vertices + 9); | |
170 | } | |
171 | glEnd(); | |
172 | ||
173 | glPopAttrib(); | |
174 | ||
175 | } | |
176 | ||
177 | //______________________________________________________________________ | |
178 | void MUONChamberGL::DrawChamberFrame() const | |
179 | { | |
180 | // | |
181 | // draw the chamber frame as GL_LINE_LOOP | |
182 | // | |
183 | ||
184 | MUONChamberData* chamberData = fChamber->GetChamberData(); | |
185 | Int_t nDetElem = chamberData->GetNDetElem(); | |
186 | Float_t *frameCoord; | |
187 | Float_t xOrig, yOrig, xRad, yRad, x, y, z; | |
188 | ||
189 | UChar_t pix[4]; | |
190 | pix[0] = 255; | |
191 | pix[1] = 0; | |
192 | pix[2] = 0; | |
193 | pix[3] = 255; | |
194 | ||
195 | glColor4ubv(pix); | |
196 | ||
197 | for (Int_t id = 0; id < nDetElem; id++) { | |
198 | ||
199 | frameCoord = chamberData->GetFrameCoord(id); | |
200 | ||
201 | if (fChamber->GetID() < 4) { | |
202 | ||
203 | xOrig = frameCoord[0]; | |
204 | yOrig = frameCoord[1]; | |
205 | xRad = frameCoord[2]; | |
206 | yRad = frameCoord[3]; | |
207 | z = frameCoord[4]; | |
208 | ||
209 | xRad += 0.0; | |
210 | yRad += 0.0; | |
211 | ||
212 | glBegin(GL_LINE_LOOP); | |
213 | ||
214 | glVertex3f(xOrig,yOrig,z); | |
215 | ||
216 | Int_t nstep = 100; | |
217 | Float_t dstep = TMath::Pi()/2.0 / (Float_t)nstep; | |
218 | Float_t d; | |
219 | for (Int_t istep = 0; istep < nstep; istep++) { | |
220 | ||
221 | d = istep * dstep; | |
222 | x = xOrig + xRad * TMath::Cos(d); | |
223 | y = yOrig + yRad * TMath::Sin(d); | |
224 | ||
225 | glVertex3f(x,y,z); | |
226 | ||
227 | } | |
228 | ||
229 | glVertex3f(xOrig,yOrig,z); | |
230 | ||
231 | glEnd(); | |
232 | ||
233 | } else { | |
234 | ||
235 | glBegin(GL_LINE_LOOP); | |
236 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
237 | glVertex3f(frameCoord[0],frameCoord[3],frameCoord[4]); | |
238 | glVertex3f(frameCoord[2],frameCoord[3],frameCoord[4]); | |
239 | glVertex3f(frameCoord[2],frameCoord[1],frameCoord[4]); | |
240 | glVertex3f(frameCoord[0],frameCoord[1],frameCoord[4]); | |
241 | glEnd(); | |
242 | ||
243 | } | |
244 | ||
245 | } | |
246 | ||
247 | } |