Logo ROOT   6.12/07
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
29 GL renderer for TF2.
30 TGLPlotPainter is used internally.
31 */
32 
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Constructor.
37 
38 TF2GL::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 
63  fH->GetZaxis()->SetLimits(fH->GetMinimum(), fH->GetMaximum());
64 
65  if (dynamic_cast<TF3*>(fM))
66  SetPainter( new TGLTF3Painter((TF3*)fM, fH, 0, &fCoord) );
67  else
68  SetPainter( new TGLSurfacePainter(fH, 0, &fCoord) );
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 
94 void 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 
103  fPlotPainter->InitGL();
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 }
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
TH2 * fH
Definition: TF2GL.h:29
void SetUseAxisColors(Bool_t x)
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
void SetPainter(TGLPlotPainter *p)
Set painter object and destroy the old one.
Definition: TGLPlot3D.cxx:52
const char Option_t
Definition: RtypesCore.h:62
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
virtual ~TF2GL()
Destructor.
Definition: TF2GL.cxx:45
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:303
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
void SetFontMode(TGLFont::EMode m)
Basic string class.
Definition: TString.h:125
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TF2GL.cxx:53
Implements painting of TH2 with "SURF" option.
Plot-painter for TF3 functions.
Definition: TGLTF3Painter.h:29
TF2 * fM
Definition: TF2GL.h:28
TGLPlotPainter * fPlotPainter
Definition: TGLPlot3D.h:29
Utility class to paint axis in GL.
GL renderer for TF2.
Definition: TF2GL.h:21
virtual TH1 * CreateHistogram()
Create a histogram from function.
Definition: TF2.cxx:653
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render the object.
Definition: TF2GL.cxx:94
Description of TGLPlot3D.
Definition: TGLPlot3D.h:22
virtual void SetBBox()
Setup bounding-box.
Definition: TF2GL.cxx:86
Service class for 2-Dim histogram classes.
Definition: TH2.h:30
A 3-Dim function with parameters.
Definition: TF3.h:28
Int_t FindFrontPoint() const
Convert 3d points into window coordinate system and find the nearest.
Definition: TGLPlotBox.cxx:245
TGLPlotCoordinates fCoord
Definition: TGLPlot3D.h:30
const TGLPlotBox & RefBackBox() const
virtual void AddOption(const TString &stringOption)=0
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define ClassImp(name)
Definition: Rtypes.h:359
virtual Bool_t InitGeometry()=0
void SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
TF2GL()
Constructor.
Definition: TF2GL.cxx:38
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void InitGL() const =0
TGLBoundingBox fBoundingBox
Also plays the role of ID.
virtual void DrawPlot() const =0
const Bool_t kTRUE
Definition: RtypesCore.h:87