Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TF2GL.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 "TF2GL.h"
13
14#include <TF2.h>
15#include <TF3.h>
16#include <TH2.h>
17
18#include "TGLSurfacePainter.h"
19#include "TGLTF3Painter.h"
20#include "TGLAxisPainter.h"
21
22#include "TGLRnrCtx.h"
23
24#include "TGLIncludes.h"
25
26/** \class TF2GL
27\ingroup opengl
28GL renderer for TF2.
29TGLPlotPainter is used internally.
30*/
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
36TF2GL::TF2GL() : TGLPlot3D(), fM(nullptr), fH(nullptr)
37{
38}
39
40////////////////////////////////////////////////////////////////////////////////
41/// Destructor.
42
44{
45 delete fH;
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Set model object.
50
52{
53 TString option(opt);
54 option.ToLower();
55
57
58 fH = (TH2*) fM->CreateHistogram();
59 if (!fH) return kFALSE;
60
61 fH->GetZaxis()->SetLimits(fH->GetMinimum(), fH->GetMaximum());
62
63 if (dynamic_cast<TF3*>(fM))
64 SetPainter( new TGLTF3Painter((TF3*)fM, fH, nullptr, &fCoord) );
65 else
66 SetPainter( new TGLSurfacePainter(fH, nullptr, &fCoord) );
67
68 if (option.Index("sph") != kNPOS)
69 fCoord.SetCoordType(kGLSpherical);
70 else if (option.Index("pol") != kNPOS)
71 fCoord.SetCoordType(kGLPolar);
72 else if (option.Index("cyl") != kNPOS)
73 fCoord.SetCoordType(kGLCylindrical);
74
75 fPlotPainter->AddOption(option);
76 fPlotPainter->InitGeometry();
77
78 return kTRUE;
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Setup bounding-box.
83
85{
86 fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
87}
88
89////////////////////////////////////////////////////////////////////////////////
90/// Render the object.
91
92void TF2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
93{
94 fPlotPainter->RefBackBox().FindFrontPoint();
95
96 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
97
98 glEnable(GL_NORMALIZE);
99 glDisable(GL_COLOR_MATERIAL);
100
101 fPlotPainter->InitGL();
102 fPlotPainter->DrawPlot();
103
104 glDisable(GL_CULL_FACE);
105 glPopAttrib();
106
107 // Axes
108 TGLAxisPainterBox axe_painter;
109 axe_painter.SetUseAxisColors(kFALSE);
110 axe_painter.SetFontMode(TGLFont::kPixmap);
111 axe_painter.PlotStandard(rnrCtx, fH, fBoundingBox);
112}
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
~TF2GL() override
Destructor.
Definition TF2GL.cxx:43
void SetBBox() override
Setup bounding-box.
Definition TF2GL.cxx:84
TF2GL()
Constructor.
Definition TF2GL.cxx:36
TH2 * fH
Definition TF2GL.h:29
TF2 * fM
Definition TF2GL.h:28
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
Definition TF2GL.cxx:51
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render the object.
Definition TF2GL.cxx:92
Definition TF3.h:28
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)
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.
Plot-painter for TF3 functions.
Service class for 2-D histogram classes.
Definition TH2.h:30
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
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660