The Gnome Chemistry Utils  0.12.11
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-2010 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 2 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?)
75  virtual Atom* GetAtom (Atom* pAtom, int which = 0) const; //"which" is just a place holder for multicenter bonds; returns an atom different from pAtom
76  //i.e. the other end of the bond
80  unsigned char GetOrder () const;
86  void SetOrder (unsigned char Order);
91  virtual xmlNodePtr Save (xmlDocPtr xml) const;
97  virtual bool Load (xmlNodePtr node);
103  virtual void IncOrder (int n = 1);
110  virtual bool LoadNode (xmlNodePtr node);
118  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
126  virtual void Move (double x, double y, double z = 0.);
134  virtual void Transform2D (Matrix2D& m, double x, double y);
135 
143  bool SetProperty (unsigned property, char const *value);
144 
151  std::string GetProperty (unsigned property) const;
152 
156  virtual void AddCycle (Cycle* pCycle);
157 
161  virtual void RemoveCycle (Cycle* pCycle);
162 
166  virtual void RemoveAllCycles ();
167 
171  unsigned IsCyclic () {return m_Cycles.size ();}
172 
180  Cycle* GetFirstCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
181 
189  Cycle* GetNextCycle (std::list<Cycle*>::iterator& i, Cycle * pCycle);
190 
196  bool IsInCycle (Cycle* pCycle);
197 
201  double Get2DLength ();
202 
208  double GetAngle2DRad (Atom* pAtom);
209 
217  bool ReplaceAtom (Atom* oldAtom, Atom* newAtom);
218 
222  void OnLoaded ();
223 
227  std::string Name ();
228 
229 protected:
233  unsigned char m_order;
241  Atom *m_End;// only 2 centered bonds, other bonds should be covered by derived classes
242 
246  std::list<Cycle*> m_Cycles;
247 };
248 
249 } // namespace gcu
250 
251 #endif // GCU_BOND_H