1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute slab command. Change slab mode or change the position of
9
front or back slab surface.
12
(1) Pointer to MolComplexS structure, with macromol. complexes.
13
(2) The number of macromolecular complexes.
14
(3) Pointer to RuntimeS structure, with some runtime data.
15
(4) Pointer to ConfigS structure, with configuration data.
16
(5) Pointer to GUIS structure, with GUI data.
17
(6) Pointer to NearestAtomS structure.
18
(7) The number of pixels in the main window free area.
19
(8) Pointer to refreshI.
20
(9) String which contains slab surface specification and slab
24
(1) The hiddenF set for each atom in each caught complex.
28
(1) Positive (command) code on success.
29
(2) Negative (error) code on failure.
31
========includes:============================================================*/
38
#include <X11/Xutil.h>
40
#include <X11/Xatom.h>
46
/*======function prototypes:=================================================*/
48
char *ExtractToken_ (char *, int, char *, char *);
49
int ChangeSlab_ (MolComplexS *, int, unsigned char);
50
void MoveBackSlab_ (MolComplexS *, int, ConfigS *, double);
51
void MoveFrontSlab_ (MolComplexS *, int, ConfigS *, double);
52
size_t MainRefresh_ (MolComplexS *, int,
53
RuntimeS *, ConfigS *, GUIS *,
54
NearestAtomS *, size_t, unsigned int);
55
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
57
/*======execute slab command:================================================*/
59
int CommandSlab_ (MolComplexS *mol_complexSP, int mol_complexesN,
60
RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
61
NearestAtomS *nearest_atomSP, size_t pixelsN,
62
unsigned int *refreshIP, char *stringP)
65
char tokenA[STRINGSIZE];
69
/* Extract the first token: */
70
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
73
strcpy (runtimeSP->messageA, "Slab specification incomplete!");
74
runtimeSP->message_length = strlen (runtimeSP->messageA);
78
/* Switch slab off: */
79
if (strstr (tokenA, "OFF") == tokenA)
81
ChangeSlab_ (mol_complexSP, mol_complexesN, 0);
83
MainRefresh_ (mol_complexSP, mol_complexesN,
84
runtimeSP, configSP, guiSP,
85
nearest_atomSP, pixelsN, *refreshIP);
86
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
91
/* Change slab to planar: */
92
else if (strstr (tokenA, "PLA") == tokenA)
94
ChangeSlab_ (mol_complexSP, mol_complexesN, 1);
96
MainRefresh_ (mol_complexSP, mol_complexesN,
97
runtimeSP, configSP, guiSP,
98
nearest_atomSP, pixelsN, *refreshIP);
99
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
104
/* Change slab to spherical: */
105
else if (strstr (tokenA, "SPH") == tokenA)
107
ChangeSlab_ (mol_complexSP, mol_complexesN, 2);
109
MainRefresh_ (mol_complexSP, mol_complexesN,
110
runtimeSP, configSP, guiSP,
111
nearest_atomSP, pixelsN, *refreshIP);
112
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
117
/* Change slab to semi-spherical: */
118
else if ((strstr (tokenA, "HALF-SPH") == tokenA) ||
119
(strstr (tokenA, "HALF_SPH") == tokenA))
121
ChangeSlab_ (mol_complexSP, mol_complexesN, 3);
123
MainRefresh_ (mol_complexSP, mol_complexesN,
124
runtimeSP, configSP, guiSP,
125
nearest_atomSP, pixelsN, *refreshIP);
126
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
131
/* Change slab to cylindrical: */
132
else if (strstr (tokenA, "CYL") == tokenA)
134
ChangeSlab_ (mol_complexSP, mol_complexesN, 4);
136
MainRefresh_ (mol_complexSP, mol_complexesN,
137
runtimeSP, configSP, guiSP,
138
nearest_atomSP, pixelsN, *refreshIP);
139
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
144
/* Change slab to semi-cylindrical: */
145
else if ((strstr (tokenA, "HALF-CYL") == tokenA) ||
146
(strstr (tokenA, "HALF_CYL") == tokenA))
148
ChangeSlab_ (mol_complexSP, mol_complexesN, 5);
150
MainRefresh_ (mol_complexSP, mol_complexesN,
151
runtimeSP, configSP, guiSP,
152
nearest_atomSP, pixelsN, *refreshIP);
153
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
158
/* Identify the surface: */
159
else if (strstr (tokenA, "FRO") == tokenA) surfaceID = 1;
160
else if (strstr (tokenA, "BAC") == tokenA) surfaceID = 2;
163
strcpy (runtimeSP->messageA,
164
"Bad surface (valid keywords are front and back)!");
165
runtimeSP->message_length = strlen (runtimeSP->messageA);
166
return ERROR_BAD_SURFACE;
169
/* Extract the token which contains the shift: */
170
remainderP = ExtractToken_ (tokenA, STRINGSIZE, remainderP, " \t\n");
173
strcpy (runtimeSP->messageA, "Slab shift missing!");
174
runtimeSP->message_length = strlen (runtimeSP->messageA);
175
return ERROR_NO_SHIFT;
178
/* Extract the shift: */
179
if (sscanf (tokenA, "%lf", &shift) != 1)
181
strcpy (runtimeSP->messageA,
182
"Slab specification is bad (unknown keyword used)!");
183
runtimeSP->message_length = strlen (runtimeSP->messageA);
184
return ERROR_NO_SHIFT;
187
/* Move the specified slab surface: */
190
MoveFrontSlab_ (mol_complexSP, mol_complexesN, configSP, shift);
194
MoveBackSlab_ (mol_complexSP, mol_complexesN, configSP, shift);
197
/* Refresh the main window: */
199
MainRefresh_ (mol_complexSP, mol_complexesN,
200
runtimeSP, configSP, guiSP,
201
nearest_atomSP, pixelsN, *refreshIP);
203
/* Refresh the control window: */
204
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
206
/* Return positive value on success: */
210
/*===========================================================================*/