00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TF2GL.h"
00013
00014 #include <TF2.h>
00015 #include <TF3.h>
00016 #include <TH2.h>
00017 #include <TVirtualPad.h>
00018
00019 #include "TGLSurfacePainter.h"
00020 #include "TGLTF3Painter.h"
00021 #include "TGLAxisPainter.h"
00022
00023 #include "TGLRnrCtx.h"
00024
00025 #include "TGLIncludes.h"
00026
00027
00028
00029
00030
00031
00032 ClassImp(TF2GL);
00033
00034
00035 TF2GL::TF2GL() : TGLPlot3D(), fM(0), fH(0)
00036 {
00037
00038 }
00039
00040
00041 TF2GL::~TF2GL()
00042 {
00043
00044
00045 delete fH;
00046 }
00047
00048
00049
00050
00051 Bool_t TF2GL::SetModel(TObject* obj, const Option_t* opt)
00052 {
00053
00054
00055 TString option(opt);
00056 option.ToLower();
00057
00058 fM = SetModelDynCast<TF2>(obj);
00059
00060 fH = (TH2*) fM->CreateHistogram();
00061 fH->GetZaxis()->SetLimits(fH->GetMinimum(), fH->GetMaximum());
00062
00063 if (dynamic_cast<TF3*>(fM))
00064 SetPainter( new TGLTF3Painter((TF3*)fM, fH, 0, &fCoord) );
00065 else
00066 SetPainter( new TGLSurfacePainter(fH, 0, &fCoord) );
00067
00068 if (option.Index("sph") != kNPOS)
00069 fCoord.SetCoordType(kGLSpherical);
00070 else if (option.Index("pol") != kNPOS)
00071 fCoord.SetCoordType(kGLPolar);
00072 else if (option.Index("cyl") != kNPOS)
00073 fCoord.SetCoordType(kGLCylindrical);
00074
00075 fPlotPainter->AddOption(option);
00076 fPlotPainter->InitGeometry();
00077
00078 return kTRUE;
00079 }
00080
00081
00082 void TF2GL::SetBBox()
00083 {
00084
00085
00086 fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
00087 }
00088
00089
00090 void TF2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
00091 {
00092
00093
00094 fPlotPainter->RefBackBox().FindFrontPoint();
00095
00096 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
00097
00098 glEnable(GL_NORMALIZE);
00099 glDisable(GL_COLOR_MATERIAL);
00100
00101 fPlotPainter->InitGL();
00102 fPlotPainter->DrawPlot();
00103
00104 glDisable(GL_CULL_FACE);
00105 glPopAttrib();
00106
00107
00108 TGLAxisPainterBox axe_painter;
00109 axe_painter.SetUseAxisColors(kFALSE);
00110 axe_painter.SetFontMode(TGLFont::kPixmap);
00111 axe_painter.PlotStandard(rnrCtx, fH, fBoundingBox);
00112 }