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

« back to all changes in this revision

Viewing changes to select_model.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_model.c
 
6
 
 
7
Purpose:
 
8
        Select atoms which belong to the specified model.  This should be
 
9
        useful with NMR structures.
 
10
 
 
11
Input:
 
12
        (1) Pointer to MolComplexS structure, with macromol. complexes.
 
13
        (2) Number of macromolecular complexes.
 
14
        (3) Selection mode index (0 = overwrite, 1 = restrict, 2 = expand
 
15
            previous selection).
 
16
 
 
17
Output:
 
18
        (1) The flag  selectedF  set for  all atoms  which belong  to the
 
19
            specified model, in all currently caught macromol. complexes.
 
20
        (2) Return value.
 
21
 
 
22
Return value:
 
23
        (1) The number of selected atoms (zero or positive value).
 
24
 
 
25
Notes:
 
26
        (1) The position_changedF is updated,  because some atoms may not
 
27
            have the proper color.
 
28
 
 
29
========includes:============================================================*/
 
30
 
 
31
#include <stdio.h>
 
32
 
 
33
#include <X11/Xlib.h>
 
34
#include <X11/Xutil.h>
 
35
#include <X11/Xos.h>
 
36
#include <X11/Xatom.h>
 
37
 
 
38
#include "defines.h"
 
39
#include "typedefs.h"
 
40
 
 
41
/*======select atoms which belong to the specified model:====================*/
 
42
 
 
43
long SelectModel_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
44
                   int selection_modeI, short int model_serialI)
 
45
{
 
46
long            selected_atomsN = 0;
 
47
int             mol_complexI;
 
48
MolComplexS     *curr_mol_complexSP;
 
49
size_t          atomsN, atomI;
 
50
AtomS           *curr_atomSP;
 
51
unsigned char   modelF;
 
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 model serial number: **/
 
72
                modelF = 0;
 
73
                if (curr_atomSP->raw_atomS.model_serialI == model_serialI)
 
74
                        {
 
75
                        modelF = 1;
 
76
                        }
 
77
 
 
78
                /** Set the selection flag for the current atom: **/
 
79
                switch (selection_modeI)
 
80
                        {
 
81
                        /*** Overwrite the previous selection: ***/
 
82
                        case 0:
 
83
                                curr_atomSP->selectedF = modelF;
 
84
                                break;
 
85
 
 
86
                        /*** Restrict the previous selection: ***/
 
87
                        case 1:
 
88
                                curr_atomSP->selectedF &= modelF;
 
89
                                break;
 
90
 
 
91
                        /*** Expand the previous selection: ***/
 
92
                        case 2:
 
93
                                curr_atomSP->selectedF |= modelF;
 
94
                                break;
 
95
 
 
96
                        default:
 
97
                                ;
 
98
                        }
 
99
 
 
100
                /** Check the selection flag; increase **/
 
101
                /** the count if flag is equal to one: **/
 
102
                if (curr_atomSP->selectedF) selected_atomsN++;
 
103
                }
 
104
 
 
105
        /** Update the position_changedF (some atoms may have bad color): **/
 
106
        curr_mol_complexSP->position_changedF = 1;
 
107
        }
 
108
 
 
109
/* Return the number of selected atoms: */
 
110
return selected_atomsN;
 
111
}
 
112
 
 
113
/*===========================================================================*/
 
114
 
 
115