]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/Alieve/ITSModuleStepperGL.cxx
Invert the modality of run-loader and esd loading: always try to open them and compla...
[u/mrichter/AliRoot.git] / EVE / Alieve / ITSModuleStepperGL.cxx
index 0274642e22d4606295c166db9d838dbdef61df7b..7600eb03703e56558548800b83a1c7fe9e037282 100644 (file)
@@ -4,7 +4,12 @@
 
 #include <Reve/GLTextNS.h>
 #include <Reve/GLUtilNS.h>
+#include <Reve/RGTopFrame.h>
+#include <Reve/RGEditor.h>
+#include <Reve/RGBAPalette.h>
+
 #include <Alieve/ITSModuleStepper.h>
+#include <Alieve/ITSScaledModule.h>
 
 #include <TGLDrawFlags.h>
 
@@ -19,7 +24,7 @@ ClassImp(ITSModuleStepperGL)
 
 ITSModuleStepperGL::ITSModuleStepperGL() : TGLObject(), fM(0)
 {
-  // fCached = false; // Disable display list.
+  fCached = false; // Disable display list.
 }
 
 ITSModuleStepperGL::~ITSModuleStepperGL()
@@ -52,35 +57,33 @@ void ITSModuleStepperGL::DirectDraw(const TGLDrawFlags & flags) const
   Int_t W = Int_t(MS.fStepper->Dx*MS.fStepper->Nx);
   Int_t H = Int_t(MS.fStepper->Dy*MS.fStepper->Ny);
   Float_t dx = W*MS.fWWidth;
-  Float_t dy = H*MS.fWHeight;
+  Float_t dy = 6; // H*MS.fWHeight;
 
   GLboolean lightp;
   glGetBooleanv(GL_LIGHTING, &lightp);
   if (lightp) glDisable(GL_LIGHTING);
    
+  UChar_t color[4];
+  ColorFromIdx(MS.fWColor, color);
+  glColor4ubv(color);
+
   // render frame of grid stepper
   if (MS.fRnrFrame)
   {
-    UChar_t color[4];
-    ColorFromIdx(MS.fFrameColor, color);
-    glColor4ubv(color);
-
     glBegin(GL_LINE_LOOP);
-    glVertex2f(0., 0.);       
-    glVertex2f(W , 0.);
-    glVertex2f(W , H );
-    glVertex2f(0 , H );
+    glVertex2f(-1,  -1);       
+    glVertex2f(W+1, -1);
+    glVertex2f(W+1,  H+1);
+    glVertex2f(-1 ,  H+1);
     glEnd();
   }
 
   // triangles
   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-  // glEnable(GL_POLYGON_OFFSET_FILL);
-
-  UChar_t color[4];
-  ColorFromIdx(MS.fWColor, color);
-  glColor4ubv(color);
+  glDisable(GL_CULL_FACE);
+  glEnable(GL_BLEND);
+  glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
     
   Float_t sx =0 ,sy = 0;
   switch(MS.fWCorner) {
@@ -102,43 +105,60 @@ void ITSModuleStepperGL::DirectDraw(const TGLDrawFlags & flags) const
   }
   
   if (flags.SecSelection()) glPushName(0);
-
   glPushMatrix();
-  // traslate according to orentation 
   glTranslatef(sx, sy, 0.);
 
+  // pager
   if (flags.SecSelection()) glLoadName(2);
-  RenderTriangle(dx, dy, 2);
-
+  RenderSymbol(dx, dy, 2);
   glTranslatef(dx, 0, 0);
   if (flags.SecSelection()) glLoadName(1);
-  RenderTriangle(dx, dy, 1);
+  RenderSymbol(dx*1.2, dy, 1);
   glTranslatef(dx, 0, 0);
-
-  Float_t movex = 0; 
+  RenderString(Form(" %d/%d ", MS.GetCurrentPage(), MS.GetPages()), dy);
+  if (flags.SecSelection()) glLoadName(3);
+  RenderSymbol(dx*1.2, dy, 3);
+  glTranslatef(dx, 0, 0);
+  if (flags.SecSelection()) glLoadName(4);
+  RenderSymbol(dx, dy, 4);
+  glTranslatef(2*dx, 0, 0);
+  
+  // scale info
+  Int_t cnx = 0, cnz = 0;
+  ITSDigitsInfo* di = MS.fDigitsInfo;
+  Int_t scale = fM->fScaleInfo->GetScale() - 1;
+  ITSScaledModule* sm = dynamic_cast<ITSScaledModule*>(*fM->BeginChildren());
+  switch(sm->GetSubDetID())
   {
-    GLUtilNS::GL_Capability_Switch texure_on(GL_TEXTURE_2D, true);
-    GLTextNS::txfBindFontTexture(GLTextNS::fgDefaultFont);
-    glPushMatrix();
-    glTranslatef(0, dy*0.25, 0);
-    Float_t s = (dy)/ (GLTextNS::fgDefaultFont->max_height());
-    glScalef(s, s, 1);
-    TString info = Form(" %d / %d ", MS.GetCurrentPage(),MS.GetPages());
-    txfRenderString(GLTextNS::fgDefaultFont, info.Data(), info.Length());
-    Int_t w, ma, md;
-    txfGetStringMetrics(GLTextNS::fgDefaultFont,info.Data(), info.Length() , w, ma, md);
-    movex = w*s;
-    glPopMatrix();
+    case 0: 
+      cnx = di->fSPDScaleX[scale], cnz = di->fSPDScaleZ[scale];
+      break;
+    case 1: 
+      cnx = di->fSDDScaleX[scale], cnz = di->fSDDScaleZ[scale];
+      break;
+    case 2:
+      cnx = di->fSSDScale[scale], cnz = 1;
+      break;
   }
-  glTranslatef(movex, 0, 0); 
+  if (flags.SecSelection()) glLoadName(0);
+  RenderString(Form("Scale"), dy);
+  glTranslatef(0.07*dx, 0, 0);
+  // up down arrows 
+  if (flags.SecSelection()) glLoadName(6);
+  RenderSymbol(dx*1.2, dy*0.9, 5);
 
-  if (flags.SecSelection()) glLoadName(3);
-  RenderTriangle(dx, dy, 3);
+  if (flags.SecSelection()) glLoadName(7);
+  RenderSymbol(dx*1.2, dy*0.9, 6);
 
-  glTranslatef(dx, 0, 0);
-  if (flags.SecSelection()) glLoadName(4);
-  RenderTriangle(dx, dy, 4);
+  glTranslatef(1*dx, 0, 0);
+  if (flags.SecSelection()) glLoadName(0);
+  RenderString(Form(" %dx%d ", cnx, cnz), dy, kFALSE);
 
+  glPopMatrix();
+  if (flags.SecSelection()) glLoadName(5);
+  glPushMatrix();
+  glTranslatef(W+2, 0, 0);
+  RenderPalette(H, 4);
   glPopMatrix();
 
   if (flags.SecSelection()) glPopName();
@@ -146,13 +166,44 @@ void ITSModuleStepperGL::DirectDraw(const TGLDrawFlags & flags) const
   glPopAttrib();
 
   if (lightp) glEnable(GL_LIGHTING);
-      
 }
+
 /**************************************************************************/
-void ITSModuleStepperGL::RenderTriangle(Float_t dx, Float_t dy, Int_t id) const
+
+void ITSModuleStepperGL::RenderPalette(Float_t dx, Float_t dy) const
+{
+  ITSModule* qs = dynamic_cast<ITSModule*>(*fM->BeginChildren());
+  RGBAPalette* p = qs->GetPalette();
+  Float_t xs = dx/(p->GetMaxVal()- p->GetMinVal());
+  Float_t ys = dy;
+
+  Float_t x  = 0;
+  glBegin(GL_QUAD_STRIP);
+  for(Int_t i=p->GetMinVal(); i<=p->GetMaxVal(); i++) 
+  {
+    glColor4ubv(p->ColorFromValue(i + p->GetMinVal()));
+    glVertex2f(0,  x);
+    glVertex2f(ys, x);
+    x+=xs;
+  }
+  glEnd();
+}
+
+/**************************************************************************/
+
+void ITSModuleStepperGL::RenderSymbol(Float_t dx, Float_t dy, Int_t id) const
 {
   Float_t xs = dx/4, ys = dy/4;
 
+  if(id == 0) {
+    glBegin(GL_QUADS);
+    glVertex2f(0,ys); glVertex2f(0, ys*3); 
+    glVertex2f(dx, ys*3); glVertex2f(dx, ys);
+    glEnd();
+    return;
+  }
+  
+
   glBegin(GL_TRIANGLES);
   switch (id) {
     case 1:
@@ -177,19 +228,44 @@ void ITSModuleStepperGL::RenderTriangle(Float_t dx, Float_t dy, Int_t id) const
       glVertex2f(xs*2, ys); glVertex2f(xs*3, ys*2); glVertex2f(xs*2, ys*3);
       break;
     }
+    case 5:
+    {
+      glVertex2f(xs, ys*2.5);  glVertex2f(xs*2, ys*3.5); glVertex2f(xs*3, ys*2.5);
+      break;
+    }
+    case 6:
+    {
+      glVertex2f(xs, ys*1.5);  glVertex2f(xs*2, ys*0.5); glVertex2f(xs*3, ys*1.5);
+      break;
+    }
+   
     default:
       break;
   }
   glEnd();
+}
 
-  /*
-    glBegin(GL_LINE_LOOP);
-    glVertex2f(0,0);
-    glVertex2f(0,dy);
-    glVertex2f(dx,dy);
-    glVertex2f(dx,0);
-    glEnd();
-  */
+/**************************************************************************/
+void ITSModuleStepperGL::RenderString(TString info, Float_t dy, Bool_t trans) const
+{
+  Float_t movex = 0; 
+  
+  GLUtilNS::GL_Capability_Switch texure_on(GL_TEXTURE_2D, true);
+  GLTextNS::txfBindFontTexture(GLTextNS::fgDefaultFont);
+
+  glPushMatrix();
+  glTranslatef(0, dy*0.25, 0);
+  Float_t s = (dy)/ (GLTextNS::fgDefaultFont->max_height());
+  Float_t sx = s*0.75; Float_t sy = s*0.8;
+  glScalef(sx, sy, 1);
+  txfRenderString(GLTextNS::fgDefaultFont, info.Data(), info.Length());
+  Int_t w, ma, md;
+  txfGetStringMetrics(GLTextNS::fgDefaultFont,info.Data(), info.Length() , w, ma, md);
+  movex = w*sx;
+  glPopMatrix();
+
+  if(trans)
+    glTranslatef(movex, 0, 0);
 }
 
 /**************************************************************************/
@@ -201,14 +277,46 @@ void ITSModuleStepperGL::ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*)
   // point as an argument.
 
   if (ptr[0] < 2) return;
-  UInt_t id = ptr[4]; 
-
-  if(id == 1)
-    fM->Previous();
-  if(id == 2)
-    fM->Start();
-  if(id == 3)
-    fM->Next();
-  if(id == 4)
-    fM->End();
+
+  switch (ptr[4]){
+    case 1:
+      fM->Previous();
+      break;
+    case 2:
+      fM->Start();
+      break;
+    case 3:
+      fM->Next();
+      break;
+    case 4:
+      fM->End();
+      break;
+    case 5:
+      gReve->GetEditor()->DisplayRenderElement(*fM->BeginChildren());
+      break;
+    case 6:
+    {
+      DigitScaleInfo* si = fM->fScaleInfo;
+      if(si->fScale < 5) 
+      {
+       si->ScaleChanged(si->fScale + 1);
+       gReve->GetEditor()->DisplayObject(gReve->GetEditor()->GetModel());
+       gReve->Redraw3D();
+      }
+      break;
+    }
+    case 7:
+    {
+      DigitScaleInfo* si = fM->fScaleInfo;
+      if(si->fScale > 1) 
+      {
+       si->ScaleChanged(si->GetScale() - 1);
+       gReve->GetEditor()->DisplayObject(gReve->GetEditor()->GetModel());
+       gReve->Redraw3D();
+      }
+      break;
+    }
+    default:
+      break;
+  }
 }