1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Draw bond which fits into quadrant 1 using style 1. See the file
9
file bonds_style1.c for description of quadrants.
12
(1) Pointer to Aux1S structure, which contains required data.
15
(1) A single bond drawn.
19
(1) One if at least one pixel is drawn.
22
=============================================================================*/
28
#include <X11/Xutil.h>
30
#include <X11/Xatom.h>
35
/*======draw bond in quadrant 1 using style 1:===============================*/
37
int BondStyle1Quadrant1_ (Aux1S *aux1SP)
39
long pixels_drawnN = 0;
40
double recip_denom, x_to_y_scale, x_to_z_scale;
41
int screen_x, screen_x1, delta_x, screen_y;
44
NearestAtomS *curr_pixelSP;
46
/* Scale factor required to calculate screen_y from screen_x: */
47
if (aux1SP->screen_delta_x != 0) recip_denom = 1.0 / aux1SP->screen_delta_x;
48
else recip_denom = 0.0;
49
x_to_y_scale = aux1SP->screen_delta_y * recip_denom;
51
/* Scale factor required to calculate z (in atomic units) from screen_x: */
52
x_to_z_scale = aux1SP->atomic_delta_z * recip_denom;
54
/* Horizontal scan, from left to right: */
55
screen_x1 = aux1SP->screen_x0 + (aux1SP->screen_delta_x + 1) / 2;
56
for (screen_x = aux1SP->screen_x0; screen_x <= screen_x1; screen_x++)
58
/* Check is this pixel inside the area reserved for the */
59
/* current image (there are two images in stereo mode): */
60
if (screen_x < aux1SP->configSP->image_screen_x0[aux1SP->imageI])
64
if (screen_x > aux1SP->configSP->image_screen_x1[aux1SP->imageI])
69
/* Relative position: */
70
delta_x = screen_x - aux1SP->screen_x0;
72
/* Find the corresponding screen_y: */
73
d = aux1SP->screen_y0 + x_to_y_scale * delta_x;
74
screen_y = (int) (d + 0.5);
76
/* Check is this pixel inside the area reserved for the */
77
/* current image (there are two images in stereo mode): */
78
if (screen_y < aux1SP->configSP->image_screen_y0) continue;
79
if (screen_y > aux1SP->configSP->image_screen_y1) continue;
81
/* z value (in atomic units): */
82
atomic_z = aux1SP->atomic_z0 + x_to_z_scale * delta_x;
84
/* Current pixel index: */
85
pixelI = aux1SP->guiSP->main_win_free_area_width * screen_y + screen_x;
87
/* Check pixel index: */
88
if (pixelI >= aux1SP->pixelsN) break;
90
/* Pointer to NearestAtomS struct. */
91
/* assigned to current coordinates: */
92
curr_pixelSP = aux1SP->nearest_atomSP + pixelI;
94
/* Check was this pixel used already in */
95
/* this drawing step; if it was, compare */
96
/* the z value of the current atom with z */
97
/* value previously stored to this pixel: */
98
if (aux1SP->refreshI == curr_pixelSP->last_refreshI)
100
if (atomic_z >= curr_pixelSP->z) continue;
103
/* If this point is reached, draw the pixel: */
104
XDrawPoint (aux1SP->guiSP->displaySP,
105
aux1SP->guiSP->main_hidden_pixmapID,
106
aux1SP->guiSP->theGCA[0],
109
/* Refresh the content of NearestAtomS */
110
/* array associated with this pixel: */
111
curr_pixelSP->styleI = 1;
112
curr_pixelSP->last_refreshI = aux1SP->refreshI;
113
curr_pixelSP->mol_complexI = aux1SP->mol_complexI;
114
curr_pixelSP->atomI = aux1SP->atomI;
115
curr_pixelSP->z = atomic_z;
116
curr_pixelSP->colorID = aux1SP->colorIDA[0];
118
/* Update the number of pixels drawn: */
122
/* Check is at least one pixel drawn: */
123
if (pixels_drawnN > 0) return 1;
125
/* If this point is reached, nothing is drawn: */
129
/*===========================================================================*/