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

« back to all changes in this revision

Viewing changes to read_config.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
                                read_config.c
 
6
 
 
7
Purpose:
 
8
        Read configuration data.  Configuration file is .garlicrc  and up to
 
9
        five directories are  searched for this file.  If all attempts fail,
 
10
        default (hard-coded) parameters are used.
 
11
 
 
12
Input:
 
13
        (1) Pointer to  ConfigS  structure,  where some data will be stored.
 
14
 
 
15
Output:
 
16
        (1) Some data stored to ConfigS structure.
 
17
        (2) Return value.
 
18
 
 
19
Return value:
 
20
        (1) Positive if configuration read from file.
 
21
        (2) Zero if default values used for initialization.
 
22
 
 
23
Notes:
 
24
        (1) This function is quite fast:  on a 233 MHz Pentium MMX,  it will
 
25
            take few milliseconds to execute.  Therefore do not be surprised
 
26
            that if's are not optimized here.
 
27
 
 
28
========includes:============================================================*/
 
29
 
 
30
#include <stdio.h>
 
31
 
 
32
#include <string.h>
 
33
#include <math.h>
 
34
 
 
35
#include <X11/Xlib.h>
 
36
#include <X11/Xutil.h>
 
37
#include <X11/Xos.h>
 
38
#include <X11/Xatom.h>
 
39
 
 
40
#include "defines.h"
 
41
#include "typedefs.h"
 
42
 
 
43
/*======function prototypes:=================================================*/
 
44
 
 
45
FILE            *OpenConfigFile_ (void);
 
46
int             ExtractInteger_ (char *);
 
47
int             ExtractTwoIntegers_ (int *, int *, char *);
 
48
int             ExtractPhrase_ (char *, char *);
 
49
double          ExtractDouble_ (char *);
 
50
int             ExtractTwoDoubles_ (double *, double *, char *);
 
51
int             ExtractIndex_ (char *);
 
52
int             ExtractRotationSteps_ (ConfigS *, char *);
 
53
int             ExtractTranslationSteps_ (ConfigS *, char *);
 
54
int             ExtractSlabSteps_ (ConfigS *, char *);
 
55
int             ExtractFadingSteps_ (ConfigS *, char *);
 
56
 
 
57
/*======read configuration data (.garlicrc file):============================*/
 
58
 
 
59
int ReadConfig_ (ConfigS *configSP)
 
60
{
 
61
FILE            *fileP;
 
62
char            s[STRINGSIZE];
 
63
int             line_size;
 
64
char            phraseA[SHORTSTRINGSIZE];
 
65
int             n, n1, n2;
 
66
double          d, d1, d2;
 
67
int             surfaceI;
 
68
 
 
69
/* Default values;  used if both attempts to find  .garlicrc fail, */
 
70
/* or if the corresponding entry does not exist in .garlicrc file: */
 
71
 
 
72
/** Main window geometry: **/
 
73
strcpy (configSP->geometryA, "default");
 
74
 
 
75
/** Font name and cursor name: **/
 
76
strcpy (configSP->font_nameA, "10x20");
 
77
strcpy (configSP->cursor_nameA, "default");
 
78
 
 
79
/** Coordinate system in the top left corner is visible by default: **/
 
80
configSP->show_coord_systemF = 1;
 
81
 
 
82
/** Control window in the top right corner is visible by default: **/
 
83
configSP->show_control_windowF = 1;
 
84
 
 
85
/** The sequence neighborhood of the residue **/
 
86
/** under the pointer is visible by default: **/
 
87
configSP->show_sequence_neighborhoodF = 1;
 
88
 
 
89
/** Stereo flag (default is mono): **/
 
90
configSP->stereoF = 0;
 
91
 
 
92
/** Light source theta angle (with respect to z): **/
 
93
configSP->light_theta = 150.0 * DEG_TO_RAD;
 
94
 
 
95
/** Light source phi angle (with respect to x): **/
 
96
configSP->light_phi = 225.0 * DEG_TO_RAD;
 
97
 
 
98
/** Window colors: **/
 
99
strcpy (configSP->bg_colorA, "black");
 
100
strcpy (configSP->fg_colorA, "white");
 
101
strcpy (configSP->text_bg_colorA, "black");
 
102
strcpy (configSP->text_fg_colorA, "white");
 
103
 
 
104
/** Slab mode index (default is planar): **/
 
105
configSP->default_slab_modeI = 1;
 
106
 
 
107
/** Color fading mode index (default is planar): **/
 
108
configSP->default_fading_modeI = 1;
 
109
 
 
110
/** Default number of color fading surfaces (up to MAXSURFACES): **/
 
111
configSP->default_surfacesN = 3;
 
112
 
 
113
/** Color specifications: **/
 
114
strcpy (configSP->left_colorAA[0],   "RGB:FFFF/FFFF/0000");
 
115
strcpy (configSP->middle_colorAA[0], "RGB:FFFF/AAAA/0000");
 
116
strcpy (configSP->right_colorAA[0],  "RGB:FFFF/5555/0000");
 
117
strcpy (configSP->left_colorAA[1],   "RGB:FFFF/8888/0000");
 
118
strcpy (configSP->middle_colorAA[1], "RGB:FFFF/0000/0000");
 
119
strcpy (configSP->right_colorAA[1],  "RGB:AAAA/0000/0000");
 
120
strcpy (configSP->left_colorAA[2],   "RGB:7777/0000/0000");
 
121
strcpy (configSP->middle_colorAA[2], "RGB:5555/0000/0000");
 
122
strcpy (configSP->right_colorAA[2],  "RGB:4444/0000/0000");
 
123
for (n = 3; n < MAXSURFACES; n++)
 
124
        {
 
125
        strcpy (configSP->left_colorAA[n], "white");
 
126
        strcpy (configSP->middle_colorAA[n], "gray");
 
127
        strcpy (configSP->right_colorAA[n], "DarkGray");
 
128
        }
 
129
 
 
130
/* Drawing styles for atoms, bonds and backbone: */
 
131
configSP->default_atom_styleI = 2;
 
132
configSP->default_bond_styleI = 2;
 
133
configSP->default_backbone_styleI = 5;
 
134
 
 
135
/** Bond lengths (angstroms): **/
 
136
configSP->max_bond_length = 2.2;
 
137
configSP->C_C_bond_length_min = 1.40;
 
138
configSP->C_C_bond_length_max = 1.70;
 
139
configSP->C_N_bond_length_min = 1.10;
 
140
configSP->C_N_bond_length_max = 1.60;
 
141
configSP->C_O_bond_length_min = 1.10;
 
142
configSP->C_O_bond_length_max = 1.40;
 
143
configSP->C_S_bond_length_min = 1.60;
 
144
configSP->C_S_bond_length_max = 2.00;
 
145
configSP->C_H_bond_length_min = 0.80;
 
146
configSP->C_H_bond_length_max = 1.20;
 
147
configSP->N_H_bond_length_min = 0.90;
 
148
configSP->N_H_bond_length_max = 1.30;
 
149
configSP->O_H_bond_length_min = 0.70;
 
150
configSP->O_H_bond_length_max = 1.30;
 
151
configSP->S_H_bond_length_min = 0.90;
 
152
configSP->S_H_bond_length_max = 1.60;
 
153
configSP->O_P_bond_length_min = 1.20;
 
154
configSP->O_P_bond_length_max = 1.80;
 
155
configSP->S_S_bond_length_min = 1.80;
 
156
configSP->S_S_bond_length_max = 2.30;
 
157
configSP->generic_bond_length_min = 0.8;
 
158
configSP->generic_bond_length_max = 2.0;
 
159
configSP->hydro_bond_length_min = 2.4;
 
160
configSP->hydro_bond_length_max = 4.1;
 
161
configSP->hydro_bond_angle_min = (double) 125 * DEG_TO_RAD;
 
162
configSP->hydro_bond_angle_max = (double) 180 * DEG_TO_RAD;
 
163
 
 
164
/** The maximal CA_CA distance for two neighbouring residues (angstroms): **/
 
165
configSP->CA_CA_dist_max = 4.1;
 
166
 
 
167
/** Atomic radii (in angstroms): **/
 
168
configSP->H_radius =       0.70;
 
169
configSP->C_radius =       1.20;
 
170
configSP->N_radius =       1.05;
 
171
configSP->O_radius =       1.00;
 
172
configSP->S_radius =       1.25;
 
173
configSP->P_radius =       1.25;
 
174
configSP->generic_radius = 1.40;
 
175
 
 
176
/** van der Waals radii (in angstroms): **/
 
177
configSP->H_van_der_Waals_radius       = 1.00;
 
178
configSP->C_van_der_Waals_radius       = 1.70;
 
179
configSP->N_van_der_Waals_radius       = 1.50;
 
180
configSP->O_van_der_Waals_radius       = 1.40;
 
181
configSP->S_van_der_Waals_radius       = 1.80;
 
182
configSP->P_van_der_Waals_radius       = 1.80;
 
183
configSP->generic_van_der_Waals_radius = 2.00;
 
184
 
 
185
/** Ball radius (used to draw balls and sticks): **/
 
186
configSP->ball_radius = 0.45;
 
187
 
 
188
/** Number of neighbors to be checked as bond candidates: **/
 
189
configSP->bond_candidates_backward = 50;
 
190
configSP->bond_candidates_forward  = 50; 
 
191
 
 
192
/** Geometric parameters: **/
 
193
configSP->main_margin_left = 30;
 
194
configSP->main_margin_right = 30;
 
195
configSP->main_margin_top = 60;
 
196
configSP->main_margin_bottom = 30;
 
197
configSP->max_main_win_width  = MAXWINWIDTH;
 
198
configSP->max_main_win_height = MAXWINHEIGHT;
 
199
configSP->nearest_line_thickness = MAXLINES;
 
200
configSP->screen_real_width = SCREEN_REAL_WX;
 
201
configSP->screen_real_height = SCREEN_REAL_WY;
 
202
configSP->user_screen_real_distance = USER_SCREEN_REAL_DIST;
 
203
configSP->screen_atomic_width = SCREEN_ATOMIC_WX;
 
204
configSP->user_atomic_position = USER_ATOMIC_Z;
 
205
configSP->stereo_screen_margin = STEREO_MARGIN;
 
206
configSP->stereo_angle = STEREO_ANGLE * DEG_TO_RAD;
 
207
configSP->rotation_stepA[0] = 0.2 * DEG_TO_RAD;
 
208
configSP->rotation_stepA[1] = 1.0 * DEG_TO_RAD;
 
209
configSP->rotation_stepA[2] = 5.0 * DEG_TO_RAD;
 
210
configSP->rotation_stepA[3] = 30.0 * DEG_TO_RAD;
 
211
configSP->rotation_stepA[4] = 90.0 * DEG_TO_RAD;
 
212
configSP->translation_stepA[0] =   0.2;
 
213
configSP->translation_stepA[1] =   1.0;
 
214
configSP->translation_stepA[2] =   5.0;
 
215
configSP->translation_stepA[3] =  25.0;
 
216
configSP->translation_stepA[4] = 100.0;
 
217
configSP->slab_stepA[0] =  0.2;
 
218
configSP->slab_stepA[1] =  1.0;
 
219
configSP->slab_stepA[2] =  5.0;
 
220
configSP->slab_stepA[3] = 20.0;
 
221
configSP->slab_stepA[4] = 80.0;
 
222
configSP->fading_stepA[0] =  0.2;
 
223
configSP->fading_stepA[1] =  1.0;
 
224
configSP->fading_stepA[2] =  5.0;
 
225
configSP->fading_stepA[3] = 20.0;
 
226
configSP->fading_stepA[4] = 80.0;
 
227
 
 
228
/* Try to find personal or public configuration file: */
 
229
if ((fileP = OpenConfigFile_ ()) == NULL) return 0;
 
230
 
 
231
/* If this point is reached, file is available - read and parse all lines: */
 
232
line_size = sizeof (s);
 
233
while (fgets (s, line_size, fileP))
 
234
        {
 
235
        /* Skip comments: */
 
236
        if (strstr (s, "#") == s) continue;
 
237
 
 
238
        /* Skip very short lines: */
 
239
        if (strlen (s) <= 5) continue;
 
240
 
 
241
        /* Main window geometry: */
 
242
        if (strstr (s, "main") && strstr (s, "window") &&
 
243
            strstr (s, "geometry"))
 
244
                {
 
245
                if (ExtractPhrase_ (phraseA, s) > 0)
 
246
                        {
 
247
                        strncpy (configSP->geometryA,
 
248
                                 phraseA, SHORTSTRINGSIZE - 1);
 
249
                        configSP->geometryA[SHORTSTRINGSIZE - 1] = '\0';
 
250
                        }
 
251
                continue;
 
252
                }
 
253
 
 
254
        /* Main font name: */
 
255
        if (strstr (s, "main") && strstr (s, "font"))
 
256
                {
 
257
                if (ExtractPhrase_ (phraseA, s) > 0)
 
258
                        {
 
259
                        strncpy (configSP->font_nameA,
 
260
                                 phraseA, SHORTSTRINGSIZE - 1);
 
261
                        configSP->font_nameA[SHORTSTRINGSIZE - 1] = '\0';
 
262
                        }
 
263
                continue;
 
264
                }
 
265
 
 
266
        /* Main window cursor: */
 
267
        if (strstr (s, "main") && strstr (s, "window") && strstr (s, "cursor"))
 
268
                {
 
269
                if (ExtractPhrase_ (phraseA, s) > 0)
 
270
                        {
 
271
                        strncpy (configSP->cursor_nameA,
 
272
                                 phraseA, SHORTSTRINGSIZE - 1);
 
273
                        configSP->cursor_nameA[SHORTSTRINGSIZE - 1] = '\0';
 
274
                        }
 
275
                continue;
 
276
                }
 
277
 
 
278
        /* Coordinate system in the top left corner (yes or no): */
 
279
        if (strstr (s, "show") && strstr (s, "coordinate") &&
 
280
            strstr (s, "system"))
 
281
                {
 
282
                if (ExtractPhrase_ (phraseA, s) > 0)
 
283
                        {
 
284
                        if (strstr (phraseA, "no"))     
 
285
                                {
 
286
                                configSP->show_coord_systemF = 0;
 
287
                                }
 
288
                        }
 
289
                continue;
 
290
                }
 
291
 
 
292
        /* Control window in the top right corner: */
 
293
        if (strstr (s, "show") && strstr (s, "control") &&
 
294
            strstr (s, "window"))
 
295
                {
 
296
                if (ExtractPhrase_ (phraseA, s) > 0)
 
297
                        {
 
298
                        if (strstr (phraseA, "no"))
 
299
                                {
 
300
                                configSP->show_control_windowF = 0;
 
301
                                }
 
302
                        }
 
303
                continue;
 
304
                }
 
305
 
 
306
        /* Sequence neighborhood of the residue under the pointer: */
 
307
        if (strstr (s, "show") && strstr (s, "sequence") &&
 
308
            strstr (s, "neighborhood"))
 
309
                {
 
310
                if (ExtractPhrase_ (phraseA, s) > 0)
 
311
                        {
 
312
                        if (strstr (phraseA, "no"))
 
313
                                {
 
314
                                configSP->show_sequence_neighborhoodF = 0;
 
315
                                }
 
316
                        }
 
317
                continue;
 
318
                }
 
319
        
 
320
        /* Stereo flag (0 = mono, 1 = stereo): */
 
321
        if (strstr (s, "display") && strstr (s, "stereo") &&
 
322
            strstr (s, "image"))
 
323
                {
 
324
                if (ExtractPhrase_ (phraseA, s) > 0)
 
325
                        {
 
326
                        if (strstr (phraseA, "yes")) configSP->stereoF = 1;
 
327
                        }
 
328
                continue;
 
329
                }
 
330
 
 
331
        /* Default slab mode index (see typedefs.h for available modes): */
 
332
        if (strstr (s, "default") && strstr (s, "slab") && strstr (s, "mode"))
 
333
                {
 
334
                if (ExtractPhrase_ (phraseA, s) > 0)
 
335
                        {
 
336
                        if (strncmp (phraseA, "off", 50) == 0)
 
337
                                configSP->default_slab_modeI = 0;
 
338
                        else if (strncmp (phraseA, "planar", 50) == 0)
 
339
                                configSP->default_slab_modeI = 1;
 
340
                        else if (strncmp (phraseA, "sphere", 50) == 0)
 
341
                                configSP->default_slab_modeI = 2;
 
342
                        else if (strncmp (phraseA, "half-sphere", 50) == 0)
 
343
                                configSP->default_slab_modeI = 3;
 
344
                        else if (strncmp (phraseA, "cylinder", 50) == 0)
 
345
                                configSP->default_slab_modeI = 4;
 
346
                        else if (strncmp (phraseA, "half-cylinder", 50) == 0)
 
347
                                configSP->default_slab_modeI = 5;
 
348
                        else configSP->default_slab_modeI = 1;    /* Default */
 
349
                        }
 
350
                continue;
 
351
                }
 
352
 
 
353
        /* Default fading mode index (see typedefs.h for available modes): */
 
354
        if (strstr (s, "default") && strstr (s, "fading") &&
 
355
            strstr (s, "mode"))
 
356
                {
 
357
                if (ExtractPhrase_ (phraseA, s) > 0)
 
358
                        {
 
359
                        if (strncmp (phraseA, "off", 50) == 0)
 
360
                                configSP->default_fading_modeI = 0;
 
361
                        else if (strncmp (phraseA, "planar", 50) == 0)
 
362
                                configSP->default_fading_modeI = 1;
 
363
                        else if (strncmp (phraseA, "sphere", 50) == 0)
 
364
                                configSP->default_fading_modeI = 2;
 
365
                        else if (strncmp (phraseA, "half-sphere", 50) == 0)
 
366
                                configSP->default_fading_modeI = 3;
 
367
                        else if (strncmp (phraseA, "cylinder", 50) == 0)
 
368
                                configSP->default_fading_modeI = 4;
 
369
                        else if (strncmp (phraseA, "half-cylinder", 50) == 0)
 
370
                                configSP->default_fading_modeI = 5;
 
371
                        else configSP->default_fading_modeI = 1;  /* Default */
 
372
                        }
 
373
                continue;
 
374
                }
 
375
 
 
376
        /* Main window left margin: */
 
377
        if (strstr (s, "main") && strstr (s, "window") &&
 
378
            strstr (s, "left") && strstr (s, "margin"))
 
379
                {
 
380
                n = ExtractInteger_ (s);
 
381
                if (n >= 0) configSP->main_margin_left = n;
 
382
                continue;
 
383
                }
 
384
 
 
385
        /* Main window right margin: */
 
386
        if (strstr (s, "main") && strstr (s, "window") &&
 
387
            strstr (s, "right") && strstr (s, "margin"))
 
388
                {
 
389
                n = ExtractInteger_ (s);
 
390
                if (n >= 0) configSP->main_margin_right = n;
 
391
                continue;
 
392
                }
 
393
 
 
394
        /* Main window top margin: */
 
395
        if (strstr (s, "main") && strstr (s, "window") &&
 
396
            strstr (s, "top") && strstr (s, "margin"))
 
397
                {
 
398
                n = ExtractInteger_ (s);
 
399
                if (n >= 0) configSP->main_margin_top = n;
 
400
                continue;
 
401
                }
 
402
 
 
403
        /* Main window bottom margin: */
 
404
        if (strstr (s, "main") && strstr (s, "window") &&
 
405
            strstr (s, "bottom") && strstr (s, "margin"))
 
406
                {
 
407
                n = ExtractInteger_ (s);
 
408
                if (n >= 0) configSP->main_margin_bottom = n;
 
409
                continue;
 
410
                }
 
411
 
 
412
        /* Background color specification: */
 
413
        if (strstr (s, "main") && strstr (s, "window") &&
 
414
            strstr (s, "background") && strstr (s, "color"))
 
415
                {
 
416
                if (ExtractPhrase_ (phraseA, s) > 0)
 
417
                        {
 
418
                        strncpy (configSP->bg_colorA,
 
419
                                 phraseA, SHORTSTRINGSIZE - 1);
 
420
                        configSP->bg_colorA[SHORTSTRINGSIZE - 1] = '\0';
 
421
                        }
 
422
                continue;
 
423
                }
 
424
 
 
425
        /* Foreground color specification: */
 
426
        if (strstr (s, "main") && strstr (s, "window") &&
 
427
            strstr (s, "foreground") && strstr (s, "color"))
 
428
                {
 
429
                if (ExtractPhrase_ (phraseA, s) > 0)
 
430
                        {
 
431
                        strncpy (configSP->fg_colorA,
 
432
                                 phraseA, SHORTSTRINGSIZE - 1);
 
433
                        configSP->fg_colorA[SHORTSTRINGSIZE - 1] = '\0';
 
434
                        }
 
435
                continue;
 
436
                }
 
437
 
 
438
        /* Text background color: */
 
439
        if (strstr (s, "text") && strstr (s, "background") &&
 
440
            strstr (s, "color"))
 
441
                {
 
442
                if (ExtractPhrase_ (phraseA, s) > 0)
 
443
                        {
 
444
                        strncpy (configSP->text_bg_colorA,
 
445
                                 phraseA, SHORTSTRINGSIZE - 1);
 
446
                        configSP->text_bg_colorA[SHORTSTRINGSIZE - 1] = '\0';
 
447
                        }
 
448
                continue;
 
449
                }
 
450
 
 
451
        /* Text foreground color: */
 
452
        if (strstr (s, "text") && strstr (s, "foreground") &&
 
453
            strstr (s, "color"))
 
454
                {
 
455
                if (ExtractPhrase_ (phraseA, s) > 0)
 
456
                        {
 
457
                        strncpy (configSP->text_fg_colorA,
 
458
                                 phraseA, SHORTSTRINGSIZE - 1);
 
459
                        configSP->text_fg_colorA[SHORTSTRINGSIZE - 1] = '\0';
 
460
                        }
 
461
                continue;
 
462
                }
 
463
 
 
464
        /* Default number of color fading surfaces: */
 
465
        if (strstr (s, "number") && strstr (s, "color") &&
 
466
            strstr (s, "surfaces"))
 
467
                {
 
468
                n = ExtractInteger_ (s);
 
469
                if ((n > 0) && (n <= MAXSURFACES))
 
470
                        {
 
471
                        configSP->default_surfacesN = n;
 
472
                        }
 
473
                continue;
 
474
                }
 
475
 
 
476
        /* Left color: */
 
477
        if (strstr (s, "left") && strstr (s, "color"))
 
478
                {
 
479
                surfaceI = ExtractIndex_ (s);
 
480
                if ((surfaceI < 0) || (surfaceI >= MAXSURFACES)) continue;
 
481
                if (ExtractPhrase_ (phraseA, s) > 0)
 
482
                        {
 
483
                        strncpy (configSP->left_colorAA[surfaceI],
 
484
                                 phraseA, SHORTSTRINGSIZE - 1);
 
485
                        n = SHORTSTRINGSIZE - 1;
 
486
                        configSP->left_colorAA[surfaceI][n] = '\0';
 
487
                        }
 
488
                continue;
 
489
                }
 
490
 
 
491
        /* Middle color: */
 
492
        if (strstr (s, "middle") && strstr (s, "color"))
 
493
                {
 
494
                surfaceI = ExtractIndex_ (s);
 
495
                if ((surfaceI < 0) || (surfaceI >= MAXSURFACES)) continue;
 
496
                if (ExtractPhrase_ (phraseA, s) > 0)
 
497
                        {
 
498
                        strncpy (configSP->middle_colorAA[surfaceI],
 
499
                                 phraseA, SHORTSTRINGSIZE - 1);
 
500
                        n = SHORTSTRINGSIZE - 1;
 
501
                        configSP->middle_colorAA[surfaceI][n] = '\0';
 
502
                        }
 
503
                continue;
 
504
                }
 
505
 
 
506
        /* Right color: */
 
507
        if (strstr (s, "right") && strstr (s, "color"))
 
508
                {
 
509
                surfaceI = ExtractIndex_ (s);
 
510
                if ((surfaceI < 0) || (surfaceI >= MAXSURFACES)) continue;
 
511
                if (ExtractPhrase_ (phraseA, s) > 0)
 
512
                        {
 
513
                        strncpy (configSP->right_colorAA[surfaceI],
 
514
                                 phraseA, SHORTSTRINGSIZE - 1);
 
515
                        n = SHORTSTRINGSIZE - 1;
 
516
                        configSP->right_colorAA[surfaceI][n] = '\0';
 
517
                        }
 
518
                continue;
 
519
                }
 
520
 
 
521
        /* Default drawing style for atoms: */
 
522
        if (strstr (s, "default") && strstr (s, "atom") &&
 
523
            strstr (s, "drawing") && strstr (s, "style"))
 
524
                {
 
525
                n = ExtractInteger_ (s);
 
526
                if ((n >= 0) && (n <= MAXATOMSTYLEI))
 
527
                        {
 
528
                        configSP->default_atom_styleI = (short int) n;
 
529
                        }
 
530
                }
 
531
 
 
532
        /* Default drawing style for bonds: */
 
533
        if (strstr (s, "default") && strstr (s, "bond") &&
 
534
            strstr (s, "drawing") && strstr (s, "style"))
 
535
                {
 
536
                n = ExtractInteger_ (s);
 
537
                if ((n >= 0) && (n <= MAXBONDSTYLEI))
 
538
                        {
 
539
                        configSP->default_bond_styleI = (short int) n;
 
540
                        }
 
541
                }
 
542
 
 
543
        /* Default drawing style for bonds: */
 
544
        if (strstr (s, "default") && strstr (s, "backbone") &&
 
545
            strstr (s, "drawing") && strstr (s, "style"))
 
546
                {
 
547
                n = ExtractInteger_ (s);
 
548
                if ((n >= 0) && (n <= MAXBONESTYLEI))
 
549
                        {
 
550
                        configSP->default_backbone_styleI = (short int) n;
 
551
                        }
 
552
                }
 
553
 
 
554
        /* Maximal main window width: */
 
555
        if (strstr (s, "maximal") && strstr (s, "window") &&
 
556
            strstr (s, "width"))
 
557
                {
 
558
                n = ExtractInteger_ (s);
 
559
                if (n >= 0) configSP->max_main_win_width = n;
 
560
                continue;
 
561
                }
 
562
 
 
563
        /* Maximal main window height: */
 
564
        if (strstr (s, "maximal") && strstr (s, "window") &&
 
565
            strstr (s, "height"))
 
566
                {
 
567
                n = ExtractInteger_ (s);
 
568
                if (n >= 0) configSP->max_main_win_height = n;
 
569
                continue;
 
570
                }
 
571
 
 
572
        /* The nearest line  (i.e. the nearest bond) thickness. */
 
573
        /* Used only if line thickness is used for perspective! */
 
574
        if (strstr (s, "nearest") && strstr (s, "line") &&
 
575
            strstr (s, "thickness"))
 
576
                {
 
577
                n = ExtractInteger_ (s);
 
578
                if (n >= 0) configSP->nearest_line_thickness = n;
 
579
                continue;
 
580
                }
 
581
 
 
582
        /* Screen width in real world: */
 
583
        if (strstr (s, "screen") && strstr (s, "real") && strstr (s, "width"))
 
584
                {
 
585
                d = ExtractDouble_ (s);
 
586
                if (d > 0) configSP->screen_real_width = d;
 
587
                continue;
 
588
                }
 
589
 
 
590
        /* Screen height in real world: */
 
591
        if (strstr (s, "screen") && strstr (s, "real") && strstr (s, "height"))
 
592
                {
 
593
                d = ExtractDouble_ (s);
 
594
                if (d > 0) configSP->screen_real_height = d;
 
595
                continue;
 
596
                }
 
597
 
 
598
        /* Distance between user and screen in real world: */
 
599
        if (strstr (s, "distance") && strstr (s, "user") &&
 
600
            strstr (s, "screen") && strstr (s, "real"))
 
601
                {
 
602
                d = ExtractDouble_ (s);
 
603
                if (d > 0) configSP->user_screen_real_distance = d;
 
604
                continue;
 
605
                }
 
606
 
 
607
        /* Screen width in atomic world: */
 
608
        if (strstr (s, "screen") && strstr (s, "width") &&
 
609
            strstr (s, "atomic"))
 
610
                {
 
611
                d = ExtractDouble_ (s);
 
612
                if (d > 0) configSP->screen_atomic_width = d;
 
613
                continue;
 
614
                }
 
615
 
 
616
        /* User z coordinate in atomic world (must be negative!): */
 
617
        if (strstr (s, "user") && strstr (s, "position") &&
 
618
            strstr (s, "atomic"))
 
619
                {
 
620
                d = ExtractDouble_ (s);
 
621
                if (d < 0) configSP->user_atomic_position = d;  /* Negative! */
 
622
                continue;
 
623
                }
 
624
 
 
625
        /* Stereo internal margin (separating left and right image): */
 
626
        if (strstr (s, "stereo") && strstr (s, "internal") &&
 
627
            strstr (s, "margin"))
 
628
                {
 
629
                n = ExtractInteger_ (s);
 
630
                if (n > 0) configSP->stereo_screen_margin = n;
 
631
                continue;
 
632
                }
 
633
 
 
634
        /* Stereo angle. The right image is rotated around y axis for that */
 
635
        /* angle  (right-handed rotation).  Degrees read,  radians stored: */
 
636
        if (strstr (s, "stereo") && strstr (s, "angle"))
 
637
                {
 
638
                d = ExtractDouble_ (s);
 
639
                configSP->stereo_angle = d * DEG_TO_RAD;
 
640
                continue;
 
641
                }
 
642
 
 
643
        /* Light source theta angle: */
 
644
        if (strstr (s, "light") && strstr (s, "source") &&
 
645
            strstr (s, "theta") && strstr (s, "angle"))
 
646
                {
 
647
                d = ExtractDouble_ (s);
 
648
                configSP->light_theta = d * DEG_TO_RAD;
 
649
                continue;
 
650
                }
 
651
 
 
652
        /* Light source phi angle: */
 
653
        if (strstr (s, "light") && strstr (s, "source") &&
 
654
            strstr (s, "phi") && strstr (s, "angle"))
 
655
                {
 
656
                d = ExtractDouble_ (s);
 
657
                configSP->light_phi = d * DEG_TO_RAD;
 
658
                continue;
 
659
                }
 
660
 
 
661
        /* Rotation steps (very small, small, normal, large, very large): */
 
662
        if (strstr (s, "rotation") && strstr (s, "steps"))
 
663
                {
 
664
                ExtractRotationSteps_ (configSP, s);
 
665
                continue;
 
666
                }
 
667
 
 
668
        /* Translation steps (very small, small, normal, large, very large): */
 
669
        if (strstr (s, "translation") && strstr (s, "steps"))
 
670
                {
 
671
                ExtractTranslationSteps_ (configSP, s);
 
672
                continue;
 
673
                }
 
674
 
 
675
        /* Slab steps (very small, small, normal, large, very large): */
 
676
        if (strstr (s, "slab") && strstr (s, "steps"))
 
677
                {
 
678
                ExtractSlabSteps_ (configSP, s);
 
679
                continue;
 
680
                }
 
681
 
 
682
        /* Fading steps (very small, small, normal, large, very large): */
 
683
        if (strstr (s, "fading") && strstr (s, "steps"))
 
684
                {
 
685
                ExtractFadingSteps_ (configSP, s);
 
686
                continue;
 
687
                }
 
688
 
 
689
        /* Maximal  bond length,  used to check */
 
690
        /* which atoms and bonds are invisible: */
 
691
        if (strstr (s, "maximal") && strstr (s, "bond") &&
 
692
            strstr (s, "length"))
 
693
                {
 
694
                d = ExtractDouble_ (s);
 
695
                if (d > 0) configSP->max_bond_length = d;
 
696
                continue;
 
697
                }
 
698
 
 
699
        /* Crude bond length limits for C-C bond: */
 
700
        if (strstr (s, "approx") && strstr (s, "C-C") &&
 
701
            strstr (s, "bond") && strstr (s, "length"))
 
702
                {
 
703
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
704
                        {
 
705
                        if ((d1 > 0) && (d2 > d1))
 
706
                                {
 
707
                                configSP->C_C_bond_length_min = d1;
 
708
                                configSP->C_C_bond_length_max = d2;
 
709
                                }
 
710
                        }
 
711
                continue;
 
712
                }
 
713
 
 
714
        /* Crude bond length limits for C-N bond: */
 
715
        if (strstr (s, "approx") && strstr (s, "C-N") &&
 
716
            strstr (s, "bond") && strstr (s, "length"))
 
717
                {
 
718
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
719
                        {
 
720
                        if ((d1 > 0) && (d2 > d1))
 
721
                                {
 
722
                                configSP->C_N_bond_length_min = d1;
 
723
                                configSP->C_N_bond_length_max = d2;
 
724
                                }
 
725
                        }
 
726
                continue;
 
727
                }
 
728
 
 
729
        /* Crude bond length limits for C-O bond: */
 
730
        if (strstr (s, "approx") && strstr (s, "C-O") &&
 
731
            strstr (s, "bond") && strstr (s, "length"))
 
732
                {
 
733
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
734
                        {
 
735
                        if ((d1 > 0) && (d2 > d1))
 
736
                                {
 
737
                                configSP->C_O_bond_length_min = d1;
 
738
                                configSP->C_O_bond_length_max = d2;
 
739
                                }
 
740
                        }
 
741
                continue;
 
742
                }
 
743
 
 
744
        /* Crude bond length limits for C-S bond: */
 
745
        if (strstr (s, "approximate") && strstr (s, "C-S") &&
 
746
            strstr (s, "bond") && strstr (s, "length"))
 
747
                {
 
748
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
749
                        {
 
750
                        if ((d1 > 0) && (d2 > d1))
 
751
                                {
 
752
                                configSP->C_S_bond_length_min = d1;
 
753
                                configSP->C_S_bond_length_max = d2;
 
754
                                }
 
755
                        }
 
756
                continue;
 
757
                }
 
758
 
 
759
        /* Crude bond length limits for C-H bond: */
 
760
        if (strstr (s, "approximate") && strstr (s, "C-H") &&
 
761
            strstr (s, "bond") && strstr (s, "length"))
 
762
                {
 
763
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
764
                        {
 
765
                        if ((d1 > 0) && (d2 > d1))
 
766
                                {
 
767
                                configSP->C_H_bond_length_min = d1;
 
768
                                configSP->C_H_bond_length_max = d2;
 
769
                                }
 
770
                        }
 
771
                continue;
 
772
                }
 
773
 
 
774
        /* Crude bond length limits for N-H bond: */
 
775
        if (strstr (s, "approximate") && strstr (s, "N-H") &&
 
776
            strstr (s, "bond") && strstr (s, "length"))
 
777
                {
 
778
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
779
                        {
 
780
                        if ((d1 > 0) && (d2 > d1))
 
781
                                {
 
782
                                configSP->N_H_bond_length_min = d1;
 
783
                                configSP->N_H_bond_length_max = d2;
 
784
                                }
 
785
                        }
 
786
                continue;
 
787
                }
 
788
 
 
789
        /* Crude bond length limits for O-H bond: */
 
790
        if (strstr (s, "approximate") && strstr (s, "O-H") &&
 
791
            strstr (s, "bond") && strstr (s, "length"))
 
792
                {
 
793
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
794
                        {
 
795
                        if ((d1 > 0) && (d2 > d1))
 
796
                                {
 
797
                                configSP->O_H_bond_length_min = d1;
 
798
                                configSP->O_H_bond_length_max = d2;
 
799
                                }
 
800
                        }
 
801
                continue;
 
802
                }
 
803
 
 
804
        /* Crude bond length limits for S-H bond: */
 
805
        if (strstr (s, "approximate") && strstr (s, "S-H") &&
 
806
            strstr (s, "bond") && strstr (s, "length"))
 
807
                {
 
808
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
809
                        {
 
810
                        if ((d1 > 0) && (d2 > d1))
 
811
                                {
 
812
                                configSP->S_H_bond_length_min = d1;
 
813
                                configSP->S_H_bond_length_max = d2;
 
814
                                }
 
815
                        }
 
816
                continue;
 
817
                }
 
818
 
 
819
        /* Crude bond length limits for O-P bond: */
 
820
        if (strstr (s, "approximate") && strstr (s, "O-P") &&
 
821
            strstr (s, "bond") && strstr (s, "length"))
 
822
                {
 
823
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
824
                        {
 
825
                        if ((d1 > 0) && (d2 > d1))
 
826
                                {
 
827
                                configSP->O_P_bond_length_min = d1;
 
828
                                configSP->O_P_bond_length_max = d2;
 
829
                                }
 
830
                        }
 
831
                continue;
 
832
                }
 
833
 
 
834
        /* Crude bond length limits for S-S bond: */
 
835
        if (strstr (s, "approximate") && strstr (s, "S-S") &&
 
836
            strstr (s, "bond") && strstr (s, "length"))
 
837
                {
 
838
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
839
                        {
 
840
                        if ((d1 > 0) && (d2 > d1))
 
841
                                {
 
842
                                configSP->S_S_bond_length_min = d1;
 
843
                                configSP->S_S_bond_length_max = d2;
 
844
                                }
 
845
                        }
 
846
                continue;
 
847
                }
 
848
 
 
849
        /* Bond length limits for unrecognized atomic pairs: */
 
850
        if (strstr (s, "generic") && strstr (s, "bond") &&
 
851
            strstr (s, "length"))
 
852
                {
 
853
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
854
                        {
 
855
                        if ((d1 > 0) && (d2 > d1))
 
856
                                {
 
857
                                configSP->generic_bond_length_min = d1;
 
858
                                configSP->generic_bond_length_max = d2;
 
859
                                }
 
860
                        }
 
861
                continue;
 
862
                }
 
863
 
 
864
        /* Hydrogen bond length range: */
 
865
        if (strstr (s, "hydrogen") && strstr (s, "bond") &&
 
866
            strstr (s, "length"))
 
867
                {
 
868
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
869
                        {
 
870
                        if ((d1 > 0) && (d2 > d1))
 
871
                                {
 
872
                                configSP->hydro_bond_length_min = d1;
 
873
                                configSP->hydro_bond_length_max = d2;
 
874
                                }
 
875
                        }
 
876
                continue;
 
877
                }
 
878
 
 
879
        /* Hydrogen bond angular range: */
 
880
        if (strstr (s, "hydrogen") && strstr (s, "bond") &&
 
881
            strstr (s, "angle"))
 
882
                {
 
883
                if (ExtractTwoDoubles_ (&d1, &d2, s) > 0)
 
884
                        {
 
885
                        if ((d1 >= 0.0) && (d1 <= 180.0) &&
 
886
                            (d2 > d1) && (d2 <= 180))
 
887
                                {
 
888
                                configSP->hydro_bond_angle_min =
 
889
                                                        d1 * DEG_TO_RAD;
 
890
                                configSP->hydro_bond_angle_max =
 
891
                                                        d2 * DEG_TO_RAD;
 
892
                                }
 
893
                        }
 
894
                }
 
895
 
 
896
        /* The maximal CA-CA distance for two neighbouring residues: */
 
897
        if (strstr (s, "maximal") && strstr (s, "CA-CA") &&
 
898
            strstr (s, "distance"))
 
899
                {
 
900
                d = ExtractDouble_ (s);
 
901
                if (d > 0) configSP->CA_CA_dist_max = d;
 
902
                continue;
 
903
                }
 
904
 
 
905
        /* Radius of hydrogen atom: */
 
906
        if (strstr (s, "radius") && strstr (s, "hydrogen") &&
 
907
           !strstr (s, "Waals"))
 
908
                {
 
909
                d = ExtractDouble_ (s);
 
910
                if (d > 0) configSP->H_radius = (float) d;
 
911
                continue;
 
912
                }
 
913
 
 
914
        /* Radius of carbon atom: */
 
915
        if (strstr (s, "radius") && strstr (s, "carbon") &&
 
916
           !strstr (s, "Waals"))
 
917
                {
 
918
                d = ExtractDouble_ (s);
 
919
                if (d > 0) configSP->C_radius = (float) d;
 
920
                continue;
 
921
                }
 
922
 
 
923
        /* Radius of nitrogen atom: */
 
924
        if (strstr (s, "radius") && strstr (s, "nitrogen") &&
 
925
           !strstr (s, "Waals"))
 
926
                {
 
927
                d = ExtractDouble_ (s);
 
928
                if (d > 0) configSP->N_radius = (float) d;
 
929
                continue;
 
930
                }
 
931
 
 
932
        /* Radius of oxygen atom: */
 
933
        if (strstr (s, "radius") && strstr (s, "oxygen") &&
 
934
           !strstr (s, "Waals"))
 
935
                {
 
936
                d = ExtractDouble_ (s);
 
937
                if (d > 0) configSP->O_radius = (float) d;
 
938
                continue;
 
939
                }
 
940
 
 
941
        /* Radius of sulfur atom: */
 
942
        if (strstr (s, "radius") && strstr (s, "sulfur") &&
 
943
           !strstr (s, "Waals"))
 
944
                {
 
945
                d = ExtractDouble_ (s);
 
946
                if (d > 0) configSP->S_radius = (float) d;
 
947
                continue;
 
948
                }
 
949
 
 
950
        /* Radius of phosphorus atom: */
 
951
        if (strstr (s, "radius") && strstr (s, "phosphorus") &&
 
952
           !strstr (s, "Waals"))
 
953
                {
 
954
                d = ExtractDouble_ (s);
 
955
                if (d > 0) configSP->P_radius = (float) d;
 
956
                continue;
 
957
                }
 
958
 
 
959
        /* Radius of unknown atom (generic radius): */
 
960
        if (strstr (s, "generic") && strstr (s, "radius") &&
 
961
           !strstr (s, "Waals"))
 
962
                {
 
963
                d = ExtractDouble_ (s);
 
964
                if (d > 0) configSP->generic_radius = (float) d;
 
965
                continue;
 
966
                }
 
967
 
 
968
        /* Van der Waals radius of hydrogen: */
 
969
        if (strstr (s, "hydrogen") && strstr (s, "Waals"))
 
970
                {
 
971
                d = ExtractDouble_ (s);
 
972
                if (d > 0) configSP->H_van_der_Waals_radius = (float) d;
 
973
                continue;
 
974
                }
 
975
 
 
976
        /* Van der Waals radius of carbon: */
 
977
        if (strstr (s, "carbon") && strstr (s, "Waals"))
 
978
                {
 
979
                d = ExtractDouble_ (s);
 
980
                if (d > 0) configSP->C_van_der_Waals_radius = (float) d;
 
981
                continue;
 
982
                }
 
983
 
 
984
        /* Van der Waals radius of nitrogen: */
 
985
        if (strstr (s, "nitrogen") && strstr (s, "Waals"))
 
986
                {
 
987
                d = ExtractDouble_ (s);
 
988
                if (d > 0) configSP->N_van_der_Waals_radius = (float) d;
 
989
                continue;
 
990
                }
 
991
 
 
992
        /* Van der Waals radius of oxygen: */
 
993
        if (strstr (s, "oxygen") && strstr (s, "Waals"))
 
994
                {
 
995
                d = ExtractDouble_ (s);
 
996
                if (d > 0) configSP->O_van_der_Waals_radius = (float) d;
 
997
                continue;
 
998
                }
 
999
 
 
1000
        /* Van der Waals radius of sulfur: */
 
1001
        if (strstr (s, "sulfur") && strstr (s, "Waals"))
 
1002
                {
 
1003
                d = ExtractDouble_ (s);
 
1004
                if (d > 0) configSP->S_van_der_Waals_radius = (float) d;
 
1005
                continue;
 
1006
                }
 
1007
 
 
1008
        /* Van der Waals radius of phosphorus: */
 
1009
        if (strstr (s, "phosphorus") && strstr (s, "Waals"))
 
1010
                {
 
1011
                d = ExtractDouble_ (s);
 
1012
                if (d > 0) configSP->P_van_der_Waals_radius = (float) d;
 
1013
                continue;
 
1014
                }
 
1015
 
 
1016
        /* Van der Waals radius of unknown atom (generic radius): */
 
1017
        if (strstr (s, "generic") && strstr (s, "Waals"))
 
1018
                {
 
1019
                d = ExtractDouble_ (s);
 
1020
                if (d > 0) configSP->generic_van_der_Waals_radius = (float) d;
 
1021
                continue;
 
1022
                }
 
1023
 
 
1024
        /* Ball radius (used to draw balls and sticks): */
 
1025
        if (strstr (s, "ball") && strstr (s, "radius"))
 
1026
                {
 
1027
                d = ExtractDouble_ (s);
 
1028
                if (d > 0) configSP->ball_radius = (float) d;
 
1029
                continue;
 
1030
                }
 
1031
 
 
1032
        /* The number of neighboring atoms which should be checked */
 
1033
        /* as bond candidates,  in each direction of  AtomS array: */
 
1034
        if (strstr (s, "number") && strstr (s, "bond") &&
 
1035
            strstr (s, "candidates"))
 
1036
                {
 
1037
                if (ExtractTwoIntegers_ (&n1, &n2, s) > 0)
 
1038
                        {
 
1039
                        if (n1 > 0) configSP->bond_candidates_backward = n1;
 
1040
                        if (n2 > 0) configSP->bond_candidates_forward  = n2;
 
1041
                        }
 
1042
                }
 
1043
        continue;
 
1044
        }
 
1045
 
 
1046
/* Close file: */
 
1047
fclose (fileP);
 
1048
 
 
1049
return 1;
 
1050
}
 
1051
 
 
1052
/*===========================================================================*/
 
1053
 
 
1054