1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Execute rotate command. Rotate all caught macromolecular complexes
9
for a given angle around a given axis.
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 rotation axis name and the rotation
24
(1) The hiddenF set for each atom in each caught complex.
28
(1) Positive (command) code on success.
29
(2) Negative (error) code on failure.
31
========includes:============================================================*/
38
#include <X11/Xutil.h>
40
#include <X11/Xatom.h>
46
/*======function prototypes:=================================================*/
48
char *ExtractToken_ (char *, int, char *, char *);
49
void Rotate_ (MolComplexS *, int, ConfigS *, double, int);
50
size_t MainRefresh_ (MolComplexS *, int,
51
RuntimeS *, ConfigS *, GUIS *,
52
NearestAtomS *, size_t, unsigned int);
53
int ControlRefresh_ (MolComplexS *, ConfigS *, GUIS *);
54
int DockingRefresh_ (RuntimeS *, GUIS *);
56
/*======execute rotate command:==============================================*/
58
int CommandRotate_ (MolComplexS *mol_complexSP, int mol_complexesN,
59
RuntimeS *runtimeSP, ConfigS *configSP, GUIS *guiSP,
60
NearestAtomS *nearest_atomSP, size_t pixelsN,
61
unsigned int *refreshIP, char *stringP)
64
char tokenA[STRINGSIZE];
66
double rotation_angle;
68
/* Extract axis name: */
69
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
72
strcpy (runtimeSP->messageA, "Axis specification missing!");
73
runtimeSP->message_length = strlen (runtimeSP->messageA);
77
/* Identify the axis: */
78
if (strcmp (tokenA, "X") == 0) axisID = 1;
79
else if (strcmp (tokenA, "Y") == 0) axisID = 2;
80
else if (strcmp (tokenA, "Z") == 0) axisID = 3;
83
strcpy (runtimeSP->messageA,
84
"Bad axis (only x, y and z are available)!");
85
runtimeSP->message_length = strlen (runtimeSP->messageA);
86
return ERROR_BAD_AXIS;
89
/* Extract the token which contains the rotation angle: */
90
remainderP = ExtractToken_ (tokenA, STRINGSIZE, remainderP, " \t\n");
93
strcpy (runtimeSP->messageA, "Rotation angle missing!");
94
runtimeSP->message_length = strlen (runtimeSP->messageA);
95
return ERROR_NO_ANGLE;
98
/* Extract the rotation angle: */
99
if (sscanf (tokenA, "%lf", &rotation_angle) != 1)
101
strcpy (runtimeSP->messageA, "Rotation angle specification is bad!");
102
runtimeSP->message_length = strlen (runtimeSP->messageA);
103
return ERROR_NO_ANGLE;
106
/* Convert degrees to radians: */
107
rotation_angle *= DEG_TO_RAD;
109
/* Rotate all caught macromolecular complexes: */
110
Rotate_ (mol_complexSP, mol_complexesN, configSP, rotation_angle, axisID);
112
/* Refresh the main window: */
114
MainRefresh_ (mol_complexSP, mol_complexesN, runtimeSP, configSP, guiSP,
115
nearest_atomSP, pixelsN, *refreshIP);
117
/* Refresh the control window: */
118
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
120
/* Refresh docking window, if docking is switched on: */
121
if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
123
/* Return positive value on success: */
124
return COMMAND_ROTATE;
127
/*===========================================================================*/