The Gnome Chemistry Utils  0.14.0
gcr/bond.h
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcr/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 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 GCR_BOND_H
26 #define GCR_BOND_H
27 
28 #include <libxml/parser.h>
29 #include <list>
30 #include <gcu/bond.h>
31 
32 namespace gcr
33 {
34 
38 class Bond: public gcu::Bond
39 {
40 public:
41  Bond ();
42  virtual ~Bond ();
43 
44 public :
45  Bond (double X1, double Y1, double Z1, double X2, double Y2, double Z2, double r, float red, float green, float blue, float alpha);
46  Bond (Bond& cbBond);
47  Bond& operator= (Bond&);
48 
49  void Draw ();
50  double X1 (void) {return m_dx;}
51  double Y1 (void) {return m_dy;}
52  double Z1 (void) {return m_dz;}
53  double X2 (void) {return m_dx2;}
54  double Y2 (void) {return m_dy2;}
55  double Z2 (void) {return m_dz2;}
56  double Xmax ();
57  double Ymax ();
58  double Zmax ();
59  double Xmin ();
60  double Ymin ();
61  double Zmin ();
62  double Long () {return m_dl;}
63  void SetPosition (double x, double y, double z, double x1, double y1, double z1);
64  void SetColor (float red, float green, float blue, float alpha);
65  void GetColor (double *red, double *green, double *blue, double *alpha);
66  void SetRadius (double r);
67  double GetRadius () {return m_dr;};
68  bool operator== (Bond&);
69  virtual void Move (double x, double y, double z);
70  double ScalProd (int h, int k, int l);
71  void Cleave () {m_nCleave++;}
72  void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
73  double Distance (double x, double y, double z, bool bFixed);
74  bool IsCleaved () {return m_nCleave != 0;}
75  void GetRotation (double& x, double& y, double& z, double& th);
76  virtual xmlNodePtr Save (xmlDocPtr xml);
77  virtual bool Load (xmlNodePtr node);
78 
79 private :
80  float m_fBlue, m_fRed, m_fGreen, m_fAlpha;
81  double m_dx, m_dy, m_dz, m_dx2, m_dy2, m_dz2, m_dr, m_dl;
82  double m_dxrot, m_dyrot, m_darot;//rotation axis coordinates (z = 0) and angle
83  int m_nCleave; //0 if not cleaved
84 };
85 
86 typedef std::list<Bond*> BondList;
87 
88 }// namespace gcr
89 
90 #endif // GCR_BOND_H