Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 {
32  kDefault,
33  kMaple0,
34  kMaple1,
35  kMaple2
36  };
37 
38  ETF3Style fStyle;
39 
40  Rgl::Mc::TIsoMesh<Double_t> fMesh;
41  TF3 *fF3;
42 
43  TGLTH3Slice fXOZSlice;
44  TGLTH3Slice fYOZSlice;
45  TGLTH3Slice fXOYSlice;
46 
47 public:
48  TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
49 
50  char *GetPlotInfo(Int_t px, Int_t py);
51  Bool_t InitGeometry();
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:
87  typedef Rgl::Mc::TIsoMesh<Float_t> Mesh_t;
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 
92  TGLTH3Slice fXOZSlice;
93  TGLTH3Slice fYOZSlice;
94  TGLTH3Slice fXOYSlice;
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.
103  Rgl::Range_t fMinMax;
104  //Palette. One color per iso-surface.
105  TGLLevelPalette fPalette;
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.
110  Bool_t fInit;
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);
117  Bool_t InitGeometry();
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 &);
140  TGLIsoPainter &operator = (const TGLIsoPainter &);
141 
142  ClassDef(TGLIsoPainter, 0) // Iso option for TH3.
143 };
144 
145 #endif