1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute wheel command: draw helical wheel for the sequence which
9
is kept in the sequence buffer.
12
(1) Pointer to MolComplexS structure.
13
(2) The number of macromolecular complexes.
14
(3) Pointer to RuntimeS structure.
15
(4) Pointer to ConfigS structure.
16
(5) Pointer to GUIS structure.
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) Pointer to the remainder of the command string. This command
21
may be given without any keyword, with keyword OFF or with two
22
residue serial numbers.
25
(1) The main window mode changed to 2 (default is zero), i.e. the
26
main window will be switched to helical wheel plot.
30
(1) Positive (command) code on success.
31
(2) Negative (error) code on failure.
34
(1) This command reinitializes the NearestAtomS array, except if
35
the additional keyword is not recognized.
37
(2) Helical wheel is drawn for the sequence which is currently in
38
the sequence buffer. This sequence will be typically short.
40
========includes:============================================================*/
47
#include <X11/Xutil.h>
49
#include <X11/Xatom.h>
55
/*======function prototypes:=================================================*/
57
char *ExtractToken_ (char *, int, char *, char *);
58
int ExtractTwoIntegers_ (int *, int *, char *);
59
void InitNearest_ (NearestAtomS *, size_t);
60
size_t MainRefresh_ (MolComplexS *, int,
61
RuntimeS *, ConfigS *, GUIS *,
62
NearestAtomS *, size_t, unsigned int);
63
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
65
/*======execute wheel command:===============================================*/
67
int Wheel_ (MolComplexS *mol_complexSP, int mol_complexesN,
68
RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
69
NearestAtomS *nearest_atomSP, size_t pixelsN,
70
unsigned int *refreshIP, char *stringP)
73
char tokenA[SHORTSTRINGSIZE];
76
int residue1I, residue2I;
78
/* Extract the first token: */
79
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
81
/* If available, the first token may contain keyword OFF: */
84
/* If keyword OFF is present, switch to default drawing mode: */
85
if (strstr (tokenA, "OFF") == tokenA)
87
/* Reset drawing mode index: */
88
guiSP->main_window_modeI = 0;
90
/* Reinitialize the NearestAtomS array: */
91
InitNearest_ (nearest_atomSP, pixelsN);
94
/* Refresh the main window: */
96
MainRefresh_ (mol_complexSP, mol_complexesN,
97
runtimeSP, configSP, guiSP,
98
nearest_atomSP, pixelsN, *refreshIP);
100
/* Refresh the control window: */
101
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
104
/* Return the command code: */
105
return COMMAND_WHEEL;
108
/* If keyword OFF is not present, try to read two indices: */
111
/* Replace each minus in the input string with space: */
113
while ((n = *P++) != '\0')
115
if (n == '-') *(P - 1) = ' ';
118
/* If reading fails: */
119
if (ExtractTwoIntegers_ (&residue1I, &residue2I, stringP) < 0)
121
strcpy (runtimeSP->messageA,
122
"Command interpretation failed!");
123
runtimeSP->message_length =
124
strlen (runtimeSP->messageA);
128
/* If indices were successfully read, check them: */
129
if (residue2I < residue1I)
131
strcpy (runtimeSP->messageA,
132
"Bad range (check indices)!");
133
runtimeSP->message_length =
134
strlen (runtimeSP->messageA);
138
/* Store the extracted indices: */
139
runtimeSP->range_startI = (size_t) residue1I;
140
runtimeSP->range_endI = (size_t) residue2I;
144
/* If the first token is not available, initialize range indices: */
147
runtimeSP->range_startI = *runtimeSP->serialIP;
148
runtimeSP->range_endI = *(runtimeSP->serialIP +
149
runtimeSP->residuesN - 1);
152
/* Set the main window drawing mode index: */
153
guiSP->main_window_modeI = 2;
155
/* Reinitialize the NearestAtomS array and refresh index: */
156
InitNearest_ (nearest_atomSP, pixelsN);
159
/* Refresh the main window: */
161
MainRefresh_ (mol_complexSP, mol_complexesN,
162
runtimeSP, configSP, guiSP,
163
nearest_atomSP, pixelsN, *refreshIP);
165
/* Refresh the control window: */
166
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
168
/* Return the command code: */
169
return COMMAND_WHEEL;
172
/*===========================================================================*/