1 // ATOM.H : the atom-related classes.
2 
3 // Copyright (C) 1998 Tommi Hassinen.
4 
5 // This package is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 
10 // This package is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // You should have received a copy of the GNU General Public License
16 // along with this package; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 /*################################################################################################*/
20 
21 #ifndef ATOM_H
22 #define ATOM_H
23 
24 #include "libghemicaldefine.h"
25 #include "libghemical-features.h"
26 
27 class element;
28 
29 class crec;
30 class atom;
31 
32 /*################################################################################################*/
33 
34 class bond;	// bond.h
35 class model;	// model.h
36 
37 #include "typedef.h"
38 
39 #include <cstdlib>
40 
41 #include <list>
42 #include <vector>
43 using namespace std;
44 
45 /*################################################################################################*/
46 
47 #define ELEMENT_SYMBOLS 110
48 
49 /// An element class.
50 
51 class element
52 {
53 	private:
54 
55 	i32s atomic_number;			///< This is the atomic number, or NOT_DEFINED (equal to -1) for a dummy atom.
56 
57 	static const char string[ELEMENT_SYMBOLS][32];
58 	static const char symbol[ELEMENT_SYMBOLS][4];
59 
60 	static const fGL color[ELEMENT_SYMBOLS][3];
61 
62 	static const fGL mass[ELEMENT_SYMBOLS];
63 	static const fGL vdwr[ELEMENT_SYMBOLS];
64 
65 	public:
66 
67 	static element current_element;		///< This is the current element that user has selected.
68 
69 	public:
70 
71 	element(void);
72 	element(char *);	///< By symbols.
73 	element(i32s);		///< By atomic numbers.
74 	~element(void);
75 
76 	const i32s GetAtomicNumber(void) const;
77 	const char * GetString(void) const;
78 	const char * GetSymbol(void) const;
79 	const fGL * GetColor(void) const;
80 	fGL GetAtomicMass(void) const;
81 	fGL GetVDWRadius(void) const;
82 
83 // JUST DISABLED FOR A WHILE; remove the "const" settings from tables and write prefs directly there??? QUICKER!!!
84 // JUST DISABLED FOR A WHILE; remove the "const" settings from tables and write prefs directly there??? QUICKER!!!
85 // JUST DISABLED FOR A WHILE; remove the "const" settings from tables and write prefs directly there??? QUICKER!!!
86 //	fGL GetVDWRadius(prefs *) const;
87 //	const fGL * GetColor(prefs *) const;
88 
89 	void operator++(void);
90 	void operator--(void);
91 };
92 
93 /*################################################################################################*/
94 
95 /// A connectivity record class.
96 /** The connectivity records are maintained in the atom objects, to make quick browising of
97 bond networks possible. */
98 
99 class crec
100 {
101 //	protected:
102 	public:		// TODO : not properly divided in public/protected data.
103 
104 	atom * atmr;
105 	bond * bndr;
106 
107 	public:
108 
109 	crec(void);
110 	crec(atom *, bond *);
111 	~crec(void);
112 
113 //	bool operator<(const crec &) const { return false; }		// just for STL...
114 	bool operator==(const crec &) const;
115 };
116 
117 /*################################################################################################*/
118 
119 typedef list<crec>::iterator iter_cl;		// cl = connectivity list
120 typedef list<atom>::iterator iter_al;		// al = atom list
121 
122 typedef atom * ref_atom;
123 
124 /*################################################################################################*/
125 
126 #define ATOMFLAG_USER_SELECTED		(1 << 0)
127 
128 #define ATOMFLAG_USER_HIDDEN		(1 << 1)	// the USER_HIDDEN flag means:
129 // the wants to hide these atoms from the graphics view ; the flag is NOT affected to any calculations.
130 
131 #define ATOMFLAG_USER_LOCKED		(1 << 2)	// the USER_LOCKED flag means:
132 // 1) DoSHAKE() should not move it 2) in MD acc/vel always 0.0 and is not included when calculating Ekin/T.
133 // THIS IS STILL AN INCOMPLETE IMPLEMENTATION!!! be careful with this and test before any serious use...
134 
135 // the flags below this level are "internal" and should NOT be saved in any files (mask 0xFF).
136 // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137 
138 #define ATOMFLAG_IS_SOLVENT_ATOM	(1 << 8)	// todo : energy groups?!?!?
139 #define ATOMFLAG_MEASURE_TOOL_SEL	(1 << 16)	// -> replace by this when rdy...
140 
141 #define ATOMFLAG_IS_HIDDEN		(1 << 9)	// handled by the setup classes...
142 #define ATOMFLAG_IS_QM_ATOM		(1 << 10)	// handled by the setup classes...
143 #define ATOMFLAG_IS_MM_ATOM		(1 << 11)	// handled by the setup classes...
144 #define ATOMFLAG_IS_SF_ATOM		(1 << 12)	// handled by the setup classes...
145 
146 #define ATOMFLAG_MEASURE_ND_RDF		(1 << 24)
147 #define ATOMFLAG_COUNT_IN_RDF		(1 << 25)
148 
149 /// An atom class.
150 /** Will store all data about an atom, including type, coordinates, and a connectivity
151 record list for quick access to neighbor atoms. */
152 
153 class atom
154 {
155 	protected:
156 
157 	model * mdl;
158 
159 //	protected:
160 	public:		// TODO : not properly divided in public/protected data.
161 
162 	element el;		// is saved into files!!!
163 	int formal_charge;	// is saved into files!!! NOT YET BUT SHOULD!!!
164 
165 	i32s atmtp;		///< The normal MM atomtype.
166 	i32s atmtp_E;		///< MM atomtype "exception"; related to macromolecules...
167 	char atmtp_s[4];	///< MM atomtype "exception"; related to macromolecules...
168 
169 	f64 charge;		// is saved into files???
170 	f64 mass;
171 
172 	f64 vdwr;		// important in SF!!!
173 
174 	i32u my_glname;		// this is reserved for the GUI stuff...
175 
176 protected:
177 	list<crec> cr_list;		///< Connectivity records.
178 
179 	fGL * crd_table;		///< The actual coordinate data; see also model::PushCRDSets().
180 	i32u crd_table_size_loc;
181 public:
182 
183 /// Molecule, chain, residue and atom ID-numbers.
184 /** model::GatherGroups() will maintain molecule numbers, and sequence builders will handle the rest.
185 mol/chn id's are unique, but res/atm numbers are repeated in different chains and molecules.*/
186 	i32s id[4];
187 
188 /// Residue-ID numbers related to sequence-builder. Not sensitive to protonation states etc...
189 	i32s builder_res_id;
190 
191 	i32s index;		///< Index of this entry in model::atom_list. Updated by model::UpdateIndex().
192 	i32s varind;		///< Index of this entry in setup::atmtab. Updated by setup::UpdateSetupInfo().
193 
194 	i32u flags;		///< The flags that carry various information. These are saved into files.
195 	i32s ecomp_grp_i;
196 
197 	friend class model;	// model::PushCRDSets() needs this...
198 
199 	public:
200 
201 	atom(void);
202 	atom(element, const fGL *, i32u);
203 	atom(const atom &);
204 	~atom(void);
205 
GetModel(void)206 	model * GetModel(void) { return mdl; }
207 
208 	const fGL * GetCRD(i32u);
209 	void SetCRD(i32s, fGL, fGL, fGL);
210 
GetConnRecsBegin(void)211 	iter_cl GetConnRecsBegin(void) { return cr_list.begin(); }	//const;
GetConnRecsEnd(void)212 	iter_cl GetConnRecsEnd(void) { return cr_list.end(); }		//const;
GetFirstConnRec(void)213 	crec & GetFirstConnRec(void) { return cr_list.front(); }
GetLastConnRec(void)214 	crec & GetLastConnRec(void) { return cr_list.back(); }
GetConnRecCount(void)215 	int GetConnRecCount(void) { return (int) cr_list.size(); }	///< This will return cr_list.size().
216 
217 	bool GetSelected(void) const;
218 	void SetSelected(bool);
219 
220 	bool GetLocked(void) const;
221 	void SetLocked(bool);
222 
223 	bool operator<(const atom &) const;	///< Using id-numbers.
224 	bool operator==(const atom &) const;	///< Using pointers.
225 };
226 
227 /*################################################################################################*/
228 
229 #endif	// ATOM_H
230 
231 // eof
232