Logo ROOT   6.10/09
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 #include "TGLMarchingCubes.h"
19 #include "TGLPlotPainter.h"
20 #include "TGLIsoMesh.h"
21 #include "TKDEFGT.h"
22 #include "TGLUtil.h"
23 
24 
25 class TGLPlotCamera;
26 class TGL5DDataSet;
27 
28 //
29 //Painter to draw TGL5DDataSet ("gl5d" option for TTree).
30 //
31 
32 class TGL5DPainter : public TGLPlotPainter {
33 public:
34  enum EDefaults {
36  kNLowPts = 50
37  };
38 
40 
41  //Iso surface.
42  struct Surf_t {
44  : f4D(0.), fRange(0.), fShowCloud(kFALSE), fHide(kFALSE),
45  fColor(0), fHighlight(kFALSE), fAlpha(100)
46  {
47  }
48 
49  Mesh_t fMesh; //Mesh.
50  Double_t f4D; //Iso-level.
51  Double_t fRange; //Selection critera (f4D +- fRange).
52  Bool_t fShowCloud;//Show/Hide original cloud.
53  Bool_t fHide; //Show/Hide surface.
54  Color_t fColor; //Color.
55  std::vector<Double_t> fPreds; //Predictions for 5-th variable.
56  Bool_t fHighlight;//If surface was selected via GUI - highlight it.
57  Int_t fAlpha; //Opacity percentage of a surface.
58  };
59 
60  typedef std::list<Surf_t> SurfList_t;
61  typedef SurfList_t::iterator SurfIter_t;
62  typedef SurfList_t::const_iterator ConstSurfIter_t;
63 
64 private:
65  TKDEFGT fKDE; //Density estimator.
67 
68  const Surf_t fDummy; //Empty surface (for effective insertion into list).
69  Bool_t fInit; //Geometry was set.
70 
71  SurfList_t fIsos; //List of iso-surfaces.
72  TGL5DDataSet *fData; //Dataset to visualize.
73 
74  typedef std::vector<Double_t>::size_type size_type;
75 
78  Bool_t fShowSlider; //For future.
79 
80  Double_t fAlpha; //Parameter to define selection range.
81  Int_t fNContours; //Number of "pre-defined" contours.
82 
83 public:
85 
86  //Add new iso for selected value of v4. +- range
87  SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal = 1., Double_t sigma = 1.,
88  Double_t range = 1e-3, Int_t lowNumOfPoints = kNLowPts);
89 
90  void AddSurface(Double_t v4);
91  void RemoveSurface(SurfIter_t surf);
92 
93  //TGLPlotPainter final-overriders.
94  char *GetPlotInfo(Int_t px, Int_t py);
96  void StartPan(Int_t px, Int_t py);
97  void Pan(Int_t px, Int_t py);
98  void AddOption(const TString &option);
99  void ProcessEvent(Int_t event, Int_t px, Int_t py);
100 
101  //Methods for ged.
102  void ShowBoxCut(Bool_t show) {fBoxCut.SetActive(show);}
104 
105  void SetAlpha(Double_t newAlpha);
106  Double_t GetAlpha()const{return fAlpha;}
107 
108  void SetNContours(Int_t num);
109  Int_t GetNContours()const{return fNContours;}
110 
111  void ResetGeometryRanges();
112 
113  SurfIter_t SurfacesBegin();
114  SurfIter_t SurfacesEnd();
115 
116 private:
117  //TGLPlotPainter final-overriders.
118  void InitGL()const;
119  void DeInitGL()const;
120 
121  void DrawPlot()const;
122 
123  //Empty overriders.
124  void DrawSectionXOZ()const{}
125  void DrawSectionYOZ()const{}
126  void DrawSectionXOY()const{}
127 
128  //Auxiliary functions.
129  void SetSurfaceColor(ConstSurfIter_t surf)const;
130  void DrawCloud()const;
131  void DrawSubCloud(Double_t v4, Double_t range, Color_t ci)const;
132  void DrawMesh(ConstSurfIter_t surf)const;
133 
134  TGL5DPainter(const TGL5DPainter &);
136 };
137 
138 #endif
Camera for TGLPlotPainter and sub-classes.
Definition: TGLPlotCamera.h:21
void DrawSectionXOY() const
Definition: TGL5DPainter.h:126
Bool_t fShowSlider
Definition: TGL5DPainter.h:78
void ShowBoxCut(Bool_t show)
Definition: TGL5DPainter.h:102
std::pair< Double_t, Double_t > Range_t
Definition: TGLUtil.h:1193
void DrawSectionYOZ() const
Definition: TGL5DPainter.h:125
std::vector< Double_t > fPreds
Definition: TGL5DPainter.h:55
Bool_t IsBoxCutShown() const
Definition: TGL5DPainter.h:103
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Double_t fAlpha
Definition: TGL5DPainter.h:80
void SetAlpha(Double_t newAlpha)
Set selection range parameter.
SurfList_t fIsos
Definition: TGL5DPainter.h:71
void DrawMesh(ConstSurfIter_t surf) const
Draw one iso-surface.
const Surf_t fDummy
Definition: TGL5DPainter.h:68
SurfList_t::const_iterator ConstSurfIter_t
Definition: TGL5DPainter.h:62
Bool_t InitGeometry()
Create mesh.
std::vector< Double_t >::size_type size_type
Definition: TGL5DPainter.h:74
Int_t fNContours
Definition: TGL5DPainter.h:81
Rgl::Range_t fV5SliderRange
Definition: TGL5DPainter.h:77
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:65
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:61
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:60
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.
const Bool_t kFALSE
Definition: RtypesCore.h:92
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:66
TGL5DPainter implements "gl5d" option for TTree::Draw.
Definition: TGL5DPainter.h:32
Bool_t fInit
Definition: TGL5DPainter.h:69
Rgl::Mc::TIsoMesh< Float_t > Mesh_t
Definition: TGL5DPainter.h:39
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:124
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:72
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Rgl::Range_t fV5PredictedRange
Definition: TGL5DPainter.h:76
Int_t GetNContours() const
Definition: TGL5DPainter.h:109
void InitGL() const
Initialize OpenGL state variables.
SurfIter_t SurfacesBegin()
std::list::begin.
Double_t GetAlpha() const
Definition: TGL5DPainter.h:106
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.