#include "TH2GL.h"
#include <TH2.h>
#include "TVirtualPad.h"
#include "TGLSurfacePainter.h"
#include "TGLHistPainter.h"
#include "TGLLegoPainter.h"
#include "TGLBoxPainter.h"
#include "TGLTF3Painter.h"
#include "TGLAxis.h"
#include "TGLRnrCtx.h"
#include "TGLIncludes.h"
ClassImp(TH2GL)
TH2GL::TH2GL() : TGLObject(), fM(0), fPlotPainter(0)
{
   
   fDLCache = kFALSE; 
}
TH2GL::~TH2GL()
{
   
   delete fPlotPainter;
}
Bool_t TH2GL::SetModel(TObject* obj, const Option_t* opt)
{
   
   if(SetModelCheckClass(obj, TH2::Class()))
   {
      fM = dynamic_cast<TH2*>(obj);
      TString option(opt);
      
      if (option.Index("iso") != kNPOS)
         fPlotPainter = new TGLIsoPainter(fM, 0, &fCoord);
      else if (option.Index("box") != kNPOS)
         fPlotPainter = new TGLBoxPainter(fM, 0, &fCoord);
      else if (option.Index("surf") != kNPOS)
         fPlotPainter = new TGLSurfacePainter(fM, 0, &fCoord);
      else
         fPlotPainter = new TGLLegoPainter(fM, 0, &fCoord);
      
      fCoord.SetXLog(gPad->GetLogx());
      fCoord.SetYLog(gPad->GetLogy());
      fCoord.SetZLog(gPad->GetLogz());
      if (option.Index("sph") != kNPOS)
         fCoord.SetCoordType(kGLSpherical);
      else if (option.Index("pol") != kNPOS)
         fCoord.SetCoordType(kGLPolar);
      else if (option.Index("cyl") != kNPOS)
         fCoord.SetCoordType(kGLCylindrical);
      fPlotPainter->AddOption(option);
      fPlotPainter->InitGeometry();
      return kTRUE;
   }
   return kFALSE;
}
void TH2GL::SetBBox()
{
   
   fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
}
void TH2GL::DirectDraw(TGLRnrCtx & ) const
{
   
   fPlotPainter->RefBackBox().FindFrontPoint();
   glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
   glEnable(GL_NORMALIZE);
   fPlotPainter->InitGL();
   fPlotPainter->DrawPlot();
   glDisable(GL_CULL_FACE);
   TGLAxis ap;
   const Rgl::Range_t & xr = fCoord.GetXRange();
   ap.PaintGLAxis(fBoundingBox[0].CArr(), fBoundingBox[1].CArr(),
                  xr.first, xr.second, 205);
   const Rgl::Range_t & yr = fCoord.GetXRange();
   ap.PaintGLAxis(fBoundingBox[0].CArr(), fBoundingBox[3].CArr(),
                  yr.first, yr.second, 205);
   const Rgl::Range_t & zr = fCoord.GetXRange();
   ap.PaintGLAxis(fBoundingBox[0].CArr(), fBoundingBox[4].CArr(),
                  zr.first, zr.second, 205);
   glPopAttrib();
}
Last change: Wed Jun 25 08:46:53 2008
Last generated: 2008-06-25 08:46
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.