TH3GL.cxx

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TH3GL.cxx 36384 2010-10-20 14:26:41Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, 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 "TH3GL.h"
00013 #include "TH3.h"
00014 #include "TVirtualPad.h"
00015 #include "TAxis.h"
00016 #include "TMath.h"
00017 
00018 #include "TGLSurfacePainter.h"
00019 #include "TGLHistPainter.h"
00020 #include "TGLLegoPainter.h"
00021 #include "TGLBoxPainter.h"
00022 #include "TGLTF3Painter.h"
00023 #include "TGLAxisPainter.h"
00024 #include "TGLCamera.h"
00025 
00026 #include "TGLRnrCtx.h"
00027 #include "TGLIncludes.h"
00028 
00029 //______________________________________________________________________________
00030 // OpenGL renderer class for TH3.
00031 //
00032 
00033 ClassImp(TH3GL);
00034 
00035 //______________________________________________________________________________
00036 TH3GL::TH3GL() :
00037    TGLPlot3D(), fM(0)
00038 {
00039    // Constructor.
00040 }
00041 
00042 //______________________________________________________________________________
00043 TH3GL::~TH3GL()
00044 {
00045    // Destructor.
00046 }
00047 
00048 /******************************************************************************/
00049 
00050 //______________________________________________________________________________
00051 Bool_t TH3GL::SetModel(TObject* obj, const Option_t* opt)
00052 {
00053    // Set model object.
00054 
00055    TString option(opt);
00056    option.ToLower();
00057 
00058    fM = SetModelDynCast<TH3>(obj);
00059 
00060    if (option.Index("iso") != kNPOS)
00061       SetPainter( new TGLIsoPainter(fM, 0, &fCoord) );
00062    else if (option.Index("box") != kNPOS)
00063       SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
00064    else {
00065       Warning("SetModel", "Option '%s' not supported, assuming 'box'.", option.Data());
00066       SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
00067    }
00068 
00069    fPlotPainter->AddOption(option);
00070    fPlotPainter->InitGeometry();
00071 
00072    return kTRUE;
00073 }
00074 
00075 //______________________________________________________________________________
00076 void TH3GL::SetBBox()
00077 {
00078    // Set bounding box.
00079 
00080    fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
00081 }
00082 
00083 /******************************************************************************/
00084 
00085 //______________________________________________________________________________
00086 void TH3GL::DirectDraw(TGLRnrCtx & rnrCtx) const
00087 {
00088    // Render with OpenGL.
00089 
00090    fPlotPainter->RefBackBox().FindFrontPoint();
00091 
00092    glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
00093 
00094    glEnable(GL_NORMALIZE);
00095    glDisable(GL_COLOR_MATERIAL);
00096 
00097    fPlotPainter->InitGL();
00098    fPlotPainter->DrawPlot();
00099 
00100    glDisable(GL_CULL_FACE);
00101    glPopAttrib();
00102 
00103    // Axes
00104    TGLAxisPainterBox axe_painter;
00105    axe_painter.SetUseAxisColors(kFALSE);
00106    axe_painter.SetFontMode(TGLFont::kPixmap);
00107    axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
00108 }

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