Logo ROOT   6.12/07
Reference Guide
TGLPlot3D.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 "TGLPlot3D.h"
13 
14 #include "TH3.h"
15 #include "TH3GL.h"
16 #include "TH2.h"
17 #include "TH2GL.h"
18 #include "TF2.h"
19 #include "TF2GL.h"
20 #include "TGLParametric.h"
21 #include "TPolyMarker3D.h"
23 
24 #include "TVirtualPad.h"
25 
26 /** \class TGLPlot3D
27 \ingroup opengl
28 Description of TGLPlot3D
29 */
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor.
35 
36 TGLPlot3D::TGLPlot3D() : TGLObject(), fPlotPainter(0)
37 {
38  fDLCache = kFALSE; // Disable display list.
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Destructor.
43 
45 {
46  delete fPlotPainter;
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Set painter object and destroy the old one.
51 
53 {
54  delete fPlotPainter;
55  fPlotPainter = p;
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Instantiate the correct plot-painter for given object.
60 /// Protected method.
61 
63 {
64  if (obj->InheritsFrom(TH3::Class()))
65  {
66  return new TH3GL();
67  }
68  else if (obj->InheritsFrom(TH2::Class()))
69  {
70  return new TH2GL();
71  }
72  else if (obj->InheritsFrom(TF2::Class()))
73  {
74  return new TF2GL();
75  }
77  {
78  return new TGLParametricEquationGL();
79  }
80 
81  return 0;
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Create GL plot for specified TH3 and polymarker.
86 
88 {
89  TGLPlot3D* log = new TH3GL(th3, pm);
90  log->SetBBox();
91 
92  return log;
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Create GL plot for specified object and options.
97 /// Which axes are logarithmic is determined from a pad.
98 
100 {
101  TGLPlot3D* log = InstantiatePlot(obj);
102 
103  if (log)
104  {
105  log->fCoord.SetXLog(pad->GetLogx());
106  log->fCoord.SetYLog(pad->GetLogy());
107  log->fCoord.SetZLog(pad->GetLogz());
108  log->SetModel(obj, opt);
109  log->SetBBox();
110  }
111 
112  return log;
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Create GL plot for specified object and options.
117 /// Which axes are logarithmic is determined from explicit arguments.
118 
119 TGLPlot3D* TGLPlot3D::CreatePlot(TObject* obj, const Option_t* opt, Bool_t logx, Bool_t logy, Bool_t logz)
120 {
121  TGLPlot3D* log = InstantiatePlot(obj);
122 
123  if (log)
124  {
125  log->fCoord.SetXLog(logx);
126  log->fCoord.SetYLog(logy);
127  log->fCoord.SetZLog(logz);
128  log->SetModel(obj, opt);
129  log->SetBBox();
130  }
131 
132  return log;
133 }
virtual Int_t GetLogy() const =0
virtual Int_t GetLogz() const =0
TGLPlot3D()
Constructor.
Definition: TGLPlot3D.cxx:36
void SetPainter(TGLPlotPainter *p)
Set painter object and destroy the old one.
Definition: TGLPlot3D.cxx:52
const char Option_t
Definition: RtypesCore.h:62
static TGLPlot3D * CreatePlot(TH3 *h, TPolyMarker3D *pm)
Create GL plot for specified TH3 and polymarker.
Definition: TGLPlot3D.cxx:87
bool Bool_t
Definition: RtypesCore.h:59
static TGLPlot3D * InstantiatePlot(TObject *obj)
Instantiate the correct plot-painter for given object.
Definition: TGLPlot3D.cxx:62
void Class()
Definition: Class.C:29
virtual Int_t GetLogx() const =0
Base-class for direct OpenGL renderers.
Definition: TGLObject.h:21
TGLPlotPainter * fPlotPainter
Definition: TGLPlot3D.h:29
void SetYLog(Bool_t yLog)
If log changed, sections must be reset, set fModified.
GL renderer for TF2.
Definition: TF2GL.h:21
auto * th3
Definition: textalign.C:21
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
GL-renderer wrapper for TGLParametricEquation.
The 3-D histogram classes derived from the 1-D histogram classes.
Definition: TH3.h:31
Description of TGLPlot3D.
Definition: TGLPlot3D.h:22
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)=0
OpenGL renderer class for TH3.
Definition: TH3GL.h:26
Rendering of TH2 and derived classes.
Definition: TH2GL.h:23
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
void SetXLog(Bool_t xLog)
If log changed, sections must be reset, set fModified.
TGLPlotCoordinates fCoord
Definition: TGLPlot3D.h:30
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual ~TGLPlot3D()
Destructor.
Definition: TGLPlot3D.cxx:44
#define ClassImp(name)
Definition: Rtypes.h:359
Mother of all ROOT objects.
Definition: TObject.h:37
A 3D polymarker.
Definition: TPolyMarker3D.h:32
void SetZLog(Bool_t zLog)
If log changed, sections must be reset, set fModified.
virtual void SetBBox()=0
Bool_t fDLCache
display-list validity bit-field
double log(double)