3 #include "ITSModuleStepperGL.h"
5 #include <Reve/GLTextNS.h>
6 #include <Reve/GLUtilNS.h>
7 #include <Alieve/ITSModuleStepper.h>
9 #include <TGLDrawFlags.h>
12 using namespace Alieve;
14 //______________________________________________________________________
18 ClassImp(ITSModuleStepperGL)
20 ITSModuleStepperGL::ITSModuleStepperGL() : TGLObject(), fM(0)
22 fCached = false; // Disable display list.
25 ITSModuleStepperGL::~ITSModuleStepperGL()
28 /**************************************************************************/
30 Bool_t ITSModuleStepperGL::SetModel(TObject* obj)
32 if(SetModelCheckClass(obj, ITSModuleStepper::Class())) {
33 fM = dynamic_cast<ITSModuleStepper*>(obj);
39 void ITSModuleStepperGL::SetBBox()
41 // !! This ok if master sub-classed from TAttBBox
42 SetAxisAlignedBBox(fM->AssertBBox());
45 /**************************************************************************/
47 void ITSModuleStepperGL::DirectDraw(const TGLDrawFlags & flags) const
49 // printf("ITSModuleStepperGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
51 ITSModuleStepper& MS = *fM;
52 Int_t W = Int_t(MS.fStepper->Dx*MS.fStepper->Nx);
53 Int_t H = Int_t(MS.fStepper->Dy*MS.fStepper->Ny);
54 Float_t dx = W*MS.fWWidth;
55 Float_t dy = H*MS.fWHeight;
58 glGetBooleanv(GL_LIGHTING, &lightp);
59 if (lightp) glDisable(GL_LIGHTING);
62 ColorFromIdx(MS.fWColor, color);
65 // render frame of grid stepper
68 glBegin(GL_LINE_LOOP);
77 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
78 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
79 glDisable(GL_CULL_FACE);
81 Float_t sx =0 ,sy = 0;
83 case ITSModuleStepper::PT_BottomLeft:
86 case ITSModuleStepper::PT_BottomRight:
89 case ITSModuleStepper::PT_TopLeft:
92 case ITSModuleStepper::PT_TopRight:
100 if (flags.SecSelection()) glPushName(0);
103 // traslate according to orentation
104 glTranslatef(sx, sy, 0.);
106 if (flags.SecSelection()) glLoadName(2);
107 RenderTriangle(dx, dy, 2);
109 glTranslatef(dx, 0, 0);
110 if (flags.SecSelection()) glLoadName(1);
111 RenderTriangle(dx, dy, 1);
112 glTranslatef(dx, 0, 0);
116 GLUtilNS::GL_Capability_Switch texure_on(GL_TEXTURE_2D, true);
117 GLTextNS::txfBindFontTexture(GLTextNS::fgDefaultFont);
119 glTranslatef(0, dy*0.25, 0);
120 Float_t s = (dy)/ (GLTextNS::fgDefaultFont->max_height());
122 TString info = Form(" %d / %d ", MS.GetCurrentPage(),MS.GetPages());
123 txfRenderString(GLTextNS::fgDefaultFont, info.Data(), info.Length());
125 txfGetStringMetrics(GLTextNS::fgDefaultFont,info.Data(), info.Length() , w, ma, md);
129 glTranslatef(movex, 0, 0);
131 if (flags.SecSelection()) glLoadName(3);
132 RenderTriangle(dx, dy, 3);
134 glTranslatef(dx, 0, 0);
135 if (flags.SecSelection()) glLoadName(4);
136 RenderTriangle(dx, dy, 4);
140 if (flags.SecSelection()) glPopName();
144 if (lightp) glEnable(GL_LIGHTING);
147 /**************************************************************************/
148 void ITSModuleStepperGL::RenderTriangle(Float_t dx, Float_t dy, Int_t id) const
150 Float_t xs = dx/4, ys = dy/4;
152 glBegin(GL_TRIANGLES);
156 glVertex2f(xs*2.5, ys*3); glVertex2f(xs*1.5, ys*2); glVertex2f(xs*2.5, ys);
161 glVertex2f(xs*2, ys*3); glVertex2f(xs, ys*2); glVertex2f(xs*2, ys);
162 glVertex2f(xs*3, ys*3); glVertex2f(xs*2, ys*2); glVertex2f(xs*3, ys);
167 glVertex2f(xs*1.5, ys); glVertex2f(xs*2.5, ys*2); glVertex2f(xs*1.5, ys*3);
172 glVertex2f(xs, ys); glVertex2f(xs*2, ys*2); glVertex2f(xs, ys*3);
173 glVertex2f(xs*2, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*2, ys*3);
182 glBegin(GL_LINE_LOOP);
191 /**************************************************************************/
193 void ITSModuleStepperGL::ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*)
195 // Processes secondary selection from TGLViewer.
196 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
197 // point as an argument.
199 if (ptr[0] < 2) return;