The Gnome Chemistry Utils  0.12.11
crystalatom.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * crystalatom.h
6  *
7  * Copyright (C) 2002-2008 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 CRYSTAL_ATOM_H
26 #define CRYSTAL_ATOM_H
27 
28 #include "atom.h"
29 #include "chemistry.h"
30 #include "macros.h"
31 #include <libxml/parser.h>
32 #include <libxml/parserInternals.h>
33 #include <libxml/xmlmemory.h>
34 #include <list>
35 
37 namespace gcu
38 {
39 
40 #define PREC 1e-3
41 
45 class CrystalAtom : public Atom
46 {
47 public:
48 /*
49 The default constructor.
50 */
51  CrystalAtom ();
52 /*
53 The destructor of CrystalAtom.
54 */
55  virtual ~CrystalAtom ();
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  CrystalAtom (int Z, double x, double y, double z);
72  CrystalAtom (CrystalAtom& caAtom);
73 /*
74 @param caAtom: the Atom to copy.
75 
76 @return a CrystalAtom identical to caAtom.
77 */
78  CrystalAtom& operator= (CrystalAtom& 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);
112  void SetSize (double r);
116  double GetSize ();
121  bool operator== (CrystalAtom& caAtom);
126  void Cleave () {m_nCleave++;}
135  double ScalProd (int h, int k, int l);
148  void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
161  double Distance (double x, double y, double z, bool bFixed);
165  double r () {return m_Radius.value.value;}
169  const GcuAtomicRadius& GetRadius () {return m_Radius;}
173  void SetRadius (const GcuAtomicRadius& r);
177  bool IsCleaved () {return m_nCleave != 0;}
184  virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const;
190  virtual bool LoadNode (xmlNodePtr node);
191 
192 protected:
196  float m_fBlue;
200  float m_fRed;
204  float m_fGreen;
208  float m_fAlpha;
222  int m_nCleave; //0 if not cleaved
223 
231  bool SetProperty (unsigned property, char const *value);
232 
239  std::string GetProperty (unsigned property) const;
240 
241 GCU_PROP (double, EffectiveRadiusRatio);
242 };
243 
247 typedef std::list<CrystalAtom*> CrystalAtomList;
248 }// namespace gcu
249 
250 #endif // CRYSTAL_ATOM_H