atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
read_opengl.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2025 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'read_opengl.c'
24*
25* Contains:
26*
27
28 - The functions to read the OpenGL window data in the atomes project file format
29
30*
31* List of functions:
32
33 int read_atom_a (FILE * fp, project * this_proj, int s, int a);
34 int read_atom_b (FILE * fp, project * this_proj, int s, int a);
35 int read_rings_chains_data (FILE * fp, glwin * view, int type, int rid, int size, int steps);
36 int read_this_image_label (FILE * fp, screen_label * label);
37 int read_this_box (FILE * fp, box * abc);
38 int read_this_axis (FILE * fp, axis * xyz);
39 int read_opengl_image (FILE * fp, project * this_proj, image * img, int sid);
40
41*/
42
43#include "global.h"
44#include "project.h"
45#include "glview.h"
46#include "initcoord.h"
47#include "preferences.h"
48
49extern gboolean old_la_bo_ax_gr;
50
61int read_atom_a (FILE * fp, project * this_proj, int s, int a)
62{
63 if (fread (& this_proj -> atoms[s][a].id, sizeof(int), 1, fp) != 1) return ERROR_RW;
64 if (fread (& this_proj -> atoms[s][a].sp, sizeof(int), 1, fp) != 1) return ERROR_RW;
65 if (fread (& this_proj -> atoms[s][a].x, sizeof(double), 1, fp) != 1) return ERROR_RW;
66 if (fread (& this_proj -> atoms[s][a].y, sizeof(double), 1, fp) != 1) return ERROR_RW;
67 if (fread (& this_proj -> atoms[s][a].z, sizeof(double), 1, fp) != 1) return ERROR_RW;
68 //g_debug ("Reading:: step= %d, at= %d, sp[%d]= %d, x[%d]= %f, y[%d]= %f, z[%d]= %f",
69 // s, a+1, a, this_proj -> atoms[s][a].sp, a, this_proj -> atoms[s][a].x, a, this_proj -> atoms[s][a].y, a, this_proj -> atoms[s][a].z);
70 return OK;
71}
72
83int read_atom_b (FILE * fp, project * this_proj, int s, int a)
84{
85 if (fread (this_proj -> atoms[s][a].show, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
86 if (fread (this_proj -> atoms[s][a].label, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
87 if (fread (& this_proj -> atoms[s][a].style, sizeof(int), 1, fp) != 1) return ERROR_RW;
88 int i, j, k, l, m;
89 int * rings_ij;
90 if (this_proj -> modelgl -> rings)
91 {
92 for (i=0; i<5; i++)
93 {
94 if (this_proj -> modelgl -> ring_max[i])
95 {
96 this_proj -> atoms[s][a].rings[i] = g_malloc0 (this_proj -> rsparam[i][1]*sizeof*this_proj -> atoms[s][a].rings[i]);
97 for (j=0; j<this_proj -> rsparam[i][1]; j++)
98 {
99 rings_ij = allocint(this_proj -> modelgl -> num_rings[i][s][j]);
100 m = 0;
101 for (k=0; k<this_proj -> modelgl -> num_rings[i][s][j]; k++)
102 {
103 for (l=0; l<j+1; l++)
104 {
105 if (this_proj -> modelgl -> all_rings[i][s][j][k][l] == a)
106 {
107 rings_ij[m] = k;
108 m ++;
109 break;
110 }
111 }
112 }
113 this_proj -> atoms[s][a].rings[i][j] = allocint(m+1);
114 this_proj -> atoms[s][a].rings[i][j][0] = m;
115 for (k=0; k<m; k++) this_proj -> atoms[s][a].rings[i][j][k+1] = rings_ij[k];
116 g_free (rings_ij);
117 }
118 }
119 }
120 }
121 if (this_proj -> modelgl -> chains)
122 {
123 if (this_proj -> modelgl -> chain_max)
124 {
125 this_proj -> atoms[s][a].chain = g_malloc0 (this_proj -> csparam[5]*sizeof*this_proj -> atoms[s][a].chain);
126 for (j=0; j<this_proj -> csparam[5]; j++)
127 {
128 rings_ij = allocint(this_proj -> modelgl -> num_chains[s][j]);
129 m = 0;
130 for (k=0; k<this_proj -> modelgl -> num_chains[s][j]; k++)
131 {
132 for (l=0; l<j; l++)
133 {
134 if (this_proj -> modelgl -> all_chains[s][j][k][l] == a)
135 {
136 m ++;
137 rings_ij[m] = k;
138 break;
139 }
140 }
141 }
142 this_proj -> atoms[s][a].chain[j] = allocint(m + 1);
143 this_proj -> atoms[s][a].chain[j][0] = m;
144 for (k=0; k<m; k++) this_proj -> atoms[s][a].chain[j][k+1] = rings_ij[k];
145 g_free (rings_ij);
146 }
147 }
148 }
149 return OK;
150}
151
164int read_rings_chains_data (FILE * fp, glwin * view, int type, int rid, int size, int steps)
165{
166 int i, j, k;
167 int * tmpcoo, * tmpcoord;
168 if (! type)
169 {
170 if (fread (& view -> ring_max[rid], sizeof(int), 1, fp) != 1) return ERROR_RW;
171 if (view -> ring_max[rid])
172 {
173 view -> num_rings[rid] = allocdint (steps, size);
174 view -> show_rpoly[rid] = g_malloc0 (steps*sizeof*view -> show_rpoly[rid]);
175 view -> all_rings[rid] = g_malloc0 (steps*sizeof*view -> all_rings[rid]);
176 tmpcoo = allocint(size);
177 for (i=0; i<steps; i++)
178 {
179 if (fread (view -> num_rings[rid][i], sizeof(int), size, fp) != size) return ERROR_RW;
180 view -> all_rings[rid][i] = g_malloc0 (size*sizeof*view -> all_rings[rid][i]);
181 view -> show_rpoly[rid][i] = g_malloc0 (size*sizeof*view -> show_rpoly[rid][i]);
182 for (j=0; j<size; j++)
183 {
184 tmpcoo[j] += view -> num_rings[rid][i][j];
185 if (view -> num_rings[rid][i][j])
186 {
187 view -> all_rings[rid][i][j] = allocdint (view -> num_rings[rid][i][j], j+1);
188 view -> show_rpoly[rid][i][j] = allocbool (view -> num_rings[rid][i][j]);
189 if (fread (view -> show_rpoly[rid][i][j], sizeof(int), view -> num_rings[rid][i][j], fp) != view -> num_rings[rid][i][j]) return ERROR_RW;
190 for (k=0; k<view -> num_rings[rid][i][j]; k++)
191 {
192 if (fread (view -> all_rings[rid][i][j][k], sizeof(int), j+1, fp) != j+1) return ERROR_RW;
193 }
194 }
195 }
196 }
197 i = 0;
198 for (j=0; j<size; j++)
199 {
200 if (tmpcoo[j]) i++;
201 }
202
203 tmpcoord = allocint(i);
204 i = 0;
205 for (j=0; j<size; j++)
206 {
207 if (tmpcoo[j])
208 {
209 tmpcoord[i] = j+1;
210 i ++;
211 }
212 }
213 j = 4 + rid;
214 gboolean * show_rings = duplicate_bool(i, view -> anim -> last -> img -> show_coord[j]);
215 init_opengl_coords (4+rid, i, 1);
216 k = 0;
217 init_menurings_ (& j, & rid, & i, tmpcoord, & k);
218 g_free (tmpcoo);
219 g_free (tmpcoord);
220 view -> anim -> last -> img -> show_coord[j] = duplicate_bool(i, show_rings);
221 g_free (show_rings);
222 }
223 }
224 else
225 {
226 if (fread (& view -> chain_max, sizeof(int), 1, fp) != 1) return ERROR_RW;
227 if (view -> chain_max)
228 {
229 view -> num_chains = allocdint (steps, size);
230 view -> all_chains = g_malloc0 (steps*sizeof*view -> all_rings[rid]);
231 tmpcoo = allocint(size);
232 for (i=0; i<steps; i++)
233 {
234 if (fread (view -> num_chains[i], sizeof(int), size, fp) != size) return ERROR_RW;
235 view -> all_chains[i] = g_malloc0 (size*sizeof*view -> all_chains[i]);
236 for (j=0; j<size; j++)
237 {
238 tmpcoo[j] += view -> num_chains[i][j];
239 if (view -> num_chains[i][j])
240 {
241 view -> all_chains[i][j] = allocdint (view -> num_chains[i][j], j+1);
242 for (k=0; k<view -> num_chains[i][j]; k++)
243 {
244 if (fread (view -> all_chains[i][j][k], sizeof(int), j+1, fp) != j+1) return ERROR_RW;
245 }
246 }
247 }
248 }
249 i = 0;
250 for (j=0; j<size; j++)
251 {
252 if (tmpcoo[j]) i++;
253 }
254 tmpcoord = allocint(i);
255 i = 0;
256 for (j=0; j<size; j++)
257 {
258 if (tmpcoo[j])
259 {
260 tmpcoord[i] = j+1;
261 i ++;
262 }
263 }
264 j = 9;
265 k = 0;
266 gboolean * show_chains = duplicate_bool(i, view -> anim -> last -> img -> show_coord[j]);
267 init_opengl_coords (j, i, 1);
268 init_menurings_ (& j, & k , & i, tmpcoord, & k);
269 g_free (tmpcoo);
270 g_free (tmpcoord);
271 view -> anim -> last -> img -> show_coord[j] = duplicate_bool(i, show_chains);
272 g_free (show_chains);
273 }
274 }
275 return OK;
276}
277
287{
288 if (fread (& label -> position, sizeof(int), 1, fp) != 1) return ERROR_RW;
289 if (fread (& label -> render, sizeof(int), 1, fp) != 1) return ERROR_RW;
290 if (fread (& label -> scale, sizeof(int), 1, fp) != 1) return ERROR_RW;
291 if (fread (& label -> shift, sizeof(double), 3, fp) != 3) return ERROR_RW;
292 if (fread (& label -> n_colors, sizeof(int), 1, fp) != 1) return ERROR_RW;
293 if (label -> n_colors)
294 {
295 label -> color = g_malloc (label -> n_colors*sizeof*label -> color);
296 if (fread (label -> color, sizeof(ColRGBA), label -> n_colors, fp) != label -> n_colors) return ERROR_RW;
297 }
298 else if (label -> color)
299 {
300 g_free (label -> color);
301 label -> color = NULL;
302 }
303 label -> font = read_this_string (fp);
304 if (label -> font == NULL) return ERROR_RW;
305 return OK;
306}
307
316int read_this_box (FILE * fp, box * abc)
317{
318 if (fread (& abc -> box, sizeof(int), 1, fp) != 1) return ERROR_RW;
319 if (fread (& abc -> rad, sizeof(double), 1, fp) != 1) return ERROR_RW;
320 if (fread (& abc -> line, sizeof(double), 1, fp) != 1) return ERROR_RW;
321 if (fread (& abc -> color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
322 if (fread (abc -> extra_cell, sizeof(int), 3, fp) != 3) return ERROR_RW;
323 return OK;
324}
325
334int read_this_axis (FILE * fp, axis * xyz)
335{
336 if (fread (& xyz -> axis, sizeof(int), 1, fp) != 1) return ERROR_RW;
337 if (fread (& xyz -> rad, sizeof(double), 1, fp) != 1) return ERROR_RW;
338 if (fread (& xyz -> line, sizeof(double), 1, fp) != 1) return ERROR_RW;
339 if (fread (& xyz -> color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
340 if (fread (& xyz -> t_pos, sizeof(int), 1, fp) != 1) return ERROR_RW;
341 if (fread (& xyz -> length, sizeof(double), 1, fp) != 1) return ERROR_RW;
342 if (fread (xyz -> c_pos, sizeof(double), 3, fp) != 3) return ERROR_RW;
343 gboolean val;
344 int i;
345 if (fread (& val, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
346 if (val)
347 {
348 xyz -> color = g_malloc (3*sizeof*xyz -> color);
349 for (i=0; i<3; i++)
350 {
351 if (fread (& xyz -> color[i], sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
352 }
353 }
354 if (fread (& xyz -> labels, sizeof(int), 1, fp) != 1) return ERROR_RW;
355 for (i=0; i<3; i++)
356 {
357 xyz -> title[i] = read_this_string (fp);
358 if (xyz -> title[i] == NULL) return ERROR_RW;
359 }
360 return OK;
361}
362
363
374int read_opengl_image (FILE * fp, project * this_proj, image * img, int sid)
375{
376 int i, j, k, l, m, n;
377 gboolean val;
378
380 if (! old_la_bo_ax_gr)
381 {
382 if (fread (& img -> back -> gradient, sizeof(int), 1, fp) != 1) return ERROR_RW;
383 if (img -> back -> gradient)
384 {
385 if (fread (& img -> back -> direction, sizeof(int), 1, fp) != 1) return ERROR_RW;
386 if (fread (& img -> back -> position, sizeof(float), 1, fp) != 1) return ERROR_RW;
387 if (fread (img -> back -> gradient_color, sizeof(ColRGBA), 2, fp) != 2) return ERROR_RW;
388 }
389 else
390 {
391 if (fread (& img -> back -> color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
392 }
393 }
394 else
395 {
396 img -> back -> gradient = 0;
397 img -> back -> position = 0.5;
398 if (fread (& img -> back -> color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
399 }
400 if (fread (img -> color_map, sizeof(int), 2, fp) != 2) return ERROR_RW;
401 if (img -> color_map[0] > ATOM_MAPS-1)
402 {
403 img -> color_map[0] -= 10;
404 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
405 this_proj -> modelgl -> custom_map = allocate_color_map (j, this_proj);
406 this_proj -> modelgl -> custom_map -> points = j;
407 if (fread (& this_proj -> modelgl -> custom_map -> cmax, sizeof(int), 1, fp) != 1) return ERROR_RW;
408 if (fread (& this_proj -> modelgl -> custom_map -> cmin, sizeof(int), 1, fp) != 1) return ERROR_RW;
409 this_proj -> modelgl -> custom_map -> positions = allocfloat (j);
410 this_proj -> modelgl -> custom_map -> values = g_malloc (j*sizeof*this_proj -> modelgl -> custom_map -> values);
411 if (fread (this_proj -> modelgl -> custom_map -> positions, sizeof(float), j, fp) != j) return ERROR_RW;
412 if (fread (this_proj -> modelgl -> custom_map -> values, sizeof(ColRGBA), j, fp) != j) return ERROR_RW;
413 j = this_proj -> steps*this_proj -> natomes;
414 for (i=0; i<this_proj -> steps; i++)
415 {
416 if (fread (this_proj -> modelgl -> custom_map -> data[i], sizeof(float), this_proj -> natomes, fp) != this_proj -> natomes) return ERROR_RW;
417 }
418 setup_custom_color_map (NULL, this_proj, FALSE);
419 }
420
421 if (fread (& img -> cloned_poly, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
422
423 if (fread (img -> at_color, sizeof(ColRGBA), sid*2, fp) != sid*2) return ERROR_RW;
424 if (fread (img -> sphererad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
425 if (fread (img -> pointrad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
426 if (fread (img -> atomicrad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
427
428 for (i=0; i<sid*2; i++)
429 {
430 if (fread (img -> bondrad[i], sizeof(double), 2*sid, fp) != 2*sid) return ERROR_RW;
431 if (fread (img -> linerad[i], sizeof(double), 2*sid, fp) != 2*sid) return ERROR_RW;
432 }
433 if (fread (img -> radall, sizeof(double), 2, fp) != 2) return ERROR_RW;
434 if (fread (& img -> draw_clones, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
435 if (old_la_bo_ax_gr)
436 {
437 for (i=0; i<5; i++)
438 {
439 if (fread (& img -> labels[i].position, sizeof(int), 1, fp) != 1) return ERROR_RW;
440 }
441 for (i=0; i<5; i++)
442 {
443 if (fread (& img -> labels[i].render, sizeof(int), 1, fp) != 1) return ERROR_RW;
444 }
445 for (i=0; i<5; i++)
446 {
447 if (fread (& img -> labels[i].scale, sizeof(int), 1, fp) != 1) return ERROR_RW;
448 }
449 if (fread (img -> acl_format, sizeof(int), 2, fp) != 2) return ERROR_RW;
450 for (i=0; i<5; i++)
451 {
452 if (fread (img -> labels[i].shift, sizeof(double), 3, fp) != 3) return ERROR_RW;
453 if (fread (& val, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
454 if (val)
455 {
456 if (i < 2)
457 {
458 j = 2*sid;
459 }
460 else if (i == 2)
461 {
462 j = 3;
463 }
464 else
465 {
466 j = 1;
467 }
468 img -> labels[i].n_colors = j;
469 img -> labels[i].color = g_malloc0 (j*sizeof*img -> labels[i].color);
470 for (k=0; k<j; k++)
471 {
472 if (fread (& img -> labels[i].color[k], sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
473 }
474 }
475 else
476 {
477 img -> labels[i].n_colors = 0;
478 if (img -> labels[i].color)
479 {
480 g_free (img -> labels[i].color);
481 img -> labels[i].color = NULL;
482 }
483 }
484 img -> labels[i].font = read_this_string (fp);
485 if (img -> labels[i].font == NULL) return ERROR_RW;
486 }
487
488 if (fread (& img -> mtilt[0], sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
489 img -> mtilt[1] = img -> mtilt[0];
490 if (fread (& img -> mpattern[0], sizeof(int), 1, fp) != 1) return ERROR_RW;
491 img -> mpattern[1] = img -> mpattern[0];
492 if (fread (& img -> mfactor[0], sizeof(int), 1, fp) != 1) return ERROR_RW;
493 img -> mfactor[1] = img -> mfactor[0];
494 if (fread (& img -> mwidth[0], sizeof(double), 1, fp) != 1) return ERROR_RW;
495 img -> mwidth[1] = img -> mwidth[0];
496 }
497 else
498 {
499 for (i=0; i<5; i++)
500 {
501 if (read_this_image_label (fp, & img -> labels[i])) return ERROR_RW;
502 }
503 if (fread (img -> acl_format, sizeof(int), 2, fp) != 2) return ERROR_RW;
504 if (fread (img -> mtilt, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
505 if (fread (img -> mpattern, sizeof(int), 2, fp) != 2) return ERROR_RW;
506 if (fread (img -> mfactor, sizeof(int), 2, fp) != 2) return ERROR_RW;
507 if (fread (img -> mwidth, sizeof(double), 2, fp) != 2) return ERROR_RW;
508
509 }
510 if (fread (& img -> m_is_pressed, sizeof(double), 1, fp) != 1) return ERROR_RW;
511
512 // Model box and axis
513 if (old_la_bo_ax_gr)
514 {
515 if (fread (& img -> abc -> box, sizeof(int), 1, fp) != 1) return ERROR_RW;
516 if (fread (& img -> xyz -> axis, sizeof(int), 1, fp) != 1) return ERROR_RW;
517 if (fread (& img -> abc -> rad, sizeof(double), 1, fp) != 1) return ERROR_RW;
518 if (fread (& img -> xyz -> rad, sizeof(double), 1, fp) != 1) return ERROR_RW;
519 if (fread (& img -> abc -> line, sizeof(double), 1, fp) != 1) return ERROR_RW;
520 if (fread (& img -> xyz -> line, sizeof(double), 1, fp) != 1) return ERROR_RW;
521 if (fread (& img -> abc -> color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
522 if (fread (img -> abc -> extra_cell, sizeof(int), 3, fp) != 3) return ERROR_RW;
523 // Axis
524 if (fread (& img -> xyz -> t_pos, sizeof(int), 1, fp) != 1) return ERROR_RW;
525 if (fread (& img -> xyz -> length, sizeof(double), 1, fp) != 1) return ERROR_RW;
526 if (fread (img -> xyz -> c_pos, sizeof(double), 3, fp) != 3) return ERROR_RW;
527
528 if (fread (& val, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
529 if (val)
530 {
531 img -> xyz -> color = g_malloc (3*sizeof*img -> xyz -> color);
532 for (i=0; i<3; i++)
533 {
534 if (fread (& img -> xyz -> color[i], sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
535 }
536 }
537 if (fread (& img -> xyz -> labels, sizeof(int), 1, fp) != 1) return ERROR_RW;
538 for (i=0; i<3; i++)
539 {
540 img -> xyz -> title[i] = read_this_string (fp);
541 if (img -> xyz -> title[i] == NULL) return ERROR_RW;
542 }
543 }
544 else
545 {
546 // Model box
547 if (read_this_box (fp, img -> abc)) return ERROR_RW;
548 // Axis
549 if (read_this_axis (fp, img -> xyz)) return ERROR_RW;
550 }
551 // OpenGL
552 if (fread (& img -> p_depth, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
553 if (fread (& img -> gnear, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
554 if (fread (& img -> gfar, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
555 if (fread (& img -> gleft, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
556 if (fread (& img -> gright, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
557 if (fread (& img -> gtop, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
558 if (fread (& img -> gbottom, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
559 if (fread (& img -> rotation_quaternion, sizeof(vec4_t), 1, fp) != 1) return ERROR_RW;
560 if (fread (& img -> rotation_mode, sizeof(int), 1, fp) != 1) return ERROR_RW;
561 if (fread (& img -> zoom, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
562 if (fread (img -> c_shift, sizeof(GLdouble), 2, fp) != 2) return ERROR_RW;
563 if (fread (& img -> style, sizeof(int), 1, fp) != 1) return ERROR_RW;
564 if (fread (& img -> quality, sizeof(GLint), 1, fp) != 1) return ERROR_RW;
565 if (fread (& img -> render, sizeof(GLint), 1, fp) != 1) return ERROR_RW;
566 if (fread (& img -> l_ghtning.lights, sizeof(int), 1, fp) != 1) return ERROR_RW;
567 if (img -> l_ghtning.spot != NULL)
568 {
569 g_free (img -> l_ghtning.spot);
570 img -> l_ghtning.spot = NULL;
571 }
572 img -> l_ghtning.spot = g_malloc0 (img -> l_ghtning.lights*sizeof*img -> l_ghtning.spot);
573 for (i=0; i<img -> l_ghtning.lights; i++)
574 {
575 if (fread (& img -> l_ghtning.spot[i].type, sizeof(int), 1, fp) != 1) return ERROR_RW;
576 if (fread (& img -> l_ghtning.spot[i].fix, sizeof(int), 1, fp) != 1) return ERROR_RW;
577 if (fread (& img -> l_ghtning.spot[i].show, sizeof(int), 1, fp) != 1) return ERROR_RW;
578 if (fread (& img -> l_ghtning.spot[i].position, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
579 if (fread (& img -> l_ghtning.spot[i].direction, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
580 if (fread (& img -> l_ghtning.spot[i].intensity, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
581 if (fread (& img -> l_ghtning.spot[i].attenuation, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
582 if (fread (& img -> l_ghtning.spot[i].spot_data, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
583 }
584 if (fread (& img -> m_terial.predefine, sizeof(int), 1, fp) != 1) return ERROR_RW;
585 if (fread (& img -> m_terial.albedo, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
586 if (fread (img -> m_terial.param, sizeof(GLfloat), 6, fp) != 6) return ERROR_RW;
587 if (fread (& img -> f_g.mode, sizeof(int), 1, fp) != 1) return ERROR_RW;
588 if (fread (& img -> f_g.based, sizeof(int), 1, fp) != 1) return ERROR_RW;
589 if (fread (& img -> f_g.density, sizeof(float), 1, fp) != 1) return ERROR_RW;
590 if (fread (& img -> f_g.depth, sizeof(float), 2, fp) != 2) return ERROR_RW;
591 if (fread (& img -> f_g.color, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
592
593 if (fread (& img -> filled_type, sizeof(int), 1, fp) != 1) return ERROR_RW;
594 if (fread (& img -> step, sizeof(int), 1, fp) != 1) return ERROR_RW;
595 if (fread (& img -> rep, sizeof(int), 1, fp) != 1) return ERROR_RW;
596
597 for (i=0; i<4; i++)
598 {
599 if (i < 2)
600 {
601 for (j=0; j<sid; j++)
602 {
603 if (fread (img -> spcolor[i][j], sizeof(ColRGBA), this_proj -> coord -> ntg[i][j], fp) != this_proj -> coord -> ntg[i][j]) return ERROR_RW;
604 }
605 }
606 else
607 {
608 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
609 if (j)
610 {
611 if (j != this_proj -> coord -> totcoord[i])
612 {
613 g_warning ("READING OPENGL:: this should not happen !\n i= %d, totcoord[i]= %d, j= %d", i, this_proj -> coord -> totcoord[i], j);
614 return ERROR_RW;
615 }
616 if (fread (img -> spcolor[i][0], sizeof(ColRGBA), this_proj -> coord -> totcoord[i], fp) != this_proj -> coord -> totcoord[i]) return ERROR_RW;
617 }
618 }
619 }
620 active_glwin = this_proj -> modelgl;
621 active_image = this_proj -> modelgl -> anim -> last -> img;
622 active_coord = this_proj -> coord;
623 if (fread (& this_proj -> modelgl -> rings, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
624 if (this_proj -> modelgl -> rings)
625 {
626 for (i=0; i<5; i++)
627 {
628 if (read_rings_chains_data (fp, this_proj -> modelgl, 0, i, this_proj -> rsparam[i][1], this_proj -> steps) != OK) return ERROR_RINGS;
629 }
630 }
631 if (fread (& this_proj -> modelgl -> chains, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
632 if (this_proj -> modelgl -> chains)
633 {
634 if (read_rings_chains_data (fp, this_proj -> modelgl, 1, 0, this_proj -> csparam[5], this_proj -> steps) != OK) return ERROR_CHAINS;
635 }
636
637 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
638 if (i)
639 {
640 this_proj -> modelgl -> create_shaders[VOLMS] = TRUE;
641 this_proj -> modelgl -> volumes = TRUE;
642 for (i=0; i<FILLED_STYLES; i++)
643 {
644 this_proj -> modelgl -> atoms_volume[i] = allocdouble (this_proj -> steps);
645 this_proj -> modelgl -> atoms_ppvolume[i] = allocdouble (this_proj -> steps);
646 if (fread (this_proj -> modelgl -> atoms_volume[i], sizeof(double), this_proj -> steps, fp) != this_proj -> steps) return ERROR_RW;
647 if (fread (this_proj -> modelgl -> atoms_ppvolume[i], sizeof(double), this_proj -> steps, fp) != this_proj -> steps) return ERROR_RW;
648 this_proj -> modelgl -> volume_box[i] = allocddouble (this_proj -> steps, 9);
649 for (j=0; j<this_proj -> steps; j++)
650 {
651 if (fread (this_proj -> modelgl -> volume_box[i][j], sizeof(double), 9, fp) != 9) return ERROR_RW;
652 }
653 }
654 if (fread (this_proj -> modelgl -> comp_vol, sizeof(gboolean), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
655 if (fread (active_image -> show_vol, sizeof(gboolean), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
656 if (fread (active_image -> vol_col, sizeof(ColRGBA), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
657 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
658 if (i)
659 {
660 for (j=0; j<FILLED_STYLES; j++)
661 {
662 if (fread (& k, sizeof(int), 1, fp) != 1) return ERROR_RW;
663 if (k)
664 {
665 this_proj -> modelgl -> frag_mol_volume[0][j] = allocddouble (this_proj -> steps, i);
666 this_proj -> modelgl -> frag_mol_ppvolume[0][j] = allocddouble (this_proj -> steps, i);
667 this_proj -> modelgl -> fm_comp_vol[0][j] = allocdbool (this_proj -> steps, i);
668 active_image -> fm_show_vol[0][j] = allocbool (i);
669 this_proj -> modelgl -> frag_box[j] = alloctdouble (this_proj -> steps, i, 9);
670 for (l=0; l<k; l++)
671 {
672 if (fread (& m, sizeof(int), 1, fp) != 1) return ERROR_RW;
673 if (fread (& n, sizeof(int), 1, fp) != 1) return ERROR_RW;
674 if (fread (& this_proj -> modelgl -> frag_mol_ppvolume[0][j][m][n], sizeof(double), 1, fp) != 1) return ERROR_RW;
675 if (fread (this_proj -> modelgl -> frag_box[j][m][n], sizeof(double), 9, fp) != 9) return ERROR_RW;
676 this_proj -> modelgl -> fm_comp_vol[0][j][m][n] = TRUE;
677 }
678 active_image -> fm_vol_col[0][j] = g_malloc0 (i*sizeof*active_image -> fm_vol_col[0][j]);
679 if (fread (active_image -> fm_show_vol[0][j], sizeof(gboolean), i, fp) != i) return ERROR_RW;
680 if (fread (active_image -> fm_vol_col[0][j], sizeof(ColRGBA), i, fp) != i) return ERROR_RW;
681 }
682 }
683 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
684 if (i)
685 {
686 for (j=0; j<FILLED_STYLES; j++)
687 {
688 if (fread (& k, sizeof(int), 1, fp) != 1) return ERROR_RW;
689 if (k)
690 {
691 this_proj -> modelgl -> frag_mol_volume[1][j] = allocddouble (this_proj -> steps, i);
692 this_proj -> modelgl -> frag_mol_ppvolume[1][j] = allocddouble (this_proj -> steps, i);
693 this_proj -> modelgl -> fm_comp_vol[1][j] = allocdbool (this_proj -> steps, i);
694 active_image -> fm_show_vol[1][j] = allocbool (i);
695 for (l=0; l<k; l++)
696 {
697 if (fread (& m, sizeof(int), 1, fp) != 1) return ERROR_RW;
698 if (fread (& n, sizeof(int), 1, fp) != 1) return ERROR_RW;
699 if (fread (& this_proj -> modelgl -> frag_mol_ppvolume[1][j][m][n], sizeof(double), 1, fp) != 1) return ERROR_RW;
700 this_proj -> modelgl -> fm_comp_vol[1][j][m][n] = TRUE;
701 }
702 if (fread (active_image -> fm_show_vol[1][j], sizeof(gboolean), i, fp) != i) return ERROR_RW;
703 active_image -> fm_vol_col[1][j] = g_malloc0 (i*sizeof*active_image -> fm_vol_col[1][j]);
704 if (fread (active_image -> fm_vol_col[1][j], sizeof(ColRGBA), i, fp) != i) return ERROR_RW;
705 }
706 }
707 }
708 }
709 }
710
711 for (i=0; i<this_proj -> steps; i++)
712 {
713 for (j=0; j< this_proj -> natomes; j++)
714 {
715 if (read_atom_b (fp, this_proj, i, j) != OK) return ERROR_ATOM_B;
716 }
717 }
718 // Finally selection lists, bonds, angles and dihedrals
719 for (i=0; i<2; i++)
720 {
721 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
722 if (j)
723 {
724 for (k=0; k<j; k++)
725 {
726 if (fread (& l, sizeof(int), 1, fp) != 1) return ERROR_RW;
727 process_selected_atom (this_proj, this_proj -> modelgl, l, 0, 0, i);
728 }
729 update_all_selections (this_proj -> modelgl, i);
730 if (img -> selected[i] -> selected >= 2 && img -> selected[i] -> selected <= 20)
731 {
732 j = num_bonds (img -> selected[i] -> selected);
733 if (fread (img -> selected[i] -> selected_bonds, sizeof(int), j, fp) != j) return ERROR_RW;
734 if (img -> selected[i] -> selected >= 3)
735 {
736 j = num_angles (img -> selected[i] -> selected);
737 if (fread (img -> selected[i] -> selected_angles, sizeof(int), j, fp) != j) return ERROR_RW;
738 if (img -> selected[i] -> selected >= 4 && img -> selected[i] -> selected <= 10)
739 {
740 j = num_dihedrals (img -> selected[i] -> selected);
741 if (fread (img -> selected[i] -> selected_dihedrals, sizeof(int), j, fp) != j) return ERROR_RW;
742 }
743 }
744 }
745 }
746 }
747 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
748#ifdef GTK3
749 // GTK3 Menu Action To Check
750 for (i=0; i<2; i++)
751 {
752 for (j=0; j<sid; j++)
753 {
754 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_spec[i][j]))
755 {
756 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j]) != img -> show_atom[i][j])
757 {
758 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j], img -> show_atom[i][j]);
759 }
760 }
761 }
762 }
763 for (i=0; i<10; i++)
764 {
765 if (this_proj -> modelgl -> ogl_poly[0][i] != NULL)
766 {
767 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
768 {
769 if (i < 2 || (i > 3 && i < 9))
770 {
771 if (this_proj -> modelgl -> ogl_poly[0][i][j] != NULL)
772 {
773 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_poly[0][i][j]))
774 {
775 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j]) != img -> show_poly[i][j])
776 {
777 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j], img -> show_poly[i][j]);
778 }
779 }
780 }
781 }
782 }
783 }
784 if (this_proj -> modelgl -> ogl_geom[0][i] != NULL)
785 {
786 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
787 {
788 if (this_proj -> modelgl -> ogl_geom[0][i][j] != NULL)
789 {
790 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_geom[0][i][j]))
791 {
792 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j]) != img -> show_coord[i][j])
793 {
794 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j], img -> show_coord[i][j]);
795 }
796 }
797 }
798 }
799 }
800 }
801 show_the_widgets (this_proj -> modelgl -> ogl_coord[0]);
802 update_all_menus (this_proj -> modelgl, this_proj -> natomes);
803#endif
804 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
805#ifdef GTK4
806 for (i=0; i<2; i++)
807 {
808 for (j=0; j<sid; j++)
809 {
810 if (! img -> show_atom[i][j])
811 {
812 show_hide_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[i][j]);
813 }
814 }
815 }
816 for (i=0; i<10; i++)
817 {
818 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
819 {
820 if (i < 2 || (i > 3 && i < 9))
821 {
822 if (img -> show_poly[i][j])
823 {
824 show_hide_poly (NULL, NULL, & this_proj -> modelgl -> gcid[i][j][i]);
825 }
826 }
827 }
828 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
829 {
830 if (! img -> show_coord[i][j])
831 {
832 show_hide_coord (NULL, NULL, & this_proj -> modelgl -> gcid[i][j][i]);
833 }
834 }
835 }
836 update_menu_bar (this_proj -> modelgl);
837#endif
838 return OK;
839}
int num_bonds(int i)
number of distinct pair(s) of atoms in selection
Definition selection.c:183
int num_dihedrals(int i)
number of distinct quadruplet(s) of atoms in selection
Definition selection.c:207
int num_angles(int i)
number of distinct triplet(s) of atoms in selection
Definition selection.c:195
integer function chains()
Definition chains.F90:54
color colorp[64]
double scale(double axe)
find appropriate major tick spacing based on axis length
Definition curve.c:204
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
int * shift
Definition d_measures.c:72
int atoms[NUM_STYLES][2]
float val
Definition dlp_init.c:117
dint rep
Definition dlp_edit.c:2227
gboolean * duplicate_bool(int num, gboolean *old_val)
copy a list of gboolean
Definition global.c:576
FILE * fp
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:254
double ** allocddouble(int xal, int yal)
allocate a double ** pointer
Definition global.c:475
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:459
double *** alloctdouble(int xal, int yal, int zal)
allocate a double *** pointer
Definition global.c:498
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
gboolean ** allocdbool(int xal, int yal)
allocate a gboolean ** pointer
Definition global.c:270
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
Global variable declarations Global convenience function declarations Global data structure defin...
#define ERROR_CHAINS
Definition global.h:292
glwin * active_glwin
Definition project.c:53
G_MODULE_EXPORT void show_hide_poly(GtkWidget *widg, gpointer data)
show / hide polyhedra callback - GTK3
Definition m_poly.c:79
coord_info * active_coord
Definition project.c:49
#define ERROR_ATOM_B
Definition global.h:287
#define ERROR_RW
Definition global.h:282
G_MODULE_EXPORT void show_hide_coord(GtkWidget *widg, gpointer data)
show/hide coordination callback GTK3
Definition m_coord.c:106
#define ERROR_RINGS
Definition global.h:291
#define OK
Definition global.h:281
G_MODULE_EXPORT void show_hide_atoms(GtkWidget *widg, gpointer data)
image * active_image
Definition project.c:52
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1017
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void update_all_menus(glwin *view, int nats)
update all menus of the OpenGL window
Definition glwindow.c:337
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1039
render
Definition glview.h:191
int step
Definition ogl_draw.c:74
labels
Definition glview.h:223
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
#define FILLED_STYLES
Definition glwin.h:106
@ VOLMS
Definition glwin.h:102
#define ATOM_MAPS
Definition glwin.h:61
void init_opengl_coords(int id, int nt, int init)
initialize data to store the coordination data
Definition initcoord.c:658
void init_menurings_(int *coo, int *ids, int *ngsp, int coordt[*ngsp], int *init)
getting rings statistics data from Fortran90, and related GTK3 menu elements creation
Definition initcoord.c:569
Function declarations to handle the atomic coordination data.
gboolean setup_custom_color_map(float *data, project *this_proj, gboolean init)
prepare the custom color map data
Definition m_map.c:211
colormap * allocate_color_map(int pts, project *this_proj)
allocate custom color map data
Definition m_map.c:188
G_MODULE_EXPORT void cloned_poly(GtkWidget *widg, gpointer data)
cloned polyehdra callback - GTK3
Definition m_poly.c:181
position
Definition m_proj.c:48
double z
Definition ogl_draw.c:61
double y
Definition ogl_draw.c:61
double x
Definition ogl_draw.c:61
gchar * read_this_string(FILE *fp)
is there a string to read in this file ? yes do it
Definition open_p.c:98
background default_background
void duplicate_background_data(background *new_back, background *old_back)
duplicate background data structure
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int read_this_image_label(FILE *fp, screen_label *label)
gboolean old_la_bo_ax_gr
Definition open_p.c:68
int read_this_box(FILE *fp, box *abc)
read OpenGL image box properties to file
int read_rings_chains_data(FILE *fp, glwin *view, int type, int rid, int size, int steps)
read rings and chains statistics data from file
int read_atom_b(FILE *fp, project *this_proj, int s, int a)
read atom properties from file (b)
Definition read_opengl.c:83
int read_opengl_image(FILE *fp, project *this_proj, image *img, int sid)
read OpenGL image properties from file
int read_atom_a(FILE *fp, project *this_proj, int s, int a)
read atom properties from file (a)
Definition read_opengl.c:61
int read_this_axis(FILE *fp, axis *xyz)
read OpenGL image axis properties to file
Definition glwin.h:333
Definition glwin.h:351
Definition glwin.h:965
Definition glwin.h:365
int a
Definition tab-1.c:95
GtkWidget * img
Definition workspace.c:70