Logo ROOT  
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
32Rendering of TH2 and derived classes.
33Interface 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
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
108void 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
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}
const Ssiz_t kNPOS
Definition: RtypesCore.h:113
const Bool_t kFALSE
Definition: RtypesCore.h:90
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassImp(name)
Definition: Rtypes.h:361
@ kGLSpherical
Definition: TGLUtil.h:46
@ kGLCylindrical
Definition: TGLUtil.h:45
@ kGLPolar
Definition: TGLUtil.h:44
Utility class to paint axis in GL.
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
void SetUseAxisColors(Bool_t x)
void SetFontMode(TGLFont::EMode m)
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
Plot-painter implementing LEGO rendering of TH2 histograms in cartesian, polar, cylindrical and spher...
TGLBoundingBox fBoundingBox
Also plays the role of ID.
Description of TGLPlot3D.
Definition: TGLPlot3D.h:23
TGLPlotCoordinates fCoord
Definition: TGLPlot3D.h:30
TGLPlotPainter * fPlotPainter
Definition: TGLPlot3D.h:29
void SetPainter(TGLPlotPainter *p)
Set painter object and destroy the old one.
Definition: TGLPlot3D.cxx:52
Int_t FindFrontPoint() const
Convert 3d points into window coordinate system and find the nearest.
Definition: TGLPlotBox.cxx:245
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:303
void SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
const TGLPlotBox & RefBackBox() const
void SetDrawAxes(Bool_t s)
virtual void DrawPlot() const =0
virtual Bool_t InitGeometry()=0
void SetDrawBackBox(Bool_t b)
void SetDrawFrontBox(Bool_t b)
virtual void InitGL() const =0
Bool_t GetDrawAxes()
virtual void AddOption(const TString &stringOption)=0
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
Implements painting of TH2 with "SURF" option.
Rendering of TH2 and derived classes.
Definition: TH2GL.h:24
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render the object.
Definition: TH2GL.cxx:108
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TH2GL.cxx:56
virtual ~TH2GL()
Destructor.
Definition: TH2GL.cxx:49
TH2GL()
Constructor.
Definition: TH2GL.cxx:41
virtual void SetBBox()
Setup bounding-box.
Definition: TH2GL.cxx:100
TH2 * fM
Definition: TH2GL.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634