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