ROOT logo
// @(#)root/table:$Id: TTablePoints.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Valery Fine   14/05/99  (E-mail: fine@bnl.gov)

/*************************************************************************
 * 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_TTablePoints
#define ROOT_TTablePoints

#include "TPoints3DABC.h"
#include "TTableSorter.h"
#include "TTable.h"

class TTablePoints : public TPoints3DABC
{
protected:
   TTableSorter   *fTableSorter;
   const void     *fKey;            // pointer to key value to select rows
   Int_t           fFirstRow;       // The first row to take in account
   Int_t           fSize;
   void           *fRows;           // Pointer the first row of the STAF table

   virtual void SetTablePointer(void *table);
   TTablePoints();
public:
   TTablePoints(TTableSorter *sorter,const void *key,Option_t *opt="");
   TTablePoints(TTableSorter *sorter, Int_t keyIndex,Option_t *opt="");
   ~TTablePoints(){}
   virtual Int_t     DistancetoPrimitive(Int_t px, Int_t py);
   virtual Int_t     GetLastPosition()const;
   virtual Float_t   GetX(Int_t idx)  const = 0;
   virtual Float_t   GetY(Int_t idx)  const = 0;
   virtual Float_t   GetZ(Int_t idx)  const = 0;
   virtual void     *GetTable();
   virtual Option_t *GetOption()      const { return 0;}
   virtual Int_t     Indx(Int_t sortedIndx) const;
   virtual Int_t     SetLastPosition(Int_t idx);
   virtual void      SetOption(Option_t *){;}
   virtual Int_t     SetPoint(Int_t, Float_t, Float_t, Float_t ){return -1;}
   virtual Int_t     SetPoints(Int_t , Float_t *, Option_t *){return -1;}
   virtual Int_t     Size() const;
   ClassDef(TTablePoints,0)  // Defines the TTable as an element of "event" geometry
};

//____________________________________________________________________________
inline void TTablePoints::SetTablePointer(void *table){ fRows = table;}

//____________________________________________________________________________
// return the index of the origial row by its index from the sorted table
inline Int_t TTablePoints::Indx(Int_t sortedIndx) const
{return fTableSorter?fTableSorter->GetIndex(fFirstRow+sortedIndx):-1;}
//____________________________________________________________________________
// return the pointer to the original table object
inline void *TTablePoints::GetTable(){
   void *ret = 0;
   if (fTableSorter) {
      TTable *t = fTableSorter->GetTable();
      if (t) ret = t->GetArray();
   }
   return ret;
}
//____________________________________________________________________________
inline Int_t TTablePoints::Size() const { return fSize;}
//____________________________________________________________________________
inline Int_t TTablePoints::GetLastPosition() const {return Size()-1;}

//____________________________________________________________________________
inline Int_t TTablePoints::SetLastPosition(Int_t idx)
{
   Int_t pos = GetLastPosition();
   fSize = TMath::Min(pos,idx)+1;
   return pos;
}

#endif

 TTablePoints.h:1
 TTablePoints.h:2
 TTablePoints.h:3
 TTablePoints.h:4
 TTablePoints.h:5
 TTablePoints.h:6
 TTablePoints.h:7
 TTablePoints.h:8
 TTablePoints.h:9
 TTablePoints.h:10
 TTablePoints.h:11
 TTablePoints.h:12
 TTablePoints.h:13
 TTablePoints.h:14
 TTablePoints.h:15
 TTablePoints.h:16
 TTablePoints.h:17
 TTablePoints.h:18
 TTablePoints.h:19
 TTablePoints.h:20
 TTablePoints.h:21
 TTablePoints.h:22
 TTablePoints.h:23
 TTablePoints.h:24
 TTablePoints.h:25
 TTablePoints.h:26
 TTablePoints.h:27
 TTablePoints.h:28
 TTablePoints.h:29
 TTablePoints.h:30
 TTablePoints.h:31
 TTablePoints.h:32
 TTablePoints.h:33
 TTablePoints.h:34
 TTablePoints.h:35
 TTablePoints.h:36
 TTablePoints.h:37
 TTablePoints.h:38
 TTablePoints.h:39
 TTablePoints.h:40
 TTablePoints.h:41
 TTablePoints.h:42
 TTablePoints.h:43
 TTablePoints.h:44
 TTablePoints.h:45
 TTablePoints.h:46
 TTablePoints.h:47
 TTablePoints.h:48
 TTablePoints.h:49
 TTablePoints.h:50
 TTablePoints.h:51
 TTablePoints.h:52
 TTablePoints.h:53
 TTablePoints.h:54
 TTablePoints.h:55
 TTablePoints.h:56
 TTablePoints.h:57
 TTablePoints.h:58
 TTablePoints.h:59
 TTablePoints.h:60
 TTablePoints.h:61
 TTablePoints.h:62
 TTablePoints.h:63
 TTablePoints.h:64
 TTablePoints.h:65
 TTablePoints.h:66
 TTablePoints.h:67
 TTablePoints.h:68
 TTablePoints.h:69
 TTablePoints.h:70
 TTablePoints.h:71
 TTablePoints.h:72
 TTablePoints.h:73
 TTablePoints.h:74
 TTablePoints.h:75
 TTablePoints.h:76
 TTablePoints.h:77
 TTablePoints.h:78
 TTablePoints.h:79
 TTablePoints.h:80
 TTablePoints.h:81