Logo ROOT   6.18/05
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#include <TVirtualPad.h>
18
19#include "TGLSurfacePainter.h"
20#include "TGLTF3Painter.h"
21#include "TGLAxisPainter.h"
22
23#include "TGLRnrCtx.h"
24
25#include "TGLIncludes.h"
26
27/** \class TF2GL
28\ingroup opengl
29GL renderer for TF2.
30TGLPlotPainter is used internally.
31*/
32
34
35////////////////////////////////////////////////////////////////////////////////
36/// Constructor.
37
38TF2GL::TF2GL() : TGLPlot3D(), fM(0), fH(0)
39{
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Destructor.
44
46{
47 delete fH;
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Set model object.
52
54{
55 TString option(opt);
56 option.ToLower();
57
58 fM = SetModelDynCast<TF2>(obj);
59
60 fH = (TH2*) fM->CreateHistogram();
61 if (!fH) return kFALSE;
62
64
65 if (dynamic_cast<TF3*>(fM))
66 SetPainter( new TGLTF3Painter((TF3*)fM, fH, 0, &fCoord) );
67 else
69
70 if (option.Index("sph") != kNPOS)
72 else if (option.Index("pol") != kNPOS)
74 else if (option.Index("cyl") != kNPOS)
76
77 fPlotPainter->AddOption(option);
79
80 return kTRUE;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Setup bounding-box.
85
87{
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Render the object.
93
94void TF2GL::DirectDraw(TGLRnrCtx & rnrCtx) const
95{
97
98 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
99
100 glEnable(GL_NORMALIZE);
101 glDisable(GL_COLOR_MATERIAL);
102
105
106 glDisable(GL_CULL_FACE);
107 glPopAttrib();
108
109 // Axes
110 TGLAxisPainterBox axe_painter;
111 axe_painter.SetUseAxisColors(kFALSE);
112 axe_painter.SetFontMode(TGLFont::kPixmap);
113 axe_painter.PlotStandard(rnrCtx, fH, fBoundingBox);
114}
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
@ kGLSpherical
Definition: TGLUtil.h:46
@ kGLCylindrical
Definition: TGLUtil.h:45
@ kGLPolar
Definition: TGLUtil.h:44
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:94
virtual ~TF2GL()
Destructor.
Definition: TF2GL.cxx:45
TF2GL()
Constructor.
Definition: TF2GL.cxx:38
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TF2GL.cxx:53
TH2 * fH
Definition: TF2GL.h:29
TF2 * fM
Definition: TF2GL.h:28
virtual void SetBBox()
Setup bounding-box.
Definition: TF2GL.cxx:86
virtual TH1 * CreateHistogram()
Create a histogram from function.
Definition: TF2.cxx:677
A 3-Dim function with parameters.
Definition: TF3.h:28
Utility class to paint axis in GL.
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:318
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:7964
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:8049
Service class for 2-Dim histogram classes.
Definition: TH2.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634