// @(#)root/gl:$Id$
// Author:  Timur Pocheptsov  14/06/2006

/*************************************************************************
 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
#include <algorithm>
#include <cctype>

#include "KeySymbols.h"
#include "TVirtualX.h"
#include "Buttons.h"
#include "TString.h"
#include "TColor.h"
#include "TROOT.h"
#include "TClass.h"
#include "TStyle.h"
#include "TAxis.h"
#include "TMath.h"
#include "TH1.h"

#include "TGLLegoPainter.h"
#include "TGLPlotCamera.h"
#include "TGLIncludes.h"

//______________________________________________________________________________
//
// Plot-painter implementing LEGO rendering of TH2 histograms in
// cartesian, polar, cylindrical and spherical coordinates.

ClassImp(TGLLegoPainter)

//______________________________________________________________________________
TGLLegoPainter::TGLLegoPainter(TH1 *hist, TGLPlotCamera *cam, TGLPlotCoordinates *coord)
                  : TGLPlotPainter(hist, cam, coord, kFALSE, kTRUE, kTRUE),
                    fLegoType(kColorSimple),
                    fMinZ(0.),
                    fDrawErrors(kFALSE)
{
   //Ctor.
}

//______________________________________________________________________________
char *TGLLegoPainter::GetPlotInfo(Int_t /*px*/, Int_t /*py*/)
{
   //Obtain bin's info (i, j, value).
   fBinInfo = "";

   if (fSelectedPart) {
      if (fSelectedPart < fSelectionBase) {
         if (fHist->Class())
            fBinInfo += fHist->Class()->GetName();
         fBinInfo += "::";
         fBinInfo += fHist->GetName();
      } else if (!fHighColor) {
         const Int_t binI = (fSelectedPart - fSelectionBase) / fCoord->GetNYBins() + fCoord->GetFirstXBin();
         const Int_t binJ = (fSelectedPart - fSelectionBase) % fCoord->GetNYBins() + fCoord->GetFirstYBin();
         fBinInfo.Form("(binx = %d; biny = %d; binc = %f)", binI, binJ,
                       fHist->GetBinContent(binI, binJ));
      } else
         fBinInfo = "Switch to true-color mode to obtain correct info";
   }

   return (Char_t *)fBinInfo.Data();
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::InitGeometry()
{
   //Select method.

   Bool_t ret = kFALSE;
   switch (fCoord->GetCoordType()) {
   case kGLCartesian:
      ret = InitGeometryCartesian(); break;
   case kGLPolar:
      ret = InitGeometryPolar(); break;
   case kGLCylindrical:
      ret = InitGeometryCylindrical(); break;
   case kGLSpherical:
      ret = InitGeometrySpherical(); break;
   default:
      return kFALSE;
   }
   if (ret && fCamera) fCamera->SetViewVolume(fBackBox.Get3DBox());
   return ret;
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::InitGeometryCartesian()
{
   //Geometry for lego in cartesian coords.
   if (!fCoord->SetRanges(fHist, fDrawErrors, kFALSE))
      return kFALSE;

   fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());

   //Find bin edges
   const Int_t nX = fCoord->GetNXBins();
   const Double_t barWidth = fHist->GetBarWidth(), barOffset = fHist->GetBarOffset();
   const TGLVertex3 *frame = fBackBox.Get3DBox();
   fXEdges.resize(nX);

   if (fCoord->GetXLog()) {
      for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
         const Double_t xWidth = fXAxis->GetBinWidth(ir);
         Double_t low = fXAxis->GetBinLowEdge(ir) + xWidth * barOffset;
         fXEdges[i].first  = TMath::Log10(low) * fCoord->GetXScale();
         fXEdges[i].second = TMath::Log10(low + xWidth * barWidth) * fCoord->GetXScale();
         if (fXEdges[i].second > frame[1].X())
            fXEdges[i].second = frame[1].X();
         if (fXEdges[i].first < frame[0].X())
            fXEdges[i].first = frame[0].X();
         if (fXEdges[i].second < frame[0].X())
            fXEdges[i].second = frame[0].X();
      }
   } else {
      for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
         const Double_t xWidth = fXAxis->GetBinWidth(ir);
         fXEdges[i].first  = (fXAxis->GetBinLowEdge(ir) + xWidth * barOffset) * fCoord->GetXScale();
         fXEdges[i].second = fXEdges[i].first + xWidth * barWidth * fCoord->GetXScale();
         if (fXEdges[i].second > frame[1].X())
            fXEdges[i].second = frame[1].X();
         if (fXEdges[i].first < frame[0].X())
            fXEdges[i].first = frame[0].X();
         if (fXEdges[i].second < frame[0].X())
            fXEdges[i].second = frame[0].X();
      }
   }

   const Int_t nY = fCoord->GetNYBins();
   fYEdges.resize(nY);

   if (fCoord->GetYLog()) {
      for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         const Double_t yWidth = fYAxis->GetBinWidth(jr);
         Double_t low = fYAxis->GetBinLowEdge(jr) + yWidth * barOffset;
         fYEdges[j].first  = TMath::Log10(low) * fCoord->GetYScale();
         fYEdges[j].second = TMath::Log10(low + yWidth * barWidth) * fCoord->GetYScale();
         if (fYEdges[j].second > frame[2].Y())
            fYEdges[j].second = frame[2].Y();
         if (fYEdges[j].first < frame[0].Y())
            fYEdges[j].first = frame[0].Y();
         if (fYEdges[j].second < frame[0].Y())
            fYEdges[j].second = frame[0].Y();
      }
   } else {
      for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         const Double_t yWidth = fYAxis->GetBinWidth(jr);
         fYEdges[j].first  = (fYAxis->GetBinLowEdge(jr) + yWidth * barOffset) * fCoord->GetYScale();
         fYEdges[j].second = fYEdges[j].first + yWidth * barWidth * fCoord->GetYScale();
         if (fYEdges[j].second > frame[2].Y())
            fYEdges[j].second = frame[2].Y();
         if (fYEdges[j].first < frame[0].Y())
            fYEdges[j].first = frame[0].Y();
         if (fYEdges[j].second < frame[0].Y())
            fYEdges[j].second = frame[0].Y();
      }
   }

   fMinZ = frame[0].Z();
   if (fMinZ < 0.)
      frame[4].Z() > 0. ? fMinZ = 0. : fMinZ = frame[4].Z();

   if (fCoord->Modified()) {
      fUpdateSelection = kTRUE;
      fXOZSectionPos = frame[0].Y();
      fYOZSectionPos = frame[0].X();
      fXOYSectionPos = frame[0].Z();
      fCoord->ResetModified();
      Rgl::SetZLevels(fZAxis, fCoord->GetZRange().first, fCoord->GetZRange().second, fCoord->GetZScale(), fZLevels);
   }

   fMinMaxVal.first  = fHist->GetBinContent(fCoord->GetFirstXBin(), fCoord->GetFirstYBin());
   fMinMaxVal.second = fMinMaxVal.first;

   for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
      for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
         Double_t val = fHist->GetBinContent(i, j);
         fMinMaxVal.first  = TMath::Min(fMinMaxVal.first, val);
         fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
      }
   }

   ClampZ(fMinMaxVal.first);
   ClampZ(fMinMaxVal.second);

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::InitGeometryPolar()
{
   //Geometry for lego in polar coords.
   if (!fCoord->SetRanges(fHist, kFALSE, kFALSE))
      return kFALSE;

   fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());

   if (fCoord->Modified()) {
      fUpdateSelection = kTRUE;
      fCoord->ResetModified();
   }

   const Int_t nY = fCoord->GetNYBins();//yBins.second - yBins.first + 1;
   fYEdges.resize(nY);

   for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
      fYEdges[j].first = ((fYAxis->GetBinLowEdge(jr)) - fCoord->GetYRange().first) /
                           fCoord->GetYLength() * fCoord->GetYScale();
      fYEdges[j].second = ((fYAxis->GetBinUpEdge(jr)) - fCoord->GetYRange().first) /
                           fCoord->GetYLength() * fCoord->GetYScale();
   }

   const Int_t nX = fCoord->GetNXBins();
   fCosSinTableX.resize(nX + 1);
   const Double_t fullAngle = fXAxis->GetXmax() - fXAxis->GetXmin();
   const Double_t phiLow = fXAxis->GetXmin();
   Double_t angle = 0;
   for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullAngle * TMath::TwoPi();
      fCosSinTableX[i].first  = TMath::Cos(angle);
      fCosSinTableX[i].second = TMath::Sin(angle);
   }
   angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullAngle * TMath::TwoPi();
   fCosSinTableX[nX].first  = TMath::Cos(angle);
   fCosSinTableX[nX].second = TMath::Sin(angle);

   fMinZ = fBackBox.Get3DBox()[0].Z();
   if (fMinZ < 0.)
      fBackBox.Get3DBox()[4].Z() > 0. ? fMinZ = 0. : fMinZ = fBackBox.Get3DBox()[4].Z();

   fMinMaxVal.first  = fHist->GetBinContent(fCoord->GetFirstXBin(), fCoord->GetFirstYBin());
   fMinMaxVal.second = fMinMaxVal.first;

   for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
      for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
         Double_t val = fHist->GetBinContent(i, j);
         fMinMaxVal.first  = TMath::Min(fMinMaxVal.first, val);
         fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
      }
   }

   ClampZ(fMinMaxVal.first);
   ClampZ(fMinMaxVal.second);

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::InitGeometryCylindrical()
{
   //Geometry for lego in cylindrical coords.
   if (!fCoord->SetRanges(fHist, kFALSE, kFALSE))
      return kFALSE;

   fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());

   const Int_t nY = fCoord->GetNYBins();
   fYEdges.resize(nY);

   if (fCoord->GetYLog()) {
      for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         fYEdges[j].first  = TMath::Log10(fYAxis->GetBinLowEdge(jr)) * fCoord->GetYScale();
         fYEdges[j].second = TMath::Log10(fYAxis->GetBinUpEdge(jr))  * fCoord->GetYScale();
      }
   } else {
      for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         fYEdges[j].first  = fYAxis->GetBinLowEdge(jr) * fCoord->GetYScale();
         fYEdges[j].second = fYAxis->GetBinUpEdge(jr)  * fCoord->GetYScale();
      }
   }

   const Int_t nX = fCoord->GetNXBins();
   fCosSinTableX.resize(nX + 1);
   const Double_t fullAngle = fXAxis->GetXmax() - fXAxis->GetXmin();
   const Double_t phiLow    = fXAxis->GetXmin();
   Double_t angle = 0.;
   for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullAngle * TMath::TwoPi();
      fCosSinTableX[i].first  = TMath::Cos(angle);
      fCosSinTableX[i].second = TMath::Sin(angle);
   }
   angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullAngle * TMath::TwoPi();
   fCosSinTableX[nX].first  = TMath::Cos(angle);
   fCosSinTableX[nX].second = TMath::Sin(angle);

   if (fCoord->Modified()) {
      fUpdateSelection = kTRUE;
      fCoord->ResetModified();
   }

   fMinZ = fCoord->GetZRange().first;
   if (fMinZ < 0.)
      fCoord->GetZRange().second > 0. ? fMinZ = 0. : fMinZ = fCoord->GetZRange().second;


   fMinMaxVal.first  = fHist->GetBinContent(fCoord->GetFirstXBin(), fCoord->GetFirstYBin());
   fMinMaxVal.second = fMinMaxVal.first;

   for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
      for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
         Double_t val = fHist->GetBinContent(i, j);
         fMinMaxVal.first  = TMath::Min(fMinMaxVal.first, val);
         fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
      }
   }

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::InitGeometrySpherical()
{
   //Geometry for lego in spherical coords.
   if (!fCoord->SetRanges(fHist, kFALSE, kFALSE))
      return kFALSE;

   fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());

   const Int_t nY = fCoord->GetNYBins();
   fCosSinTableY.resize(nY + 1);
   const Double_t fullTheta = fYAxis->GetXmax() - fYAxis->GetXmin();
   const Double_t thetaLow  = fYAxis->GetXmin();
   Double_t angle = 0.;
   for (Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
      angle = (fYAxis->GetBinLowEdge(jr) - thetaLow) / fullTheta * TMath::Pi();
      fCosSinTableY[j].first = TMath::Cos(angle);
      fCosSinTableY[j].second = TMath::Sin(angle);
   }
   angle = (fYAxis->GetBinUpEdge(fCoord->GetLastYBin()) - thetaLow) / fullTheta * TMath::Pi();
   fCosSinTableY[nY].first = TMath::Cos(angle);
   fCosSinTableY[nY].second = TMath::Sin(angle);

   const Int_t nX = fCoord->GetNXBins();
   fCosSinTableX.resize(nX + 1);
   const Double_t fullPhi = fXAxis->GetXmax() - fXAxis->GetXmin();
   const Double_t phiLow  = fXAxis->GetXmin();

   for (Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      angle = (fXAxis->GetBinLowEdge(ir) - phiLow) / fullPhi * TMath::TwoPi();
      fCosSinTableX[i].first  = TMath::Cos(angle);
      fCosSinTableX[i].second = TMath::Sin(angle);
   }

   angle = (fXAxis->GetBinUpEdge(fCoord->GetLastXBin()) - phiLow) / fullPhi * TMath::TwoPi();
   fCosSinTableX[nX].first  = TMath::Cos(angle);
   fCosSinTableX[nX].second = TMath::Sin(angle);

   fMinZ = fCoord->GetZRange().first;
   if (fMinZ < 0.)
      fCoord->GetZRange().second > 0. ? fMinZ = 0. : fMinZ = fCoord->GetZRange().second;

   fMinMaxVal.first  = fHist->GetBinContent(fCoord->GetFirstXBin(), fCoord->GetFirstYBin());
   fMinMaxVal.second = fMinMaxVal.first;

   for (Int_t i = fCoord->GetFirstXBin(), e = fCoord->GetLastXBin(); i <= e; ++i) {
      for (Int_t j = fCoord->GetFirstYBin(), e1 = fCoord->GetLastYBin(); j <= e1; ++j) {
         Double_t val = fHist->GetBinContent(i, j);
         fMinMaxVal.first  = TMath::Min(fMinMaxVal.first, val);
         fMinMaxVal.second = TMath::Max(fMinMaxVal.second, val);
      }
   }


   return kTRUE;
}

//______________________________________________________________________________
void TGLLegoPainter::StartPan(Int_t px, Int_t py)
{
   //User clicks on a lego with middle mouse button (middle for pad).
   fMousePosition.fX = px;
   fMousePosition.fY = fCamera->GetHeight() - py;
   fCamera->StartPan(px, py);
   fBoxCut.StartMovement(px, py);
}

//______________________________________________________________________________
void TGLLegoPainter::Pan(Int_t px, Int_t py)
{
   //Move lego or section.
   if (fSelectedPart >= fSelectionBase || fSelectedPart == 1) {
      SaveModelviewMatrix();
      SaveProjectionMatrix();

      fCamera->SetCamera();
      fCamera->Apply(fPadPhi, fPadTheta);
      fCamera->Pan(px, py);

      RestoreProjectionMatrix();
      RestoreModelviewMatrix();
   } else if (fSelectedPart > 0) {
      //Convert py into bottom-top orientation.
      py = fCamera->GetHeight() - py;

      SaveModelviewMatrix();
      SaveProjectionMatrix();

      fCamera->SetCamera();
      fCamera->Apply(fPadPhi, fPadTheta);

      if (!fHighColor) {
         if (fBoxCut.IsActive() && (fSelectedPart >= kXAxis && fSelectedPart <= kZAxis))
            fBoxCut.MoveBox(px, py, fSelectedPart);
         else
            MoveSection(px, py);
      } else
         MoveSection(px, py);

      RestoreProjectionMatrix();
      RestoreModelviewMatrix();
   }

   fMousePosition.fX = px, fMousePosition.fY = py;
   fUpdateSelection = kTRUE;
}

//______________________________________________________________________________
void TGLLegoPainter::AddOption(const TString &option)
{
   //Parse additional options.
   using namespace std;
   const Ssiz_t legoPos = option.Index("lego");//"lego" _already_ _exists_ in a string.
   if (legoPos + 4 < option.Length() && isdigit(option[legoPos + 4])) {
      switch (option[legoPos + 4] - '0') {
      case 1:
         fLegoType = kColorSimple;
         break;
      case 2:
         fLegoType = kColorLevel;
         break;
      case 3:
         fLegoType = kCylindricBars;
         break;
      default:
         fLegoType = kColorSimple;
         break;
      }
   } else
      fLegoType = kColorSimple;
   //check 'e' option
   Ssiz_t ePos = option.Index("e");
   if (ePos == legoPos + 1)
      ePos = option.Index("e", legoPos + 4);
   fDrawErrors = ePos != kNPOS ? kTRUE : kFALSE;

   option.Index("z") == kNPOS ? fDrawPalette = kFALSE : fDrawPalette = kTRUE;
}

//______________________________________________________________________________
void TGLLegoPainter::InitGL()const
{
   //Initialize some gl state variables.
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);
   //For lego, back polygons are culled (but not for sections).
   glEnable(GL_CULL_FACE);
   glCullFace(GL_BACK);

   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
}

//______________________________________________________________________________
void TGLLegoPainter::DeInitGL()const
{
   //Return some gl states to original values.
   glDisable(GL_DEPTH_TEST);
   glDisable(GL_LIGHTING);
   glDisable(GL_LIGHT0);
   glDisable(GL_CULL_FACE);
   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
}

//______________________________________________________________________________
void TGLLegoPainter::DrawPlot()const
{
   //Select method corresponding to coordinate system.

   //Shift plot to point of origin.
   const Rgl::PlotTranslation trGuard(this);

   switch (fCoord->GetCoordType()) {
   case kGLCartesian:
      return DrawLegoCartesian();
   case kGLPolar:
      return DrawLegoPolar();
   case kGLCylindrical:
      return DrawLegoCylindrical();
   case kGLSpherical:
      return DrawLegoSpherical();
   default:;
   }
}

//______________________________________________________________________________
void TGLLegoPainter::DrawLegoCartesian()const
{
   //Lego in cartesian system.
   if (fCoord->GetCoordType() == kGLCartesian) {
      fBackBox.DrawBox(fSelectedPart, fSelectionPass, fZLevels, fHighColor);
      const TGLDisableGuard cullGuard(GL_CULL_FACE);
      DrawSections();
   }

   //const TGLDisableGuard depthTest(GL_DEPTH_TEST); //[0-0]

   if (!fSelectionPass) {
      glEnable(GL_POLYGON_OFFSET_FILL);//[0
      glPolygonOffset(1.f, 1.f);
      SetLegoColor();
      if (fXOZSectionPos > fBackBox.Get3DBox()[0].Y() || fYOZSectionPos> fBackBox.Get3DBox()[0].X()) {
         //Lego is semi-transparent if we have any sections.
         glEnable(GL_BLEND);//[1
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      }
   }

   //Using front point, find the correct order to draw bars from
   //back to front (it's important only for semi-transparent lego).
   //Only in cartesian.
   const Int_t nX = fXEdges.size();
   const Int_t nY = fYEdges.size();
   const Int_t frontPoint = fBackBox.GetFrontPoint();
   Int_t iInit = 0, jInit = 0, irInit = fCoord->GetFirstXBin(), jrInit = fCoord->GetFirstYBin();
   const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit = fCoord->GetLastXBin(), -1);
   const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit = fCoord->GetLastYBin(), -1);

   if (fLegoType == kColorLevel && !fSelectionPass) {
      if (!PreparePalette()) {
         fLegoType = kColorSimple;
         fDrawPalette = kFALSE;
      } else
         fPalette.EnableTexture(GL_MODULATE);
   }

   if (fSelectionPass && fHighColor)
      Rgl::ObjectIDToColor(fSelectionBase, kTRUE);

   for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
      for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
         Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
         if (!ClampZ(zMax))
            continue;

         const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;

         if (fSelectionPass && !fHighColor)
            Rgl::ObjectIDToColor(binID, kFALSE);
         else if(!fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);

         if (fLegoType == kCylindricBars) {
            Rgl::DrawCylinder(&fQuadric, fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
                              fYEdges[j].second, fMinZ, zMax);
         } else if (fLegoType == kColorLevel && !fSelectionPass) {
            Rgl::DrawBoxFrontTextured(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
                                      fYEdges[j].second, fMinZ, zMax, fPalette.GetTexCoord(fMinZ),
                                      fPalette.GetTexCoord(zMax), frontPoint);
         } else {
            Rgl::DrawBoxFront(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
                              fYEdges[j].second, fMinZ, zMax, frontPoint);
         }

         if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
      }
   }

   if (fLegoType == kColorLevel && !fSelectionPass)
      fPalette.DisableTexture();

   //Draw outlines for non-cylindrical bars.
   if (!fSelectionPass) {
      glDisable(GL_POLYGON_OFFSET_FILL);//0]
      const TGLDisableGuard lightGuard(GL_LIGHTING);//[2 - 2]
      if (fXOZSectionPos <= fBackBox.Get3DBox()[0].Y() && fYOZSectionPos <= fBackBox.Get3DBox()[0].X())
         glColor3d(0., 0., 0.);
      else
         glColor4d(0., 0., 0., 0.4);
      glPolygonMode(GL_FRONT, GL_LINE);//[3

      const TGLEnableGuard blendGuard(GL_BLEND);//[4-4] + 1]
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);//[5-5]
      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

      for(Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
         for(Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
            Double_t zMax = fHist->GetBinContent(ir, jr) * fCoord->GetFactor();
            if (!ClampZ(zMax))
               continue;
            if (fLegoType != kCylindricBars) {
               Rgl::DrawBoxFront(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
                                 fYEdges[j].second, fMinZ, zMax, frontPoint);
            }
            if (fDrawErrors && zMax > 0.) {
               Double_t errorZMax = (fHist->GetBinContent(ir, jr) + fHist->GetBinError(ir, jr)) * fCoord->GetFactor();
               ClampZ(errorZMax);
               Rgl::DrawError(fXEdges[i].first, fXEdges[i].second, fYEdges[j].first,
                              fYEdges[j].second, zMax, errorZMax);
            }
         }
      }

      glPolygonMode(GL_FRONT, GL_FILL);//3]
   }

   if(!fSelectionPass && fDrawPalette)
      DrawPalette();
}

//______________________________________________________________________________
void TGLLegoPainter::DrawLegoPolar()const
{
   //Lego in polar system.
   const Int_t nX = fCosSinTableX.size() - 1;
   const Int_t nY = fYEdges.size();

   if (!fSelectionPass) {
      SetLegoColor();
      glEnable(GL_POLYGON_OFFSET_FILL);
      glPolygonOffset(1.f, 1.f);
   }

   Double_t points[4][2] = {};

   if (fLegoType == kColorLevel && !fSelectionPass) {
      if (!PreparePalette()) {
         fLegoType = kColorSimple;
         fDrawPalette = kFALSE;
      } else
         fPalette.EnableTexture(GL_MODULATE);
   }

   if (fHighColor && fSelectionPass)
      Rgl::ObjectIDToColor(fSelectionBase, kTRUE);

   for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         Double_t zMax = fHist->GetBinContent(ir, jr);
         if (!ClampZ(zMax))
            continue;
         points[0][0] = fYEdges[j].first  * fCosSinTableX[i].first;
         points[0][1] = fYEdges[j].first  * fCosSinTableX[i].second;
         points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
         points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
         points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
         points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
         points[3][0] = fYEdges[j].first  * fCosSinTableX[i + 1].first;
         points[3][1] = fYEdges[j].first  * fCosSinTableX[i + 1].second;

         const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;

         if (!fHighColor && fSelectionPass)
            Rgl::ObjectIDToColor(binID, kFALSE);
         else if(!fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);

         if (fLegoType == kColorLevel && !fSelectionPass)
            Rgl::DrawTrapezoidTextured(points, fMinZ, zMax, fPalette.GetTexCoord(fMinZ),
                                       fPalette.GetTexCoord(zMax));
         else
            Rgl::DrawTrapezoid(points, fMinZ, zMax);

         if (!fHighColor && !fSelectionPass && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
      }
   }

   if (fLegoType == kColorLevel && !fSelectionPass)
      fPalette.DisableTexture();

   //Draw otulines.
   if (!fSelectionPass) {
      glDisable(GL_POLYGON_OFFSET_FILL);//0]
      const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
      glColor3d(0., 0., 0.);
      glPolygonMode(GL_FRONT, GL_LINE);//[3
      const TGLEnableGuard blendGuard(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

      for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
         for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
            Double_t zMax = fHist->GetBinContent(ir, jr);
            if (!ClampZ(zMax))
               continue;
            points[0][0] = fYEdges[j].first  * fCosSinTableX[i].first;
            points[0][1] = fYEdges[j].first  * fCosSinTableX[i].second;
            points[1][0] = fYEdges[j].second * fCosSinTableX[i].first;
            points[1][1] = fYEdges[j].second * fCosSinTableX[i].second;
            points[2][0] = fYEdges[j].second * fCosSinTableX[i + 1].first;
            points[2][1] = fYEdges[j].second * fCosSinTableX[i + 1].second;
            points[3][0] = fYEdges[j].first  * fCosSinTableX[i + 1].first;
            points[3][1] = fYEdges[j].first  * fCosSinTableX[i + 1].second;
            Rgl::DrawTrapezoid(points, fMinZ, zMax, kFALSE);
         }
      }

      glPolygonMode(GL_FRONT, GL_FILL);//3]
   }

   if(!fSelectionPass && fDrawPalette)
      DrawPalette();
}

//______________________________________________________________________________
void TGLLegoPainter::DrawLegoCylindrical()const
{
   //Lego in cylindrical system.
   const Int_t nX = fCosSinTableX.size() - 1;
   const Int_t nY = fYEdges.size();
   Double_t legoR = gStyle->GetLegoInnerR();
   if (legoR > 1. || legoR < 0.)
      legoR = 0.5;
   const Double_t rRange = fCoord->GetZLength();

   if (!fSelectionPass) {
      SetLegoColor();
      glEnable(GL_POLYGON_OFFSET_FILL);
      glPolygonOffset(1.f, 1.f);
   }

   Double_t points[4][2] = {};
   const Double_t sc = (1 - legoR) * fCoord->GetXScale();
   legoR *= fCoord->GetXScale();

   if (fLegoType == kColorLevel && !fSelectionPass) {
      if (!PreparePalette()) {
         fLegoType = kColorSimple;
         fDrawPalette = kFALSE;
      } else
         fPalette.EnableTexture(GL_MODULATE);
   }

   if (fHighColor && fSelectionPass)
      Rgl::ObjectIDToColor(fSelectionBase, kTRUE);

   for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
         Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
         if (zMin > zMax)
            std::swap(zMin, zMax);

         points[0][0] = fCosSinTableX[i].first * zMin;
         points[0][1] = fCosSinTableX[i].second * zMin;
         points[1][0] = fCosSinTableX[i].first * zMax;
         points[1][1] = fCosSinTableX[i].second * zMax;
         points[2][0] = fCosSinTableX[i + 1].first * zMax;
         points[2][1] = fCosSinTableX[i + 1].second * zMax;
         points[3][0] = fCosSinTableX[i + 1].first * zMin;
         points[3][1] = fCosSinTableX[i + 1].second * zMin;

         const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;

         if (fSelectionPass && !fHighColor)
            Rgl::ObjectIDToColor(binID, kFALSE);
         else if(!fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);

         if (fLegoType == kColorLevel && !fSelectionPass){
            Rgl::DrawTrapezoidTextured2(points, fYEdges[j].first, fYEdges[j].second,
                                        fPalette.GetTexCoord(fMinZ), fPalette.GetTexCoord(fHist->GetBinContent(ir, jr)));
         }else
            Rgl::DrawTrapezoid(points, fYEdges[j].first, fYEdges[j].second);

         if(!fSelectionPass && !fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
      }
   }

   if (fLegoType == kColorLevel && !fSelectionPass)
      fPalette.DisableTexture();

   //Draw otulines.
   if (!fSelectionPass) {
      glDisable(GL_POLYGON_OFFSET_FILL);//0]
      const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
      glColor3d(0., 0., 0.);
      glPolygonMode(GL_FRONT, GL_LINE);//[3

      const TGLEnableGuard blendGuard(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

      for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
         for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
            Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
            Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
            if (zMin > zMax)
               std::swap(zMin, zMax);

            points[0][0] = fCosSinTableX[i].first * zMin;
            points[0][1] = fCosSinTableX[i].second * zMin;
            points[1][0] = fCosSinTableX[i].first * zMax;
            points[1][1] = fCosSinTableX[i].second * zMax;
            points[2][0] = fCosSinTableX[i + 1].first * zMax;
            points[2][1] = fCosSinTableX[i + 1].second * zMax;
            points[3][0] = fCosSinTableX[i + 1].first * zMin;
            points[3][1] = fCosSinTableX[i + 1].second * zMin;
            Rgl::DrawTrapezoid(points, fYEdges[j].first, fYEdges[j].second);
         }
      }

      glPolygonMode(GL_FRONT, GL_FILL);//3]
   }

   if(!fSelectionPass && fDrawPalette)
      DrawPalette();
}

//______________________________________________________________________________
void TGLLegoPainter::DrawLegoSpherical()const
{
   //Lego in spherical system.
   const Int_t nX = fCosSinTableX.size() - 1;
   const Int_t nY = fCosSinTableY.size() - 1;
   const Double_t rRange = fCoord->GetZLength();
   Double_t legoR = gStyle->GetLegoInnerR();
   if (legoR > 1. || legoR < 0.)
      legoR = 0.5;

   if (!fSelectionPass) {
      SetLegoColor();
      glEnable(GL_POLYGON_OFFSET_FILL);
      glPolygonOffset(1.f, 1.f);
   }

   Double_t points[8][3] = {};
   const Double_t sc = 1 - legoR;

   if (fLegoType == kColorLevel && !fSelectionPass) {
      if (!PreparePalette()) {
         fLegoType = kColorSimple;
         fDrawPalette = kFALSE;
      } else
         fPalette.EnableTexture(GL_MODULATE);
   }

   if (fSelectionPass && fHighColor)
      Rgl::ObjectIDToColor(fSelectionBase, kTRUE);

   for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
      for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
         Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
         Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
         if (zMin > zMax)
            std::swap(zMin, zMax);

         points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
         points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
         points[4][2] = zMin * fCosSinTableY[j].first;
         points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
         points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
         points[5][2] = zMin * fCosSinTableY[j].first;
         points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
         points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
         points[6][2] = zMax * fCosSinTableY[j].first;
         points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
         points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
         points[7][2] = zMax * fCosSinTableY[j].first;
         points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
         points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
         points[0][2] = zMin * fCosSinTableY[j + 1].first;
         points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
         points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
         points[1][2] = zMin * fCosSinTableY[j + 1].first;
         points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
         points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
         points[2][2] = zMax * fCosSinTableY[j + 1].first;
         points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
         points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
         points[3][2] = zMax * fCosSinTableY[j + 1].first;

         const Int_t binID = fSelectionBase + i * fCoord->GetNYBins() + j;

         if (fSelectionPass && !fHighColor)
            Rgl::ObjectIDToColor(binID, kFALSE);
         else if(!fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gOrangeEmission);
         if (fLegoType == kColorLevel && !fSelectionPass)
            Rgl::DrawTrapezoidTextured(points, fPalette.GetTexCoord(fMinZ),
                                       fPalette.GetTexCoord(fHist->GetBinContent(ir, jr)));
         else
            Rgl::DrawTrapezoid(points);

         if(!fHighColor && fSelectedPart == binID)
            glMaterialfv(GL_FRONT, GL_EMISSION, Rgl::gNullEmission);
      }
   }

   if (fLegoType == kColorLevel && !fSelectionPass)
      fPalette.DisableTexture();

   //Draw otulines.
   if (!fSelectionPass) {
      glDisable(GL_POLYGON_OFFSET_FILL);//0]
      const TGLDisableGuard lightGuard(GL_LIGHTING);//[2-2]
      glColor3d(0., 0., 0.);
      glPolygonMode(GL_FRONT, GL_LINE);//[3
      const TGLEnableGuard blendGuard(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      const TGLEnableGuard smoothGuard(GL_LINE_SMOOTH);
      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

      for(Int_t i = 0, ir = fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
         for(Int_t j = 0, jr = fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
            Double_t zMin = legoR + (fMinZ - fCoord->GetZRange().first) / rRange * sc;
            Double_t zMax = legoR + (fHist->GetBinContent(ir, jr) - fCoord->GetZRange().first) / rRange * sc;
            if (zMin > zMax)
               std::swap(zMin, zMax);

            points[4][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].first;
            points[4][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i].second;
            points[4][2] = zMin * fCosSinTableY[j].first;
            points[5][0] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
            points[5][1] = zMin * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
            points[5][2] = zMin * fCosSinTableY[j].first;
            points[6][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].first;
            points[6][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i + 1].second;
            points[6][2] = zMax * fCosSinTableY[j].first;
            points[7][0] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].first;
            points[7][1] = zMax * fCosSinTableY[j].second * fCosSinTableX[i].second;
            points[7][2] = zMax * fCosSinTableY[j].first;
            points[0][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
            points[0][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
            points[0][2] = zMin * fCosSinTableY[j + 1].first;
            points[1][0] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
            points[1][1] = zMin * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
            points[1][2] = zMin * fCosSinTableY[j + 1].first;
            points[2][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].first;
            points[2][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i + 1].second;
            points[2][2] = zMax * fCosSinTableY[j + 1].first;
            points[3][0] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].first;
            points[3][1] = zMax * fCosSinTableY[j + 1].second * fCosSinTableX[i].second;
            points[3][2] = zMax * fCosSinTableY[j + 1].first;
            Rgl::DrawTrapezoid(points);
         }
      }

      glPolygonMode(GL_FRONT, GL_FILL);//3]
   }

   if(!fSelectionPass && fDrawPalette)
      DrawPalette();
}

//______________________________________________________________________________
void TGLLegoPainter::SetLegoColor()const
{
   //Set lego's color.
   Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};

   if (fLegoType != kColorLevel && fHist->GetFillColor() != kWhite)
      if (const TColor *c = gROOT->GetColor(fHist->GetFillColor()))
         c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);

   glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
   const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
}

//______________________________________________________________________________
void TGLLegoPainter::DrawSectionXOZ()const
{
   //XOZ plane parallel section.
   Int_t binY = -1;

   for (Int_t i = 0, e = fYEdges.size(); i < e; ++i) {
      if (fYEdges[i].first <= fXOZSectionPos && fXOZSectionPos <= fYEdges[i].second) {
         binY = i;
         break;
      }
   }

   if (binY >= 0) {
      binY += fCoord->GetFirstYBin();
      glColor3d(1., 0., 0.);
      glLineWidth(3.f);
      //Draw 2d hist on the profile's plane.
      for (UInt_t i = 0, ir = fCoord->GetFirstXBin(), e = fXEdges.size(); i < e; ++i, ++ir) {
         Double_t zMax = fHist->GetBinContent(Int_t(ir), binY);
         if (!ClampZ(zMax))
            continue;

         glBegin(GL_LINE_LOOP);
         glVertex3d(fXEdges[i].first,  fXOZSectionPos, fMinZ);
         glVertex3d(fXEdges[i].first,  fXOZSectionPos, zMax);
         glVertex3d(fXEdges[i].second, fXOZSectionPos, zMax);
         glVertex3d(fXEdges[i].second, fXOZSectionPos, fMinZ);
         glEnd();
      }

      glLineWidth(1.f);
   }
}

//______________________________________________________________________________
void TGLLegoPainter::DrawSectionYOZ()const
{
   //YOZ plane parallel section.
   Int_t binX = -1;

   for (Int_t i = 0, e = fXEdges.size(); i < e; ++i) {
      if (fXEdges[i].first <= fYOZSectionPos && fYOZSectionPos <= fXEdges[i].second) {
         binX = i;
         break;
      }
   }

   if (binX >= 0) {
      binX += fCoord->GetFirstXBin();//fBinsX.first;
      glColor3d(1., 0., 0.);
      glLineWidth(3.f);
      //Draw 2d hist on the profile's plane.
      for (UInt_t i = 0, ir = fCoord->GetFirstYBin(), e = fYEdges.size(); i < e; ++i, ++ir) {
         Double_t zMax = fHist->GetBinContent(binX, ir);
         if (!ClampZ(zMax))
            continue;

         glBegin(GL_LINE_LOOP);
         glVertex3d(fYOZSectionPos, fYEdges[i].first,  fMinZ);
         glVertex3d(fYOZSectionPos, fYEdges[i].first,   zMax);
         glVertex3d(fYOZSectionPos, fYEdges[i].second,  zMax);
         glVertex3d(fYOZSectionPos, fYEdges[i].second, fMinZ);
         glEnd();
      }

      glLineWidth(1.f);
   }
}

//______________________________________________________________________________
void TGLLegoPainter::DrawSectionXOY()const
{
   //Empty. No such sections for lego.
}

//______________________________________________________________________________
void TGLLegoPainter::ProcessEvent(Int_t event, Int_t /*px*/, Int_t py)
{
   //Remove all sections and repaint.
   const TGLVertex3 *frame = fBackBox.Get3DBox();
   if (event == kButton1Double && (fXOZSectionPos > frame[0].Y() || fYOZSectionPos > frame[0].X())) {
      fXOZSectionPos = frame[0].Y();
      fYOZSectionPos = frame[0].X();
      if (fBoxCut.IsActive())
         fBoxCut.TurnOnOff();
      //gGLManager->PaintSingleObject(this);
      if (!gVirtualX->IsCmdThread())
         gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%lx)->Paint()", (ULong_t)this));
      else
         Paint();
   } else if (event == kKeyPress && (py == kKey_c || py == kKey_C)) {
      Info("ProcessEvent", "Box cut does not exist for lego");
   }
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::ClampZ(Double_t &zVal)const
{
   //Clamp z value.
   if (fCoord->GetZLog())
      if (zVal <= 0.)
         return kFALSE;
      else
         zVal = TMath::Log10(zVal) * fCoord->GetZScale();
   else
      zVal *= fCoord->GetZScale();

   const TGLVertex3 *frame = fBackBox.Get3DBox();

   if (zVal > frame[4].Z())
      zVal = frame[4].Z();
   else if (zVal < frame[0].Z())
      zVal = frame[0].Z();

   return kTRUE;
}

//______________________________________________________________________________
Bool_t TGLLegoPainter::PreparePalette()const
{
   //Initialize color palette.
   if(fMinMaxVal.first == fMinMaxVal.second)
      return kFALSE;//must be std::abs(fMinMaxVal.second - fMinMaxVal.first) < ...

   //User-defined contours are disabled, to be fixed in a future.
   if (fHist->TestBit(TH1::kUserContour))
      fHist->ResetBit(TH1::kUserContour);

   UInt_t paletteSize = gStyle->GetNumberContours();
   if (!paletteSize)
      paletteSize = 20;

   return fPalette.GeneratePalette(paletteSize, Rgl::Range_t(fMinZ, fMinMaxVal.second));
}

//______________________________________________________________________________
void TGLLegoPainter::DrawPalette()const
{
   //Draw. Palette.
   //Originally, fCamera was never null.
   //It can be a null now because of gl-viewer.
   if (!fCamera) {
      //Thank you, gl-viewer!
      return;
   }

   Rgl::DrawPalette(fCamera, fPalette);

   glFinish();

   fCamera->SetCamera();
   fCamera->Apply(fPadPhi, fPadTheta);
}

//______________________________________________________________________________
void TGLLegoPainter::DrawPaletteAxis()const
{
   //Draw. Palette. Axis.
   gVirtualX->SetDrawMode(TVirtualX::kCopy);//TCanvas by default sets in kInverse
   Rgl::DrawPaletteAxis(fCamera, fMinMaxVal, fCoord->GetCoordType() == kGLCartesian ? fCoord->GetZLog() : kFALSE);
}
 TGLLegoPainter.cxx:1
 TGLLegoPainter.cxx:2
 TGLLegoPainter.cxx:3
 TGLLegoPainter.cxx:4
 TGLLegoPainter.cxx:5
 TGLLegoPainter.cxx:6
 TGLLegoPainter.cxx:7
 TGLLegoPainter.cxx:8
 TGLLegoPainter.cxx:9
 TGLLegoPainter.cxx:10
 TGLLegoPainter.cxx:11
 TGLLegoPainter.cxx:12
 TGLLegoPainter.cxx:13
 TGLLegoPainter.cxx:14
 TGLLegoPainter.cxx:15
 TGLLegoPainter.cxx:16
 TGLLegoPainter.cxx:17
 TGLLegoPainter.cxx:18
 TGLLegoPainter.cxx:19
 TGLLegoPainter.cxx:20
 TGLLegoPainter.cxx:21
 TGLLegoPainter.cxx:22
 TGLLegoPainter.cxx:23
 TGLLegoPainter.cxx:24
 TGLLegoPainter.cxx:25
 TGLLegoPainter.cxx:26
 TGLLegoPainter.cxx:27
 TGLLegoPainter.cxx:28
 TGLLegoPainter.cxx:29
 TGLLegoPainter.cxx:30
 TGLLegoPainter.cxx:31
 TGLLegoPainter.cxx:32
 TGLLegoPainter.cxx:33
 TGLLegoPainter.cxx:34
 TGLLegoPainter.cxx:35
 TGLLegoPainter.cxx:36
 TGLLegoPainter.cxx:37
 TGLLegoPainter.cxx:38
 TGLLegoPainter.cxx:39
 TGLLegoPainter.cxx:40
 TGLLegoPainter.cxx:41
 TGLLegoPainter.cxx:42
 TGLLegoPainter.cxx:43
 TGLLegoPainter.cxx:44
 TGLLegoPainter.cxx:45
 TGLLegoPainter.cxx:46
 TGLLegoPainter.cxx:47
 TGLLegoPainter.cxx:48
 TGLLegoPainter.cxx:49
 TGLLegoPainter.cxx:50
 TGLLegoPainter.cxx:51
 TGLLegoPainter.cxx:52
 TGLLegoPainter.cxx:53
 TGLLegoPainter.cxx:54
 TGLLegoPainter.cxx:55
 TGLLegoPainter.cxx:56
 TGLLegoPainter.cxx:57
 TGLLegoPainter.cxx:58
 TGLLegoPainter.cxx:59
 TGLLegoPainter.cxx:60
 TGLLegoPainter.cxx:61
 TGLLegoPainter.cxx:62
 TGLLegoPainter.cxx:63
 TGLLegoPainter.cxx:64
 TGLLegoPainter.cxx:65
 TGLLegoPainter.cxx:66
 TGLLegoPainter.cxx:67
 TGLLegoPainter.cxx:68
 TGLLegoPainter.cxx:69
 TGLLegoPainter.cxx:70
 TGLLegoPainter.cxx:71
 TGLLegoPainter.cxx:72
 TGLLegoPainter.cxx:73
 TGLLegoPainter.cxx:74
 TGLLegoPainter.cxx:75
 TGLLegoPainter.cxx:76
 TGLLegoPainter.cxx:77
 TGLLegoPainter.cxx:78
 TGLLegoPainter.cxx:79
 TGLLegoPainter.cxx:80
 TGLLegoPainter.cxx:81
 TGLLegoPainter.cxx:82
 TGLLegoPainter.cxx:83
 TGLLegoPainter.cxx:84
 TGLLegoPainter.cxx:85
 TGLLegoPainter.cxx:86
 TGLLegoPainter.cxx:87
 TGLLegoPainter.cxx:88
 TGLLegoPainter.cxx:89
 TGLLegoPainter.cxx:90
 TGLLegoPainter.cxx:91
 TGLLegoPainter.cxx:92
 TGLLegoPainter.cxx:93
 TGLLegoPainter.cxx:94
 TGLLegoPainter.cxx:95
 TGLLegoPainter.cxx:96
 TGLLegoPainter.cxx:97
 TGLLegoPainter.cxx:98
 TGLLegoPainter.cxx:99
 TGLLegoPainter.cxx:100
 TGLLegoPainter.cxx:101
 TGLLegoPainter.cxx:102
 TGLLegoPainter.cxx:103
 TGLLegoPainter.cxx:104
 TGLLegoPainter.cxx:105
 TGLLegoPainter.cxx:106
 TGLLegoPainter.cxx:107
 TGLLegoPainter.cxx:108
 TGLLegoPainter.cxx:109
 TGLLegoPainter.cxx:110
 TGLLegoPainter.cxx:111
 TGLLegoPainter.cxx:112
 TGLLegoPainter.cxx:113
 TGLLegoPainter.cxx:114
 TGLLegoPainter.cxx:115
 TGLLegoPainter.cxx:116
 TGLLegoPainter.cxx:117
 TGLLegoPainter.cxx:118
 TGLLegoPainter.cxx:119
 TGLLegoPainter.cxx:120
 TGLLegoPainter.cxx:121
 TGLLegoPainter.cxx:122
 TGLLegoPainter.cxx:123
 TGLLegoPainter.cxx:124
 TGLLegoPainter.cxx:125
 TGLLegoPainter.cxx:126
 TGLLegoPainter.cxx:127
 TGLLegoPainter.cxx:128
 TGLLegoPainter.cxx:129
 TGLLegoPainter.cxx:130
 TGLLegoPainter.cxx:131
 TGLLegoPainter.cxx:132
 TGLLegoPainter.cxx:133
 TGLLegoPainter.cxx:134
 TGLLegoPainter.cxx:135
 TGLLegoPainter.cxx:136
 TGLLegoPainter.cxx:137
 TGLLegoPainter.cxx:138
 TGLLegoPainter.cxx:139
 TGLLegoPainter.cxx:140
 TGLLegoPainter.cxx:141
 TGLLegoPainter.cxx:142
 TGLLegoPainter.cxx:143
 TGLLegoPainter.cxx:144
 TGLLegoPainter.cxx:145
 TGLLegoPainter.cxx:146
 TGLLegoPainter.cxx:147
 TGLLegoPainter.cxx:148
 TGLLegoPainter.cxx:149
 TGLLegoPainter.cxx:150
 TGLLegoPainter.cxx:151
 TGLLegoPainter.cxx:152
 TGLLegoPainter.cxx:153
 TGLLegoPainter.cxx:154
 TGLLegoPainter.cxx:155
 TGLLegoPainter.cxx:156
 TGLLegoPainter.cxx:157
 TGLLegoPainter.cxx:158
 TGLLegoPainter.cxx:159
 TGLLegoPainter.cxx:160
 TGLLegoPainter.cxx:161
 TGLLegoPainter.cxx:162
 TGLLegoPainter.cxx:163
 TGLLegoPainter.cxx:164
 TGLLegoPainter.cxx:165
 TGLLegoPainter.cxx:166
 TGLLegoPainter.cxx:167
 TGLLegoPainter.cxx:168
 TGLLegoPainter.cxx:169
 TGLLegoPainter.cxx:170
 TGLLegoPainter.cxx:171
 TGLLegoPainter.cxx:172
 TGLLegoPainter.cxx:173
 TGLLegoPainter.cxx:174
 TGLLegoPainter.cxx:175
 TGLLegoPainter.cxx:176
 TGLLegoPainter.cxx:177
 TGLLegoPainter.cxx:178
 TGLLegoPainter.cxx:179
 TGLLegoPainter.cxx:180
 TGLLegoPainter.cxx:181
 TGLLegoPainter.cxx:182
 TGLLegoPainter.cxx:183
 TGLLegoPainter.cxx:184
 TGLLegoPainter.cxx:185
 TGLLegoPainter.cxx:186
 TGLLegoPainter.cxx:187
 TGLLegoPainter.cxx:188
 TGLLegoPainter.cxx:189
 TGLLegoPainter.cxx:190
 TGLLegoPainter.cxx:191
 TGLLegoPainter.cxx:192
 TGLLegoPainter.cxx:193
 TGLLegoPainter.cxx:194
 TGLLegoPainter.cxx:195
 TGLLegoPainter.cxx:196
 TGLLegoPainter.cxx:197
 TGLLegoPainter.cxx:198
 TGLLegoPainter.cxx:199
 TGLLegoPainter.cxx:200
 TGLLegoPainter.cxx:201
 TGLLegoPainter.cxx:202
 TGLLegoPainter.cxx:203
 TGLLegoPainter.cxx:204
 TGLLegoPainter.cxx:205
 TGLLegoPainter.cxx:206
 TGLLegoPainter.cxx:207
 TGLLegoPainter.cxx:208
 TGLLegoPainter.cxx:209
 TGLLegoPainter.cxx:210
 TGLLegoPainter.cxx:211
 TGLLegoPainter.cxx:212
 TGLLegoPainter.cxx:213
 TGLLegoPainter.cxx:214
 TGLLegoPainter.cxx:215
 TGLLegoPainter.cxx:216
 TGLLegoPainter.cxx:217
 TGLLegoPainter.cxx:218
 TGLLegoPainter.cxx:219
 TGLLegoPainter.cxx:220
 TGLLegoPainter.cxx:221
 TGLLegoPainter.cxx:222
 TGLLegoPainter.cxx:223
 TGLLegoPainter.cxx:224
 TGLLegoPainter.cxx:225
 TGLLegoPainter.cxx:226
 TGLLegoPainter.cxx:227
 TGLLegoPainter.cxx:228
 TGLLegoPainter.cxx:229
 TGLLegoPainter.cxx:230
 TGLLegoPainter.cxx:231
 TGLLegoPainter.cxx:232
 TGLLegoPainter.cxx:233
 TGLLegoPainter.cxx:234
 TGLLegoPainter.cxx:235
 TGLLegoPainter.cxx:236
 TGLLegoPainter.cxx:237
 TGLLegoPainter.cxx:238
 TGLLegoPainter.cxx:239
 TGLLegoPainter.cxx:240
 TGLLegoPainter.cxx:241
 TGLLegoPainter.cxx:242
 TGLLegoPainter.cxx:243
 TGLLegoPainter.cxx:244
 TGLLegoPainter.cxx:245
 TGLLegoPainter.cxx:246
 TGLLegoPainter.cxx:247
 TGLLegoPainter.cxx:248
 TGLLegoPainter.cxx:249
 TGLLegoPainter.cxx:250
 TGLLegoPainter.cxx:251
 TGLLegoPainter.cxx:252
 TGLLegoPainter.cxx:253
 TGLLegoPainter.cxx:254
 TGLLegoPainter.cxx:255
 TGLLegoPainter.cxx:256
 TGLLegoPainter.cxx:257
 TGLLegoPainter.cxx:258
 TGLLegoPainter.cxx:259
 TGLLegoPainter.cxx:260
 TGLLegoPainter.cxx:261
 TGLLegoPainter.cxx:262
 TGLLegoPainter.cxx:263
 TGLLegoPainter.cxx:264
 TGLLegoPainter.cxx:265
 TGLLegoPainter.cxx:266
 TGLLegoPainter.cxx:267
 TGLLegoPainter.cxx:268
 TGLLegoPainter.cxx:269
 TGLLegoPainter.cxx:270
 TGLLegoPainter.cxx:271
 TGLLegoPainter.cxx:272
 TGLLegoPainter.cxx:273
 TGLLegoPainter.cxx:274
 TGLLegoPainter.cxx:275
 TGLLegoPainter.cxx:276
 TGLLegoPainter.cxx:277
 TGLLegoPainter.cxx:278
 TGLLegoPainter.cxx:279
 TGLLegoPainter.cxx:280
 TGLLegoPainter.cxx:281
 TGLLegoPainter.cxx:282
 TGLLegoPainter.cxx:283
 TGLLegoPainter.cxx:284
 TGLLegoPainter.cxx:285
 TGLLegoPainter.cxx:286
 TGLLegoPainter.cxx:287
 TGLLegoPainter.cxx:288
 TGLLegoPainter.cxx:289
 TGLLegoPainter.cxx:290
 TGLLegoPainter.cxx:291
 TGLLegoPainter.cxx:292
 TGLLegoPainter.cxx:293
 TGLLegoPainter.cxx:294
 TGLLegoPainter.cxx:295
 TGLLegoPainter.cxx:296
 TGLLegoPainter.cxx:297
 TGLLegoPainter.cxx:298
 TGLLegoPainter.cxx:299
 TGLLegoPainter.cxx:300
 TGLLegoPainter.cxx:301
 TGLLegoPainter.cxx:302
 TGLLegoPainter.cxx:303
 TGLLegoPainter.cxx:304
 TGLLegoPainter.cxx:305
 TGLLegoPainter.cxx:306
 TGLLegoPainter.cxx:307
 TGLLegoPainter.cxx:308
 TGLLegoPainter.cxx:309
 TGLLegoPainter.cxx:310
 TGLLegoPainter.cxx:311
 TGLLegoPainter.cxx:312
 TGLLegoPainter.cxx:313
 TGLLegoPainter.cxx:314
 TGLLegoPainter.cxx:315
 TGLLegoPainter.cxx:316
 TGLLegoPainter.cxx:317
 TGLLegoPainter.cxx:318
 TGLLegoPainter.cxx:319
 TGLLegoPainter.cxx:320
 TGLLegoPainter.cxx:321
 TGLLegoPainter.cxx:322
 TGLLegoPainter.cxx:323
 TGLLegoPainter.cxx:324
 TGLLegoPainter.cxx:325
 TGLLegoPainter.cxx:326
 TGLLegoPainter.cxx:327
 TGLLegoPainter.cxx:328
 TGLLegoPainter.cxx:329
 TGLLegoPainter.cxx:330
 TGLLegoPainter.cxx:331
 TGLLegoPainter.cxx:332
 TGLLegoPainter.cxx:333
 TGLLegoPainter.cxx:334
 TGLLegoPainter.cxx:335
 TGLLegoPainter.cxx:336
 TGLLegoPainter.cxx:337
 TGLLegoPainter.cxx:338
 TGLLegoPainter.cxx:339
 TGLLegoPainter.cxx:340
 TGLLegoPainter.cxx:341
 TGLLegoPainter.cxx:342
 TGLLegoPainter.cxx:343
 TGLLegoPainter.cxx:344
 TGLLegoPainter.cxx:345
 TGLLegoPainter.cxx:346
 TGLLegoPainter.cxx:347
 TGLLegoPainter.cxx:348
 TGLLegoPainter.cxx:349
 TGLLegoPainter.cxx:350
 TGLLegoPainter.cxx:351
 TGLLegoPainter.cxx:352
 TGLLegoPainter.cxx:353
 TGLLegoPainter.cxx:354
 TGLLegoPainter.cxx:355
 TGLLegoPainter.cxx:356
 TGLLegoPainter.cxx:357
 TGLLegoPainter.cxx:358
 TGLLegoPainter.cxx:359
 TGLLegoPainter.cxx:360
 TGLLegoPainter.cxx:361
 TGLLegoPainter.cxx:362
 TGLLegoPainter.cxx:363
 TGLLegoPainter.cxx:364
 TGLLegoPainter.cxx:365
 TGLLegoPainter.cxx:366
 TGLLegoPainter.cxx:367
 TGLLegoPainter.cxx:368
 TGLLegoPainter.cxx:369
 TGLLegoPainter.cxx:370
 TGLLegoPainter.cxx:371
 TGLLegoPainter.cxx:372
 TGLLegoPainter.cxx:373
 TGLLegoPainter.cxx:374
 TGLLegoPainter.cxx:375
 TGLLegoPainter.cxx:376
 TGLLegoPainter.cxx:377
 TGLLegoPainter.cxx:378
 TGLLegoPainter.cxx:379
 TGLLegoPainter.cxx:380
 TGLLegoPainter.cxx:381
 TGLLegoPainter.cxx:382
 TGLLegoPainter.cxx:383
 TGLLegoPainter.cxx:384
 TGLLegoPainter.cxx:385
 TGLLegoPainter.cxx:386
 TGLLegoPainter.cxx:387
 TGLLegoPainter.cxx:388
 TGLLegoPainter.cxx:389
 TGLLegoPainter.cxx:390
 TGLLegoPainter.cxx:391
 TGLLegoPainter.cxx:392
 TGLLegoPainter.cxx:393
 TGLLegoPainter.cxx:394
 TGLLegoPainter.cxx:395
 TGLLegoPainter.cxx:396
 TGLLegoPainter.cxx:397
 TGLLegoPainter.cxx:398
 TGLLegoPainter.cxx:399
 TGLLegoPainter.cxx:400
 TGLLegoPainter.cxx:401
 TGLLegoPainter.cxx:402
 TGLLegoPainter.cxx:403
 TGLLegoPainter.cxx:404
 TGLLegoPainter.cxx:405
 TGLLegoPainter.cxx:406
 TGLLegoPainter.cxx:407
 TGLLegoPainter.cxx:408
 TGLLegoPainter.cxx:409
 TGLLegoPainter.cxx:410
 TGLLegoPainter.cxx:411
 TGLLegoPainter.cxx:412
 TGLLegoPainter.cxx:413
 TGLLegoPainter.cxx:414
 TGLLegoPainter.cxx:415
 TGLLegoPainter.cxx:416
 TGLLegoPainter.cxx:417
 TGLLegoPainter.cxx:418
 TGLLegoPainter.cxx:419
 TGLLegoPainter.cxx:420
 TGLLegoPainter.cxx:421
 TGLLegoPainter.cxx:422
 TGLLegoPainter.cxx:423
 TGLLegoPainter.cxx:424
 TGLLegoPainter.cxx:425
 TGLLegoPainter.cxx:426
 TGLLegoPainter.cxx:427
 TGLLegoPainter.cxx:428
 TGLLegoPainter.cxx:429
 TGLLegoPainter.cxx:430
 TGLLegoPainter.cxx:431
 TGLLegoPainter.cxx:432
 TGLLegoPainter.cxx:433
 TGLLegoPainter.cxx:434
 TGLLegoPainter.cxx:435
 TGLLegoPainter.cxx:436
 TGLLegoPainter.cxx:437
 TGLLegoPainter.cxx:438
 TGLLegoPainter.cxx:439
 TGLLegoPainter.cxx:440
 TGLLegoPainter.cxx:441
 TGLLegoPainter.cxx:442
 TGLLegoPainter.cxx:443
 TGLLegoPainter.cxx:444
 TGLLegoPainter.cxx:445
 TGLLegoPainter.cxx:446
 TGLLegoPainter.cxx:447
 TGLLegoPainter.cxx:448
 TGLLegoPainter.cxx:449
 TGLLegoPainter.cxx:450
 TGLLegoPainter.cxx:451
 TGLLegoPainter.cxx:452
 TGLLegoPainter.cxx:453
 TGLLegoPainter.cxx:454
 TGLLegoPainter.cxx:455
 TGLLegoPainter.cxx:456
 TGLLegoPainter.cxx:457
 TGLLegoPainter.cxx:458
 TGLLegoPainter.cxx:459
 TGLLegoPainter.cxx:460
 TGLLegoPainter.cxx:461
 TGLLegoPainter.cxx:462
 TGLLegoPainter.cxx:463
 TGLLegoPainter.cxx:464
 TGLLegoPainter.cxx:465
 TGLLegoPainter.cxx:466
 TGLLegoPainter.cxx:467
 TGLLegoPainter.cxx:468
 TGLLegoPainter.cxx:469
 TGLLegoPainter.cxx:470
 TGLLegoPainter.cxx:471
 TGLLegoPainter.cxx:472
 TGLLegoPainter.cxx:473
 TGLLegoPainter.cxx:474
 TGLLegoPainter.cxx:475
 TGLLegoPainter.cxx:476
 TGLLegoPainter.cxx:477
 TGLLegoPainter.cxx:478
 TGLLegoPainter.cxx:479
 TGLLegoPainter.cxx:480
 TGLLegoPainter.cxx:481
 TGLLegoPainter.cxx:482
 TGLLegoPainter.cxx:483
 TGLLegoPainter.cxx:484
 TGLLegoPainter.cxx:485
 TGLLegoPainter.cxx:486
 TGLLegoPainter.cxx:487
 TGLLegoPainter.cxx:488
 TGLLegoPainter.cxx:489
 TGLLegoPainter.cxx:490
 TGLLegoPainter.cxx:491
 TGLLegoPainter.cxx:492
 TGLLegoPainter.cxx:493
 TGLLegoPainter.cxx:494
 TGLLegoPainter.cxx:495
 TGLLegoPainter.cxx:496
 TGLLegoPainter.cxx:497
 TGLLegoPainter.cxx:498
 TGLLegoPainter.cxx:499
 TGLLegoPainter.cxx:500
 TGLLegoPainter.cxx:501
 TGLLegoPainter.cxx:502
 TGLLegoPainter.cxx:503
 TGLLegoPainter.cxx:504
 TGLLegoPainter.cxx:505
 TGLLegoPainter.cxx:506
 TGLLegoPainter.cxx:507
 TGLLegoPainter.cxx:508
 TGLLegoPainter.cxx:509
 TGLLegoPainter.cxx:510
 TGLLegoPainter.cxx:511
 TGLLegoPainter.cxx:512
 TGLLegoPainter.cxx:513
 TGLLegoPainter.cxx:514
 TGLLegoPainter.cxx:515
 TGLLegoPainter.cxx:516
 TGLLegoPainter.cxx:517
 TGLLegoPainter.cxx:518
 TGLLegoPainter.cxx:519
 TGLLegoPainter.cxx:520
 TGLLegoPainter.cxx:521
 TGLLegoPainter.cxx:522
 TGLLegoPainter.cxx:523
 TGLLegoPainter.cxx:524
 TGLLegoPainter.cxx:525
 TGLLegoPainter.cxx:526
 TGLLegoPainter.cxx:527
 TGLLegoPainter.cxx:528
 TGLLegoPainter.cxx:529
 TGLLegoPainter.cxx:530
 TGLLegoPainter.cxx:531
 TGLLegoPainter.cxx:532
 TGLLegoPainter.cxx:533
 TGLLegoPainter.cxx:534
 TGLLegoPainter.cxx:535
 TGLLegoPainter.cxx:536
 TGLLegoPainter.cxx:537
 TGLLegoPainter.cxx:538
 TGLLegoPainter.cxx:539
 TGLLegoPainter.cxx:540
 TGLLegoPainter.cxx:541
 TGLLegoPainter.cxx:542
 TGLLegoPainter.cxx:543
 TGLLegoPainter.cxx:544
 TGLLegoPainter.cxx:545
 TGLLegoPainter.cxx:546
 TGLLegoPainter.cxx:547
 TGLLegoPainter.cxx:548
 TGLLegoPainter.cxx:549
 TGLLegoPainter.cxx:550
 TGLLegoPainter.cxx:551
 TGLLegoPainter.cxx:552
 TGLLegoPainter.cxx:553
 TGLLegoPainter.cxx:554
 TGLLegoPainter.cxx:555
 TGLLegoPainter.cxx:556
 TGLLegoPainter.cxx:557
 TGLLegoPainter.cxx:558
 TGLLegoPainter.cxx:559
 TGLLegoPainter.cxx:560
 TGLLegoPainter.cxx:561
 TGLLegoPainter.cxx:562
 TGLLegoPainter.cxx:563
 TGLLegoPainter.cxx:564
 TGLLegoPainter.cxx:565
 TGLLegoPainter.cxx:566
 TGLLegoPainter.cxx:567
 TGLLegoPainter.cxx:568
 TGLLegoPainter.cxx:569
 TGLLegoPainter.cxx:570
 TGLLegoPainter.cxx:571
 TGLLegoPainter.cxx:572
 TGLLegoPainter.cxx:573
 TGLLegoPainter.cxx:574
 TGLLegoPainter.cxx:575
 TGLLegoPainter.cxx:576
 TGLLegoPainter.cxx:577
 TGLLegoPainter.cxx:578
 TGLLegoPainter.cxx:579
 TGLLegoPainter.cxx:580
 TGLLegoPainter.cxx:581
 TGLLegoPainter.cxx:582
 TGLLegoPainter.cxx:583
 TGLLegoPainter.cxx:584
 TGLLegoPainter.cxx:585
 TGLLegoPainter.cxx:586
 TGLLegoPainter.cxx:587
 TGLLegoPainter.cxx:588
 TGLLegoPainter.cxx:589
 TGLLegoPainter.cxx:590
 TGLLegoPainter.cxx:591
 TGLLegoPainter.cxx:592
 TGLLegoPainter.cxx:593
 TGLLegoPainter.cxx:594
 TGLLegoPainter.cxx:595
 TGLLegoPainter.cxx:596
 TGLLegoPainter.cxx:597
 TGLLegoPainter.cxx:598
 TGLLegoPainter.cxx:599
 TGLLegoPainter.cxx:600
 TGLLegoPainter.cxx:601
 TGLLegoPainter.cxx:602
 TGLLegoPainter.cxx:603
 TGLLegoPainter.cxx:604
 TGLLegoPainter.cxx:605
 TGLLegoPainter.cxx:606
 TGLLegoPainter.cxx:607
 TGLLegoPainter.cxx:608
 TGLLegoPainter.cxx:609
 TGLLegoPainter.cxx:610
 TGLLegoPainter.cxx:611
 TGLLegoPainter.cxx:612
 TGLLegoPainter.cxx:613
 TGLLegoPainter.cxx:614
 TGLLegoPainter.cxx:615
 TGLLegoPainter.cxx:616
 TGLLegoPainter.cxx:617
 TGLLegoPainter.cxx:618
 TGLLegoPainter.cxx:619
 TGLLegoPainter.cxx:620
 TGLLegoPainter.cxx:621
 TGLLegoPainter.cxx:622
 TGLLegoPainter.cxx:623
 TGLLegoPainter.cxx:624
 TGLLegoPainter.cxx:625
 TGLLegoPainter.cxx:626
 TGLLegoPainter.cxx:627
 TGLLegoPainter.cxx:628
 TGLLegoPainter.cxx:629
 TGLLegoPainter.cxx:630
 TGLLegoPainter.cxx:631
 TGLLegoPainter.cxx:632
 TGLLegoPainter.cxx:633
 TGLLegoPainter.cxx:634
 TGLLegoPainter.cxx:635
 TGLLegoPainter.cxx:636
 TGLLegoPainter.cxx:637
 TGLLegoPainter.cxx:638
 TGLLegoPainter.cxx:639
 TGLLegoPainter.cxx:640
 TGLLegoPainter.cxx:641
 TGLLegoPainter.cxx:642
 TGLLegoPainter.cxx:643
 TGLLegoPainter.cxx:644
 TGLLegoPainter.cxx:645
 TGLLegoPainter.cxx:646
 TGLLegoPainter.cxx:647
 TGLLegoPainter.cxx:648
 TGLLegoPainter.cxx:649
 TGLLegoPainter.cxx:650
 TGLLegoPainter.cxx:651
 TGLLegoPainter.cxx:652
 TGLLegoPainter.cxx:653
 TGLLegoPainter.cxx:654
 TGLLegoPainter.cxx:655
 TGLLegoPainter.cxx:656
 TGLLegoPainter.cxx:657
 TGLLegoPainter.cxx:658
 TGLLegoPainter.cxx:659
 TGLLegoPainter.cxx:660
 TGLLegoPainter.cxx:661
 TGLLegoPainter.cxx:662
 TGLLegoPainter.cxx:663
 TGLLegoPainter.cxx:664
 TGLLegoPainter.cxx:665
 TGLLegoPainter.cxx:666
 TGLLegoPainter.cxx:667
 TGLLegoPainter.cxx:668
 TGLLegoPainter.cxx:669
 TGLLegoPainter.cxx:670
 TGLLegoPainter.cxx:671
 TGLLegoPainter.cxx:672
 TGLLegoPainter.cxx:673
 TGLLegoPainter.cxx:674
 TGLLegoPainter.cxx:675
 TGLLegoPainter.cxx:676
 TGLLegoPainter.cxx:677
 TGLLegoPainter.cxx:678
 TGLLegoPainter.cxx:679
 TGLLegoPainter.cxx:680
 TGLLegoPainter.cxx:681
 TGLLegoPainter.cxx:682
 TGLLegoPainter.cxx:683
 TGLLegoPainter.cxx:684
 TGLLegoPainter.cxx:685
 TGLLegoPainter.cxx:686
 TGLLegoPainter.cxx:687
 TGLLegoPainter.cxx:688
 TGLLegoPainter.cxx:689
 TGLLegoPainter.cxx:690
 TGLLegoPainter.cxx:691
 TGLLegoPainter.cxx:692
 TGLLegoPainter.cxx:693
 TGLLegoPainter.cxx:694
 TGLLegoPainter.cxx:695
 TGLLegoPainter.cxx:696
 TGLLegoPainter.cxx:697
 TGLLegoPainter.cxx:698
 TGLLegoPainter.cxx:699
 TGLLegoPainter.cxx:700
 TGLLegoPainter.cxx:701
 TGLLegoPainter.cxx:702
 TGLLegoPainter.cxx:703
 TGLLegoPainter.cxx:704
 TGLLegoPainter.cxx:705
 TGLLegoPainter.cxx:706
 TGLLegoPainter.cxx:707
 TGLLegoPainter.cxx:708
 TGLLegoPainter.cxx:709
 TGLLegoPainter.cxx:710
 TGLLegoPainter.cxx:711
 TGLLegoPainter.cxx:712
 TGLLegoPainter.cxx:713
 TGLLegoPainter.cxx:714
 TGLLegoPainter.cxx:715
 TGLLegoPainter.cxx:716
 TGLLegoPainter.cxx:717
 TGLLegoPainter.cxx:718
 TGLLegoPainter.cxx:719
 TGLLegoPainter.cxx:720
 TGLLegoPainter.cxx:721
 TGLLegoPainter.cxx:722
 TGLLegoPainter.cxx:723
 TGLLegoPainter.cxx:724
 TGLLegoPainter.cxx:725
 TGLLegoPainter.cxx:726
 TGLLegoPainter.cxx:727
 TGLLegoPainter.cxx:728
 TGLLegoPainter.cxx:729
 TGLLegoPainter.cxx:730
 TGLLegoPainter.cxx:731
 TGLLegoPainter.cxx:732
 TGLLegoPainter.cxx:733
 TGLLegoPainter.cxx:734
 TGLLegoPainter.cxx:735
 TGLLegoPainter.cxx:736
 TGLLegoPainter.cxx:737
 TGLLegoPainter.cxx:738
 TGLLegoPainter.cxx:739
 TGLLegoPainter.cxx:740
 TGLLegoPainter.cxx:741
 TGLLegoPainter.cxx:742
 TGLLegoPainter.cxx:743
 TGLLegoPainter.cxx:744
 TGLLegoPainter.cxx:745
 TGLLegoPainter.cxx:746
 TGLLegoPainter.cxx:747
 TGLLegoPainter.cxx:748
 TGLLegoPainter.cxx:749
 TGLLegoPainter.cxx:750
 TGLLegoPainter.cxx:751
 TGLLegoPainter.cxx:752
 TGLLegoPainter.cxx:753
 TGLLegoPainter.cxx:754
 TGLLegoPainter.cxx:755
 TGLLegoPainter.cxx:756
 TGLLegoPainter.cxx:757
 TGLLegoPainter.cxx:758
 TGLLegoPainter.cxx:759
 TGLLegoPainter.cxx:760
 TGLLegoPainter.cxx:761
 TGLLegoPainter.cxx:762
 TGLLegoPainter.cxx:763
 TGLLegoPainter.cxx:764
 TGLLegoPainter.cxx:765
 TGLLegoPainter.cxx:766
 TGLLegoPainter.cxx:767
 TGLLegoPainter.cxx:768
 TGLLegoPainter.cxx:769
 TGLLegoPainter.cxx:770
 TGLLegoPainter.cxx:771
 TGLLegoPainter.cxx:772
 TGLLegoPainter.cxx:773
 TGLLegoPainter.cxx:774
 TGLLegoPainter.cxx:775
 TGLLegoPainter.cxx:776
 TGLLegoPainter.cxx:777
 TGLLegoPainter.cxx:778
 TGLLegoPainter.cxx:779
 TGLLegoPainter.cxx:780
 TGLLegoPainter.cxx:781
 TGLLegoPainter.cxx:782
 TGLLegoPainter.cxx:783
 TGLLegoPainter.cxx:784
 TGLLegoPainter.cxx:785
 TGLLegoPainter.cxx:786
 TGLLegoPainter.cxx:787
 TGLLegoPainter.cxx:788
 TGLLegoPainter.cxx:789
 TGLLegoPainter.cxx:790
 TGLLegoPainter.cxx:791
 TGLLegoPainter.cxx:792
 TGLLegoPainter.cxx:793
 TGLLegoPainter.cxx:794
 TGLLegoPainter.cxx:795
 TGLLegoPainter.cxx:796
 TGLLegoPainter.cxx:797
 TGLLegoPainter.cxx:798
 TGLLegoPainter.cxx:799
 TGLLegoPainter.cxx:800
 TGLLegoPainter.cxx:801
 TGLLegoPainter.cxx:802
 TGLLegoPainter.cxx:803
 TGLLegoPainter.cxx:804
 TGLLegoPainter.cxx:805
 TGLLegoPainter.cxx:806
 TGLLegoPainter.cxx:807
 TGLLegoPainter.cxx:808
 TGLLegoPainter.cxx:809
 TGLLegoPainter.cxx:810
 TGLLegoPainter.cxx:811
 TGLLegoPainter.cxx:812
 TGLLegoPainter.cxx:813
 TGLLegoPainter.cxx:814
 TGLLegoPainter.cxx:815
 TGLLegoPainter.cxx:816
 TGLLegoPainter.cxx:817
 TGLLegoPainter.cxx:818
 TGLLegoPainter.cxx:819
 TGLLegoPainter.cxx:820
 TGLLegoPainter.cxx:821
 TGLLegoPainter.cxx:822
 TGLLegoPainter.cxx:823
 TGLLegoPainter.cxx:824
 TGLLegoPainter.cxx:825
 TGLLegoPainter.cxx:826
 TGLLegoPainter.cxx:827
 TGLLegoPainter.cxx:828
 TGLLegoPainter.cxx:829
 TGLLegoPainter.cxx:830
 TGLLegoPainter.cxx:831
 TGLLegoPainter.cxx:832
 TGLLegoPainter.cxx:833
 TGLLegoPainter.cxx:834
 TGLLegoPainter.cxx:835
 TGLLegoPainter.cxx:836
 TGLLegoPainter.cxx:837
 TGLLegoPainter.cxx:838
 TGLLegoPainter.cxx:839
 TGLLegoPainter.cxx:840
 TGLLegoPainter.cxx:841
 TGLLegoPainter.cxx:842
 TGLLegoPainter.cxx:843
 TGLLegoPainter.cxx:844
 TGLLegoPainter.cxx:845
 TGLLegoPainter.cxx:846
 TGLLegoPainter.cxx:847
 TGLLegoPainter.cxx:848
 TGLLegoPainter.cxx:849
 TGLLegoPainter.cxx:850
 TGLLegoPainter.cxx:851
 TGLLegoPainter.cxx:852
 TGLLegoPainter.cxx:853
 TGLLegoPainter.cxx:854
 TGLLegoPainter.cxx:855
 TGLLegoPainter.cxx:856
 TGLLegoPainter.cxx:857
 TGLLegoPainter.cxx:858
 TGLLegoPainter.cxx:859
 TGLLegoPainter.cxx:860
 TGLLegoPainter.cxx:861
 TGLLegoPainter.cxx:862
 TGLLegoPainter.cxx:863
 TGLLegoPainter.cxx:864
 TGLLegoPainter.cxx:865
 TGLLegoPainter.cxx:866
 TGLLegoPainter.cxx:867
 TGLLegoPainter.cxx:868
 TGLLegoPainter.cxx:869
 TGLLegoPainter.cxx:870
 TGLLegoPainter.cxx:871
 TGLLegoPainter.cxx:872
 TGLLegoPainter.cxx:873
 TGLLegoPainter.cxx:874
 TGLLegoPainter.cxx:875
 TGLLegoPainter.cxx:876
 TGLLegoPainter.cxx:877
 TGLLegoPainter.cxx:878
 TGLLegoPainter.cxx:879
 TGLLegoPainter.cxx:880
 TGLLegoPainter.cxx:881
 TGLLegoPainter.cxx:882
 TGLLegoPainter.cxx:883
 TGLLegoPainter.cxx:884
 TGLLegoPainter.cxx:885
 TGLLegoPainter.cxx:886
 TGLLegoPainter.cxx:887
 TGLLegoPainter.cxx:888
 TGLLegoPainter.cxx:889
 TGLLegoPainter.cxx:890
 TGLLegoPainter.cxx:891
 TGLLegoPainter.cxx:892
 TGLLegoPainter.cxx:893
 TGLLegoPainter.cxx:894
 TGLLegoPainter.cxx:895
 TGLLegoPainter.cxx:896
 TGLLegoPainter.cxx:897
 TGLLegoPainter.cxx:898
 TGLLegoPainter.cxx:899
 TGLLegoPainter.cxx:900
 TGLLegoPainter.cxx:901
 TGLLegoPainter.cxx:902
 TGLLegoPainter.cxx:903
 TGLLegoPainter.cxx:904
 TGLLegoPainter.cxx:905
 TGLLegoPainter.cxx:906
 TGLLegoPainter.cxx:907
 TGLLegoPainter.cxx:908
 TGLLegoPainter.cxx:909
 TGLLegoPainter.cxx:910
 TGLLegoPainter.cxx:911
 TGLLegoPainter.cxx:912
 TGLLegoPainter.cxx:913
 TGLLegoPainter.cxx:914
 TGLLegoPainter.cxx:915
 TGLLegoPainter.cxx:916
 TGLLegoPainter.cxx:917
 TGLLegoPainter.cxx:918
 TGLLegoPainter.cxx:919
 TGLLegoPainter.cxx:920
 TGLLegoPainter.cxx:921
 TGLLegoPainter.cxx:922
 TGLLegoPainter.cxx:923
 TGLLegoPainter.cxx:924
 TGLLegoPainter.cxx:925
 TGLLegoPainter.cxx:926
 TGLLegoPainter.cxx:927
 TGLLegoPainter.cxx:928
 TGLLegoPainter.cxx:929
 TGLLegoPainter.cxx:930
 TGLLegoPainter.cxx:931
 TGLLegoPainter.cxx:932
 TGLLegoPainter.cxx:933
 TGLLegoPainter.cxx:934
 TGLLegoPainter.cxx:935
 TGLLegoPainter.cxx:936
 TGLLegoPainter.cxx:937
 TGLLegoPainter.cxx:938
 TGLLegoPainter.cxx:939
 TGLLegoPainter.cxx:940
 TGLLegoPainter.cxx:941
 TGLLegoPainter.cxx:942
 TGLLegoPainter.cxx:943
 TGLLegoPainter.cxx:944
 TGLLegoPainter.cxx:945
 TGLLegoPainter.cxx:946
 TGLLegoPainter.cxx:947
 TGLLegoPainter.cxx:948
 TGLLegoPainter.cxx:949
 TGLLegoPainter.cxx:950
 TGLLegoPainter.cxx:951
 TGLLegoPainter.cxx:952
 TGLLegoPainter.cxx:953
 TGLLegoPainter.cxx:954
 TGLLegoPainter.cxx:955
 TGLLegoPainter.cxx:956
 TGLLegoPainter.cxx:957
 TGLLegoPainter.cxx:958
 TGLLegoPainter.cxx:959
 TGLLegoPainter.cxx:960
 TGLLegoPainter.cxx:961
 TGLLegoPainter.cxx:962
 TGLLegoPainter.cxx:963
 TGLLegoPainter.cxx:964
 TGLLegoPainter.cxx:965
 TGLLegoPainter.cxx:966
 TGLLegoPainter.cxx:967
 TGLLegoPainter.cxx:968
 TGLLegoPainter.cxx:969
 TGLLegoPainter.cxx:970
 TGLLegoPainter.cxx:971
 TGLLegoPainter.cxx:972
 TGLLegoPainter.cxx:973
 TGLLegoPainter.cxx:974
 TGLLegoPainter.cxx:975
 TGLLegoPainter.cxx:976
 TGLLegoPainter.cxx:977
 TGLLegoPainter.cxx:978
 TGLLegoPainter.cxx:979
 TGLLegoPainter.cxx:980
 TGLLegoPainter.cxx:981
 TGLLegoPainter.cxx:982
 TGLLegoPainter.cxx:983
 TGLLegoPainter.cxx:984
 TGLLegoPainter.cxx:985
 TGLLegoPainter.cxx:986
 TGLLegoPainter.cxx:987
 TGLLegoPainter.cxx:988
 TGLLegoPainter.cxx:989
 TGLLegoPainter.cxx:990
 TGLLegoPainter.cxx:991
 TGLLegoPainter.cxx:992
 TGLLegoPainter.cxx:993
 TGLLegoPainter.cxx:994
 TGLLegoPainter.cxx:995
 TGLLegoPainter.cxx:996
 TGLLegoPainter.cxx:997
 TGLLegoPainter.cxx:998
 TGLLegoPainter.cxx:999
 TGLLegoPainter.cxx:1000
 TGLLegoPainter.cxx:1001
 TGLLegoPainter.cxx:1002
 TGLLegoPainter.cxx:1003
 TGLLegoPainter.cxx:1004
 TGLLegoPainter.cxx:1005
 TGLLegoPainter.cxx:1006
 TGLLegoPainter.cxx:1007
 TGLLegoPainter.cxx:1008
 TGLLegoPainter.cxx:1009
 TGLLegoPainter.cxx:1010
 TGLLegoPainter.cxx:1011
 TGLLegoPainter.cxx:1012
 TGLLegoPainter.cxx:1013
 TGLLegoPainter.cxx:1014
 TGLLegoPainter.cxx:1015
 TGLLegoPainter.cxx:1016
 TGLLegoPainter.cxx:1017
 TGLLegoPainter.cxx:1018
 TGLLegoPainter.cxx:1019
 TGLLegoPainter.cxx:1020
 TGLLegoPainter.cxx:1021
 TGLLegoPainter.cxx:1022
 TGLLegoPainter.cxx:1023
 TGLLegoPainter.cxx:1024
 TGLLegoPainter.cxx:1025
 TGLLegoPainter.cxx:1026
 TGLLegoPainter.cxx:1027
 TGLLegoPainter.cxx:1028
 TGLLegoPainter.cxx:1029
 TGLLegoPainter.cxx:1030
 TGLLegoPainter.cxx:1031
 TGLLegoPainter.cxx:1032
 TGLLegoPainter.cxx:1033
 TGLLegoPainter.cxx:1034
 TGLLegoPainter.cxx:1035
 TGLLegoPainter.cxx:1036
 TGLLegoPainter.cxx:1037
 TGLLegoPainter.cxx:1038
 TGLLegoPainter.cxx:1039
 TGLLegoPainter.cxx:1040
 TGLLegoPainter.cxx:1041
 TGLLegoPainter.cxx:1042
 TGLLegoPainter.cxx:1043
 TGLLegoPainter.cxx:1044
 TGLLegoPainter.cxx:1045
 TGLLegoPainter.cxx:1046
 TGLLegoPainter.cxx:1047
 TGLLegoPainter.cxx:1048
 TGLLegoPainter.cxx:1049
 TGLLegoPainter.cxx:1050
 TGLLegoPainter.cxx:1051
 TGLLegoPainter.cxx:1052
 TGLLegoPainter.cxx:1053
 TGLLegoPainter.cxx:1054
 TGLLegoPainter.cxx:1055
 TGLLegoPainter.cxx:1056
 TGLLegoPainter.cxx:1057
 TGLLegoPainter.cxx:1058
 TGLLegoPainter.cxx:1059
 TGLLegoPainter.cxx:1060
 TGLLegoPainter.cxx:1061
 TGLLegoPainter.cxx:1062
 TGLLegoPainter.cxx:1063
 TGLLegoPainter.cxx:1064
 TGLLegoPainter.cxx:1065
 TGLLegoPainter.cxx:1066
 TGLLegoPainter.cxx:1067
 TGLLegoPainter.cxx:1068
 TGLLegoPainter.cxx:1069
 TGLLegoPainter.cxx:1070
 TGLLegoPainter.cxx:1071
 TGLLegoPainter.cxx:1072
 TGLLegoPainter.cxx:1073
 TGLLegoPainter.cxx:1074
 TGLLegoPainter.cxx:1075
 TGLLegoPainter.cxx:1076
 TGLLegoPainter.cxx:1077
 TGLLegoPainter.cxx:1078
 TGLLegoPainter.cxx:1079
 TGLLegoPainter.cxx:1080
 TGLLegoPainter.cxx:1081
 TGLLegoPainter.cxx:1082
 TGLLegoPainter.cxx:1083
 TGLLegoPainter.cxx:1084
 TGLLegoPainter.cxx:1085
 TGLLegoPainter.cxx:1086
 TGLLegoPainter.cxx:1087
 TGLLegoPainter.cxx:1088
 TGLLegoPainter.cxx:1089
 TGLLegoPainter.cxx:1090
 TGLLegoPainter.cxx:1091
 TGLLegoPainter.cxx:1092
 TGLLegoPainter.cxx:1093
 TGLLegoPainter.cxx:1094
 TGLLegoPainter.cxx:1095
 TGLLegoPainter.cxx:1096
 TGLLegoPainter.cxx:1097
 TGLLegoPainter.cxx:1098
 TGLLegoPainter.cxx:1099
 TGLLegoPainter.cxx:1100
 TGLLegoPainter.cxx:1101
 TGLLegoPainter.cxx:1102
 TGLLegoPainter.cxx:1103
 TGLLegoPainter.cxx:1104
 TGLLegoPainter.cxx:1105
 TGLLegoPainter.cxx:1106
 TGLLegoPainter.cxx:1107
 TGLLegoPainter.cxx:1108
 TGLLegoPainter.cxx:1109
 TGLLegoPainter.cxx:1110
 TGLLegoPainter.cxx:1111
 TGLLegoPainter.cxx:1112
 TGLLegoPainter.cxx:1113
 TGLLegoPainter.cxx:1114
 TGLLegoPainter.cxx:1115
 TGLLegoPainter.cxx:1116
 TGLLegoPainter.cxx:1117
 TGLLegoPainter.cxx:1118
 TGLLegoPainter.cxx:1119
 TGLLegoPainter.cxx:1120
 TGLLegoPainter.cxx:1121
 TGLLegoPainter.cxx:1122
 TGLLegoPainter.cxx:1123
 TGLLegoPainter.cxx:1124
 TGLLegoPainter.cxx:1125
 TGLLegoPainter.cxx:1126
 TGLLegoPainter.cxx:1127
 TGLLegoPainter.cxx:1128
 TGLLegoPainter.cxx:1129
 TGLLegoPainter.cxx:1130
 TGLLegoPainter.cxx:1131
 TGLLegoPainter.cxx:1132
 TGLLegoPainter.cxx:1133
 TGLLegoPainter.cxx:1134