The Gnome Chemistry Utils 0.13.3
|
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 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 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;} 00152 double y () const {return m_y;} 00156 double z () const {return m_z;} 00160 Vector GetVector () const; 00167 Bond *GetFirstBond (std::map < Atom *, Bond * >::iterator& i); 00168 Bond const *GetFirstBond (std::map< Atom *, Bond * >::const_iterator& i) const; 00175 Bond *GetNextBond (std::map<Atom*, Bond*>::iterator& i); 00176 Bond const *GetNextBond (std::map< Atom *, Bond * >::const_iterator& i) const; 00181 Bond* GetBond (Atom* pAtom) const; 00185 int GetBondsNumber () const {return m_Bonds.size();} 00190 virtual xmlNodePtr Save (xmlDocPtr xml) const; 00196 virtual bool Load (xmlNodePtr node); 00203 virtual bool LoadNode (xmlNodePtr node); 00211 virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const; 00219 virtual void Move (double x, double y, double z = 0.); 00227 virtual void Transform2D (Matrix2D& m, double x, double y); 00228 00236 bool SetProperty (unsigned property, char const *value); 00237 00244 std::string GetProperty (unsigned property) const; 00245 00251 bool IsInCycle (Cycle* pCycle); 00252 00263 virtual bool Match (Atom *atom, AtomMatchState &state); 00264 00268 std::string Name (); 00269 00270 protected: 00274 int m_Z; 00278 double m_x; 00282 double m_y; 00286 double m_z; 00290 char m_Charge; 00294 std::map<Atom*, Bond*> m_Bonds; 00295 }; 00296 00302 class AtomPair { 00303 public: 00304 00311 AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;} 00312 00316 Atom *atom1; 00317 00321 Atom *atom2; 00322 }; 00323 00329 class AtomMatchState 00330 { 00331 public: 00332 00336 std::map <Atom*, int> mol1; 00337 00341 std::map <Atom*, int> mol2; 00342 00346 std::vector <AtomPair> atoms; 00347 }; 00348 00349 } //namespace gcu 00350 #endif // GCU_ATOM_H