Logo ROOT  
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
32OpenGL 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
114void 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
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}
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
int Ssiz_t
Definition: RtypesCore.h:63
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
void Warning(const char *location, const char *msgfmt,...)
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.
Paints TH3 histograms by rendering variable-sized boxes matching the bin contents.
Definition: TGLBoxPainter.h:32
"gliso" option for TH3.
Definition: TGLTF3Painter.h:85
TGLBoundingBox fBoundingBox
Also plays the role of ID.
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
const Float_t * Color() const
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
const TGLPlotBox & RefBackBox() const
void SetDrawAxes(Bool_t s)
virtual void DrawPlot() const =0
virtual Bool_t InitGeometry()=0
void SetDrawBackBox(Bool_t b)
void SetDrawFrontBox(Bool_t b)
virtual void InitGL() const =0
Bool_t GetDrawAxes()
void SetPhysicalShapeColor(const Float_t *rgba)
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
OpenGL renderer class for TH3.
Definition: TH3GL.h:27
TH3 * fM
Definition: TH3GL.h:33
TH3GL()
Constructor.
Definition: TH3GL.cxx:40
virtual void SetBBox()
Set bounding box.
Definition: TH3GL.cxx:106
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
Definition: TH3GL.cxx:65
virtual ~TH3GL()
Destructor.
Definition: TH3GL.cxx:58
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render with OpenGL.
Definition: TH3GL.cxx:114
The 3-D histogram classes derived from the 1-D histogram classes.
Definition: TH3.h:31
Mother of all ROOT objects.
Definition: TObject.h:37
A 3D polymarker.
Definition: TPolyMarker3D.h:33
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
const char * Data() const
Definition: TString.h:364
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
auto * th3
Definition: textalign.C:21