gcu/atom.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * Gnome Chemistry Utils
00005  * atom.h 
00006  *
00007  * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCU_ATOM_H
00026 #define GCU_ATOM_H
00027 
00028 #include "object.h"
00029 #include <glib.h>
00030 #include <map>
00031 #include <vector>
00032 
00033 namespace gcu
00034 {
00035         
00036 class Bond;
00037 class Cycle;
00038 class AtomMatchState;
00039 
00044 class Atom: public Object
00045 {
00046 public:
00050         Atom ();
00059         Atom (int Z, double x, double y, double z = 0.);
00065         Atom (Atom& a);
00071         Atom& operator= (Atom& a);
00075         virtual ~Atom ();
00076 
00077 public :
00082         double Distance (Atom* pAtom);
00088         void zoom (double ZoomFactor);
00097         virtual bool GetCoords (double *x, double *y, double *z = NULL) const;
00105         void SetCoords (double x, double y, double z = 0) {m_x = x; m_y = y; m_z = z;}
00109         int GetZ () const {return m_Z;}
00116         virtual void SetZ (int Z);
00122         virtual void SetCharge (char Charge) {m_Charge = Charge;}
00126         char GetCharge () {return m_Charge;}
00130         virtual const gchar* GetSymbol () const;
00136         virtual void AddBond (Bond* pBond);
00142         virtual void RemoveBond (Bond* pBond);
00146         double x () const {return m_x;}
00150         double y () const {return m_y;}
00154         double z () const {return m_z;}
00161         Bond* GetFirstBond (std::map<Atom*, Bond*>::iterator& i);
00168         Bond* GetNextBond (std::map<Atom*, Bond*>::iterator& i);
00173         Bond* GetBond (Atom* pAtom) const;
00177         int GetBondsNumber () const {return m_Bonds.size();}
00182         virtual xmlNodePtr Save (xmlDocPtr xml) const;
00188         virtual bool Load (xmlNodePtr node);
00195         virtual bool LoadNode (xmlNodePtr node);
00203         virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
00211         virtual void Move (double x, double y, double z = 0.);
00219         virtual void Transform2D (Matrix2D& m, double x, double y);
00220 
00223         bool SetProperty (unsigned property, char const *value);
00224 
00227         std::string GetProperty (unsigned property) const;
00228 
00231         bool IsInCycle (Cycle* pCycle);
00232 
00235         virtual bool Match (Atom *atom, AtomMatchState &state);
00236 
00237 protected:
00241         int m_Z;
00245         double m_x;
00249         double m_y;
00253         double m_z;
00257         char m_Charge;
00261         std::map<Atom*, Bond*> m_Bonds;
00262 };
00263 
00264 class AtomPair {
00265         public:
00266         AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;}
00267         Atom *atom1, *atom2;
00268 };
00269 
00270 class AtomMatchState
00271 {
00272 public:
00273         std::map <Atom*, int>  mol1, mol2;
00274         std::vector <AtomPair> atoms;
00275 };
00276 
00277 } //namespace gcu
00278 #endif // GCU_ATOM_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6