#include "TH2GL.h"
#include "TH2.h"
#include "TVirtualPad.h"
#include "TAxis.h"
#include "TMath.h"
#include "TGLSurfacePainter.h"
#include "TGLHistPainter.h"
#include "TGLLegoPainter.h"
#include "TGLBoxPainter.h"
#include "TGLTF3Painter.h"
#include "TGLAxisPainter.h"
#include "TGLCamera.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)
{
TString option(opt);
option.ToLower();
if (SetModelCheckClass(obj, TH2::Class()))
{
fM = dynamic_cast<TH2*>(obj);
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 & rnrCtx) const
{
fPlotPainter->RefBackBox().FindFrontPoint();
glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
glEnable(GL_NORMALIZE);
glDisable(GL_COLOR_MATERIAL);
fPlotPainter->InitGL();
fPlotPainter->DrawPlot();
glDisable(GL_CULL_FACE);
glPopAttrib();
TGLAxisPainterBox axe_painter;
axe_painter.SetFontMode(TGLFont::kPixmap);
axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
}