The Gnome Chemistry Utils  0.14.0
gcr/atom.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcr/atom.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_ATOM_H
26 #define GCR_ATOM_H
27 
28 #include <gcu/atom.h>
29 #include <gcu/chemistry.h>
30 #include <gcu/macros.h>
31 #include <libxml/parser.h>
32 #include <libxml/parserInternals.h>
33 #include <libxml/xmlmemory.h>
34 #include <list>
35 
37 namespace gcr
38 {
39 
40 #define PREC 1e-3
41 
45 class Atom : public gcu::Atom
46 {
47 public:
48 /*
49 The default constructor.
50 */
51  Atom ();
52 /*
53 The destructor of Atom.
54 */
55  virtual ~Atom ();
56 
57 public :
58 /*
59 @param Z: the atomic number of the new atom.
60 @param x: the x coordinate of the new atom.
61 @param y: the y coordinate of the new atom.
62 @param z: the z coordinate of the new atom.
63 
64 Creates an atom.
65 */
66  Atom (int Z, double x, double y, double z);
72  Atom (Atom& caAtom);
73 /*
74 @param caAtom: the Atom to copy.
75 
76 @return an Atom identical to caAtom.
77 */
78  Atom& operator= (Atom& caAtom);
79 
88  void SetColor (float red, float green, float blue, float alpha);
92  void SetDefaultColor ();
96  bool HasCustomColor () {return m_bCustomColor;}
106  void GetColor (double *red, double *green, double *blue, double *alpha);
107  void GetColor (GdkRGBA &rgba);
113  void SetSize (double r);
117  double GetSize ();
122  bool operator== (Atom& caAtom);
127  void Cleave () {m_nCleave++;}
136  double ScalProd (int h, int k, int l);
149  double Distance (double x, double y, double z, bool bFixed);
153  double r () {return m_Radius.value.value;}
157  const GcuAtomicRadius& GetRadius () {return m_Radius;}
161  void SetRadius (const GcuAtomicRadius& r);
165  bool IsCleaved () {return m_nCleave != 0;}
172  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
178  virtual bool LoadNode (xmlNodePtr node);
179 
180 protected:
184  float m_fBlue;
188  float m_fRed;
192  float m_fGreen;
196  float m_fAlpha;
210  int m_nCleave; //0 if not cleaved
211 
219  bool SetProperty (unsigned property, char const *value);
220 
227  std::string GetProperty (unsigned property) const;
228 
229 GCU_PROP (double, EffectiveRadiusRatio);
230 };
231 
235 typedef std::list<Atom*> AtomList;
236 }// namespace gcr
237 
238 #endif // GCR_ATOM_H