#if !defined(AFX_ATOM_H__04809119_1A26_4E7D_8E45_A3024D490E6B__INCLUDED_)
#define AFX_ATOM_H__04809119_1A26_4E7D_8E45_A3024D490E6B__INCLUDED_


#include <string>
#include <vector>
#include <map>
#include "coordinate.h"
#include "kryomolecule_export.h"

enum bondtype {eSINGLE, eAROMATIC,eDOUBLE, eTRIPLE };
struct KRYOMOLECULE_EXPORT bond
{
  bond() { order=eSINGLE; }
  bond(int i, bondtype e= eSINGLE) { index=i; order=e; }
  int index;
  bondtype order;
  friend bool operator == (const bond& a,const bond& b) { return (a.index == b.index); }
  friend bool operator < (const bond& a,const bond& b) { return (a.index < b.index); }
};
class KRYOMOLECULE_EXPORT CAtom
{ 
public:
 struct atomdata
 {
   struct rgb
   {
     rgb(int lr, int lg, int lb) : r(lr) , g(lg) ,b (lb) {};
     int r; int g; int b;
   };
   atomdata(int z, double m, double w, rgb c) : Z(z), mass(m), vdw(w), color(c) {};
   int Z;
   double mass;
   double vdw;
   rgb color;
   
 };

public:
  CAtom();
  virtual ~CAtom();
  void GetScreenPoint(int* x, int* y, int* z);
  bool IsSelected()   { return m_selected;}
  bool IsIrradiated() { return m_irradiated;}
  void Select(bool b) { m_selected=b;}
  void Irradiate(bool b) {m_irradiated=b;}
  void SetCShift(float cs) { m_chemicalshift=cs; }
  void SetZ(int z);
  float CShift() const { return m_chemicalshift; }
  coordinate& Gradient() { return m_gradient; }
  const coordinate& Gradient() const { return m_gradient; }
  /** Get atomic mass */
  double GetAtomicMass();
  void GetColor(float* r, float* g, float* b);
  double GetVdW();
  coordinate c; std::string name; /*std::string label;*/ std::vector<bond> conexion; std::vector<coordinate> mode; 
  coordinate& XYZ() { return c; }
  const coordinate& XYZ() const { return c; }
protected:
  float m_chemicalshift;
  bool m_selected;
  bool m_irradiated;
  coordinate m_gradient;
  
};

class Isotope
{
  public:
  Isotope(int z, int mass,int mult, double mg=0, double q=0) : m_z(z) , m_mass(mass), m_multiplicity(mult) ,  m_mg(mg) , m_mq(q) {};
  ~Isotope() {};
  int  Mass() const { return m_mass; }
  int Z() const { return m_z; }
  double MagnetoGyricRatio() const { return m_mg; }
  double Quadrupole() const { return m_mq; }
  private:  
  int  m_z;
  int m_mass;
  int m_multiplicity;
  double m_mg;
  double m_mq;
  
};

typedef std::map<std::string,CAtom::atomdata> PeriodicTable;
KRYOMOLECULE_EXPORT const PeriodicTable& GetPeriodicTable();
KRYOMOLECULE_EXPORT void BuildPeriodicTable();

#endif // !defined(AFX_ATOM_H__04809119_1A26_4E7D_8E45_A3024D490E6B__INCLUDED_)
