1 /* Copyright (C) 2000 Damir Zucic */
2 
3 /*=============================================================================
4 
5 				fading.c
6 
7 Purpose:
8 	Prepare the left, middle and right color for each atom in a complex.
9 	These are the only colors required by fast drawing styles. Some slow
10 	drawing styles may require additional colors. The AtomS structure is
11 	not capable  to  store  these  additional  colors,  so they  are not
12 	prepared here. Colors for hydrogen bonds are  not generated here. In
13 	fact,  this function does almost nothing - it just calls  the proper
14 	function which takes care about color fading.
15 
16 Input:
17 	(1) Pointer to MolComplexS structure.
18 	(2) Number of macromolecular complexes.
19 	(3) Pointer to GUIS structure.
20 
21 Output:
22 	(1) Colors (pixel values) initialized  for each atom in the complex.
23 	(2) Return value.
24 
25 Return value:
26 	The number  of atoms which  have colors  different from near and far
27 	color.
28 
29 =============================================================================*/
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 /*======function prototypes:=================================================*/
42 
43 size_t		NoFading_ (MolComplexS *, GUIS *);
44 size_t		PlanarFading_ (MolComplexS *, GUIS *);
45 size_t		SphereFading_ (MolComplexS *, GUIS *);
46 size_t		HalfSphereFading_ (MolComplexS *, GUIS *);
47 size_t		CylinFading_ (MolComplexS *, GUIS *);
48 size_t		HalfCylinFading_ (MolComplexS *, GUIS *);
49 
50 /*======prepare atomic colors (apply fading):================================*/
51 
Fading_(MolComplexS * mol_complexSP,int mol_complexesN,GUIS * guiSP)52 size_t Fading_ (MolComplexS *mol_complexSP, int mol_complexesN, GUIS *guiSP)
53 {
54 size_t		atoms_in_sandwichN = 0;
55 int		mol_complexI;
56 MolComplexS	*curr_mol_complexSP;
57 
58 /* Check every macromolecular complex: */
59 for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
60 	{
61 	/** Pointer to the current macromolecular complex: **/
62 	curr_mol_complexSP = mol_complexSP + mol_complexI;
63 
64 	/** Do not prepare new colors if position has not changed: **/
65 	if (curr_mol_complexSP->position_changedF == 0) continue;
66 
67 	/** Apply the proper fading: **/
68 	switch (curr_mol_complexSP->fading_modeI)
69 		{
70 		/*** No fading at all: ***/
71 		case 0:
72 			atoms_in_sandwichN +=
73 				NoFading_ (curr_mol_complexSP, guiSP);
74 			break;
75 
76 		/*** Planar: ***/
77 		case 1:
78 			atoms_in_sandwichN +=
79 				PlanarFading_ (curr_mol_complexSP, guiSP);
80 			break;
81 
82 		/*** Spherical: ***/
83 		case 2:
84 			atoms_in_sandwichN +=
85 				SphereFading_ (curr_mol_complexSP, guiSP);
86 			break;
87 
88 		/*** Semi-spherical: ***/
89 		case 3:
90 			atoms_in_sandwichN +=
91 				HalfSphereFading_ (curr_mol_complexSP, guiSP);
92 			break;
93 
94 		/*** Cylindrical: ***/
95 		case 4:
96 			atoms_in_sandwichN +=
97 				CylinFading_ (curr_mol_complexSP, guiSP);
98 			break;
99 
100 		/*** Semi-cylindrical: ***/
101 		case 5:
102 			atoms_in_sandwichN +=
103 				HalfCylinFading_ (curr_mol_complexSP, guiSP);
104 			break;
105 
106 		/*** Unknown fading mode: ***/
107 		default:
108 			;
109 		}
110 	}
111 
112 /* Return the total number of atoms between the fading surfaces: */
113 return atoms_in_sandwichN;
114 }
115 
116 /*===========================================================================*/
117 
118 
119