Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 "TAxis.h"
15
16#include "TGLSurfacePainter.h"
17#include "TGLHistPainter.h"
18#include "TGLLegoPainter.h"
19#include "TGLBoxPainter.h"
20#include "TGLTF3Painter.h"
21#include "TGLAxisPainter.h"
22#include "TGLCamera.h"
23
24#include "TGLRnrCtx.h"
25
26#include "TGLIncludes.h"
27
28/** \class TH2GL
29\ingroup opengl
30Rendering of TH2 and derived classes.
31Interface to plot-painters also used for gl-in-pad.
32*/
33
34
35////////////////////////////////////////////////////////////////////////////////
36/// Constructor.
37
39 TGLPlot3D(), fM(nullptr)
40{
41}
42
43////////////////////////////////////////////////////////////////////////////////
44/// Destructor.
45
47{
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Set model object.
52
54{
55 TString option(opt);
56 option.ToLower();
57
59
60 // Plot type
61 if (option.Index("surf") != kNPOS)
62 SetPainter( new TGLSurfacePainter(fM, nullptr, &fCoord) );
63 else
64 SetPainter( new TGLLegoPainter(fM, nullptr, &fCoord) );
65
66 if (option.Index("sph") != kNPOS)
67 fCoord.SetCoordType(kGLSpherical);
68 else if (option.Index("pol") != kNPOS)
69 fCoord.SetCoordType(kGLPolar);
70 else if (option.Index("cyl") != kNPOS)
71 fCoord.SetCoordType(kGLCylindrical);
72
73 fPlotPainter->AddOption(option);
74
75 Ssiz_t pos = option.Index("fb");
76 if (pos != kNPOS) {
77 option.Remove(pos, 2);
78 fPlotPainter->SetDrawFrontBox(kFALSE);
79 }
80
81 pos = option.Index("bb");
82 if (pos != kNPOS)
83 fPlotPainter->SetDrawBackBox(kFALSE);
84
85 pos = option.Index("a");
86 if (pos != kNPOS)
87 fPlotPainter->SetDrawAxes(kFALSE);
88
89 fPlotPainter->InitGeometry();
90
91 return kTRUE;
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Setup bounding-box.
96
98{
99 fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Render the object.
104
105void TH2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
106{
107 fPlotPainter->RefBackBox().FindFrontPoint();
108
109 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
110
111 glEnable(GL_NORMALIZE);
112 glDisable(GL_COLOR_MATERIAL);
113
114 fPlotPainter->InitGL();
115 fPlotPainter->DrawPlot();
116
117 glDisable(GL_CULL_FACE);
118 glPopAttrib();
119
120 // Axes
121 if (fPlotPainter->GetDrawAxes()) {
122 TGLAxisPainterBox axe_painter;
123 axe_painter.SetUseAxisColors(kFALSE);
124 axe_painter.SetFontMode(TGLFont::kPixmap);
125 axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
126 }
127}
int Ssiz_t
String size (currently int).
Definition RtypesCore.h:81
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
@ kGLSpherical
Definition TGLUtil.h:47
@ kGLCylindrical
Definition TGLUtil.h:46
@ kGLPolar
Definition TGLUtil.h:45
Painter class for axes encompassing a 3D box.
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
void SetUseAxisColors(Bool_t x)
void SetFontMode(TGLFont::EMode m)
Plot-painter implementing LEGO rendering of TH2 histograms in cartesian, polar, cylindrical and spher...
TGLBoundingBox fBoundingBox
! Shape's bounding box.
TT * SetModelDynCast(TObject *obj)
Definition TGLObject.h:37
TGLPlot3D(const TGLPlot3D &)=delete
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:51
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.
~TH2GL() override
Destructor.
Definition TH2GL.cxx:46
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
Definition TH2GL.cxx:53
TH2GL()
Constructor.
Definition TH2GL.cxx:38
void SetBBox() override
Setup bounding-box.
Definition TH2GL.cxx:97
TH2 * fM
Definition TH2GL.h:30
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render the object.
Definition TH2GL.cxx:105
Mother of all ROOT objects.
Definition TObject.h:42
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
TString & Remove(Ssiz_t pos)
Definition TString.h:694
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660