The Gnome Chemistry Utils 0.13.3
|
00001 // -*- C++ -*- 00002 00003 /* 00004 * Gnome Chemistry Utils 00005 * bond.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_BOND_H 00026 #define GCU_BOND_H 00027 00028 #include <list> 00029 #include "object.h" 00030 00032 namespace gcu 00033 { 00034 00035 class Atom; 00036 class Cycle; 00037 00042 class Bond: public Object 00043 { 00044 public: 00048 Bond (); 00057 Bond (Atom* first, Atom* last, unsigned char order); 00061 virtual ~Bond (); 00062 00068 virtual Atom* GetAtom (int which) const; //0 = first, 1 = last, others reserved (for multicentered bonds?) 00075 virtual Atom* GetAtom (Atom* pAtom, int which = 0) const; //"which" is just a place holder for multicenter bonds; returns an atom different from pAtom 00076 //i.e. the other end of the bond 00077 virtual Atom const * GetAtom (Atom const * pAtom, int which = 0) const; 00081 unsigned char GetOrder () const; 00087 void SetOrder (unsigned char Order); 00092 virtual xmlNodePtr Save (xmlDocPtr xml) const; 00098 virtual bool Load (xmlNodePtr node); 00104 virtual void IncOrder (int n = 1); 00111 virtual bool LoadNode (xmlNodePtr node); 00119 virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const; 00127 virtual void Move (double x, double y, double z = 0.); 00135 virtual void Transform2D (Matrix2D& m, double x, double y); 00136 00144 bool SetProperty (unsigned property, char const *value); 00145 00152 std::string GetProperty (unsigned property) const; 00153 00157 virtual void AddCycle (Cycle* pCycle); 00158 00162 virtual void RemoveCycle (Cycle* pCycle); 00163 00167 virtual void RemoveAllCycles (); 00168 00172 unsigned IsCyclic () {return m_Cycles.size ();} 00173 00181 Cycle* GetFirstCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle); 00182 00190 Cycle* GetNextCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle); 00191 00197 bool IsInCycle (Cycle* pCycle); 00198 00202 double Get2DLength (); 00203 00209 double GetAngle2DRad (Atom* pAtom); 00210 00218 bool ReplaceAtom (Atom* oldAtom, Atom* newAtom); 00219 00223 void OnLoaded (); 00224 00228 std::string Name (); 00229 00230 protected: 00234 unsigned char m_order; 00238 Atom *m_Begin; 00242 Atom *m_End;// only 2 centered bonds, other bonds should be covered by derived classes 00243 00247 std::list<Cycle*> m_Cycles; 00248 }; 00249 00250 } // namespace gcu 00251 00252 #endif // GCU_BOND_H