Logo ROOT   6.14/05
Reference Guide
TH2GL.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TH2GL.h"
13 #include "TH2.h"
14 #include "TVirtualPad.h"
15 #include "TAxis.h"
16 #include "TMath.h"
17 
18 #include "TGLSurfacePainter.h"
19 #include "TGLHistPainter.h"
20 #include "TGLLegoPainter.h"
21 #include "TGLBoxPainter.h"
22 #include "TGLTF3Painter.h"
23 #include "TGLAxisPainter.h"
24 #include "TGLCamera.h"
25 
26 #include "TGLRnrCtx.h"
27 
28 #include "TGLIncludes.h"
29 
30 /** \class TH2GL
31 \ingroup opengl
32 Rendering of TH2 and derived classes.
33 Interface to plot-painters also used for gl-in-pad.
34 */
35 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Constructor.
40 
42  TGLPlot3D(), fM(0)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Destructor.
48 
50 {
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Set model object.
55 
57 {
58  TString option(opt);
59  option.ToLower();
60 
61  fM = SetModelDynCast<TH2>(obj);
62 
63  // Plot type
64  if (option.Index("surf") != kNPOS)
66  else
67  SetPainter( new TGLLegoPainter(fM, 0, &fCoord) );
68 
69  if (option.Index("sph") != kNPOS)
71  else if (option.Index("pol") != kNPOS)
73  else if (option.Index("cyl") != kNPOS)
75 
76  fPlotPainter->AddOption(option);
77 
78  Ssiz_t pos = option.Index("fb");
79  if (pos != kNPOS) {
80  option.Remove(pos, 2);
82  }
83 
84  pos = option.Index("bb");
85  if (pos != kNPOS)
87 
88  pos = option.Index("a");
89  if (pos != kNPOS)
91 
93 
94  return kTRUE;
95 }
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Setup bounding-box.
99 
101 {
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 /// Render the object.
107 
108 void TH2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
109 {
111 
112  glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
113 
114  glEnable(GL_NORMALIZE);
115  glDisable(GL_COLOR_MATERIAL);
116 
117  fPlotPainter->InitGL();
119 
120  glDisable(GL_CULL_FACE);
121  glPopAttrib();
122 
123  // Axes
124  if (fPlotPainter->GetDrawAxes()) {
125  TGLAxisPainterBox axe_painter;
126  axe_painter.SetUseAxisColors(kFALSE);
127  axe_painter.SetFontMode(TGLFont::kPixmap);
128  axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
129  }
130 }
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
void SetUseAxisColors(Bool_t x)
Plot-painter implementing LEGO rendering of TH2 histograms in cartesian, polar, cylindrical and spher...
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
void SetPainter(TGLPlotPainter *p)
Set painter object and destroy the old one.
Definition: TGLPlot3D.cxx:52
const char Option_t
Definition: RtypesCore.h:62
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:303
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
void SetFontMode(TGLFont::EMode m)
Basic string class.
Definition: TString.h:131
Bool_t GetDrawAxes()
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1100
bool Bool_t
Definition: RtypesCore.h:59
Implements painting of TH2 with "SURF" option.
TH2 * fM
Definition: TH2GL.h:30
TGLPlotPainter * fPlotPainter
Definition: TGLPlot3D.h:29
Utility class to paint axis in GL.
Description of TGLPlot3D.
Definition: TGLPlot3D.h:22
Rendering of TH2 and derived classes.
Definition: TH2GL.h:23
void SetDrawBackBox(Bool_t b)
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render the object.
Definition: TH2GL.cxx:108
virtual ~TH2GL()
Destructor.
Definition: TH2GL.cxx:49
Int_t FindFrontPoint() const
Convert 3d points into window coordinate system and find the nearest.
Definition: TGLPlotBox.cxx:245
TGLPlotCoordinates fCoord
Definition: TGLPlot3D.h:30
const TGLPlotBox & RefBackBox() const
virtual void AddOption(const TString &stringOption)=0
const Bool_t kFALSE
Definition: RtypesCore.h:88
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
int Ssiz_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:359
void SetDrawFrontBox(Bool_t b)
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TH2GL.cxx:56
virtual Bool_t InitGeometry()=0
void SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
virtual void SetBBox()
Setup bounding-box.
Definition: TH2GL.cxx:100
Mother of all ROOT objects.
Definition: TObject.h:37
TH2GL()
Constructor.
Definition: TH2GL.cxx:41
virtual void InitGL() const =0
TGLBoundingBox fBoundingBox
Also plays the role of ID.
virtual void DrawPlot() const =0
const Bool_t kTRUE
Definition: RtypesCore.h:87
void SetDrawAxes(Bool_t s)