~ubuntu-branches/ubuntu/lucid/gnome-chemistry-utils/lucid-security

« back to all changes in this revision

Viewing changes to gcu/crystalatom.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2005-03-28 20:10:22 UTC
  • Revision ID: james.westby@ubuntu.com-20050328201022-jljjos2ot9942zsb
Tags: upstream-0.4.1
Import upstream version 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
 
 
3
/* 
 
4
 * Gnome Chemistry Utils
 
5
 * crystalatom.h 
 
6
 *
 
7
 * Copyright (C) 2002-2004
 
8
 *
 
9
 * Developed by Jean Br�fort <jean.brefort@normalesup.org>
 
10
 *
 
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.
 
15
 *
 
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.
 
20
 *
 
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.
 
25
 */
 
26
 
 
27
#ifndef CRYSTAL_ATOM_H
 
28
#define CRYSTAL_ATOM_H
 
29
 
 
30
#include <list>
 
31
#include <libxml/parser.h>
 
32
#include <libxml/parserInternals.h>
 
33
#include <libxml/xmlmemory.h>
 
34
#include "atom.h"
 
35
#include "chemistry.h"
 
36
 
 
37
using namespace std;
 
38
 
 
39
namespace gcu
 
40
{
 
41
 
 
42
/*! \class CrystalAtom gcu/crystalatom.h
 
43
Used to represent atoms in a crystal.
 
44
*/
 
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);
 
67
/*!
 
68
@param caAtom: the CrystalAtom to duplicate.
 
69
 
 
70
Creates a new CrystalAtom identical to caAtom.
 
71
*/
 
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
 
 
80
/*!
 
81
Draws the atom inside the active OpenGL window.
 
82
*/
 
83
        void Draw ();
 
84
/*!
 
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.
 
89
 
 
90
Sets a custom color to the atom.
 
91
*/
 
92
        void SetColor (float red, float green, float blue, float alpha);
 
93
/*!
 
94
Gives the atom the default color.
 
95
*/
 
96
        void SetDefaultColor ();
 
97
/*!
 
98
@return: true if the color is user defined and false if it is the default color.
 
99
*/
 
100
        bool HasCustomColor () {return m_bCustomColor;}
 
101
/*!
 
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.
 
106
 
 
107
Used to retreive the color used in the representation of the atom. Mainly useful for user defined
 
108
colors.
 
109
*/
 
110
        void GetColor (double *red, double *green, double *blue, double *alpha);
 
111
/*!
 
112
@param r: the new value of the atomic radius.
 
113
 
 
114
Sets the value of the radius (in pm).
 
115
*/
 
116
        void SetSize (double r);
 
117
/*!
 
118
@return the value of the radius (in pm).
 
119
*/
 
120
        double GetSize ();
 
121
/*!
 
122
@param caAtom: a CrystalAtom instance.
 
123
@return true if the atoms are at the same position and false if their positions are different.
 
124
*/
 
125
        bool operator== (CrystalAtom& caAtom);
 
126
/*!
 
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.
 
129
*/
 
130
        void Cleave () {m_nCleave++;}
 
131
/*!
 
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.
 
135
 
 
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().
 
138
*/
 
139
        double ScalProd (int h, int k, int l);
 
140
/*!
 
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.
 
147
 
 
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
 
150
displaying the atom.
 
151
*/
 
152
        void NetToCartesian (double a, double b, double c, double alpha, double beta, double gamma);
 
153
/*!
 
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.
 
158
 
 
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.
 
162
 
 
163
@return the distance of the atom to the center of the view or 0 if bFixed is false and the atom cleaved. 
 
164
*/
 
165
        double Distance (double x, double y, double z, bool bFixed);
 
166
/*!
 
167
@return the value of the radius (in pm).
 
168
*/
 
169
        double r () {return m_Radius.value;}
 
170
/*!
 
171
@return the GcuAtomicRadius containing the caracteristics of the atom radius.
 
172
*/
 
173
        const GcuAtomicRadius& GetRadius () {return m_Radius;}
 
174
/*!
 
175
@param r: a GcuAtomicRadius with the caracteristics of the atom radius.
 
176
*/
 
177
        void SetRadius (const GcuAtomicRadius& r);
 
178
/*!
 
179
@return true if the atom is cleaved by at least one cleavage or false if the atom is not cleaved at all.
 
180
*/
 
181
        bool IsCleaved () {return m_nCleave != 0;}
 
182
/*!
 
183
@param xml: the xmlDoc used to save the document.
 
184
@param node: a pointer to the xmlNode to which this Atom is serialized.
 
185
 
 
186
Saves the color and the radius of the atom.
 
187
*/
 
188
        virtual bool SaveNode (xmlDocPtr xml, xmlNodePtr node);
 
189
/*!
 
190
@param node: a pointer to the xmlNode containing the serialized Atom.
 
191
 
 
192
Loads the color and the radius of the atom.
 
193
*/
 
194
        virtual bool LoadNode (xmlNodePtr node);
 
195
        
 
196
protected:
 
197
/*!
 
198
The blue component of the color of the sphere representing the atom.
 
199
*/
 
200
        float m_fBlue;
 
201
/*!
 
202
The red component of the color of the sphere representing the atom.
 
203
*/
 
204
        float m_fRed;
 
205
/*!
 
206
The green component of the color of the sphere representing the atom.
 
207
*/
 
208
        float m_fGreen;
 
209
/*!
 
210
The alpha component of the color of the sphere representing the atom.
 
211
*/
 
212
        float m_fAlpha;
 
213
/*!
 
214
False if the color used is the default color and true if it is a user defined color.
 
215
*/
 
216
        bool m_bCustomColor;
 
217
/*!
 
218
The GcuAtomicRadius containing the radius caracteristics of the atom.
 
219
*/
 
220
        GcuAtomicRadius m_Radius;
 
221
/*!
 
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
 
224
not be displayed.
 
225
*/
 
226
        int m_nCleave; //0 if not cleaved
 
227
};
 
228
 
 
229
/*!\class CrystalAtomList
 
230
a list of pointers to CrystalAtom instances derived from std::list.
 
231
*/
 
232
typedef list<CrystalAtom*> CrystalAtomList;
 
233
 
 
234
}// namespace gcu
 
235
 
 
236
#endif // CRYSTAL_ATOM_H