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
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor.
38
40 TGLPlot3D(), fM(0)
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Destructor.
46
48{
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Set model object.
53
55{
56 TString option(opt);
57 option.ToLower();
58
59 fM = SetModelDynCast<TH2>(obj);
60
61 // Plot type
62 if (option.Index("surf") != kNPOS)
64 else
66
67 if (option.Index("sph") != kNPOS)
69 else if (option.Index("pol") != kNPOS)
71 else if (option.Index("cyl") != kNPOS)
73
75
76 Ssiz_t pos = option.Index("fb");
77 if (pos != kNPOS) {
78 option.Remove(pos, 2);
80 }
81
82 pos = option.Index("bb");
83 if (pos != kNPOS)
85
86 pos = option.Index("a");
87 if (pos != kNPOS)
89
91
92 return kTRUE;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Setup bounding-box.
97
99{
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// Render the object.
105
106void TH2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
107{
109
110 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
111
112 glEnable(GL_NORMALIZE);
113 glDisable(GL_COLOR_MATERIAL);
114
117
118 glDisable(GL_CULL_FACE);
119 glPopAttrib();
120
121 // Axes
122 if (fPlotPainter->GetDrawAxes()) {
123 TGLAxisPainterBox axe_painter;
124 axe_painter.SetUseAxisColors(kFALSE);
125 axe_painter.SetFontMode(TGLFont::kPixmap);
126 axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
127 }
128}
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
@ 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
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.
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.
Rendering of TH2 and derived classes.
Definition TH2GL.h:24
~TH2GL() override
Destructor.
Definition TH2GL.cxx:47
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
Definition TH2GL.cxx:54
TH2GL()
Constructor.
Definition TH2GL.cxx:39
void SetBBox() override
Setup bounding-box.
Definition TH2GL.cxx:98
TH2 * fM
Definition TH2GL.h:30
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render the object.
Definition TH2GL.cxx:106
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139