The Gnome Chemistry Utils  0.14.0
gcu/bond.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * bond.h
6  *
7  * Copyright (C) 2002-2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_BOND_H
26 #define GCU_BOND_H
27 
28 #include <list>
29 #include "object.h"
30 
32 namespace gcu
33 {
34 
35 class Atom;
36 class Cycle;
37 
42 class Bond: public Object
43 {
44 public:
48  Bond ();
57  Bond (Atom* first, Atom* last, unsigned char order);
61  virtual ~Bond ();
62 
68  virtual Atom* GetAtom (int which) const; //0 = first, 1 = last, others reserved (for multicentered bonds?)
69 
77  virtual Atom* GetAtom (Atom* pAtom, int which = 0) const; //"which" is just a place holder for multicenter bonds; returns an atom different from pAtom
78  //i.e. the other end of the bond
79 
88  virtual Atom const * GetAtom (Atom const * pAtom, int which = 0) const;
92  unsigned char GetOrder () const;
98  void SetOrder (unsigned char Order);
103  virtual xmlNodePtr Save (xmlDocPtr xml) const;
109  virtual bool Load (xmlNodePtr node);
115  virtual void IncOrder (int n = 1);
122  virtual bool LoadNode (xmlNodePtr node);
130  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
138  virtual void Move (double x, double y, double z = 0.);
146  virtual void Transform2D (Matrix2D& m, double x, double y);
147 
155  bool SetProperty (unsigned property, char const *value);
156 
163  std::string GetProperty (unsigned property) const;
164 
168  virtual void AddCycle (Cycle* pCycle);
169 
173  virtual void RemoveCycle (Cycle* pCycle);
174 
178  virtual void RemoveAllCycles ();
179 
183  unsigned IsCyclic () {return m_Cycles.size ();}
184 
192  Cycle* GetFirstCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
193 
201  Cycle* GetNextCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
202 
208  bool IsInCycle (Cycle* pCycle);
209 
213  double Get2DLength ();
214 
220  double GetAngle2DRad (Atom* pAtom);
221 
229  bool ReplaceAtom (Atom* oldAtom, Atom* newAtom);
230 
234  void OnLoaded ();
235 
239  std::string Name ();
240 
241 protected:
245  unsigned char m_order;
253  Atom *m_End;// only 2 centered bonds, other bonds should be covered by derived classes
254 
258  std::list<Cycle*> m_Cycles;
259 };
260 
261 } // namespace gcu
262 
263 #endif // GCU_BOND_H