1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute color command: assign the requested color scheme to all
9
currently selected atoms in each caught complex.
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 the color scheme name.
23
(1) The hiddenF set for each atom in each caught complex.
27
(1) Positive (command) code on success.
28
(2) Negative (error) code on failure.
30
========includes:============================================================*/
37
#include <X11/Xutil.h>
39
#include <X11/Xatom.h>
45
/*======function prototypes:=================================================*/
47
int FullColors_ (MolComplexS *, int, GUIS *, char *);
48
char *ExtractToken_ (char *, int, char *, char *);
49
int ColorSchemes_ (MolComplexS *, int, GUIS *, char *);
50
size_t MainRefresh_ (MolComplexS *, int,
51
RuntimeS *, ConfigS *, GUIS *,
52
NearestAtomS *, size_t, unsigned int);
53
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
55
/*======execute color command:===============================================*/
57
int Color_ (MolComplexS *mol_complexSP, int mol_complexesN,
59
ConfigS *configSP, GUIS *guiSP,
60
NearestAtomS *nearest_atomSP, size_t pixelsN,
61
unsigned int *refreshIP, char *stringP)
65
char tokenA[STRINGSIZE];
68
/* Try to interpret the string as the full color */
69
/* specification. Use the original command string: */
70
commandP = runtimeSP->curr_commandA;
71
if (FullColors_ (mol_complexSP, mol_complexesN, guiSP, commandP) > 0)
74
MainRefresh_ (mol_complexSP, mol_complexesN,
75
runtimeSP, configSP, guiSP,
76
nearest_atomSP, pixelsN, *refreshIP);
77
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI,
82
/* Extract the color scheme name: */
83
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
86
strcpy (runtimeSP->messageA, "Color scheme specification missing!");
87
runtimeSP->message_length = strlen (runtimeSP->messageA);
88
return ERROR_NO_SCHEME;
91
/* Assign the requested predefined colors to all selected atoms: */
93
/** If some simple color scheme is requested: **/
94
n = ColorSchemes_ (mol_complexSP, mol_complexesN, guiSP, tokenA);
96
/** If scheme is not recognized: **/
99
sprintf (runtimeSP->messageA,
100
"Color scheme %s is not available!", tokenA);
101
runtimeSP->message_length = strlen (runtimeSP->messageA);
102
return ERROR_BAD_SCHEME;
105
/* Refresh the main window: */
107
MainRefresh_ (mol_complexSP, mol_complexesN, runtimeSP, configSP, guiSP,
108
nearest_atomSP, pixelsN, *refreshIP);
110
/* Refresh the control window: */
111
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
113
/* Return positive value on success: */
114
return COMMAND_COLOR;
117
/*===========================================================================*/