# gcu/atom.h

Go to the documentation of this file.

    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
    00034 namespace gcu
    00035 {
    00036
    00037 class Bond;
    00038 class Cycle;
    00039 class AtomMatchState;
    00040
    00045 class Atom: public Object
    00046 {
    00047 public:
    00051         Atom ();
    00060         Atom (int Z, double x, double y, double z = 0.);
    00066         Atom (Atom& a);
    00072         Atom& operator= (Atom& a);
    00076         virtual ~Atom ();
    00077
    00078 public :
    00083         double Distance (Atom* pAtom);
    00089         void zoom (double ZoomFactor);
    00098         virtual bool GetCoords (double *x, double *y, double *z = NULL) const;
    00106         void SetCoords (double x, double y, double z = 0) {m_x = x; m_y = y; m_z = z;}
    00110         int GetZ () const {return m_Z;}
    00117         virtual void SetZ (int Z);
    00123         virtual void SetCharge (char Charge) {m_Charge = Charge;}
    00127         char GetCharge () {return m_Charge;}
    00131         virtual const gchar* GetSymbol () const;
    00137         virtual void AddBond (Bond* pBond);
    00143         virtual void RemoveBond (Bond* pBond);
    00147         double x () const {return m_x;}
    00151         double y () const {return m_y;}
    00155         double z () const {return m_z;}
    00162         Bond* GetFirstBond (std::map<Atom*, Bond*>::iterator& i);
    00169         Bond* GetNextBond (std::map<Atom*, Bond*>::iterator& i);
    00174         Bond* GetBond (Atom* pAtom) const;
    00178         int GetBondsNumber () const {return m_Bonds.size();}
    00183         virtual xmlNodePtr Save (xmlDocPtr xml) const;
    00189         virtual bool Load (xmlNodePtr node);
    00196         virtual bool LoadNode (xmlNodePtr node);
    00204         virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
    00212         virtual void Move (double x, double y, double z = 0.);
    00220         virtual void Transform2D (Matrix2D& m, double x, double y);
    00221
    00229         bool SetProperty (unsigned property, char const *value);
    00230
    00237         std::string GetProperty (unsigned property) const;
    00238
    00244         bool IsInCycle (Cycle* pCycle);
    00245
    00256         virtual bool Match (Atom *atom, AtomMatchState &state);
    00257
    00258 protected:
    00262         int m_Z;
    00266         double m_x;
    00270         double m_y;
    00274         double m_z;
    00278         char m_Charge;
    00282         std::map<Atom*, Bond*> m_Bonds;
    00283 };
    00284
    00290 class AtomPair {
    00291 public:
    00292
    00299         AtomPair (Atom *at1, Atom *at2) {atom1 = at1; atom2 = at2;}
    00300
    00304         Atom *atom1;
    00305
    00309         Atom *atom2;
    00310 };
    00311
    00317 class AtomMatchState
    00318 {
    00319 public:
    00320
    00324         std::map <Atom*, int> mol1;
    00325
    00329         std::map <Atom*, int> mol2;
    00330
    00334         std::vector <AtomPair> atoms;
    00335 };
    00336
    00337 } //namespace gcu
    00338 #endif // GCU_ATOM_H