#include "TF2GL.h"
#include <TF2.h>
#include <TF3.h>
#include <TH2.h>
#include <TVirtualPad.h>
#include "TGLSurfacePainter.h"
#include "TGLTF3Painter.h"
#include "TGLAxis.h"
#include "TGLRnrCtx.h"
#include "TGLIncludes.h"
ClassImp(TF2GL)
TF2GL::TF2GL() : TGLObject(), fM(0), fH(0)
{
fDLCache = kFALSE;
}
TF2GL::~TF2GL()
{
delete fH;
delete fPlotPainter;
}
Bool_t TF2GL::SetModel(TObject* obj, const Option_t* opt)
{
if(SetModelCheckClass(obj, TF2::Class()))
{
fM = dynamic_cast<TF2*>(obj);
fH = (TH2*) fM->CreateHistogram();
if (dynamic_cast<TF3*>(fM))
fPlotPainter = new TGLTF3Painter((TF3*)fM, fH, 0, &fCoord);
else
fPlotPainter = new TGLSurfacePainter(fH, 0, &fCoord);
fCoord.SetXLog(gPad->GetLogx());
fCoord.SetYLog(gPad->GetLogy());
fCoord.SetZLog(gPad->GetLogz());
TString option(opt);
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 TF2GL::SetBBox()
{
fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
}
void TF2GL::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:38:52 2008
Last generated: 2008-06-25 08:38
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.