Logo ROOT   6.08/07
Reference Guide
TGL5DPainter.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov 28/07/2009
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2009, 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_TGL5DPainter
13 #define ROOT_TGL5DPainter
14 
15 #include <vector>
16 #include <list>
17 
18 #ifndef ROOT_TGLMarchingCubes
19 #include "TGLMarchingCubes.h"
20 #endif
21 #ifndef ROOT_TGLPlotPainter
22 #include "TGLPlotPainter.h"
23 #endif
24 #ifndef ROOT_TGLIsoMesh
25 #include "TGLIsoMesh.h"
26 #endif
27 #ifndef ROOT_TKDEFGT
28 #include "TKDEFGT.h"
29 #endif
30 #ifndef ROOT_TGLUtil
31 #include "TGLUtil.h"
32 #endif
33 
34 
35 class TGLPlotCamera;
36 class TGL5DDataSet;
37 
38 //
39 //Painter to draw TGL5DDataSet ("gl5d" option for TTree).
40 //
41 
42 class TGL5DPainter : public TGLPlotPainter {
43 public:
44  enum EDefaults {
46  kNLowPts = 50
47  };
48 
50 
51  //Iso surface.
52  struct Surf_t {
54  : f4D(0.), fRange(0.), fShowCloud(kFALSE), fHide(kFALSE),
55  fColor(0), fHighlight(kFALSE), fAlpha(100)
56  {
57  }
58 
59  Mesh_t fMesh; //Mesh.
60  Double_t f4D; //Iso-level.
61  Double_t fRange; //Selection critera (f4D +- fRange).
62  Bool_t fShowCloud;//Show/Hide original cloud.
63  Bool_t fHide; //Show/Hide surface.
64  Color_t fColor; //Color.
65  std::vector<Double_t> fPreds; //Predictions for 5-th variable.
66  Bool_t fHighlight;//If surface was selected via GUI - highlight it.
67  Int_t fAlpha; //Opacity percentage of a surface.
68  };
69 
70  typedef std::list<Surf_t> SurfList_t;
71  typedef SurfList_t::iterator SurfIter_t;
72  typedef SurfList_t::const_iterator ConstSurfIter_t;
73 
74 private:
75  TKDEFGT fKDE; //Density estimator.
77 
78  const Surf_t fDummy; //Empty surface (for effective insertion into list).
79  Bool_t fInit; //Geometry was set.
80 
81  SurfList_t fIsos; //List of iso-surfaces.
82  TGL5DDataSet *fData; //Dataset to visualize.
83 
84  typedef std::vector<Double_t>::size_type size_type;
85 
88  Bool_t fShowSlider; //For future.
89 
90  Double_t fAlpha; //Parameter to define selection range.
91  Int_t fNContours; //Number of "pre-defined" contours.
92 
93 public:
95 
96  //Add new iso for selected value of v4. +- range
97  SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal = 1., Double_t sigma = 1.,
98  Double_t range = 1e-3, Int_t lowNumOfPoints = kNLowPts);
99 
100  void AddSurface(Double_t v4);
101  void RemoveSurface(SurfIter_t surf);
102 
103  //TGLPlotPainter final-overriders.
104  char *GetPlotInfo(Int_t px, Int_t py);
106  void StartPan(Int_t px, Int_t py);
107  void Pan(Int_t px, Int_t py);
108  void AddOption(const TString &option);
109  void ProcessEvent(Int_t event, Int_t px, Int_t py);
110 
111  //Methods for ged.
112  void ShowBoxCut(Bool_t show) {fBoxCut.SetActive(show);}
114 
115  void SetAlpha(Double_t newAlpha);
116  Double_t GetAlpha()const{return fAlpha;}
117 
118  void SetNContours(Int_t num);
119  Int_t GetNContours()const{return fNContours;}
120 
121  void ResetGeometryRanges();
122 
123  SurfIter_t SurfacesBegin();
124  SurfIter_t SurfacesEnd();
125 
126 private:
127  //TGLPlotPainter final-overriders.
128  void InitGL()const;
129  void DeInitGL()const;
130 
131  void DrawPlot()const;
132 
133  //Empty overriders.
134  void DrawSectionXOZ()const{}
135  void DrawSectionYOZ()const{}
136  void DrawSectionXOY()const{}
137 
138  //Auxiliary functions.
139  void SetSurfaceColor(ConstSurfIter_t surf)const;
140  void DrawCloud()const;
141  void DrawSubCloud(Double_t v4, Double_t range, Color_t ci)const;
142  void DrawMesh(ConstSurfIter_t surf)const;
143 
144  TGL5DPainter(const TGL5DPainter &);
146 };
147 
148 #endif
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:21
void DrawSectionXOY() const
Definition: TGL5DPainter.h:136
Bool_t fShowSlider
Definition: TGL5DPainter.h:88
void ShowBoxCut(Bool_t show)
Definition: TGL5DPainter.h:112
std::pair< Double_t, Double_t > Range_t
Definition: TGLUtil.h:1197
void DrawSectionYOZ() const
Definition: TGL5DPainter.h:135
std::vector< Double_t > fPreds
Definition: TGL5DPainter.h:65
Bool_t IsBoxCutShown() const
Definition: TGL5DPainter.h:113
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Double_t fAlpha
Definition: TGL5DPainter.h:90
void SetAlpha(Double_t newAlpha)
Set selection range parameter.
SurfList_t fIsos
Definition: TGL5DPainter.h:81
void DrawMesh(ConstSurfIter_t surf) const
Draw one iso-surface.
const Surf_t fDummy
Definition: TGL5DPainter.h:78
SurfList_t::const_iterator ConstSurfIter_t
Definition: TGL5DPainter.h:72
Bool_t InitGeometry()
Create mesh.
std::vector< Double_t >::size_type size_type
Definition: TGL5DPainter.h:84
Int_t fNContours
Definition: TGL5DPainter.h:91
Rgl::Range_t fV5SliderRange
Definition: TGL5DPainter.h:87
TGL5DPainter(TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Constructor.
Bool_t IsActive() const
void DeInitGL() const
Return some gl states to original values.
const Double_t sigma
TKDEFGT fKDE
Definition: TGL5DPainter.h:75
void Pan(Int_t px, Int_t py)
Mouse events handler.
short Color_t
Definition: RtypesCore.h:79
TGL5DPainter & operator=(const TGL5DPainter &)
SurfList_t::iterator SurfIter_t
Definition: TGL5DPainter.h:71
char * GetPlotInfo(Int_t px, Int_t py)
Return info for plot part under cursor.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
std::list< Surf_t > SurfList_t
Definition: TGL5DPainter.h:70
SurfIter_t SurfacesEnd()
std::list::end.
void ResetGeometryRanges()
No need to create or delete meshes, number of meshes (iso-levels) are the same, but meshes must be re...
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
void SetSurfaceColor(ConstSurfIter_t surf) const
Set the color for iso-surface.
void SetActive(Bool_t a)
Turn the box cut on/off.
double Double_t
Definition: RtypesCore.h:55
void AddOption(const TString &option)
No additional options for TGL5DPainter.
Rgl::Mc::TMeshBuilder< TKDEFGT, Float_t > fMeshBuilder
Definition: TGL5DPainter.h:76
TGL5DPainter implements "gl5d" option for TTree::Draw.
Definition: TGL5DPainter.h:42
Bool_t fInit
Definition: TGL5DPainter.h:79
Rgl::Mc::TIsoMesh< Float_t > Mesh_t
Definition: TGL5DPainter.h:49
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
void DrawSectionXOZ() const
Definition: TGL5DPainter.h:134
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal=1., Double_t sigma=1., Double_t range=1e-3, Int_t lowNumOfPoints=kNLowPts)
Try to add new iso-surface.
void SetNContours(Int_t num)
Set the number of predefined contours.
TGL5DDataSet * fData
Definition: TGL5DPainter.h:82
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Rgl::Range_t fV5PredictedRange
Definition: TGL5DPainter.h:86
Int_t GetNContours() const
Definition: TGL5DPainter.h:119
void InitGL() const
Initialize OpenGL state variables.
SurfIter_t SurfacesBegin()
std::list::begin.
Double_t GetAlpha() const
Definition: TGL5DPainter.h:116
void RemoveSurface(SurfIter_t surf)
Remove iso-surface.
void DrawSubCloud(Double_t v4, Double_t range, Color_t ci) const
Draw cloud for selected iso-surface.
TGLBoxCut fBoxCut
void DrawPlot() const
Draw a set of meshes.
void DrawCloud() const
Draw full cloud of points.