The Gnome Chemistry Utils  0.14.0
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 <glib.h>
30 #include <map>
31 #include <vector>
32 
34 namespace gcu
35 {
36 
37 class Bond;
38 class Cycle;
39 class AtomMatchState;
40 class Vector;
41 
46 class Atom: public Object
47 {
48 public:
52  Atom ();
61  Atom (int Z, double x, double y, double z = 0.);
67  Atom (Atom& a);
73  Atom& operator= (Atom& a);
77  virtual ~Atom ();
78 
79 public :
84  double Distance (Atom* pAtom);
90  void zoom (double ZoomFactor);
99  bool GetCoords (double *x, double *y, double *z = NULL) const;
107  void SetCoords (double x, double y, double z = 0) {m_x = x; m_y = y; m_z = z;}
111  int GetZ () const {return m_Z;}
118  virtual void SetZ (int Z);
124  virtual void SetCharge (char Charge) {m_Charge = Charge;}
128  char GetCharge () {return m_Charge;}
132  virtual const gchar* GetSymbol () const;
138  virtual void AddBond (Bond* pBond);
144  virtual void RemoveBond (Bond* pBond);
148  double x () const {return m_x;}
149  double &x () {return m_x;}
153  double y () const {return m_y;}
154  double &y () {return m_y;}
158  double z () const {return m_z;}
159  double &z () {return m_z;}
163  Vector GetVector () const;
170  Bond *GetFirstBond (std::map < Atom *, Bond * >::iterator& i);
177  Bond const *GetFirstBond (std::map< Atom *, Bond * >::const_iterator& i) const;
184  Bond *GetNextBond (std::map<Atom*, Bond*>::iterator& i);
191  Bond const *GetNextBond (std::map< Atom *, Bond * >::const_iterator& i) const;
196  Bond* GetBond (Atom* pAtom) const;
200  int GetBondsNumber () const {return m_Bonds.size();}
205  virtual xmlNodePtr Save (xmlDocPtr xml) const;
211  virtual bool Load (xmlNodePtr node);
218  virtual bool LoadNode (xmlNodePtr node);
226  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
234  virtual void Move (double x, double y, double z = 0.);
242  virtual void Transform2D (Matrix2D& m, double x, double y);
243 
251  bool SetProperty (unsigned property, char const *value);
252 
259  std::string GetProperty (unsigned property) const;
260 
266  bool IsInCycle (Cycle* pCycle);
267 
278  virtual bool Match (Atom *atom, AtomMatchState &state);
279 
283  std::string Name ();
284 
297  void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
298 
299 protected:
303  int m_Z;
307  double m_x;
311  double m_y;
315  double m_z;
319  char m_Charge;
323  std::map<Atom*, Bond*> m_Bonds;
324 };
325 
331 class AtomPair {
332 public:
333 
340  AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;}
341 
346 
351 };
352 
359 {
360 public:
361 
365  std::map <Atom*, int> mol1;
366 
370  std::map <Atom*, int> mol2;
371 
375  std::vector <AtomPair> atoms;
376 };
377 
378 } //namespace gcu
379 #endif // GCU_ATOM_H