// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007

/*************************************************************************
 * Copyright (C) 1995-2007, 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_TEvePointSet
#define ROOT_TEvePointSet

#include "TEveElement.h"
#include "TEveProjectionBases.h"
#include "TEveTreeTools.h"

#include "TArrayI.h"
#include "TPointSet3D.h"
#include "TQObject.h"

class TTree;
class TF3;
class TGListTreeItem;

/******************************************************************************/
// TEvePointSet
/******************************************************************************/

class TEvePointSet : public TEveElement,
                     public TPointSet3D,
                     public TEvePointSelectorConsumer,
                     public TEveProjectable,
                     public TQObject
{
   friend class TEvePointSetArray;

private:
   TEvePointSet& operator=(const TEvePointSet&); // Not implemented

protected:
   TString  fTitle;           // Title/tooltip of the TEvePointSet.
   TArrayI *fIntIds;          // Optional array of integer ideices.
   Int_t    fIntIdsPerPoint;  // Number of integer indices assigned to each point.

   void AssertIntIdsSize();

public:
   TEvePointSet(Int_t n_points=0, ETreeVarType_e tv_type=kTVT_XYZ);
   TEvePointSet(const char* name, Int_t n_points=0, ETreeVarType_e tv_type=kTVT_XYZ);
   TEvePointSet(const TEvePointSet& e);
   virtual ~TEvePointSet();

   virtual TObject* GetObject(const TEveException&) const
   { const TObject* obj = this; return const_cast<TObject*>(obj); }

   virtual TEvePointSet* CloneElement() const { return new TEvePointSet(*this); }

   virtual void ClonePoints(const TEvePointSet& e);

   void  Reset(Int_t n_points=0, Int_t n_int_ids=0);
   Int_t GrowFor(Int_t n_points);

   virtual const char* GetTitle()         const { return fTitle; }
   virtual const char* GetElementName()   const { return TPointSet3D::GetName(); }
   virtual const char* GetElementTitle()  const { return fTitle; }
   virtual void  SetElementName (const char* n) { fName  = n; NameTitleChanged(); }
   virtual void  SetTitle(const char* t)        { fTitle = t; NameTitleChanged(); }
   virtual void  SetElementTitle(const char* t) { fTitle = t; NameTitleChanged(); }
   virtual void  SetElementNameTitle(const char* n, const char* t)
   { fName = n; fTitle = t; NameTitleChanged(); }

   Int_t  GetIntIdsPerPoint() const { return fIntIdsPerPoint; }
   Int_t* GetPointIntIds(Int_t p) const;
   Int_t  GetPointIntId(Int_t p, Int_t i) const;

   void   SetPointIntIds(Int_t* ids);
   void   SetPointIntIds(Int_t n, Int_t* ids);

   virtual void SetMarkerColor(Color_t col) { SetMainColor(col); }
   virtual void SetMarkerStyle(Style_t mstyle=1);
   virtual void SetMarkerSize(Size_t msize=1);

   virtual void Paint(Option_t* option="");

   virtual void InitFill(Int_t subIdNum);
   virtual void TakeAction(TEvePointSelector*);

   virtual void PointSelected(Int_t id); // *SIGNAL*

   virtual const TGPicture* GetListTreeIcon(Bool_t open=kFALSE);

   virtual void CopyVizParams(const TEveElement* el);
   virtual void WriteVizParams(std::ostream& out, const TString& var);

   virtual TClass* ProjectedClass(const TEveProjection* p) const;

   ClassDef(TEvePointSet, 1); // Set of 3D points with same marker attributes; optionally each point can be assigned an external TRef or a number of integer indices.
};


/******************************************************************************/
// TEvePointSetArray
/******************************************************************************/

class TEvePointSetArray : public TEveElement,
                          public TNamed,
                          public TAttMarker,
                          public TEvePointSelectorConsumer
{
   friend class TEvePointSetArrayEditor;

   TEvePointSetArray(const TEvePointSetArray&);            // Not implemented
   TEvePointSetArray& operator=(const TEvePointSetArray&); // Not implemented

protected:
   TEvePointSet **fBins;               //  Pointers to subjugated TEvePointSet's.
   Int_t        fDefPointSetCapacity;  //  Default capacity of subjugated TEvePointSet's.
   Int_t        fNBins;                //  Number of subjugated TEvePointSet's.
   Int_t        fLastBin;              //! Index of the last filled TEvePointSet.
   Double_t     fMin, fCurMin;         //  Overall and current minimum value of the separating quantity.
   Double_t     fMax, fCurMax;         //  Overall and current maximum value of the separating quantity.
   Double_t     fBinWidth;             //  Separating quantity bin-width.
   TString      fQuantName;            //  Name of the separating quantity.

public:
   TEvePointSetArray(const char* name="TEvePointSetArray", const char* title="");
   virtual ~TEvePointSetArray();

   virtual void RemoveElementLocal(TEveElement* el);
   virtual void RemoveElementsLocal();

   virtual void SetMarkerColor(Color_t tcolor=1);
   virtual void SetMarkerStyle(Style_t mstyle=1);
   virtual void SetMarkerSize(Size_t msize=1);

   virtual void TakeAction(TEvePointSelector*);

   virtual Int_t Size(Bool_t under=kFALSE, Bool_t over=kFALSE) const;

   void   InitBins(const char* quant_name, Int_t nbins, Double_t min, Double_t max);
   Bool_t Fill(Double_t x, Double_t y, Double_t z, Double_t quant);
   void   SetPointId(TObject* id);
   void   CloseBins();

   void   SetOwnIds(Bool_t o);

   Int_t  GetDefPointSetCapacity() const  { return fDefPointSetCapacity; }
   void   SetDefPointSetCapacity(Int_t c) { fDefPointSetCapacity = c; }

   Int_t         GetNBins()        const { return fNBins; }
   TEvePointSet* GetBin(Int_t bin) const { return fBins[bin]; }

   Double_t GetMin()    const { return fMin; }
   Double_t GetCurMin() const { return fCurMin; }
   Double_t GetMax()    const { return fMax; }
   Double_t GetCurMax() const { return fCurMax; }

   void SetRange(Double_t min, Double_t max);

   ClassDef(TEvePointSetArray, 1); // Array of TEvePointSet's filled via a common point-source; range of displayed TEvePointSet's can be controlled, based on a separating quantity provided on fill-time by a user.
};


/******************************************************************************/
// TEvePointSetProjected
/******************************************************************************/

class TEvePointSetProjected : public TEvePointSet,
                              public TEveProjected
{
private:
   TEvePointSetProjected(const TEvePointSetProjected&);            // Not implemented
   TEvePointSetProjected& operator=(const TEvePointSetProjected&); // Not implemented

protected:
   virtual void SetDepthLocal(Float_t d);

public:
   TEvePointSetProjected();
   virtual ~TEvePointSetProjected() {}

   virtual void SetProjection(TEveProjectionManager* proj, TEveProjectable* model);
   virtual void UpdateProjection();
   virtual TEveElement* GetProjectedAsElement() { return this; }

   virtual void PointSelected(Int_t id);


   ClassDef(TEvePointSetProjected, 1); // Projected copy of a TEvePointSet.
};

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