The Gnome Chemistry Utils
0.13.7
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * atom.h 00006 * 00007 * Copyright (C) 2002-2011 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 3 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 00034 namespace gcu 00035 { 00036 00037 class Bond; 00038 class Cycle; 00039 class AtomMatchState; 00040 class Vector; 00041 00046 class Atom: public Object 00047 { 00048 public: 00052 Atom (); 00061 Atom (int Z, double x, double y, double z = 0.); 00067 Atom (Atom& a); 00073 Atom& operator= (Atom& a); 00077 virtual ~Atom (); 00078 00079 public : 00084 double Distance (Atom* pAtom); 00090 void zoom (double ZoomFactor); 00099 bool GetCoords (double *x, double *y, double *z = NULL) const; 00107 void SetCoords (double x, double y, double z = 0) {m_x = x; m_y = y; m_z = z;} 00111 int GetZ () const {return m_Z;} 00118 virtual void SetZ (int Z); 00124 virtual void SetCharge (char Charge) {m_Charge = Charge;} 00128 char GetCharge () {return m_Charge;} 00132 virtual const gchar* GetSymbol () const; 00138 virtual void AddBond (Bond* pBond); 00144 virtual void RemoveBond (Bond* pBond); 00148 double x () const {return m_x;} 00149 double &x () {return m_x;} 00153 double y () const {return m_y;} 00154 double &y () {return m_y;} 00158 double z () const {return m_z;} 00159 double &z () {return m_z;} 00163 Vector GetVector () const; 00170 Bond *GetFirstBond (std::map < Atom *, Bond * >::iterator& i); 00177 Bond const *GetFirstBond (std::map< Atom *, Bond * >::const_iterator& i) const; 00184 Bond *GetNextBond (std::map<Atom*, Bond*>::iterator& i); 00191 Bond const *GetNextBond (std::map< Atom *, Bond * >::const_iterator& i) const; 00196 Bond* GetBond (Atom* pAtom) const; 00200 int GetBondsNumber () const {return m_Bonds.size();} 00205 virtual xmlNodePtr Save (xmlDocPtr xml) const; 00211 virtual bool Load (xmlNodePtr node); 00218 virtual bool LoadNode (xmlNodePtr node); 00226 virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const; 00234 virtual void Move (double x, double y, double z = 0.); 00242 virtual void Transform2D (Matrix2D& m, double x, double y); 00243 00251 bool SetProperty (unsigned property, char const *value); 00252 00259 std::string GetProperty (unsigned property) const; 00260 00266 bool IsInCycle (Cycle* pCycle); 00267 00278 virtual bool Match (Atom *atom, AtomMatchState &state); 00279 00283 std::string Name (); 00284 00285 protected: 00289 int m_Z; 00293 double m_x; 00297 double m_y; 00301 double m_z; 00305 char m_Charge; 00309 std::map<Atom*, Bond*> m_Bonds; 00310 }; 00311 00317 class AtomPair { 00318 public: 00319 00326 AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;} 00327 00331 Atom *atom1; 00332 00336 Atom *atom2; 00337 }; 00338 00344 class AtomMatchState 00345 { 00346 public: 00347 00351 std::map <Atom*, int> mol1; 00352 00356 std::map <Atom*, int> mol2; 00357 00361 std::vector <AtomPair> atoms; 00362 }; 00363 00364 } //namespace gcu 00365 #endif // GCU_ATOM_H