TF2GL.cxx

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TF2GL.cxx 36384 2010-10-20 14:26:41Z matevz $
00002 // Author:  Matevz Tadel, Jun 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
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 // GL renderer for TF2.
00030 // TGLPlotPainter is used internally.
00031 
00032 ClassImp(TF2GL);
00033 
00034 //______________________________________________________________________________
00035 TF2GL::TF2GL() : TGLPlot3D(), fM(0), fH(0)
00036 {
00037    // Constructor.
00038 }
00039 
00040 //______________________________________________________________________________
00041 TF2GL::~TF2GL()
00042 {
00043    // Destructor.
00044 
00045    delete fH;
00046 }
00047 
00048 /**************************************************************************/
00049 
00050 //______________________________________________________________________________
00051 Bool_t TF2GL::SetModel(TObject* obj, const Option_t* opt)
00052 {
00053    // Set model object.
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    // Setup bounding-box.
00085 
00086    fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
00087 }
00088 
00089 //______________________________________________________________________________
00090 void TF2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
00091 {
00092    // Render the object.
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    // Axes
00108    TGLAxisPainterBox axe_painter;
00109    axe_painter.SetUseAxisColors(kFALSE);
00110    axe_painter.SetFontMode(TGLFont::kPixmap);
00111    axe_painter.PlotStandard(rnrCtx, fH, fBoundingBox);
00112 }

Generated on Tue Jul 5 14:18:05 2011 for ROOT_528-00b_version by  doxygen 1.5.1