1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute plot command: plot requested functions. The command plot
9
may be followed by a list of keywords. If keyword OFF is present,
10
the main window drawing mode will be changed to default mode.
11
Otherwise, for all recognized keywords the corresponding flags in
12
RuntimeS structure will be set to one.
15
(1) Pointer to MolComplexS structure.
16
(2) The number of macromolecular complexes.
17
(3) Pointer to RuntimeS structure.
18
(4) Pointer to ConfigS structure.
19
(5) Pointer to GUIS structure.
20
(6) Pointer to NearestAtomS structure.
21
(7) The number of pixels in the main window free area.
22
(8) Pointer to refreshI.
23
(9) Pointer to the remainder of the command string. This command
24
may be given with a list of keywords or with keyword OFF.
27
(1) The main window mode changed to 4 (default is zero).
31
(1) Positive (command) code on success.
32
(2) Negative (error) code on failure.
35
(1) This command reinitializes the NearestAtomS array, except if
36
at least one of additional keywords is not recognized.
38
========includes:============================================================*/
45
#include <X11/Xutil.h>
47
#include <X11/Xatom.h>
53
/*======function prototypes:=================================================*/
55
void InitNearest_ (NearestAtomS *, size_t);
56
int ExtractTwoIntegers_ (int *, int *, char *);
57
size_t MainRefresh_ (MolComplexS *, int,
58
RuntimeS *, ConfigS *, GUIS *,
59
NearestAtomS *, size_t, unsigned int);
60
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
62
/*======execute plot command:================================================*/
64
int Plot_ (MolComplexS *mol_complexSP, int mol_complexesN,
65
RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
66
NearestAtomS *nearest_atomSP, size_t pixelsN,
67
unsigned int *refreshIP, char *stringP)
71
int residue1I, residue2I;
74
runtimeSP->averaged_hydrophobicityF = 0;
75
runtimeSP->hydrophobic_momentF = 0;
77
/* If keyword OFF is present, switch to default drawing mode: */
78
if (strstr (stringP, "OFF"))
80
/* Reset drawing mode index: */
81
guiSP->main_window_modeI = 0;
83
/* Reinitialize the NearestAtomS array: */
84
InitNearest_ (nearest_atomSP, pixelsN);
87
/* Refresh the main window: */
89
MainRefresh_ (mol_complexSP, mol_complexesN,
90
runtimeSP, configSP, guiSP,
91
nearest_atomSP, pixelsN, *refreshIP);
93
/* Refresh the control window: */
94
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
97
/* Return the command code: */
101
/* The sliding window should not be wider than the sequence: */
102
if (runtimeSP->sliding_window_width > runtimeSP->residuesN)
104
strcpy (runtimeSP->messageA,
105
"The sliding window is wider than the sequence!");
106
runtimeSP->message_length = strlen (runtimeSP->messageA);
110
/* If keyword HYD (short for HYDROPHOBICITY) is present, set the */
111
/* flag which signals that averaged hydrophobicity should be drawn: */
112
if (strstr (stringP, "HYD"))
114
runtimeSP->averaged_hydrophobicityF = 1;
117
/* If keyword MOM (short for MOMENT) is present, set the flag */
118
/* which signals that hydrophobic moment should be drawn: */
119
if (strstr (stringP, "MOM"))
121
runtimeSP->hydrophobic_momentF = 1;
124
/* At least one flag should be set to one: */
125
if ((runtimeSP->averaged_hydrophobicityF == 0) &&
126
(runtimeSP->hydrophobic_momentF == 0))
128
strcpy (runtimeSP->messageA,
129
"Failed to recognize what should be drawn!");
130
runtimeSP->message_length = strlen (runtimeSP->messageA);
134
/* Replace each minus and colon in the input string with space: */
136
while ((n = *P++) != '\0')
138
if (n == '-') *(P - 1) = ' ';
139
else if (n == ':') *(P - 1) = ' ';
142
/* Try to extract two indices: */
143
if (ExtractTwoIntegers_ (&residue1I, &residue2I, stringP) > 0)
146
if (residue2I < residue1I)
148
strcpy (runtimeSP->messageA, "Bad range (check indices)!");
149
runtimeSP->message_length = strlen (runtimeSP->messageA);
153
/* Store the extracted indices: */
154
runtimeSP->range_startI = (size_t) residue1I;
155
runtimeSP->range_endI = (size_t) residue2I;
158
/* If failed to extract indices, use default values: */
161
runtimeSP->range_startI = *runtimeSP->serialIP;
162
runtimeSP->range_endI = *(runtimeSP->serialIP +
163
runtimeSP->residuesN - 1);
166
/* Set the main window drawing mode index: */
167
guiSP->main_window_modeI = 4;
169
/* Reinitialize the NearestAtomS array and refresh index: */
170
InitNearest_ (nearest_atomSP, pixelsN);
173
/* Refresh the main window: */
175
MainRefresh_ (mol_complexSP, mol_complexesN,
176
runtimeSP, configSP, guiSP,
177
nearest_atomSP, pixelsN, *refreshIP);
179
/* Refresh the control window: */
180
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
182
/* Return the command code: */
186
/*===========================================================================*/