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
33
34////////////////////////////////////////////////////////////////////////////////
35/// Constructor.
36
37TF2GL::TF2GL() : TGLPlot3D(), fM(nullptr), fH(nullptr)
38{
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// Destructor.
43
45{
46 delete fH;
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Set model object.
51
53{
54 TString option(opt);
55 option.ToLower();
56
57 fM = SetModelDynCast<TF2>(obj);
58
59 fH = (TH2*) fM->CreateHistogram();
60 if (!fH) return kFALSE;
61
63
64 if (dynamic_cast<TF3*>(fM))
65 SetPainter( new TGLTF3Painter((TF3*)fM, fH, nullptr, &fCoord) );
66 else
67 SetPainter( new TGLSurfacePainter(fH, nullptr, &fCoord) );
68
69 if (option.Index("sph") != kNPOS)
71 else if (option.Index("pol") != kNPOS)
73 else if (option.Index("cyl") != kNPOS)
75
78
79 return kTRUE;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Setup bounding-box.
84
86{
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Render the object.
92
93void TF2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
94{
96
97 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
98
99 glEnable(GL_NORMALIZE);
100 glDisable(GL_COLOR_MATERIAL);
101
104
105 glDisable(GL_CULL_FACE);
106 glPopAttrib();
107
108 // Axes
109 TGLAxisPainterBox axe_painter;
110 axe_painter.SetUseAxisColors(kFALSE);
111 axe_painter.SetFontMode(TGLFont::kPixmap);
112 axe_painter.PlotStandard(rnrCtx, fH, fBoundingBox);
113}
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
@ kGLSpherical
Definition TGLUtil.h:47
@ kGLCylindrical
Definition TGLUtil.h:46
@ kGLPolar
Definition TGLUtil.h:45
Option_t Option_t option
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition TAxis.h:164
GL renderer for TF2.
Definition TF2GL.h:22
~TF2GL() override
Destructor.
Definition TF2GL.cxx:44
void SetBBox() override
Setup bounding-box.
Definition TF2GL.cxx:85
TF2GL()
Constructor.
Definition TF2GL.cxx:37
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:52
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render the object.
Definition TF2GL.cxx:93
TH1 * CreateHistogram() override
Create a histogram from function.
Definition TF2.cxx:697
A 3-Dim function with parameters.
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)
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
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
virtual void DrawPlot() const =0
virtual Bool_t InitGeometry()=0
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.
Plot-painter for TF3 functions.
TAxis * GetZaxis()
Definition TH1.h:326
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition TH1.cxx:8536
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Definition TH1.cxx:8626
Service class for 2-D histogram classes.
Definition TH2.h:30
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139