ROOT logo
// @(#)root/gl:$Id$
// Author: Matevz Tadel 2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/
#include "TH3GL.h"
#include "TH3.h"
#include "TVirtualPad.h"
#include "TAxis.h"
#include "TMath.h"

#include "TGLSurfacePainter.h"
#include "TGLHistPainter.h"
#include "TGLLegoPainter.h"
#include "TGLBoxPainter.h"
#include "TGLTF3Painter.h"
#include "TGLAxisPainter.h"
#include "TGLPhysicalShape.h"
#include "TGLCamera.h"
#include "TPolyMarker3D.h"

#include "TGLRnrCtx.h"
#include "TGLIncludes.h"

//______________________________________________________________________________
// OpenGL renderer class for TH3.
//

ClassImp(TH3GL);

//______________________________________________________________________________
TH3GL::TH3GL() :
   TGLPlot3D(), fM(0)
{
   // Constructor.
}

//______________________________________________________________________________
TH3GL::TH3GL(TH3 *th3, TPolyMarker3D *pm) :
   TGLPlot3D(), fM(th3)
{
   // Constructor.
   SetPainter(new TGLBoxPainter(th3, pm, 0, &fCoord));
   fPlotPainter->InitGeometry();
}

//______________________________________________________________________________
TH3GL::~TH3GL()
{
   // Destructor.
}

/******************************************************************************/

//______________________________________________________________________________
Bool_t TH3GL::SetModel(TObject* obj, const Option_t* opt)
{
   // Set model object.

   TString option(opt);
   option.ToLower();

   fM = SetModelDynCast<TH3>(obj);

   if (option.Index("iso") != kNPOS)
      SetPainter( new TGLIsoPainter(fM, 0, &fCoord) );
   else if (option.Index("box") != kNPOS)
      SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
   else {
      Warning("SetModel", "Option '%s' not supported, assuming 'box'.", option.Data());
      SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
   }

   fPlotPainter->AddOption(option);

   Ssiz_t pos = option.Index("fb");
   if (pos != kNPOS) {
      option.Remove(pos, 2);
      fPlotPainter->SetDrawFrontBox(kFALSE);
   }

   pos = option.Index("bb");
   if (pos != kNPOS)
      fPlotPainter->SetDrawBackBox(kFALSE);

   pos = option.Index("a");
   if (pos != kNPOS)
      fPlotPainter->SetDrawAxes(kFALSE);


   fPlotPainter->InitGeometry();

   return kTRUE;
}

//______________________________________________________________________________
void TH3GL::SetBBox()
{
   // Set bounding box.

   fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
}

/******************************************************************************/

//______________________________________________________________________________
void TH3GL::DirectDraw(TGLRnrCtx & rnrCtx) const
{
   // Render with OpenGL.
   if (fFirstPhysical)
      fPlotPainter->SetPhysicalShapeColor(fFirstPhysical->Color());

   fPlotPainter->RefBackBox().FindFrontPoint();

   glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);

   glEnable(GL_NORMALIZE);
   glDisable(GL_COLOR_MATERIAL);

   fPlotPainter->InitGL();
   fPlotPainter->DrawPlot();

   glDisable(GL_CULL_FACE);
   glPopAttrib();

   // Axes
   const Rgl::PlotTranslation trGuard(fPlotPainter);

   if (fPlotPainter->GetDrawAxes()) {
      TGLAxisPainterBox axe_painter;
      axe_painter.SetUseAxisColors(kFALSE);
      axe_painter.SetFontMode(TGLFont::kPixmap);
      axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
   }
}
 TH3GL.cxx:1
 TH3GL.cxx:2
 TH3GL.cxx:3
 TH3GL.cxx:4
 TH3GL.cxx:5
 TH3GL.cxx:6
 TH3GL.cxx:7
 TH3GL.cxx:8
 TH3GL.cxx:9
 TH3GL.cxx:10
 TH3GL.cxx:11
 TH3GL.cxx:12
 TH3GL.cxx:13
 TH3GL.cxx:14
 TH3GL.cxx:15
 TH3GL.cxx:16
 TH3GL.cxx:17
 TH3GL.cxx:18
 TH3GL.cxx:19
 TH3GL.cxx:20
 TH3GL.cxx:21
 TH3GL.cxx:22
 TH3GL.cxx:23
 TH3GL.cxx:24
 TH3GL.cxx:25
 TH3GL.cxx:26
 TH3GL.cxx:27
 T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
 TH3GL.cxx:107
 TH3GL.cxx:108
 TH3GL.cxx:109
 TH3GL.cxx:110
 TH3GL.cxx:111
 TH3GL.cxx:112
 TH3GL.cxx:113
 TH3GL.cxx:114
 TH3GL.cxx:115
 TH3GL.cxx:116
 TH3GL.cxx:117
 TH3GL.cxx:118
 TH3GL.cxx:119
 TH3GL.cxx:120
 TH3GL.cxx:121
 TH3GL.cxx:122
 TH3GL.cxx:123
 TH3GL.cxx:124
 TH3GL.cxx:125
 TH3GL.cxx:126
 TH3GL.cxx:127
 TH3GL.cxx:128
 TH3GL.cxx:129
 TH3GL.cxx:130
 TH3GL.cxx:131
 TH3GL.cxx:132
 TH3GL.cxx:133
 TH3GL.cxx:134
 TH3GL.cxx:135
 TH3GL.cxx:136
 TH3GL.cxx:137
 TH3GL.cxx:138
 TH3GL.cxx:139
 TH3GL.cxx:140