#ifndef LANDED_VIEWERBASE
#define LANDED_VIEWERBASE

#include "types.hh"

#include <QString>

//a detector hit
//x, y and z are inherited from the base class ThreeVector
class Hit : public ThreeVector
{
 public:
  Hit(void):
    ThreeVector()
  {
    value=0;  
    selected=false;
    show=true;
  }

  //the notional size of the hit, in MeV at time of writing
  double value;
  //has the hit been selected fro highlighting by the user
  bool selected;
  //is the hit visible
  bool show;
};

//a track in the detector
class Track
{
 public:
  Track(void)
  {
    value=0;
    delta=0;
    selected=false;
    show=true;
  }

  ThreeVector start;
  ThreeVector end;
  double value;
  double delta;
  bool selected;
  int pdgcode;
  bool show;
};

//clearly there can be multiple hits per event, so:
typedef std::vector<Hit> HitCollection;
typedef HitCollection::size_type HitIndex;
typedef std::vector<Track> TrackCollection;
typedef TrackCollection::size_type TrackIndex;

//base for the 3d and 2d event display widgets
//common functionality goes here as far as possible to save double-coding
class ViewerBase
{
 protected:
  ViewerBase(void);

 protected:
  //hits
  HitCollection hits_;
  //scaling for hits
  float hitScale_;
  //tracks
  TrackCollection tracks_;
  //scaling for tracks
  //tracks are scaled according to de/dx
  float trackScale_;

  bool showTracks_;
  bool showHits_;
  
 public:
  bool showTracks(void) const;
  void setShowTracks(bool);
  bool showHits(void) const;
  void setShowHits(bool);
  //add a hit
  void addHit(const Hit&);
  //access hit list
  HitIndex numHits(void) const;
  const Hit& hit(HitIndex) const;
  //forget current set of hits
  void clearHits(void);
  //set hit selected
  void highlightHit(HitIndex, bool=true);
  //hit scaling (mm/unit_value)
  float hitScale(void) const;
  void setHitScale(float);
  //add a track
  void addTrack(const Track&);
  //access track list
  TrackIndex numTracks(void) const;
  const Track& track(TrackIndex) const;
  //forget
  void clearTracks(void);
  //set track selected
  void highlightTrack(TrackIndex, bool=true);
  //track scaling
  float trackScale(void) const;
  void setTrackScale(float);
  //set hit visibility
  void setHitVis(HitIndex, bool);
  //set track visibility
  void setTrackVis(TrackIndex, bool);

};

#endif //ifndef LANDED_VIEWER
