The Gnome Chemistry Utils  0.15.1
gcu/atom.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * atom.h
6  *
7  * Copyright (C) 2002-2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_ATOM_H
26 #define GCU_ATOM_H
27 
28 #include "object.h"
29 #include "macros.h"
30 #include <glib.h>
31 #include <map>
32 #include <vector>
33 
35 namespace gcu
36 {
37 
38 class Bond;
39 class Cycle;
40 class AtomMatchState;
41 class Vector;
42 
47 class Atom: public Object
48 {
49 public:
53  Atom ();
62  Atom (int Z, double x, double y, double z = 0.);
68  Atom (Atom& a);
74  Atom& operator= (Atom& a);
78  virtual ~Atom ();
79 
80 public :
85  double Distance (Atom* pAtom);
91  void zoom (double ZoomFactor);
100  bool GetCoords (double *x, double *y, double *z = NULL) const;
108  void SetCoords (double x, double y, double z = 0) {m_x = x; m_y = y; m_z = z;}
112  int GetZ () const {return m_Z;}
119  virtual void SetZ (int Z);
125  virtual void SetCharge (char Charge) {m_Charge = Charge;}
129  char GetCharge () {return m_Charge;}
133  virtual const gchar* GetSymbol () const;
139  virtual void AddBond (Bond* pBond);
145  virtual void RemoveBond (Bond* pBond);
149  double x () const {return m_x;}
150  double &x () {return m_x;}
154  double y () const {return m_y;}
155  double &y () {return m_y;}
159  double z () const {return m_z;}
160  double &z () {return m_z;}
164  Vector GetVector () const;
171  Bond *GetFirstBond (std::map < Atom *, Bond * >::iterator& i);
178  Bond const *GetFirstBond (std::map< Atom *, Bond * >::const_iterator& i) const;
185  Bond *GetNextBond (std::map<Atom*, Bond*>::iterator& i);
192  Bond const *GetNextBond (std::map< Atom *, Bond * >::const_iterator& i) const;
197  Bond* GetBond (Atom* pAtom) const;
201  int GetBondsNumber () const {return m_Bonds.size();}
206  virtual xmlNodePtr Save (xmlDocPtr xml) const;
212  virtual bool Load (xmlNodePtr node);
219  virtual bool LoadNode (xmlNodePtr node);
227  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
235  virtual void Move (double x, double y, double z = 0.);
243  virtual void Transform2D (Matrix2D& m, double x, double y);
244 
252  bool SetProperty (unsigned property, char const *value);
253 
260  std::string GetProperty (unsigned property) const;
261 
267  bool IsInCycle (Cycle* pCycle);
268 
279  virtual bool Match (Atom *atom, AtomMatchState &state);
280 
284  std::string Name ();
285 
298  void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
299 
300 private:
301  void AChanged ();
302 
303 protected:
307  int m_Z;
311  double m_x;
315  double m_y;
319  double m_z;
323  char m_Charge;
327  std::map<Atom*, Bond*> m_Bonds;
328 
329 GCU_PROP_FULL (int, A, AChanged) // nucleon number, 0 means natural or not specified.
330 
331 };
332 
338 class AtomPair {
339 public:
340 
347  AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;}
348 
353 
358 };
359 
366 {
367 public:
368 
372  std::map <Atom*, int> mol1;
373 
377  std::map <Atom*, int> mol2;
378 
382  std::vector <AtomPair> atoms;
383 };
384 
385 } //namespace gcu
386 #endif // GCU_ATOM_H
virtual bool LoadNode(xmlNodePtr node)
virtual void AddBond(Bond *pBond)
virtual ~Atom()
bool SetProperty(unsigned property, char const *value)
virtual void RemoveBond(Bond *pBond)
std::vector< AtomPair > atoms
Definition: gcu/atom.h:382
bool GetCoords(double *x, double *y, double *z=NULL) const
virtual void Move(double x, double y, double z=0.)
virtual bool SaveNode(xmlDocPtr xml, xmlNodePtr node) const
virtual bool Load(xmlNodePtr node)
virtual void SetZ(int Z)
Vector GetVector() const
Bond * GetFirstBond(std::map< Atom *, Bond * >::iterator &i)
int m_Z
Definition: gcu/atom.h:307
void zoom(double ZoomFactor)
std::map< Atom *, int > mol1
Definition: gcu/atom.h:372
Bond * GetBond(Atom *pAtom) const
double z() const
Definition: gcu/atom.h:159
Bond * GetNextBond(std::map< Atom *, Bond * >::iterator &i)
Atom * atom2
Definition: gcu/atom.h:357
virtual void Transform2D(Matrix2D &m, double x, double y)
bool IsInCycle(Cycle *pCycle)
virtual const gchar * GetSymbol() const
double m_y
Definition: gcu/atom.h:315
virtual void SetCharge(char Charge)
Definition: gcu/atom.h:125
int GetZ() const
Definition: gcu/atom.h:112
char GetCharge()
Definition: gcu/atom.h:129
double m_x
Definition: gcu/atom.h:311
Atom * atom1
Definition: gcu/atom.h:352
std::map< Atom *, Bond * > m_Bonds
Definition: gcu/atom.h:327
std::string Name()
Atom & operator=(Atom &a)
double m_z
Definition: gcu/atom.h:319
void NetToCartesian(double a, double b, double c, double alpha, double beta, double gamma)
std::map< Atom *, int > mol2
Definition: gcu/atom.h:377
virtual xmlNodePtr Save(xmlDocPtr xml) const
std::string GetProperty(unsigned property) const
double Distance(Atom *pAtom)
virtual bool Match(Atom *atom, AtomMatchState &state)
AtomPair(Atom *at1, Atom *at2)
Definition: gcu/atom.h:347
double x() const
Definition: gcu/atom.h:149
double y() const
Definition: gcu/atom.h:154
void SetCoords(double x, double y, double z=0)
Definition: gcu/atom.h:108
int GetBondsNumber() const
Definition: gcu/atom.h:201
char m_Charge
Definition: gcu/atom.h:323