Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
31 ClassImp(TGLPlot3D);
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// Constructor.
35 
36 TGLPlot3D::TGLPlot3D() : TGLObject(), fPlotPainter(0)
37 {
38  fDLCache = kFALSE; // Disable display list.
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// Destructor.
43 
44 TGLPlot3D::~TGLPlot3D()
45 {
46  delete fPlotPainter;
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Set painter object and destroy the old one.
51 
52 void TGLPlot3D::SetPainter(TGLPlotPainter* p)
53 {
54  delete fPlotPainter;
55  fPlotPainter = p;
56 }
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// Instantiate the correct plot-painter for given object.
60 /// Protected method.
61 
62 TGLPlot3D* TGLPlot3D::InstantiatePlot(TObject* obj)
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  }
76  else if (obj->InheritsFrom(TGLParametricEquation::Class()))
77  {
78  return new TGLParametricEquationGL();
79  }
80 
81  return 0;
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Create GL plot for specified TH3 and polymarker.
86 
87 TGLPlot3D* TGLPlot3D::CreatePlot(TH3 *th3, TPolyMarker3D *pm)
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 
99 TGLPlot3D* TGLPlot3D::CreatePlot(TObject* obj, const Option_t* opt, TVirtualPad* pad)
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 }