gcu/atom.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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 }
00278 #endif // GCU_ATOM_H