Logo ROOT   6.08/07
Reference Guide
TGLTF3Painter.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov 31/08/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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 #ifndef ROOT_TGLTF3Painter
13 #define ROOT_TGLTF3Painter
14 
15 #include <vector>
16 #include <list>
17 
18 #ifndef ROOT_TGLPlotPainter
19 #include "TGLPlotPainter.h"
20 #endif
21 #ifndef ROOT_TGLIsoMesh
22 #include "TGLIsoMesh.h"
23 #endif
24 #ifndef ROOT_TGLUtil
25 #include "TGLUtil.h"
26 #endif
27 
28 class TGLPlotCamera;
29 class TF3;
30 
31 /*
32 Draw TF3 using marching cubes.
33 */
34 
35 class TGLTF3Painter : public TGLPlotPainter {
36 private:
37  enum ETF3Style {
42  };
43 
45 
47  TF3 *fF3;
48 
52 
53 public:
54  TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
55 
56  char *GetPlotInfo(Int_t px, Int_t py);
58  void StartPan(Int_t px, Int_t py);
59  void Pan(Int_t px, Int_t py);
60  void AddOption(const TString &stringOption);
61  void ProcessEvent(Int_t event, Int_t px, Int_t py);
62 
63 private:
64  void InitGL()const;
65  void DeInitGL()const;
66 
67  void DrawPlot()const;
68  //
69  void DrawToSelectionBuffer()const;
70  void DrawDefaultPlot()const;
71  void DrawMaplePlot()const;
72  //
73 
74  void SetSurfaceColor()const;
75  Bool_t HasSections()const;
76 
77  void DrawSectionXOZ()const;
78  void DrawSectionYOZ()const;
79  void DrawSectionXOY()const;
80 
81  ClassDef(TGLTF3Painter, 0) // GL TF3 painter.
82 };
83 
84 /*
85  Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
86  Can be one-level iso (as standard non-gl "iso" option),
87  or multi-level iso: equidistant contours (if you only specify
88  number of contours, or at user defined levels).
89 */
90 
91 class TGLIsoPainter : public TGLPlotPainter {
92 private:
94  typedef std::list<Mesh_t> MeshList_t;
95  typedef std::list<Mesh_t>::iterator MeshIter_t;
96  typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;
97 
101 
102  Mesh_t fDummyMesh;
103  //List of meshes.
104  MeshList_t fIsos;
105  //Cached meshes (will be used if geometry must be rebuilt
106  //after TPad::PaintModified)
107  MeshList_t fCache;
108  //Min and max bin contents.
110  //Palette. One color per iso-surface.
112  //Iso levels. Equidistant or user-defined.
113  std::vector<Double_t> fColorLevels;
114  //Now meshes are initialized only once.
115  //To be changed in future.
117 
118 public:
119  TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
120 
121  //TGLPlotPainter final-overriders.
122  char *GetPlotInfo(Int_t px, Int_t py);
124  void StartPan(Int_t px, Int_t py);
125  void Pan(Int_t px, Int_t py);
126  void AddOption(const TString &option);
127  void ProcessEvent(Int_t event, Int_t px, Int_t py);
128 
129 private:
130  //TGLPlotPainter final-overriders.
131  void InitGL()const;
132  void DeInitGL()const;
133 
134  void DrawPlot()const;
135  void DrawSectionXOZ()const;
136  void DrawSectionYOZ()const;
137  void DrawSectionXOY()const;
138  //Auxiliary methods.
139  Bool_t HasSections()const;
140  void SetSurfaceColor(Int_t ind)const;
141  void SetMesh(Mesh_t &mesh, Double_t isoValue);
142  void DrawMesh(const Mesh_t &mesh, Int_t level)const;
143  void FindMinMax();
144 
145  TGLIsoPainter(const TGLIsoPainter &);
146  TGLIsoPainter &operator = (const TGLIsoPainter &);
147 
148  ClassDef(TGLIsoPainter, 0) // Iso option for TH3.
149 };
150 
151 #endif
void DrawToSelectionBuffer() const
Draw triangles, no normals, no lighting.
MeshList_t fIsos
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:21
std::pair< Double_t, Double_t > Range_t
Definition: TGLUtil.h:1197
Bool_t InitGeometry()
Create mesh.
void DrawPlot() const
Draw mesh.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
A slice of a TH3.
#define ClassDef(name, id)
Definition: Rtypes.h:254
Plot-painter for TF3 functions.
Definition: TGLTF3Painter.h:35
void DeInitGL() const
Initialize OpenGL state variables.
Rgl::Mc::TIsoMesh< Float_t > Mesh_t
Definition: TGLTF3Painter.h:93
void SetSurfaceColor() const
Set color for surface.
std::vector< Double_t > fColorLevels
TGLTH3Slice fXOZSlice
Definition: TGLTF3Painter.h:49
TGLTH3Slice fYOZSlice
Definition: TGLTF3Painter.h:50
void AddOption(const TString &stringOption)
No options for tf3.
void InitGL() const
Initialize OpenGL state variables.
void DrawSectionYOZ() const
Draw YOZ parallel section.
A 3-Dim function with parameters.
Definition: TF3.h:30
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
MeshList_t fCache
TGLTH3Slice fXOZSlice
Definition: TGLTF3Painter.h:98
"gliso" option for TH3.
Definition: TGLTF3Painter.h:91
void Pan(Int_t px, Int_t py)
User&#39;s moving mouse cursor, with middle mouse button pressed (for pad).
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
ETF3Style fStyle
Definition: TGLTF3Painter.h:44
std::list< Mesh_t > MeshList_t
Definition: TGLTF3Painter.h:94
void DrawDefaultPlot() const
Surface with material properties and lighting.
std::list< Mesh_t >::const_iterator ConstMeshIter_t
Definition: TGLTF3Painter.h:96
double Double_t
Definition: RtypesCore.h:55
TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Constructor.
Rgl::Mc::TIsoMesh< Double_t > fMesh
Definition: TGLTF3Painter.h:46
The TH1 histogram class.
Definition: TH1.h:80
TGLTH3Slice fXOYSlice
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Change color scheme.
Bool_t HasSections() const
Any section exists.
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
TGLTH3Slice fXOYSlice
Definition: TGLTF3Painter.h:51
Rgl::Range_t fMinMax
void DrawSectionXOY() const
Draw XOY parallel section.
std::list< Mesh_t >::iterator MeshIter_t
Definition: TGLTF3Painter.h:95
void DrawMaplePlot() const
Colored surface, without lighting and material properties.
TGLTH3Slice fYOZSlice
Definition: TGLTF3Painter.h:99
char * GetPlotInfo(Int_t px, Int_t py)
Coords for point on surface under cursor.
TGLLevelPalette fPalette
void DrawMesh(const std::vector< Float_t > &vs, const std::vector< Float_t > &ns, const std::vector< UInt_t > &ts)
Call function-template.
Definition: TGLIsoMesh.cxx:39
void DrawSectionXOZ() const
Draw XOZ parallel section.