Logo ROOT  
Reference Guide
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(0), fH(0)
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, 0, &fCoord) );
66 else
68
69 if (option.Index("sph") != kNPOS)
71 else if (option.Index("pol") != kNPOS)
73 else if (option.Index("cyl") != kNPOS)
75
76 fPlotPainter->AddOption(option);
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}
const Ssiz_t kNPOS
Definition: RtypesCore.h:124
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
@ kGLSpherical
Definition: TGLUtil.h:47
@ kGLCylindrical
Definition: TGLUtil.h:46
@ kGLPolar
Definition: TGLUtil.h:45
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:154
GL renderer for TF2.
Definition: TF2GL.h:22
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render the object.
Definition: TF2GL.cxx:93
virtual ~TF2GL()
Destructor.
Definition: TF2GL.cxx:44
TF2GL()
Constructor.
Definition: TF2GL.cxx:37
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TF2GL.cxx:52
TH2 * fH
Definition: TF2GL.h:29
TF2 * fM
Definition: TF2GL.h:28
virtual void SetBBox()
Setup bounding-box.
Definition: TF2GL.cxx:85
virtual TH1 * CreateHistogram()
Create a histogram from function.
Definition: TF2.cxx:700
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.
Definition: TGLPlotBox.cxx:245
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:303
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.
Definition: TGLTF3Painter.h:29
TAxis * GetZaxis()
Definition: TH1.h:322
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:8388
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:8478
Service class for 2-D histogram classes.
Definition: TH2.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:136
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1150
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639