1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Select atoms which belong to the specified model. This should be
9
useful with NMR structures.
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
18
(1) The flag selectedF set for all atoms which belong to the
19
specified model, in all currently caught macromol. complexes.
23
(1) The number of selected atoms (zero or positive value).
26
(1) The position_changedF is updated, because some atoms may not
27
have the proper color.
29
========includes:============================================================*/
34
#include <X11/Xutil.h>
36
#include <X11/Xatom.h>
41
/*======select atoms which belong to the specified model:====================*/
43
long SelectModel_ (MolComplexS *mol_complexSP, int mol_complexesN,
44
int selection_modeI, short int model_serialI)
46
long selected_atomsN = 0;
48
MolComplexS *curr_mol_complexSP;
53
/* Check every macromolecular complex: */
54
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
56
/** Pointer to the current macromolecular complex: **/
57
curr_mol_complexSP = mol_complexSP + mol_complexI;
59
/** Check is the current macromolecular complex caught: **/
60
if (curr_mol_complexSP->catchF == 0) continue;
62
/** Number of atoms in a macromolecular complex: **/
63
atomsN = curr_mol_complexSP->atomsN;
65
/** Scan all atoms in the current complex: **/
66
for (atomI = 0; atomI < atomsN; atomI++)
68
/** Pointer to the current atom: **/
69
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
71
/** Check the model serial number: **/
73
if (curr_atomSP->raw_atomS.model_serialI == model_serialI)
78
/** Set the selection flag for the current atom: **/
79
switch (selection_modeI)
81
/*** Overwrite the previous selection: ***/
83
curr_atomSP->selectedF = modelF;
86
/*** Restrict the previous selection: ***/
88
curr_atomSP->selectedF &= modelF;
91
/*** Expand the previous selection: ***/
93
curr_atomSP->selectedF |= modelF;
100
/** Check the selection flag; increase **/
101
/** the count if flag is equal to one: **/
102
if (curr_atomSP->selectedF) selected_atomsN++;
105
/** Update the position_changedF (some atoms may have bad color): **/
106
curr_mol_complexSP->position_changedF = 1;
109
/* Return the number of selected atoms: */
110
return selected_atomsN;
113
/*===========================================================================*/