00001 // @(#)root/gl:$Id: TH2GL.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 "TH2GL.h" 00013 #include "TH2.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 00028 #include "TGLIncludes.h" 00029 00030 //______________________________________________________________________________ 00031 // 00032 // Rendering of TH2 and derived classes. 00033 // Interface to plot-painters also used for gl-in-pad. 00034 00035 ClassImp(TH2GL); 00036 00037 //______________________________________________________________________________ 00038 TH2GL::TH2GL() : 00039 TGLPlot3D(), fM(0) 00040 { 00041 // Constructor. 00042 } 00043 00044 //______________________________________________________________________________ 00045 TH2GL::~TH2GL() 00046 { 00047 // Destructor. 00048 } 00049 00050 //______________________________________________________________________________ 00051 Bool_t TH2GL::SetModel(TObject* obj, const Option_t* opt) 00052 { 00053 // Set model object. 00054 00055 TString option(opt); 00056 option.ToLower(); 00057 00058 fM = SetModelDynCast<TH2>(obj); 00059 00060 // Plot type 00061 if (option.Index("surf") != kNPOS) 00062 SetPainter( new TGLSurfacePainter(fM, 0, &fCoord) ); 00063 else 00064 SetPainter( new TGLLegoPainter(fM, 0, &fCoord) ); 00065 00066 if (option.Index("sph") != kNPOS) 00067 fCoord.SetCoordType(kGLSpherical); 00068 else if (option.Index("pol") != kNPOS) 00069 fCoord.SetCoordType(kGLPolar); 00070 else if (option.Index("cyl") != kNPOS) 00071 fCoord.SetCoordType(kGLCylindrical); 00072 00073 fPlotPainter->AddOption(option); 00074 fPlotPainter->InitGeometry(); 00075 00076 return kTRUE; 00077 } 00078 00079 //______________________________________________________________________________ 00080 void TH2GL::SetBBox() 00081 { 00082 // Setup bounding-box. 00083 00084 fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox()); 00085 } 00086 00087 //______________________________________________________________________________ 00088 void TH2GL::DirectDraw(TGLRnrCtx & rnrCtx) const 00089 { 00090 // Render the object. 00091 00092 fPlotPainter->RefBackBox().FindFrontPoint(); 00093 00094 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT); 00095 00096 glEnable(GL_NORMALIZE); 00097 glDisable(GL_COLOR_MATERIAL); 00098 00099 fPlotPainter->InitGL(); 00100 fPlotPainter->DrawPlot(); 00101 00102 glDisable(GL_CULL_FACE); 00103 glPopAttrib(); 00104 00105 // Axes 00106 TGLAxisPainterBox axe_painter; 00107 axe_painter.SetUseAxisColors(kFALSE); 00108 axe_painter.SetFontMode(TGLFont::kPixmap); 00109 axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox); 00110 }