4
* Gnome Chemistry Utils
7
* Copyright (C) 2002-2004
9
* Developed by Jean Br�fort <jean.brefort@normalesup.org>
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public
13
* License as published by the Free Software Foundation; either
14
* version 2.1 of the License, or (at your option) any later version.
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this library; if not, write to the
23
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24
* Boston, MA 02111-1307, USA.
27
#ifndef CRYSTAL_ATOM_H
28
#define CRYSTAL_ATOM_H
31
#include <libxml/parser.h>
32
#include <libxml/parserInternals.h>
33
#include <libxml/xmlmemory.h>
35
#include "chemistry.h"
42
/*! \class CrystalAtom gcu/crystalatom.h
43
Used to represent atoms in a crystal.
45
class CrystalAtom : public Atom
49
The default constructor.
53
The destructor of CrystalAtom.
55
virtual ~CrystalAtom ();
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.
66
CrystalAtom (int Z, double x, double y, double z);
68
@param caAtom: the CrystalAtom to duplicate.
70
Creates a new CrystalAtom identical to caAtom.
72
CrystalAtom (CrystalAtom& caAtom);
74
@param caAtom: the Atom to copy.
76
@return a CrystalAtom identical to caAtom.
78
CrystalAtom& operator= (CrystalAtom& caAtom);
81
Draws the atom inside the active OpenGL window.
85
@param red: the red component of the color.
86
@param green: the green component of the color.
87
@param blue: the blue component of the color.
88
@param alpha: the alpha component of the color.
90
Sets a custom color to the atom.
92
void SetColor (float red, float green, float blue, float alpha);
94
Gives the atom the default color.
96
void SetDefaultColor ();
98
@return: true if the color is user defined and false if it is the default color.
100
bool HasCustomColor () {return m_bCustomColor;}
102
@param red: a pointer to the red component.
103
@param green: a pointer to the green component.
104
@param blue: a pointer to the blue component.
105
@param alpha: a pointer to the alpha component.
107
Used to retreive the color used in the representation of the atom. Mainly useful for user defined
110
void GetColor (double *red, double *green, double *blue, double *alpha);
112
@param r: the new value of the atomic radius.
114
Sets the value of the radius (in pm).
116
void SetSize (double r);
118
@return the value of the radius (in pm).
122
@param caAtom: a CrystalAtom instance.
123
@return true if the atoms are at the same position and false if their positions are different.
125
bool operator== (CrystalAtom& caAtom);
127
Method used to cleave an atom. The inverse operation does not exist since the whole crystal must be recalculated
128
after a change in the definition.
130
void Cleave () {m_nCleave++;}
132
@param h: the h Miller index of a plane.
133
@param k: the k Miller index of a plane.
134
@param l: the l Miller index of a plane.
136
@return the product hx+ky+lz where x, y and z are the coordinates of the atom. This makes sense only if coordinates
137
are related to the net and are not the cartesian coordinates. This method should not be called after NetToCartesian().
139
double ScalProd (int h, int k, int l);
141
@param a: the a parameter of the unit cell.
142
@param b: the b parameter of the unit cell.
143
@param c: the c parameter of the unit cell.
144
@param alpha: the alpha angle of the unit cell.
145
@param beta: the beta angle of the unit cell.
146
@param gamma: the gamma angle of the unit cell.
148
Converts the coordinates of the atom from net related ones to cartesian. Initially, atoms are defined by their
149
position relative to the unit cell and the coordinates must be transformed to the cartesian ones before
152
void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
154
@param x: the x coordinate of the center.
155
@param y: the y coordinate of the center.
156
@param z: the z coordinate of the center.
157
@param bFixed: tells if cleaved atoms are taken into account.
159
This helper method is called when searching for the size of the crystal. When some cleavages are defined,
160
the procedure cn take into account atoms cleaved to get the same position in the view for the cleaved crystal
161
than for the whole crystal. If bFixed is true, all atoms are taken into account.
163
@return the distance of the atom to the center of the view or 0 if bFixed is false and the atom cleaved.
165
double Distance (double x, double y, double z, bool bFixed);
167
@return the value of the radius (in pm).
169
double r () {return m_Radius.value;}
171
@return the GcuAtomicRadius containing the caracteristics of the atom radius.
173
const GcuAtomicRadius& GetRadius () {return m_Radius;}
175
@param r: a GcuAtomicRadius with the caracteristics of the atom radius.
177
void SetRadius (const GcuAtomicRadius& r);
179
@return true if the atom is cleaved by at least one cleavage or false if the atom is not cleaved at all.
181
bool IsCleaved () {return m_nCleave != 0;}
183
@param xml: the xmlDoc used to save the document.
184
@param node: a pointer to the xmlNode to which this Atom is serialized.
186
Saves the color and the radius of the atom.
188
virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node);
190
@param node: a pointer to the xmlNode containing the serialized Atom.
192
Loads the color and the radius of the atom.
194
virtual bool LoadNode (xmlNodePtr node);
198
The blue component of the color of the sphere representing the atom.
202
The red component of the color of the sphere representing the atom.
206
The green component of the color of the sphere representing the atom.
210
The alpha component of the color of the sphere representing the atom.
214
False if the color used is the default color and true if it is a user defined color.
218
The GcuAtomicRadius containing the radius caracteristics of the atom.
220
GcuAtomicRadius m_Radius;
222
When cleavages (see CrystalCleavage class documentation) are defined, the atom might be cleaved. m_nCleave is
223
the number of CrystalCleavage instances which remove the atom. If this member is not 0, the atom will
226
int m_nCleave; //0 if not cleaved
229
/*!\class CrystalAtomList
230
a list of pointers to CrystalAtom instances derived from std::list.
232
typedef list<CrystalAtom*> CrystalAtomList;
236
#endif // CRYSTAL_ATOM_H