#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;
Int_t fFirstRow;
Int_t fSize;
void *fRows;
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)
};
inline void TTablePoints::SetTablePointer(void *table){ fRows = table;}
inline Int_t TTablePoints::Indx(Int_t sortedIndx) const
{return fTableSorter?fTableSorter->GetIndex(fFirstRow+sortedIndx):-1;}
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