// @(#)root/gl:$Id$
// 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 <memory>
#include <vector>

#ifndef ROOT_TGLHistPainter
#include "TGLHistPainter.h"
#endif
#ifndef ROOT_TGLUtil
#include "TGLUtil.h"
#endif
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TAxis
#include "TAxis.h"
#endif

class TGL5DPainter;
class TTree;

//TGL5D is a class to setup TGL5DPainter from TTree,
//hold data pointers, select required ranges,
//convert them into unit cube.
class TGL5DDataSet : public TNamed {
   friend class TGL5DPainter;
private:
   enum Edefaults{
      kDefaultNB = 50//Default number of bins along X,Y,Z axes.
   };
public:
   TGL5DDataSet(TTree *inputData);

   //These are functions for TPad and
   //TPad's standard machinery (picking, painting).
   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);

   //This is for editor.
   TGL5DPainter *GetRealPainter()const;

   //Select points for iso-surface.
   void     SelectPoints(Double_t v4Level, Double_t range);
   UInt_t   SelectedSize()const;

   //Take a point from selected sub-range (V1 == X, V2 == Y, V3 == Z for 3D).
   Double_t V1(UInt_t ind)const;
   Double_t V2(UInt_t ind)const;
   Double_t V3(UInt_t ind)const;

   //Very similar to TH3's axes.
   TAxis   *GetXAxis()const;
   TAxis   *GetYAxis()const;
   TAxis   *GetZAxis()const;

   //Data ranges for V1, V2, V3, V4.
   const Rgl::Range_t &GetXRange()const;
   const Rgl::Range_t &GetYRange()const;
   const Rgl::Range_t &GetZRange()const;
   const Rgl::Range_t &GetV4Range()const;

private:
   //These three functions for TKDEFGT,
   //which will convert all point coordinates
   //into unit cube before density estimation.
   Double_t V1ToUnitCube(Double_t v1)const;
   Double_t V2ToUnitCube(Double_t v2)const;
   Double_t V3ToUnitCube(Double_t v3)const;

   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.

   //These are fixed ranges of the data set,
   //calculated during construction.
   Rgl::Range_t    fV1MinMax;//V1 range.
   Double_t        fV1Range;//max - min.
   Rgl::Range_t    fV2MinMax;//V2 range.
   Double_t        fV2Range;//max - min.
   Rgl::Range_t    fV3MinMax;//V3 range.
   Double_t        fV3Range;//max - min.
   Rgl::Range_t    fV4MinMax;//V4 range.
   Rgl::Range_t    fV5MinMax;//V5 range.

   //This are ranges and bin numbers
   //for plot, inside fixed ranges.
   mutable TAxis   fXAxis;
   mutable TAxis   fYAxis;
   mutable TAxis   fZAxis;
   //V4 can have a string type.
   Bool_t          fV4IsString;
   //Painter to visualize dataset.
   std::auto_ptr<TGLHistPainter> fPainter;
   //Indices of points, selected for some iso-level.
   std::vector<UInt_t> fIndices;

   TGL5DDataSet(const TGL5DDataSet &rhs);
   TGL5DDataSet &operator = (const TGL5DDataSet &rhs);

   ClassDef(TGL5DDataSet, 0)//Class to read data from TTree and create TGL5DPainter.
};

#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