~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to comm_rotate.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                comm_rotate.c
 
6
 
 
7
Purpose:
 
8
        Execute rotate command. Rotate all caught macromolecular complexes
 
9
        for a given angle around a given axis.
 
10
 
 
11
Input:
 
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
 
21
            angle.
 
22
 
 
23
Output:
 
24
        (1) The hiddenF set for each atom in each caught complex.
 
25
        (2) Return value.
 
26
 
 
27
Return value:
 
28
        (1) Positive (command) code on success.
 
29
        (2) Negative (error) code on failure.
 
30
 
 
31
========includes:============================================================*/
 
32
 
 
33
#include <stdio.h>
 
34
 
 
35
#include <string.h>
 
36
 
 
37
#include <X11/Xlib.h>
 
38
#include <X11/Xutil.h>
 
39
#include <X11/Xos.h>
 
40
#include <X11/Xatom.h>
 
41
 
 
42
#include "defines.h"
 
43
#include "commands.h"
 
44
#include "typedefs.h"
 
45
 
 
46
/*======function prototypes:=================================================*/
 
47
 
 
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 *);
 
55
 
 
56
/*======execute rotate command:==============================================*/
 
57
 
 
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)
 
62
{
 
63
char            *remainderP;
 
64
char            tokenA[STRINGSIZE];
 
65
int             axisID;
 
66
double          rotation_angle;
 
67
 
 
68
/* Extract axis name: */
 
69
remainderP = ExtractToken_ (tokenA, STRINGSIZE, stringP, " \t\n");
 
70
if (!remainderP)
 
71
        {
 
72
        strcpy (runtimeSP->messageA, "Axis specification missing!");
 
73
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
74
        return ERROR_NO_AXIS;
 
75
        }
 
76
 
 
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;
 
81
else
 
82
        {
 
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;
 
87
        }
 
88
 
 
89
/* Extract the token which contains the rotation angle: */
 
90
remainderP = ExtractToken_ (tokenA, STRINGSIZE, remainderP, " \t\n");
 
91
if (!remainderP)
 
92
        {
 
93
        strcpy (runtimeSP->messageA, "Rotation angle missing!");
 
94
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
95
        return ERROR_NO_ANGLE;
 
96
        }
 
97
 
 
98
/* Extract the rotation angle: */
 
99
if (sscanf (tokenA, "%lf", &rotation_angle) != 1)
 
100
        {
 
101
        strcpy (runtimeSP->messageA, "Rotation angle specification is bad!");
 
102
        runtimeSP->message_length = strlen (runtimeSP->messageA);
 
103
        return ERROR_NO_ANGLE;
 
104
        }
 
105
 
 
106
/* Convert degrees to radians: */
 
107
rotation_angle *= DEG_TO_RAD;
 
108
 
 
109
/* Rotate all caught macromolecular complexes: */
 
110
Rotate_ (mol_complexSP, mol_complexesN, configSP, rotation_angle, axisID);
 
111
 
 
112
/* Refresh the main window: */
 
113
(*refreshIP)++;
 
114
MainRefresh_ (mol_complexSP, mol_complexesN, runtimeSP, configSP, guiSP,
 
115
              nearest_atomSP, pixelsN, *refreshIP);
 
116
 
 
117
/* Refresh the control window: */
 
118
ControlRefresh_ (mol_complexSP + runtimeSP->default_complexI, configSP, guiSP);
 
119
 
 
120
/* Refresh docking window, if docking is switched on: */
 
121
if (guiSP->dockingF) DockingRefresh_ (runtimeSP, guiSP);
 
122
 
 
123
/* Return positive value on success: */
 
124
return COMMAND_ROTATE;
 
125
}
 
126
 
 
127
/*===========================================================================*/
 
128
 
 
129