ROOT logo
// @(#)root/gl:$Id: TGL5D.h 28619 2009-05-14 07:10:01Z brun $
// Author: Timur Pocheptsov  2009
/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGL5D
#define ROOT_TGL5D

#include <utility>
#include <vector>
#include <list>

#ifndef ROOT_TGLPlotPainter
#include "TGLPlotPainter.h"
#endif
#ifndef ROOT_TGLHistPainter
#include "TGLHistPainter.h"
#endif
#ifndef ROOT_TGLIsoMesh
#include "TGLIsoMesh.h"
#endif
#ifndef ROOT_TGLUtil
#include "TGLUtil.h"
#endif
#ifndef ROOT_KDEFGT
#include "TKDEFGT.h"
#endif
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

class TGLPlotCamera;
class TGL5DPainter;
class TTree;
class TH3F;

//TGL5D is a class to setup TGL5DPainter from TTree.
class TGL5DDataSet : public TNamed {
   friend class TGL5DPainter;
private:
   enum {
      kDefaultNB = 100
   };
public:
   TGL5DDataSet(TTree *inputData);
   ~TGL5DDataSet();//
   
   Int_t                DistancetoPrimitive(Int_t px, Int_t py);
   void                 ExecuteEvent(Int_t event, Int_t px, Int_t py);
   char                *GetObjectInfo(Int_t px, Int_t py) const;
   void                 Paint(Option_t *option);
   
   TH3F                *GetHist()const {return fHist;}
   TGL5DPainter        *GetRealPainter()const;
   
private:
   Long64_t        fNP;//Number of entries.
   const Double_t *fV1;//V1.
   const Double_t *fV2;//V2.
   const Double_t *fV3;//V3.
   const Double_t *fV4;//V4.
   const Double_t *fV5;//V5.
   
   Rgl::Range_t    fV1MinMax;//V1 range.
   Rgl::Range_t    fV2MinMax;//V2 range.
   Rgl::Range_t    fV3MinMax;//V3 range.
   Rgl::Range_t    fV4MinMax;//V4 range.
   Rgl::Range_t    fV5MinMax;//V5 range.

   TH3F           *fHist;
   
   Bool_t          fV4IsString;
   
   std::auto_ptr<TGLHistPainter> fPainter;
   
   TGL5DDataSet(const TGL5DDataSet &rhs);
   TGL5DDataSet &operator = (const TGL5DDataSet &rhs);
   
   ClassDef(TGL5DDataSet, 0)//Class to read data from TTree and create TGL5DPainter.
};

//
//This class paints set of iso-surfaces. xyz - range must be specified
//via TH3F, data (5 vectors) must be set via SetDataSources.
//

class TGL5DPainter : public TGLPlotPainter {
public:
   enum EDefaults {
      kNContours = 4,
      kNLowPts   = 50
   };
   typedef Rgl::Mc::TIsoMesh<Float_t>        Mesh_t;
   
   //Iso surfaces.
   struct Surf_t {
      Surf_t() : f4D(0.), fShowCloud(kFALSE), fHide(kFALSE), fColor(0)//, fKDE(0)
      {
      }
      
      Mesh_t                fMesh;     //Mesh.
      Double_t              f4D;       //Iso-level.
      Double_t              fRange;    //Selection critera (f4D +- fRange).
      Bool_t                fShowCloud;//Show/Hide original cloud.
      Bool_t                fHide;     //Show/Hide surface.
      Color_t               fColor;    //Color.
      std::vector<Double_t> fPreds;    //Predictions for 5-th variable.
      //TKDEFGT              *fKDE;
   };
   
   typedef std::list<Surf_t> SurfList_t;
   typedef SurfList_t::iterator SurfIter_t;
   typedef SurfList_t::const_iterator ConstSurfIter_t;

private:
   //Density estimator.
   TKDEFGT                  fKDE;  //Density estimator.
   
   const Surf_t             fDummy; //Empty surface.
   Bool_t                   fInit;  //Geometry was set.
   
   SurfList_t               fIsos;  //List of iso-surfaces.
   
   //Input data.
   const TGL5DDataSet      *fData;
   
   typedef std::vector<Double_t>::size_type size_type;
   //
   mutable std::vector<Double_t>    fTS;  //targets.
   mutable std::vector<Double_t>    fDens;//densities in target points.
   //
   std::vector<Double_t>    fPtsSorted;//Packed xyz coordinates for cloud.

   Rgl::Range_t             fV5PredictedRange;
   Rgl::Range_t             fV5SliderRange;

   Bool_t                   fShowSlider;//For future.
   
   Double_t                 fAlpha;//
   Int_t                    fNContours;
   
public:
   TGL5DPainter(const TGL5DDataSet *data, TGLPlotCamera *camera, TGLPlotCoordinates *coord);
   //~TGL5DPainter();
   
   //Interface to manipulate TGL5DPainter object.
   const Rgl::Range_t &GetV1Range()const;
   const Rgl::Range_t &GetV2Range()const;
   const Rgl::Range_t &GetV3Range()const;
   const Rgl::Range_t &GetV4Range()const;
   const Rgl::Range_t &GetV5Range()const;
   
   Double_t   GetV5PredictedMin()const{return fV5PredictedRange.first;}
   Double_t   GetV5PredictedMax()const{return fV5PredictedRange.second;}
   
   void       SetV5SliderMin(Double_t min);
   Double_t   GetV5SliderMin() const {return fV5SliderRange.first;}
   
   void       SetV5SliderMax(Double_t max);
   Double_t   GetV5SliderMax() const {return fV5SliderRange.second;}
   
   Bool_t     ShowSlider() const {return fShowSlider;}
   void       ShowSlider(Bool_t show) {fShowSlider = show;}
   //Add new iso for selected value of v4. +- range
   SurfIter_t AddSurface(Double_t v4, Color_t ci, Double_t isoVal = 1., Double_t sigma = 1., 
                         Double_t e = 10., Double_t range = 1e-3, Int_t lowNumOfPoints = kNLowPts);
   void       SetSurfaceMode(SurfIter_t surf, Bool_t cloudOn);
   void       SetSurfaceColor(SurfIter_t surf, Color_t colorIndex);
   void       HideSurface(SurfIter_t surf);
   void       ShowSurface(SurfIter_t surf);
   void       RemoveSurface(SurfIter_t surf);
   
   //TGLPlotPainter final-overriders.
   char      *GetPlotInfo(Int_t px, Int_t py);
   Bool_t     InitGeometry();
   void       StartPan(Int_t px, Int_t py);
   void       Pan(Int_t px, Int_t py);
   void       AddOption(const TString &option);
   void       ProcessEvent(Int_t event, Int_t px, Int_t py);

   //Methods for ged.
   void       ShowBoxCut(Bool_t show) {fBoxCut.SetActive(show);}
   Bool_t     IsBoxCutShown()const{return fBoxCut.IsActive();}
   
   void       SetAlpha(Double_t newAlpha);
   Double_t   GetAlpha()const{return fAlpha;}
   
   void       SetNContours(Int_t num);
   Int_t      GetNContours()const{return fNContours;}
   
private:
   //TGLPlotPainter final-overriders.
   void       InitGL()const;
   void       DeInitGL()const;
   
   void       DrawPlot()const;
   
   //Empty overriders.
   void       DrawSectionXOZ()const{}
   void       DrawSectionYOZ()const{}
   void       DrawSectionXOY()const{}
   
   //Auxiliary functions.
   void       SetSurfaceColor(Color_t index)const;
   void       DrawCloud()const;
   void       DrawSubCloud(Double_t v4, Double_t range, Color_t ci)const;
   void       DrawMesh(ConstSurfIter_t surf)const;
   
   TGL5DPainter(const TGL5DPainter &);
   TGL5DPainter &operator = (const TGL5DPainter &);

   ClassDef(TGL5DPainter, 0)//Class to paint set of iso surfaces.
};

#endif
 TGL5D.h:1
 TGL5D.h:2
 TGL5D.h:3
 TGL5D.h:4
 TGL5D.h:5
 TGL5D.h:6
 TGL5D.h:7
 TGL5D.h:8
 TGL5D.h:9
 TGL5D.h:10
 TGL5D.h:11
 TGL5D.h:12
 TGL5D.h:13
 TGL5D.h:14
 TGL5D.h:15
 TGL5D.h:16
 TGL5D.h:17
 TGL5D.h:18
 TGL5D.h:19
 TGL5D.h:20
 TGL5D.h:21
 TGL5D.h:22
 TGL5D.h:23
 TGL5D.h:24
 TGL5D.h:25
 TGL5D.h:26
 TGL5D.h:27
 TGL5D.h:28
 TGL5D.h:29
 TGL5D.h:30
 TGL5D.h:31
 TGL5D.h:32
 TGL5D.h:33
 TGL5D.h:34
 TGL5D.h:35
 TGL5D.h:36
 TGL5D.h:37
 TGL5D.h:38
 TGL5D.h:39
 TGL5D.h:40
 TGL5D.h:41
 TGL5D.h:42
 TGL5D.h:43
 TGL5D.h:44
 TGL5D.h:45
 TGL5D.h:46
 TGL5D.h:47
 TGL5D.h:48
 TGL5D.h:49
 TGL5D.h:50
 TGL5D.h:51
 TGL5D.h:52
 TGL5D.h:53
 TGL5D.h:54
 TGL5D.h:55
 TGL5D.h:56
 TGL5D.h:57
 TGL5D.h:58
 TGL5D.h:59
 TGL5D.h:60
 TGL5D.h:61
 TGL5D.h:62
 TGL5D.h:63
 TGL5D.h:64
 TGL5D.h:65
 TGL5D.h:66
 TGL5D.h:67
 TGL5D.h:68
 TGL5D.h:69
 TGL5D.h:70
 TGL5D.h:71
 TGL5D.h:72
 TGL5D.h:73
 TGL5D.h:74
 TGL5D.h:75
 TGL5D.h:76
 TGL5D.h:77
 TGL5D.h:78
 TGL5D.h:79
 TGL5D.h:80
 TGL5D.h:81
 TGL5D.h:82
 TGL5D.h:83
 TGL5D.h:84
 TGL5D.h:85
 TGL5D.h:86
 TGL5D.h:87
 TGL5D.h:88
 TGL5D.h:89
 TGL5D.h:90
 TGL5D.h:91
 TGL5D.h:92
 TGL5D.h:93
 TGL5D.h:94
 TGL5D.h:95
 TGL5D.h:96
 TGL5D.h:97
 TGL5D.h:98
 TGL5D.h:99
 TGL5D.h:100
 TGL5D.h:101
 TGL5D.h:102
 TGL5D.h:103
 TGL5D.h:104
 TGL5D.h:105
 TGL5D.h:106
 TGL5D.h:107
 TGL5D.h:108
 TGL5D.h:109
 TGL5D.h:110
 TGL5D.h:111
 TGL5D.h:112
 TGL5D.h:113
 TGL5D.h:114
 TGL5D.h:115
 TGL5D.h:116
 TGL5D.h:117
 TGL5D.h:118
 TGL5D.h:119
 TGL5D.h:120
 TGL5D.h:121
 TGL5D.h:122
 TGL5D.h:123
 TGL5D.h:124
 TGL5D.h:125
 TGL5D.h:126
 TGL5D.h:127
 TGL5D.h:128
 TGL5D.h:129
 TGL5D.h:130
 TGL5D.h:131
 TGL5D.h:132
 TGL5D.h:133
 TGL5D.h:134
 TGL5D.h:135
 TGL5D.h:136
 TGL5D.h:137
 TGL5D.h:138
 TGL5D.h:139
 TGL5D.h:140
 TGL5D.h:141
 TGL5D.h:142
 TGL5D.h:143
 TGL5D.h:144
 TGL5D.h:145
 TGL5D.h:146
 TGL5D.h:147
 TGL5D.h:148
 TGL5D.h:149
 TGL5D.h:150
 TGL5D.h:151
 TGL5D.h:152
 TGL5D.h:153
 TGL5D.h:154
 TGL5D.h:155
 TGL5D.h:156
 TGL5D.h:157
 TGL5D.h:158
 TGL5D.h:159
 TGL5D.h:160
 TGL5D.h:161
 TGL5D.h:162
 TGL5D.h:163
 TGL5D.h:164
 TGL5D.h:165
 TGL5D.h:166
 TGL5D.h:167
 TGL5D.h:168
 TGL5D.h:169
 TGL5D.h:170
 TGL5D.h:171
 TGL5D.h:172
 TGL5D.h:173
 TGL5D.h:174
 TGL5D.h:175
 TGL5D.h:176
 TGL5D.h:177
 TGL5D.h:178
 TGL5D.h:179
 TGL5D.h:180
 TGL5D.h:181
 TGL5D.h:182
 TGL5D.h:183
 TGL5D.h:184
 TGL5D.h:185
 TGL5D.h:186
 TGL5D.h:187
 TGL5D.h:188
 TGL5D.h:189
 TGL5D.h:190
 TGL5D.h:191
 TGL5D.h:192
 TGL5D.h:193
 TGL5D.h:194
 TGL5D.h:195
 TGL5D.h:196
 TGL5D.h:197
 TGL5D.h:198
 TGL5D.h:199
 TGL5D.h:200
 TGL5D.h:201
 TGL5D.h:202
 TGL5D.h:203
 TGL5D.h:204
 TGL5D.h:205
 TGL5D.h:206
 TGL5D.h:207
 TGL5D.h:208
 TGL5D.h:209
 TGL5D.h:210
 TGL5D.h:211
 TGL5D.h:212
 TGL5D.h:213
 TGL5D.h:214
 TGL5D.h:215
 TGL5D.h:216
 TGL5D.h:217
 TGL5D.h:218
 TGL5D.h:219
 TGL5D.h:220