// This may look like C code, but it is really -*- C++ -*-
// Module PI : Peida Interactive  PIBarGraph
// BarGraph drawer pairs(X_i,Y_i) -    R. Ansari  2004
// (C) LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA

#ifndef PIBARGRAPH
#define PIBARGRAPH

#include "pisysdep.h"
#include "pidrawer.h"
#include <vector>

// ----------------------------------------------------------
// Classe de representation d'une serie de valeurs sous 
// forme de bar-graph 
 
class PIBarGraph : public PIDrawer {
public:
                     PIBarGraph(bool horiz=false, bool fill=true);
  virtual            ~PIBarGraph();

  int                AddBar(double id, double val, string const& lab, PIColors col);
  int                AddBar(double val);

  // --- Methodes inline pour changer les options de representation  
  // Barres horizontales ou vertiacales (defaut=vertical)
  inline  void       SetVerticalBars() { fgHoriz=false; }
  inline  void       SetHorizontalBars() { fgHoriz=true; }  
  // Barres pleines ou contour
  inline  void       SetFill(bool fg) { fgFill=fg; } 
  // Fraction de remplissage des bars
  inline  void       SetPacking(double frac=0.5) { packFrac=frac; }
  // Use Bar values as labels
  inline  void	     UseBarValueAsLabel(bool fg=true) { fgValLabel = fg; }

  // ------------------------------
  virtual void       Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax);
  virtual void       UpdateLimits();

  // Methode de decodage des options   
  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);  
  virtual int        OptionToString(vector<string> & opt) const;
  virtual void	     GetOptionsHelpInfo(string& info);

 // Renvoie une distance au point x,y
 // virtual double     GetDistanceToPoint(double x, double y);

protected:
  struct _bgdata { double id,val; string lab; PIColors col; };
  vector<struct _bgdata> mBars;
  double mMin, mMax;
  double idMin, idMax;
  bool fgFill, fgHoriz;
  bool fgValLabel;   // Use values as labels
  double packFrac;
 };


#endif
