1 /* Copyright (C) 2000 Damir Zucic */
2
3 /*=============================================================================
4
5 stereo.c
6
7 Purpose:
8 Execute stereo command.
9
10 Input:
11 (1) Pointer to MolComplexS structure.
12 (2) The number of macromolecular complexes.
13 (3) Pointer to RuntimeS structure.
14 (4) Pointer to ConfigS structure.
15 (5) Pointer to GUIS structure.
16 (6) Pointer to NearestAtomS structure.
17 (7) The number of pixels in the main window free area.
18 (8) Pointer to refreshI.
19 (9) Pointer to the remainder of the command string. It is either
20 empty or contains the keyword OFF.
21
22 Output:
23 (1) Stereo flag set.
24 (2) Return value.
25
26 Return value:
27 (1) Positive (command) code on success.
28 (2) Negative (error) code on failure.
29
30 ========includes:============================================================*/
31
32 #include <stdio.h>
33
34 #include <string.h>
35
36 #include <X11/Xlib.h>
37 #include <X11/Xutil.h>
38 #include <X11/Xos.h>
39 #include <X11/Xatom.h>
40
41 #include "defines.h"
42 #include "commands.h"
43 #include "typedefs.h"
44
45 /*======function prototypes:=================================================*/
46
47 char *ExtractToken_ (char *, int, char *, char *);
48 int CalculateParameters_ (ConfigS *, GUIS *);
49 int PrepareStereoData_ (MolComplexS *, ConfigS *);
50 size_t MainRefresh_ (MolComplexS *, int,
51 RuntimeS *, ConfigS *, GUIS *,
52 NearestAtomS *, size_t, unsigned int);
53 int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
54
55 /*======execute stereo command:==============================================*/
56
CommandStereo_(MolComplexS * mol_complexSP,int mol_complexesN,RuntimeS * runtimeSP,ConfigS * configSP,GUIS * guiSP,NearestAtomS * nearest_atomSP,size_t pixelsN,unsigned int * refreshIP,char * stringP)57 int CommandStereo_ (MolComplexS *mol_complexSP, int mol_complexesN,
58 RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
59 NearestAtomS *nearest_atomSP, size_t pixelsN,
60 unsigned int *refreshIP, char *stringP)
61 {
62 char *remainderP;
63 char tokenA[STRINGSIZE];
64 int mol_complexI;
65
66 /* Initialize the stereo flag: */
67 configSP->stereoF = 1;
68
69 /* Extract the first token: */
70 remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
71
72 /* If available, the first token should contain the keyword OFF: */
73 if (remainderP)
74 {
75 if (strstr (tokenA, "OFF") == tokenA) configSP->stereoF = 0;
76 else
77 {
78 sprintf (runtimeSP->messageA,
79 "Keyword %s not recognized!",
80 tokenA);
81 runtimeSP->message_length = strlen (runtimeSP->messageA);
82 return ERROR_STEREO;
83 }
84 }
85
86 /* Refresh calculated parameters: */
87 if (CalculateParameters_ (configSP, guiSP) < 0) return ERROR_STEREO;
88
89 /* Set the position_changedF flag and update stereo data: */
90 for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
91 {
92 /** Set flag: **/
93 (mol_complexSP + mol_complexI)->position_changedF = 1;
94
95 /** Update stereo data: **/
96 for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
97 {
98 PrepareStereoData_ (mol_complexSP + mol_complexI, configSP);
99 }
100 }
101
102 /* Refresh the main window: */
103 (*refreshIP)++;
104 MainRefresh_ (mol_complexSP, mol_complexesN,
105 runtimeSP, configSP, guiSP,
106 nearest_atomSP, pixelsN, *refreshIP);
107
108 /* Refresh the control window: */
109 ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
110
111 /* Return the command code: */
112 return COMMAND_STEREO;
113 }
114
115 /*===========================================================================*/
116
117
118