Logo ROOT   6.10/09
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 #include "TGLPlotPainter.h"
19 #include "TGLIsoMesh.h"
20 #include "TGLUtil.h"
21 
22 class TGLPlotCamera;
23 class TF3;
24 
25 /*
26 Draw TF3 using marching cubes.
27 */
28 
29 class TGLTF3Painter : public TGLPlotPainter {
30 private:
31  enum ETF3Style {
36  };
37 
39 
41  TF3 *fF3;
42 
46 
47 public:
48  TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
49 
50  char *GetPlotInfo(Int_t px, Int_t py);
52  void StartPan(Int_t px, Int_t py);
53  void Pan(Int_t px, Int_t py);
54  void AddOption(const TString &stringOption);
55  void ProcessEvent(Int_t event, Int_t px, Int_t py);
56 
57 private:
58  void InitGL()const;
59  void DeInitGL()const;
60 
61  void DrawPlot()const;
62  //
63  void DrawToSelectionBuffer()const;
64  void DrawDefaultPlot()const;
65  void DrawMaplePlot()const;
66  //
67 
68  void SetSurfaceColor()const;
69  Bool_t HasSections()const;
70 
71  void DrawSectionXOZ()const;
72  void DrawSectionYOZ()const;
73  void DrawSectionXOY()const;
74 
75  ClassDef(TGLTF3Painter, 0) // GL TF3 painter.
76 };
77 
78 /*
79  Iso painter draws iso surfaces - "gliso" option for TH3XXX::Draw.
80  Can be one-level iso (as standard non-gl "iso" option),
81  or multi-level iso: equidistant contours (if you only specify
82  number of contours, or at user defined levels).
83 */
84 
85 class TGLIsoPainter : public TGLPlotPainter {
86 private:
88  typedef std::list<Mesh_t> MeshList_t;
89  typedef std::list<Mesh_t>::iterator MeshIter_t;
90  typedef std::list<Mesh_t>::const_iterator ConstMeshIter_t;
91 
95 
96  Mesh_t fDummyMesh;
97  //List of meshes.
98  MeshList_t fIsos;
99  //Cached meshes (will be used if geometry must be rebuilt
100  //after TPad::PaintModified)
101  MeshList_t fCache;
102  //Min and max bin contents.
104  //Palette. One color per iso-surface.
106  //Iso levels. Equidistant or user-defined.
107  std::vector<Double_t> fColorLevels;
108  //Now meshes are initialized only once.
109  //To be changed in future.
111 
112 public:
113  TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
114 
115  //TGLPlotPainter final-overriders.
116  char *GetPlotInfo(Int_t px, Int_t py);
118  void StartPan(Int_t px, Int_t py);
119  void Pan(Int_t px, Int_t py);
120  void AddOption(const TString &option);
121  void ProcessEvent(Int_t event, Int_t px, Int_t py);
122 
123 private:
124  //TGLPlotPainter final-overriders.
125  void InitGL()const;
126  void DeInitGL()const;
127 
128  void DrawPlot()const;
129  void DrawSectionXOZ()const;
130  void DrawSectionYOZ()const;
131  void DrawSectionXOY()const;
132  //Auxiliary methods.
133  Bool_t HasSections()const;
134  void SetSurfaceColor(Int_t ind)const;
135  void SetMesh(Mesh_t &mesh, Double_t isoValue);
136  void DrawMesh(const Mesh_t &mesh, Int_t level)const;
137  void FindMinMax();
138 
139  TGLIsoPainter(const TGLIsoPainter &);
141 
142  ClassDef(TGLIsoPainter, 0) // Iso option for TH3.
143 };
144 
145 #endif
void DrawToSelectionBuffer() const
Draw triangles, no normals, no lighting.
MeshList_t fIsos
Definition: TGLTF3Painter.h:98
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:21
Mesh_t fDummyMesh
Definition: TGLTF3Painter.h:96
std::pair< Double_t, Double_t > Range_t
Definition: TGLUtil.h:1193
Bool_t InitGeometry()
Create mesh.
void DrawPlot() const
Draw mesh.
Basic string class.
Definition: TString.h:129
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:297
Plot-painter for TF3 functions.
Definition: TGLTF3Painter.h:29
void DeInitGL() const
Initialize OpenGL state variables.
Rgl::Mc::TIsoMesh< Float_t > Mesh_t
Definition: TGLTF3Painter.h:87
void SetSurfaceColor() const
Set color for surface.
std::vector< Double_t > fColorLevels
TGLTH3Slice fXOZSlice
Definition: TGLTF3Painter.h:43
TGLTH3Slice fYOZSlice
Definition: TGLTF3Painter.h:44
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:28
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:92
"gliso" option for TH3.
Definition: TGLTF3Painter.h:85
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:38
std::list< Mesh_t > MeshList_t
Definition: TGLTF3Painter.h:88
void DrawDefaultPlot() const
Surface with material properties and lighting.
std::list< Mesh_t >::const_iterator ConstMeshIter_t
Definition: TGLTF3Painter.h:90
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:40
The TH1 histogram class.
Definition: TH1.h:56
TGLTH3Slice fXOYSlice
Definition: TGLTF3Painter.h:94
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).
Binding & operator=(OUT(*fun)(void))
TGLTH3Slice fXOYSlice
Definition: TGLTF3Painter.h:45
Rgl::Range_t fMinMax
void DrawSectionXOY() const
Draw XOY parallel section.
std::list< Mesh_t >::iterator MeshIter_t
Definition: TGLTF3Painter.h:89
void DrawMaplePlot() const
Colored surface, without lighting and material properties.
TGLTH3Slice fYOZSlice
Definition: TGLTF3Painter.h:93
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.