]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/ITSModuleStepperGL.cxx
Getting rid of effC++ warnings about missing copy constructor and assignment operator.
[u/mrichter/AliRoot.git] / EVE / Alieve / ITSModuleStepperGL.cxx
CommitLineData
0343cac7 1// $Header$
2
3#include "ITSModuleStepperGL.h"
4
5#include <Reve/GLTextNS.h>
6#include <Reve/GLUtilNS.h>
64736a7f 7#include <Reve/RGTopFrame.h>
8#include <Reve/RGEditor.h>
9#include <Reve/RGBAPalette.h>
10
0343cac7 11#include <Alieve/ITSModuleStepper.h>
64736a7f 12#include <Alieve/ITSScaledModule.h>
0343cac7 13
19208112 14#include <TGLRnrCtx.h>
15#include <TGLSelectRecord.h>
0343cac7 16
17using namespace Reve;
18using namespace Alieve;
19
20//______________________________________________________________________
21// ITSModuleStepperGL
22//
23
24ClassImp(ITSModuleStepperGL)
25
26ITSModuleStepperGL::ITSModuleStepperGL() : TGLObject(), fM(0)
27{
19208112 28 fDLCache = false; // Disable display list.
0343cac7 29}
30
31ITSModuleStepperGL::~ITSModuleStepperGL()
32{}
33
34/**************************************************************************/
35
19208112 36Bool_t ITSModuleStepperGL::SetModel(TObject* obj, const Option_t* /*opt*/)
0343cac7 37{
38 if(SetModelCheckClass(obj, ITSModuleStepper::Class())) {
39 fM = dynamic_cast<ITSModuleStepper*>(obj);
40 return kTRUE;
41 }
42 return kFALSE;
43}
44
45void ITSModuleStepperGL::SetBBox()
46{
47 // !! This ok if master sub-classed from TAttBBox
48 SetAxisAlignedBBox(fM->AssertBBox());
49}
50
51/**************************************************************************/
52
19208112 53void ITSModuleStepperGL::DirectDraw(TGLRnrCtx & rnrCtx) const
0343cac7 54{
19208112 55 // printf("ITSModuleStepperGL::DirectDraw Style %d, LOD %d\n", rnrCtx.Style(), rnrCtx.LOD());
0343cac7 56
57 ITSModuleStepper& MS = *fM;
58 Int_t W = Int_t(MS.fStepper->Dx*MS.fStepper->Nx);
59 Int_t H = Int_t(MS.fStepper->Dy*MS.fStepper->Ny);
60 Float_t dx = W*MS.fWWidth;
64736a7f 61 Float_t dy = 6; // H*MS.fWHeight;
0343cac7 62
63 GLboolean lightp;
64 glGetBooleanv(GL_LIGHTING, &lightp);
65 if (lightp) glDisable(GL_LIGHTING);
66
98b5e1dd 67 UChar_t color[4];
68 ColorFromIdx(MS.fWColor, color);
69 glColor4ubv(color);
70
0343cac7 71 // render frame of grid stepper
72 if (MS.fRnrFrame)
73 {
0343cac7 74 glBegin(GL_LINE_LOOP);
64736a7f 75 glVertex2f(-1, -1);
76 glVertex2f(W+1, -1);
77 glVertex2f(W+1, H+1);
78 glVertex2f(-1 , H+1);
0343cac7 79 glEnd();
80 }
81
82 // triangles
83 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
84 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
98b5e1dd 85 glDisable(GL_CULL_FACE);
64736a7f 86 glEnable(GL_BLEND);
87 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
0343cac7 88
89 Float_t sx =0 ,sy = 0;
90 switch(MS.fWCorner) {
91 case ITSModuleStepper::PT_BottomLeft:
92 sy = -dy;
93 break;
94 case ITSModuleStepper::PT_BottomRight:
95 sy = -dy;
96 break;
97 case ITSModuleStepper::PT_TopLeft:
98 sy = H;
99 break;
100 case ITSModuleStepper::PT_TopRight:
101 sy = H;
102 break;
103 default:
104 sy = dy;
105 break;
106 }
107
19208112 108 if (rnrCtx.SecSelection()) glPushName(0);
0343cac7 109 glPushMatrix();
0343cac7 110 glTranslatef(sx, sy, 0.);
111
64736a7f 112 // pager
19208112 113 if (rnrCtx.SecSelection()) glLoadName(2);
64736a7f 114 RenderSymbol(dx, dy, 2);
0343cac7 115 glTranslatef(dx, 0, 0);
19208112 116 if (rnrCtx.SecSelection()) glLoadName(1);
a771d35f 117 RenderSymbol(dx*1.2, dy, 1);
0343cac7 118 glTranslatef(dx, 0, 0);
64736a7f 119 RenderString(Form(" %d/%d ", MS.GetCurrentPage(), MS.GetPages()), dy);
19208112 120 if (rnrCtx.SecSelection()) glLoadName(3);
a771d35f 121 RenderSymbol(dx*1.2, dy, 3);
0343cac7 122 glTranslatef(dx, 0, 0);
19208112 123 if (rnrCtx.SecSelection()) glLoadName(4);
64736a7f 124 RenderSymbol(dx, dy, 4);
125 glTranslatef(2*dx, 0, 0);
126
127 // scale info
128 Int_t cnx = 0, cnz = 0;
129 ITSDigitsInfo* di = MS.fDigitsInfo;
a771d35f 130 Int_t scale = fM->fScaleInfo->GetScale() - 1;
64736a7f 131 ITSScaledModule* sm = dynamic_cast<ITSScaledModule*>(*fM->BeginChildren());
132 switch(sm->GetSubDetID())
133 {
134 case 0:
135 cnx = di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale];
136 break;
137 case 1:
138 cnx = di->fSDDScaleX[scale], cnz = di->fSDDScaleZ[scale];
139 break;
140 case 2:
141 cnx = di->fSSDScale[scale], cnz = 1;
142 break;
a771d35f 143 }
19208112 144 if (rnrCtx.SecSelection()) glLoadName(0);
a771d35f 145 RenderString(Form("Scale"), dy);
146 glTranslatef(0.07*dx, 0, 0);
64736a7f 147 // up down arrows
19208112 148 if (rnrCtx.SecSelection()) glLoadName(6);
a771d35f 149 RenderSymbol(dx*1.2, dy*0.9, 5);
150
19208112 151 if (rnrCtx.SecSelection()) glLoadName(7);
a771d35f 152 RenderSymbol(dx*1.2, dy*0.9, 6);
153
154 glTranslatef(1*dx, 0, 0);
19208112 155 if (rnrCtx.SecSelection()) glLoadName(0);
a771d35f 156 RenderString(Form(" %dx%d ", cnx, cnz), dy, kFALSE);
0343cac7 157
64736a7f 158 glPopMatrix();
19208112 159 if (rnrCtx.SecSelection()) glLoadName(5);
64736a7f 160 glPushMatrix();
161 glTranslatef(W+2, 0, 0);
162 RenderPalette(H, 4);
0343cac7 163 glPopMatrix();
164
19208112 165 if (rnrCtx.SecSelection()) glPopName();
0343cac7 166
167 glPopAttrib();
168
169 if (lightp) glEnable(GL_LIGHTING);
0343cac7 170}
64736a7f 171
0343cac7 172/**************************************************************************/
64736a7f 173
174void ITSModuleStepperGL::RenderPalette(Float_t dx, Float_t dy) const
175{
176 ITSModule* qs = dynamic_cast<ITSModule*>(*fM->BeginChildren());
177 RGBAPalette* p = qs->GetPalette();
178 Float_t xs = dx/(p->GetMaxVal()- p->GetMinVal());
179 Float_t ys = dy;
180
181 Float_t x = 0;
182 glBegin(GL_QUAD_STRIP);
183 for(Int_t i=p->GetMinVal(); i<=p->GetMaxVal(); i++)
184 {
185 glColor4ubv(p->ColorFromValue(i + p->GetMinVal()));
186 glVertex2f(0, x);
187 glVertex2f(ys, x);
188 x+=xs;
189 }
190 glEnd();
191}
192
193/**************************************************************************/
194
195void ITSModuleStepperGL::RenderSymbol(Float_t dx, Float_t dy, Int_t id) const
0343cac7 196{
197 Float_t xs = dx/4, ys = dy/4;
198
64736a7f 199 if(id == 0) {
200 glBegin(GL_QUADS);
201 glVertex2f(0,ys); glVertex2f(0, ys*3);
202 glVertex2f(dx, ys*3); glVertex2f(dx, ys);
203 glEnd();
204 return;
205 }
206
207
0343cac7 208 glBegin(GL_TRIANGLES);
209 switch (id) {
210 case 1:
211 {
212 glVertex2f(xs*2.5, ys*3); glVertex2f(xs*1.5, ys*2); glVertex2f(xs*2.5, ys);
213 break;
214 }
215 case 2:
216 {
217 glVertex2f(xs*2, ys*3); glVertex2f(xs, ys*2); glVertex2f(xs*2, ys);
218 glVertex2f(xs*3, ys*3); glVertex2f(xs*2, ys*2); glVertex2f(xs*3, ys);
219 break;
220 }
221 case 3:
222 {
223 glVertex2f(xs*1.5, ys); glVertex2f(xs*2.5, ys*2); glVertex2f(xs*1.5, ys*3);
224 break;
225 }
226 case 4:
227 {
228 glVertex2f(xs, ys); glVertex2f(xs*2, ys*2); glVertex2f(xs, ys*3);
229 glVertex2f(xs*2, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*2, ys*3);
230 break;
231 }
64736a7f 232 case 5:
233 {
234 glVertex2f(xs, ys*2.5); glVertex2f(xs*2, ys*3.5); glVertex2f(xs*3, ys*2.5);
235 break;
236 }
237 case 6:
238 {
239 glVertex2f(xs, ys*1.5); glVertex2f(xs*2, ys*0.5); glVertex2f(xs*3, ys*1.5);
240 break;
241 }
242
0343cac7 243 default:
244 break;
245 }
246 glEnd();
64736a7f 247}
0343cac7 248
64736a7f 249/**************************************************************************/
250void ITSModuleStepperGL::RenderString(TString info, Float_t dy, Bool_t trans) const
251{
252 Float_t movex = 0;
253
254 GLUtilNS::GL_Capability_Switch texure_on(GL_TEXTURE_2D, true);
255 GLTextNS::txfBindFontTexture(GLTextNS::fgDefaultFont);
256
257 glPushMatrix();
258 glTranslatef(0, dy*0.25, 0);
259 Float_t s = (dy)/ (GLTextNS::fgDefaultFont->max_height());
260 Float_t sx = s*0.75; Float_t sy = s*0.8;
261 glScalef(sx, sy, 1);
262 txfRenderString(GLTextNS::fgDefaultFont, info.Data(), info.Length());
263 Int_t w, ma, md;
264 txfGetStringMetrics(GLTextNS::fgDefaultFont,info.Data(), info.Length() , w, ma, md);
265 movex = w*sx;
266 glPopMatrix();
267
268 if(trans)
269 glTranslatef(movex, 0, 0);
0343cac7 270}
271
272/**************************************************************************/
273
19208112 274void ITSModuleStepperGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/,
275 TGLSelectRecord & rec)
0343cac7 276{
277 // Processes secondary selection from TGLViewer.
278 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
279 // point as an argument.
280
19208112 281 if (rec.GetN() < 2) return;
64736a7f 282
19208112 283 switch (rec.GetItem(1)) {
a771d35f 284 case 1:
64736a7f 285 fM->Previous();
286 break;
287 case 2:
288 fM->Start();
289 break;
290 case 3:
291 fM->Next();
292 break;
293 case 4:
294 fM->End();
295 break;
296 case 5:
297 gReve->GetEditor()->DisplayRenderElement(*fM->BeginChildren());
298 break;
299 case 6:
300 {
301 DigitScaleInfo* si = fM->fScaleInfo;
a771d35f 302 if(si->fScale < 5)
303 {
64736a7f 304 si->ScaleChanged(si->fScale + 1);
a771d35f 305 gReve->GetEditor()->DisplayObject(gReve->GetEditor()->GetModel());
306 gReve->Redraw3D();
307 }
64736a7f 308 break;
309 }
310 case 7:
311 {
312 DigitScaleInfo* si = fM->fScaleInfo;
a771d35f 313 if(si->fScale > 1)
314 {
64736a7f 315 si->ScaleChanged(si->GetScale() - 1);
a771d35f 316 gReve->GetEditor()->DisplayObject(gReve->GetEditor()->GetModel());
317 gReve->Redraw3D();
318 }
64736a7f 319 break;
320 }
321 default:
322 break;
323 }
0343cac7 324}