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

« back to all changes in this revision

Viewing changes to select_alternate.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
                                select_alternate.c
 
6
 
 
7
Purpose:
 
8
        Select atoms at alternate locations.
 
9
 
 
10
Input:
 
11
        (1) Pointer to MolComplexS structure, with macromol. complexes.
 
12
        (2) Number of macromolecular complexes.
 
13
        (3) Selection mode index (0 = overwrite, 1 = restrict, 2 = expand
 
14
            previous selection).
 
15
 
 
16
Output:
 
17
        (1) The flag  selectedF set for all atoms at alternate positions,
 
18
            in all currently caught macromolecular complexes.
 
19
        (2) Return value.
 
20
 
 
21
Return value:
 
22
        (1) The number of selected atoms (zero or positive value).
 
23
 
 
24
Notes:
 
25
        (1) The position_changedF is updated,  because some atoms may not
 
26
            have the proper color.
 
27
 
 
28
========includes:============================================================*/
 
29
 
 
30
#include <stdio.h>
 
31
 
 
32
#include <X11/Xlib.h>
 
33
#include <X11/Xutil.h>
 
34
#include <X11/Xos.h>
 
35
#include <X11/Xatom.h>
 
36
 
 
37
#include "defines.h"
 
38
#include "typedefs.h"
 
39
 
 
40
/*======select atoms at alternate positions:=================================*/
 
41
 
 
42
long SelectAlternate_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
43
                       int selection_modeI)
 
44
{
 
45
long            selected_atomsN = 0;
 
46
int             mol_complexI;
 
47
MolComplexS     *curr_mol_complexSP;
 
48
size_t          atomsN, atomI;
 
49
AtomS           *curr_atomSP;
 
50
char            alt_location;
 
51
unsigned char   alternateF;
 
52
 
 
53
/* Check every macromolecular complex: */
 
54
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
 
55
        {
 
56
        /** Pointer to the current macromolecular complex: **/
 
57
        curr_mol_complexSP = mol_complexSP + mol_complexI;
 
58
 
 
59
        /** Check is the current macromolecular complex caught: **/
 
60
        if (curr_mol_complexSP->catchF == 0) continue;
 
61
 
 
62
        /** Number of atoms in a macromolecular complex: **/
 
63
        atomsN = curr_mol_complexSP->atomsN;
 
64
 
 
65
        /** Scan all atoms in the current complex: **/
 
66
        for (atomI = 0; atomI < atomsN; atomI++)
 
67
                {
 
68
                /** Pointer to the current atom: **/
 
69
                curr_atomSP = curr_mol_complexSP->atomSP + atomI;
 
70
 
 
71
                /** Check the alternate position indicator: **/
 
72
                alt_location = curr_atomSP->raw_atomS.alt_location;
 
73
                alternateF = 0;
 
74
                if ((alt_location != ' ') && (alt_location != 'A'))
 
75
                        {
 
76
                        alternateF = 1;
 
77
                        }
 
78
 
 
79
                /** Set the selection flag for the current atom: **/
 
80
                switch (selection_modeI)
 
81
                        {
 
82
                        /*** Overwrite the previous selection: ***/
 
83
                        case 0:
 
84
                                curr_atomSP->selectedF = alternateF;
 
85
                                break;
 
86
 
 
87
                        /*** Restrict the previous selection: ***/
 
88
                        case 1:
 
89
                                curr_atomSP->selectedF &= alternateF;
 
90
                                break;
 
91
 
 
92
                        /*** Expand the previous selection: ***/
 
93
                        case 2:
 
94
                                curr_atomSP->selectedF |= alternateF;
 
95
                                break;
 
96
 
 
97
                        default:
 
98
                                ;
 
99
                        }
 
100
 
 
101
                /** Check the selection flag; increase **/
 
102
                /** the count if flag is equal to one: **/
 
103
                if (curr_atomSP->selectedF) selected_atomsN++;
 
104
                }
 
105
 
 
106
        /** Update the position_changedF (some atoms may have bad color): **/
 
107
        curr_mol_complexSP->position_changedF = 1;
 
108
        }
 
109
 
 
110
/* Return the number of selected atoms: */
 
111
return selected_atomsN;
 
112
}
 
113
 
 
114
/*===========================================================================*/
 
115
 
 
116