1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Draw atoms, using style 7 (11x11 circle).
11
(1) Pointer to MolComplexS structure.
12
(2) Number of macromolecular complexes.
13
(3) Pointer to ConfigS structure, with configuration data.
14
(4) Pointer to GUIS structure.
15
(5) Pointer to NearestAtomS structure, with information about the
16
atom occupying the given pixel.
17
(6) The number of pixels in the main window free area.
18
(7) The refreshI, used to check the NearestAtomS associated with
22
(1) Atoms drawn to the hidden pixmap.
26
(1) The number of atoms drawn.
29
(1) Indentation is exceptionally 4 spaces.
31
(2) The second index of indexAA and circle_maskAA is treated as
32
row index. This is somewhat unusual, but more practical in
35
=============================================================================*/
40
#include <X11/Xutil.h>
42
#include <X11/Xatom.h>
47
/*======draw atoms using style 7 (11x11 circle):=============================*/
49
size_t DrawAtomsStyle7_ (MolComplexS *mol_complexSP, int mol_complexesN,
50
ConfigS *configSP, GUIS *guiSP,
51
NearestAtomS *nearest_atomSP, size_t pixelsN,
52
unsigned int refreshI)
54
size_t atoms_drawnN = 0;
56
int left_edge[2], right_edge[2];
58
MolComplexS *curr_mol_complexSP;
61
unsigned long colorIDA[3];
62
static int indexAA[11][11] =
63
{{0, 0, 1, 1, 1, 1, 1, 2, 2, 0, 0},
64
{0, 1, 0, 0, 0, 0, 1, 1, 2, 2, 0},
65
{1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2},
66
{1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2},
67
/* Be sure to read Note 2 ! */ {1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2},
68
{1, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2},
69
{1, 1, 0, 0, 0, 0, 1, 1, 1, 2, 2},
70
{2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2},
71
{2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2},
72
{0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0},
73
{0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0}};
75
int screen_x0, screen_y0;
76
int i, j, screen_x, screen_y;
77
static int circle_maskAA[11][11] =
78
{{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
79
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
80
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
81
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
82
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
83
/* Be sure to read Note 2 ! */ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
84
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
85
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
86
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
87
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
88
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0}};
90
NearestAtomS *curr_pixelSP;
92
double third_atomic_radius;
94
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
95
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
96
{0, 0, 1, 2, 2, 2, 2, 2, 1, 0, 0},
97
{0, 1, 2, 2, 3, 3, 3, 2, 2, 1, 0},
98
{0, 1, 2, 3, 3, 4, 3, 3, 2, 1, 0},
99
{0, 1, 2, 3, 4, 4, 4, 3, 2, 1, 0},
100
{0, 1, 2, 3, 3, 4, 3, 3, 2, 1, 0},
101
{0, 1, 2, 2, 3, 3, 3, 2, 2, 1, 0},
102
{0, 0, 1, 2, 2, 2, 2, 2, 1, 0, 0},
103
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
104
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
106
/* Number of images: */
107
if (configSP->stereoF) imagesN = 2;
110
/* Left and right image edge (in stereo mode there are two images): */
111
left_edge[0] = configSP->image_screen_x0[0];
112
right_edge[0] = configSP->image_screen_x1[0];
113
left_edge[1] = configSP->image_screen_x0[1];
114
right_edge[1] = configSP->image_screen_x1[1];
117
third_atomic_radius = 2.5 * configSP->screen_to_atomic_scale_x;
119
/* Draw each macromolecular complex: */
120
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
122
/* Pointer to current macromolecular complex: */
123
curr_mol_complexSP = mol_complexSP + mol_complexI;
125
/* Prepare and check the number of atoms: */
126
atomsN = curr_mol_complexSP->atomsN;
127
if (atomsN == 0) continue;
129
/* Draw atoms which have the given style: */
130
for (atomI = 0; atomI < atomsN; atomI++)
132
/* Pointer to the current atom: */
133
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
136
if (curr_atomSP->raw_atomS.atom_styleI != 7) continue;
138
/* Check is atom hidden: */
139
if (curr_atomSP->hiddenF) continue;
141
/* Check is atom inside slab: */
142
if (!curr_atomSP->inside_slabF) continue;
144
/* Check is atom inside window: */
145
if (!curr_atomSP->inside_windowF) continue;
147
/* Prepare colors: */
148
colorIDA[0] = curr_atomSP->left_colorID;
149
colorIDA[1] = curr_atomSP->middle_colorID;
150
colorIDA[2] = curr_atomSP->right_colorID;
152
/* Set these colors as foreground colors in three auxiliary GC's: */
153
XSetForeground (guiSP->displaySP, guiSP->theGCA[0], colorIDA[0]);
154
XSetForeground (guiSP->displaySP, guiSP->theGCA[1], colorIDA[1]);
155
XSetForeground (guiSP->displaySP, guiSP->theGCA[2], colorIDA[2]);
157
/* Reset the flag: */
160
/* Draw one (mono) or two pixels (stereo): */
161
for (imageI = 0; imageI < imagesN; imageI++)
163
/* Prepare the coordinates and 9x9 box edge indices: */
164
screen_x0 = curr_atomSP->raw_atomS.screen_x[imageI];
165
screen_y0 = curr_atomSP->raw_atomS.screen_y;
167
/* Horizontal scan of the neighbourhood: */
168
for (i = 0; i < 11; i++)
170
/* Vertical scan of the neighbourhood: */
171
for (j = 0; j < 11; j++)
173
/* Single pass loop: */
176
/* Current pixel coordinates: */
177
screen_x = screen_x0 + i - 5;
178
screen_y = screen_y0 + j - 5;
180
/* Check is the pixel inside the area */
181
/* reserved for the current image (in */
182
/* stereo mode there are two images): */
183
if (screen_x < left_edge[imageI]) break;
184
if (screen_x > right_edge[imageI]) break;
186
/* Check the circle mask: */
187
if (circle_maskAA[j][i] == 0) break;
189
/* Prepare index to the array */
190
/* of NearestAtomS structures: */
191
pixelI = guiSP->main_win_free_area_width * screen_y +
194
/* Check the pixel index: */
195
if (pixelI >= pixelsN) break;
197
/* Pointer to NearestAtomS struct. */
198
/* assigned to current coordinates: */
199
curr_pixelSP = nearest_atomSP + pixelI;
201
/* Current atom z: */
202
z = curr_atomSP->raw_atomS.z[imageI] +
203
third_atomic_radius * (double) levelAA[j][i];
205
/* Check was this pixel used already in */
206
/* this drawing step; if it was, compare */
207
/* the z value of the current atom with z */
208
/* value previously stored to this pixel: */
209
if (refreshI == curr_pixelSP->last_refreshI)
211
if (z >= curr_pixelSP->z) break;
214
/* Draw the pixel: */
215
XDrawPoint (guiSP->displaySP,
216
guiSP->main_hidden_pixmapID,
217
guiSP->theGCA[indexAA[j][i]],
220
/* Refresh the content of NearestAtomS */
221
/* array associated with this pixel: */
222
curr_pixelSP->styleI = 7;
223
curr_pixelSP->last_refreshI = refreshI;
224
curr_pixelSP->mol_complexI = mol_complexI;
225
curr_pixelSP->atomI = atomI;
227
curr_pixelSP->colorID = colorIDA[indexAA[j][i]];
237
/*---------------------------------------------------------------------------*/
239
/* Check is at least one pixel drawn; */
240
/* increase the counter if it is true: */
241
if (atom_drawnF != 0) atoms_drawnN++;
249
/*===========================================================================*/