Logo ROOT   6.08/07
Reference Guide
TH3GL.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 #include "TH3GL.h"
12 #include "TH3.h"
13 #include "TVirtualPad.h"
14 #include "TAxis.h"
15 #include "TMath.h"
16 
17 #include "TGLSurfacePainter.h"
18 #include "TGLHistPainter.h"
19 #include "TGLLegoPainter.h"
20 #include "TGLBoxPainter.h"
21 #include "TGLTF3Painter.h"
22 #include "TGLAxisPainter.h"
23 #include "TGLPhysicalShape.h"
24 #include "TGLCamera.h"
25 #include "TPolyMarker3D.h"
26 
27 #include "TGLRnrCtx.h"
28 #include "TGLIncludes.h"
29 
30 /** \class TH3GL
31 \ingroup opengl
32 OpenGL renderer class for TH3.
33 */
34 
36 
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Constructor.
39 
41  TGLPlot3D(), fM(0)
42 {
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Constructor.
47 
49  TGLPlot3D(), fM(th3)
50 {
51  SetPainter(new TGLBoxPainter(th3, pm, 0, &fCoord));
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Destructor.
57 
59 {
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// Set model object.
64 
66 {
67  TString option(opt);
68  option.ToLower();
69 
70  fM = SetModelDynCast<TH3>(obj);
71 
72  if (option.Index("iso") != kNPOS)
73  SetPainter( new TGLIsoPainter(fM, 0, &fCoord) );
74  else if (option.Index("box") != kNPOS)
75  SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
76  else {
77  Warning("SetModel", "Option '%s' not supported, assuming 'box'.", option.Data());
78  SetPainter( new TGLBoxPainter(fM, 0, &fCoord) );
79  }
80 
81  fPlotPainter->AddOption(option);
82 
83  Ssiz_t pos = option.Index("fb");
84  if (pos != kNPOS) {
85  option.Remove(pos, 2);
87  }
88 
89  pos = option.Index("bb");
90  if (pos != kNPOS)
92 
93  pos = option.Index("a");
94  if (pos != kNPOS)
96 
97 
99 
100  return kTRUE;
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Set bounding box.
105 
107 {
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Render with OpenGL.
113 
114 void TH3GL::DirectDraw(TGLRnrCtx & rnrCtx) const
115 {
116  if (fFirstPhysical)
118 
120 
121  glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
122 
123  glEnable(GL_NORMALIZE);
124  glDisable(GL_COLOR_MATERIAL);
125 
126  fPlotPainter->InitGL();
128 
129  glDisable(GL_CULL_FACE);
130  glPopAttrib();
131 
132  // Axes
133  const Rgl::PlotTranslation trGuard(fPlotPainter);
134 
135  if (fPlotPainter->GetDrawAxes()) {
136  TGLAxisPainterBox axe_painter;
137  axe_painter.SetUseAxisColors(kFALSE);
138  axe_painter.SetFontMode(TGLFont::kPixmap);
139  axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
140  }
141 }
TText * th3
Definition: textalign.C:21
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
void SetUseAxisColors(Bool_t x)
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render with OpenGL.
Definition: TH3GL.cxx:114
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
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
const TGLVertex3 * Get3DBox() const
Get 3D box.
Definition: TGLPlotBox.cxx:302
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
void SetFontMode(TGLFont::EMode m)
Basic string class.
Definition: TString.h:137
Bool_t GetDrawAxes()
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1089
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetBBox()
Set bounding box.
Definition: TH3GL.cxx:106
Paints TH3 histograms by rendering variable-sized boxes matching the bin contents.
Definition: TGLBoxPainter.h:40
TH3 * fM
Definition: TH3GL.h:33
TGLPlotPainter * fPlotPainter
Definition: TGLPlot3D.h:29
Utility class to paint axis in GL.
const Float_t * Color() const
The 3-D histogram classes derived from the 1-D histogram classes.
Definition: TH3.h:35
Description of TGLPlot3D.
Definition: TGLPlot3D.h:22
OpenGL renderer class for TH3.
Definition: TH3GL.h:26
void SetDrawBackBox(Bool_t b)
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
"gliso" option for TH3.
Definition: TGLTF3Painter.h:91
virtual ~TH3GL()
Destructor.
Definition: TH3GL.cxx:58
Int_t FindFrontPoint() const
Convert 3d points into window coordinate system and find the nearest.
Definition: TGLPlotBox.cxx:244
TGLPlotCoordinates fCoord
Definition: TGLPlot3D.h:30
void Warning(const char *location, const char *msgfmt,...)
const TGLPlotBox & RefBackBox() const
virtual void AddOption(const TString &stringOption)=0
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
int Ssiz_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:279
void SetDrawFrontBox(Bool_t b)
virtual Bool_t InitGeometry()=0
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TH3GL.cxx:65
Mother of all ROOT objects.
Definition: TObject.h:37
A 3D polymarker.
Definition: TPolyMarker3D.h:40
const Ssiz_t kNPOS
Definition: Rtypes.h:115
virtual void InitGL() const =0
TH3GL()
Constructor.
Definition: TH3GL.cxx:40
TGLBoundingBox fBoundingBox
Also plays the role of ID.
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void DrawPlot() const =0
void SetPhysicalShapeColor(const Float_t *rgba)
void SetDrawAxes(Bool_t s)
const char * Data() const
Definition: TString.h:349