Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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 "TAxis.h"
14
15#include "TGLSurfacePainter.h"
16#include "TGLHistPainter.h"
17#include "TGLLegoPainter.h"
18#include "TGLBoxPainter.h"
19#include "TGLTF3Painter.h"
20#include "TGLAxisPainter.h"
21#include "TGLPhysicalShape.h"
22#include "TGLCamera.h"
23#include "TPolyMarker3D.h"
24
25#include "TGLRnrCtx.h"
26#include "TGLIncludes.h"
27
28/** \class TH3GL
29\ingroup opengl
30OpenGL renderer class for TH3.
31*/
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// Constructor.
36
38 TGLPlot3D(), fM(nullptr)
39{
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor.
44
46 TGLPlot3D(), fM(th3)
47{
48 SetPainter(new TGLBoxPainter(th3, pm, nullptr, &fCoord));
49 fPlotPainter->InitGeometry();
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Destructor.
54
56{
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Set model object.
61
63{
64 TString option(opt);
65 option.ToLower();
66
68
69 if (option.Index("iso") != kNPOS)
70 SetPainter( new TGLIsoPainter(fM, nullptr, &fCoord) );
71 else if (option.Index("box") != kNPOS)
72 SetPainter( new TGLBoxPainter(fM, nullptr, &fCoord) );
73 else {
74 Warning("SetModel", "Option '%s' not supported, assuming 'box'.", option.Data());
75 SetPainter( new TGLBoxPainter(fM, nullptr, &fCoord) );
76 }
77
78 fPlotPainter->AddOption(option);
79
80 Ssiz_t pos = option.Index("fb");
81 if (pos != kNPOS) {
82 option.Remove(pos, 2);
83 fPlotPainter->SetDrawFrontBox(kFALSE);
84 }
85
86 pos = option.Index("bb");
87 if (pos != kNPOS)
88 fPlotPainter->SetDrawBackBox(kFALSE);
89
90 pos = option.Index("a");
91 if (pos != kNPOS)
92 fPlotPainter->SetDrawAxes(kFALSE);
93
94
95 fPlotPainter->InitGeometry();
96
97 return kTRUE;
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Set bounding box.
102
104{
105 fBoundingBox.Set(fPlotPainter->RefBackBox().Get3DBox());
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Render with OpenGL.
110
111void TH3GL::DirectDraw(TGLRnrCtx & rnrCtx) const
112{
113 if (fFirstPhysical)
114 fPlotPainter->SetPhysicalShapeColor(fFirstPhysical->Color());
115
116 fPlotPainter->RefBackBox().FindFrontPoint();
117
118 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);
119
120 glEnable(GL_NORMALIZE);
121 glDisable(GL_COLOR_MATERIAL);
122
123 fPlotPainter->InitGL();
124 fPlotPainter->DrawPlot();
125
126 glDisable(GL_CULL_FACE);
127 glPopAttrib();
128
129 // Axes
130 const Rgl::PlotTranslation trGuard(fPlotPainter);
131
132 if (fPlotPainter->GetDrawAxes()) {
133 TGLAxisPainterBox axe_painter;
134 axe_painter.SetUseAxisColors(kFALSE);
135 axe_painter.SetFontMode(TGLFont::kPixmap);
136 axe_painter.PlotStandard(rnrCtx, fM, fBoundingBox);
137 }
138}
int Ssiz_t
String size (currently int).
Definition RtypesCore.h:81
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
Painter class for axes encompassing a 3D box.
void PlotStandard(TGLRnrCtx &rnrCtx, TH1 *histo, const TGLBoundingBox &bbox)
void SetUseAxisColors(Bool_t x)
void SetFontMode(TGLFont::EMode m)
Paints TH3 histograms by rendering variable-sized boxes matching the bin contents.
"gliso" option for TH3.
TGLBoundingBox fBoundingBox
! Shape's bounding box.
TGLPhysicalShape * fFirstPhysical
! first replica
TT * SetModelDynCast(TObject *obj)
Definition TGLObject.h:37
TGLPlot3D(const TGLPlot3D &)=delete
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:51
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
~TH3GL() override
Destructor.
Definition TH3GL.cxx:55
TH3 * fM
Definition TH3GL.h:33
TH3GL()
Constructor.
Definition TH3GL.cxx:37
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
Definition TH3GL.cxx:62
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render with OpenGL.
Definition TH3GL.cxx:111
void SetBBox() override
Set bounding box.
Definition TH3GL.cxx:103
The 3-D histogram classes derived from the 1-D histogram classes.
Definition TH3.h:45
Mother of all ROOT objects.
Definition TObject.h:42
A 3D polymarker.
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
const char * Data() const
Definition TString.h:384
TString & Remove(Ssiz_t pos)
Definition TString.h:694
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:660
auto * th3
Definition textalign.C:22