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
58 fM = SetModelDynCast<TH2>(obj);
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)
68 else if (option.Index("pol") != kNPOS)
70 else if (option.Index("cyl") != kNPOS)
72
74
75 Ssiz_t pos = option.Index("fb");
76 if (pos != kNPOS) {
77 option.Remove(pos, 2);
79 }
80
81 pos = option.Index("bb");
82 if (pos != kNPOS)
84
85 pos = option.Index("a");
86 if (pos != kNPOS)
88
90
91 return kTRUE;
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Setup bounding-box.
96
101
102////////////////////////////////////////////////////////////////////////////////
103/// Render the object.
104
105void TH2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
106{
108
109 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
110
111 glEnable(GL_NORMALIZE);
112 glDisable(GL_COLOR_MATERIAL);
113
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}
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kGLSpherical
Definition TGLUtil.h:47
@ kGLCylindrical
Definition TGLUtil.h:46
@ kGLPolar
Definition TGLUtil.h:45
Option_t Option_t option
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)
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
! Shape's bounding box.
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:51
Int_t FindFrontPoint() const
Convert 3d points into window coordinate system and find the nearest.
const TGLVertex3 * Get3DBox() const
Get 3D box.
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
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.
~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:137