1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute venn command: draw Venn diagram for the sequence which is
9
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 the keyword OFF or with
22
a range of residue serial indices.
25
(1) The main window mode changed to 3 (default is zero), i.e. the
26
main window will be switched to Venn diagram.
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
========includes:============================================================*/
44
#include <X11/Xutil.h>
46
#include <X11/Xatom.h>
52
/*======function prototypes:=================================================*/
54
char *ExtractToken_ (char *, int, char *, char *);
55
int ExtractTwoIntegers_ (int *, int *, char *);
56
void InitNearest_ (NearestAtomS *, size_t);
57
size_t MainRefresh_ (MolComplexS *, int,
58
RuntimeS *, ConfigS *, GUIS *,
59
NearestAtomS *, size_t, unsigned int);
60
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
62
/*======execute venn command:================================================*/
64
int Venn_ (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)
70
char tokenA[SHORTSTRINGSIZE];
73
int residue1I, residue2I;
75
/* Extract the first token: */
76
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
78
/* If available, the first token should contain keyword OFF: */
81
/* If keyword OFF is present, switch to default drawing mode: */
82
if (strstr (tokenA, "OFF") == tokenA)
84
/* Reset drawing mode index: */
85
guiSP->main_window_modeI = 0;
87
/* Reinitialize the NearestAtomS array: */
88
InitNearest_ (nearest_atomSP, pixelsN);
91
/* Refresh the main window: */
93
MainRefresh_ (mol_complexSP, mol_complexesN,
94
runtimeSP, configSP, guiSP,
95
nearest_atomSP, pixelsN, *refreshIP);
97
/* Refresh the control window: */
98
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
101
/* Return the command code: */
105
/* If keyword OFF is not present, try to read two indices: */
108
/* Replace each minus in the input string with space: */
110
while ((n = *P++) != '\0')
112
if (n == '-') *(P - 1) = ' ';
115
/* If reading fails: */
116
if (ExtractTwoIntegers_ (&residue1I, &residue2I, stringP) < 0)
118
strcpy (runtimeSP->messageA,
119
"Command interpretation failed!");
120
runtimeSP->message_length =
121
strlen (runtimeSP->messageA);
125
/* If indices were successfully read, check them: */
126
if (residue2I < residue1I)
128
strcpy (runtimeSP->messageA,
129
"Bad range (check indices)!");
130
runtimeSP->message_length =
131
strlen (runtimeSP->messageA);
135
/* Store the extracted indices: */
136
runtimeSP->range_startI = (size_t) residue1I;
137
runtimeSP->range_endI = (size_t) residue2I;
141
/* If the first token is not available, initialize range indices: */
144
runtimeSP->range_startI = *runtimeSP->serialIP;
145
runtimeSP->range_endI = *(runtimeSP->serialIP +
146
runtimeSP->residuesN - 1);
149
/* Set the main window drawing mode index: */
150
guiSP->main_window_modeI = 3;
152
/* Reinitialize the NearestAtomS array and refresh index: */
153
InitNearest_ (nearest_atomSP, pixelsN);
156
/* Refresh the main window: */
158
MainRefresh_ (mol_complexSP, mol_complexesN,
159
runtimeSP, configSP, guiSP,
160
nearest_atomSP, pixelsN, *refreshIP);
162
/* Refresh the control window: */
163
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
165
/* Return the command code: */
169
/*===========================================================================*/