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);
61 // render frame of grid stepper
65 ColorFromIdx(MS.fFrameColor, color);
68 glBegin(GL_LINE_LOOP);
77 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
78 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
79 // glEnable(GL_POLYGON_OFFSET_FILL);
82 ColorFromIdx(MS.fWColor, color);
85 Float_t sx =0 ,sy = 0;
87 case ITSModuleStepper::PT_BottomLeft:
90 case ITSModuleStepper::PT_BottomRight:
93 case ITSModuleStepper::PT_TopLeft:
96 case ITSModuleStepper::PT_TopRight:
104 if (flags.SecSelection()) glPushName(0);
107 // traslate according to orentation
108 glTranslatef(sx, sy, 0.);
110 if (flags.SecSelection()) glLoadName(2);
111 RenderTriangle(dx, dy, 2);
113 glTranslatef(dx, 0, 0);
114 if (flags.SecSelection()) glLoadName(1);
115 RenderTriangle(dx, dy, 1);
116 glTranslatef(dx, 0, 0);
120 GLUtilNS::GL_Capability_Switch texure_on(GL_TEXTURE_2D, true);
121 GLTextNS::txfBindFontTexture(GLTextNS::fgDefaultFont);
123 glTranslatef(0, dy*0.25, 0);
124 Float_t s = (dy)/ (GLTextNS::fgDefaultFont->max_height());
126 TString info = Form(" %d / %d ", MS.GetCurrentPage(),MS.GetPages());
127 txfRenderString(GLTextNS::fgDefaultFont, info.Data(), info.Length());
129 txfGetStringMetrics(GLTextNS::fgDefaultFont,info.Data(), info.Length() , w, ma, md);
133 glTranslatef(movex, 0, 0);
135 if (flags.SecSelection()) glLoadName(3);
136 RenderTriangle(dx, dy, 3);
138 glTranslatef(dx, 0, 0);
139 if (flags.SecSelection()) glLoadName(4);
140 RenderTriangle(dx, dy, 4);
144 if (flags.SecSelection()) glPopName();
148 if (lightp) glEnable(GL_LIGHTING);
151 /**************************************************************************/
152 void ITSModuleStepperGL::RenderTriangle(Float_t dx, Float_t dy, Int_t id) const
154 Float_t xs = dx/4, ys = dy/4;
156 glBegin(GL_TRIANGLES);
160 glVertex2f(xs*2.5, ys*3); glVertex2f(xs*1.5, ys*2); glVertex2f(xs*2.5, ys);
165 glVertex2f(xs*2, ys*3); glVertex2f(xs, ys*2); glVertex2f(xs*2, ys);
166 glVertex2f(xs*3, ys*3); glVertex2f(xs*2, ys*2); glVertex2f(xs*3, ys);
171 glVertex2f(xs*1.5, ys); glVertex2f(xs*2.5, ys*2); glVertex2f(xs*1.5, ys*3);
176 glVertex2f(xs, ys); glVertex2f(xs*2, ys*2); glVertex2f(xs, ys*3);
177 glVertex2f(xs*2, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*2, ys*3);
186 glBegin(GL_LINE_LOOP);
195 /**************************************************************************/
197 void ITSModuleStepperGL::ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*)
199 // Processes secondary selection from TGLViewer.
200 // Calls TPointSet3D::PointSelected(Int_t) with index of selected
201 // point as an argument.
203 if (ptr[0] < 2) return;