atomes 1.1.14
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-2024 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_opengl_image (FILE * fp, project * this_proj, image * img, int sid);
37
38*/
39
40#include "global.h"
41#include "project.h"
42#include "glview.h"
43#include "initcoord.h"
44
55int read_atom_a (FILE * fp, project * this_proj, int s, int a)
56{
57 if (fread (& this_proj -> atoms[s][a].id, sizeof(int), 1, fp) != 1) return ERROR_RW;
58 if (fread (& this_proj -> atoms[s][a].sp, sizeof(int), 1, fp) != 1) return ERROR_RW;
59 if (fread (& this_proj -> atoms[s][a].x, sizeof(double), 1, fp) != 1) return ERROR_RW;
60 if (fread (& this_proj -> atoms[s][a].y, sizeof(double), 1, fp) != 1) return ERROR_RW;
61 if (fread (& this_proj -> atoms[s][a].z, sizeof(double), 1, fp) != 1) return ERROR_RW;
62 //g_debug ("Reading:: step= %d, at= %d, sp[%d]= %d, x[%d]= %f, y[%d]= %f, z[%d]= %f",
63 // 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);
64 return OK;
65}
66
77int read_atom_b (FILE * fp, project * this_proj, int s, int a)
78{
79 if (fread (this_proj -> atoms[s][a].show, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
80 if (fread (this_proj -> atoms[s][a].label, sizeof(gboolean), 2, fp) != 2) return ERROR_RW;
81 if (fread (& this_proj -> atoms[s][a].style, sizeof(int), 1, fp) != 1) return ERROR_RW;
82 int i, j, k, l, m;
83 if (this_proj -> modelgl -> rings)
84 {
85 for (i=0; i<5; i++)
86 {
87 if (this_proj -> modelgl -> ring_max[i])
88 {
89 this_proj -> atoms[s][a].rings[i] = g_malloc0 (this_proj -> rsparam[i][1]*sizeof*this_proj -> atoms[s][a].rings[i]);
90 for (j=0; j<this_proj -> rsparam[i][1]; j++)
91 {
92 m = 0;
93 for (k=0; k<this_proj -> modelgl -> num_rings[i][s][j]; k++)
94 {
95 for (l=0; l<j+1; l++) if (this_proj -> modelgl -> all_rings[i][s][j][k][l] == a) m ++;
96 }
97 this_proj -> atoms[s][a].rings[i][j] = allocint(m + 1);
98 this_proj -> atoms[s][a].rings[i][j][0] = m;
99 m = 1;
100 for (k=0; k<this_proj -> modelgl -> num_rings[i][s][j]; k++)
101 {
102 for (l=0; l<j; l++)
103 {
104 if (this_proj -> modelgl -> all_rings[i][s][j][k][l] == a)
105 {
106 this_proj -> atoms[s][a].rings[i][j][m] = k;
107 m ++;
108 break;
109 }
110 }
111 }
112 }
113 }
114 }
115 }
116 if (this_proj -> modelgl -> chains)
117 {
118 if (this_proj -> modelgl -> chain_max)
119 {
120 this_proj -> atoms[s][a].chain = g_malloc0 (this_proj -> csparam[5]*sizeof*this_proj -> atoms[s][a].chain);
121 for (j=0; j<this_proj -> csparam[5]; j++)
122 {
123 m = 0;
124 for (k=0; k<this_proj -> modelgl -> num_chains[s][j]; k++)
125 {
126 for (l=0; l<j; l++) if (this_proj -> modelgl -> all_chains[s][j][k][l] == a) m ++;
127 }
128 this_proj -> atoms[s][a].chain[j] = allocint(m + 1);
129 this_proj -> atoms[s][a].chain[j][0] = m;
130 m = 1;
131 for (k=0; k<this_proj -> modelgl -> num_chains[s][j]; k++)
132 {
133 for (l=0; l<j; l++)
134 {
135 if (this_proj -> modelgl -> all_chains[s][j][k][l] == a)
136 {
137 this_proj -> atoms[s][a].chain[j][m] = k;
138 m ++;
139 }
140 }
141 }
142 }
143 }
144 }
145 return OK;
146}
147
160int read_rings_chains_data (FILE * fp, glwin * view, int type, int rid, int size, int steps)
161{
162 int i, j, k;
163 int * tmpcoo, * tmpcoord;
164 if (! type)
165 {
166 if (fread (& view -> ring_max[rid], sizeof(int), 1, fp) != 1) return ERROR_RW;
167 if (view -> ring_max[rid])
168 {
169 view -> num_rings[rid] = allocdint (steps, size);
170 view -> show_rpoly[rid] = g_malloc0 (steps*sizeof*view -> show_rpoly[rid]);
171 view -> all_rings[rid] = g_malloc0 (steps*sizeof*view -> all_rings[rid]);
172 tmpcoo = allocint(size);
173 for (i=0; i<steps; i++)
174 {
175 if (fread (view -> num_rings[rid][i], sizeof(int), size, fp) != size) return ERROR_RW;
176 view -> all_rings[rid][i] = g_malloc0 (size*sizeof*view -> all_rings[rid][i]);
177 view -> show_rpoly[rid][i] = g_malloc0 (size*sizeof*view -> show_rpoly[rid][i]);
178 for (j=0; j<size; j++)
179 {
180 tmpcoo[j] += view -> num_rings[rid][i][j];
181 if (view -> num_rings[rid][i][j])
182 {
183 view -> all_rings[rid][i][j] = allocdint (view -> num_rings[rid][i][j], j+1);
184 view -> show_rpoly[rid][i][j] = allocbool (view -> num_rings[rid][i][j]);
185 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;
186 for (k=0; k<view -> num_rings[rid][i][j]; k++)
187 {
188 if (fread (view -> all_rings[rid][i][j][k], sizeof(int), j+1, fp) != j+1) return ERROR_RW;
189 }
190 }
191 }
192 }
193 i = 0;
194 for (j=0; j<size; j++)
195 {
196 if (tmpcoo[j]) i++;
197 }
198
199 tmpcoord = allocint(i);
200 i = 0;
201 for (j=0; j<size; j++)
202 {
203 if (tmpcoo[j])
204 {
205 tmpcoord[i] = j+1;
206 i ++;
207 }
208 }
209 j = 4 + rid;
210 gboolean * show_rings = duplicate_bool(i, view -> anim -> last -> img -> show_coord[j]);
211 init_opengl_coords (4+rid, i, 1);
212 k = 0;
213 init_menurings_ (& j, & rid, & i, tmpcoord, & k);
214 g_free (tmpcoo);
215 g_free (tmpcoord);
216 view -> anim -> last -> img -> show_coord[j] = duplicate_bool(i, show_rings);
217 g_free (show_rings);
218 }
219 }
220 else
221 {
222 if (fread (& view -> chain_max, sizeof(int), 1, fp) != 1) return ERROR_RW;
223 if (view -> chain_max)
224 {
225 view -> num_chains = allocdint (steps, size);
226 view -> all_chains = g_malloc0 (steps*sizeof*view -> all_rings[rid]);
227 tmpcoo = allocint(size);
228 for (i=0; i<steps; i++)
229 {
230 if (fread (view -> num_chains[i], sizeof(int), size, fp) != size) return ERROR_RW;
231 view -> all_chains[i] = g_malloc0 (size*sizeof*view -> all_chains[i]);
232 for (j=0; j<size; j++)
233 {
234 tmpcoo[j] += view -> num_chains[i][j];
235 if (view -> num_chains[i][j])
236 {
237 view -> all_chains[i][j] = allocdint (view -> num_chains[i][j], j+1);
238 for (k=0; k<view -> num_chains[i][j]; k++)
239 {
240 if (fread (view -> all_chains[i][j][k], sizeof(int), j+1, fp) != j+1) return ERROR_RW;
241 }
242 }
243 }
244 }
245 i = 0;
246 for (j=0; j<size; j++)
247 {
248 if (tmpcoo[j]) i++;
249 }
250 tmpcoord = allocint(i);
251 i = 0;
252 for (j=0; j<size; j++)
253 {
254 if (tmpcoo[j])
255 {
256 tmpcoord[i] = j+1;
257 i ++;
258 }
259 }
260 j = 9;
261 k = 0;
262 gboolean * show_chains = duplicate_bool(i, view -> anim -> last -> img -> show_coord[j]);
263 init_opengl_coords (j, i, 1);
264 init_menurings_ (& j, & k , & i, tmpcoord, & k);
265 g_free (tmpcoo);
266 g_free (tmpcoord);
267 view -> anim -> last -> img -> show_coord[j] = duplicate_bool(i, show_chains);
268 g_free (show_chains);
269 }
270 }
271 return OK;
272}
273
284int read_opengl_image (FILE * fp, project * this_proj, image * img, int sid)
285{
286 int i, j, k, l, m, n;
287 gboolean val;
288 if (fread (& img -> backcolor, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
289 if (fread (img -> color_map, sizeof(int), 2, fp) != 2) return ERROR_RW;
290 if (img -> color_map[0] > ATOM_MAPS-1)
291 {
292 img -> color_map[0] -= 10;
293 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
294 this_proj -> modelgl -> custom_map = allocate_color_map (j, this_proj);
295 this_proj -> modelgl -> custom_map -> points = j;
296 if (fread (& this_proj -> modelgl -> custom_map -> cmax, sizeof(int), 1, fp) != 1) return ERROR_RW;
297 if (fread (& this_proj -> modelgl -> custom_map -> cmin, sizeof(int), 1, fp) != 1) return ERROR_RW;
298 this_proj -> modelgl -> custom_map -> positions = allocfloat (j);
299 this_proj -> modelgl -> custom_map -> values = g_malloc (j*sizeof*this_proj -> modelgl -> custom_map -> values);
300 if (fread (this_proj -> modelgl -> custom_map -> positions, sizeof(float), j, fp) != j) return ERROR_RW;
301 if (fread (this_proj -> modelgl -> custom_map -> values, sizeof(ColRGBA), j, fp) != j) return ERROR_RW;
302 j = this_proj -> steps*this_proj -> natomes;
303 for (i=0; i<this_proj -> steps; i++)
304 {
305 if (fread (this_proj -> modelgl -> custom_map -> data[i], sizeof(float), this_proj -> natomes, fp) != this_proj -> natomes) return ERROR_RW;
306 }
307 setup_custom_color_map (NULL, this_proj, FALSE);
308 }
309
310 if (fread (& img -> cloned_poly, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
311
312 if (fread (img -> at_color, sizeof(ColRGBA), sid*2, fp) != sid*2) return ERROR_RW;
313 if (fread (img -> sphererad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
314 if (fread (img -> pointrad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
315 if (fread (img -> atomicrad, sizeof(double), sid*2, fp) != sid*2) return ERROR_RW;
316
317 for (i=0; i<sid*2; i++)
318 {
319 if (fread (img -> bondrad[i], sizeof(double), 2*sid, fp) != 2*sid) return ERROR_RW;
320 if (fread (img -> linerad[i], sizeof(double), 2*sid, fp) != 2*sid) return ERROR_RW;
321 }
322 if (fread (img -> radall, sizeof(double), 2, fp) != 2) return ERROR_RW;
323 if (fread (& img -> draw_clones, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
324 if (fread (img -> labels_position, sizeof(int), 5, fp) != 5) return ERROR_RW;
325 if (fread (img -> labels_render, sizeof(int), 5, fp) != 5) return ERROR_RW;
326 if (fread (img -> labels_scale, sizeof(int), 5, fp) != 5) return ERROR_RW;
327 if (fread (img -> labels_format, sizeof(int), 2, fp) != 2) return ERROR_RW;
328 for (i=0; i<5; i++)
329 {
330 if (fread (img -> labels_shift[i], sizeof(double), 3, fp) != 3) return ERROR_RW;
331 if (fread (& val, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
332 if (val)
333 {
334 if (i < 2)
335 {
336 j = 2*sid;
337 }
338 else if (i == 2)
339 {
340 j = 3;
341 }
342 else
343 {
344 j = 1;
345 }
346 img -> labels_color[i] = g_malloc (j*sizeof*img -> labels_color[i]);
347 for (k=0; k<j; k++)
348 {
349 if (fread (& img -> labels_color[i][k], sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
350 }
351 }
352 img -> labels_font[i] = read_this_string (fp);
353 if (img -> labels_font[i] == NULL) return ERROR_RW;
354 }
355
356 // Measures
357 if (fread (& img -> mtilt, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
358 if (fread (& img -> mpattern, sizeof(int), 1, fp) != 1) return ERROR_RW;
359 if (fread (& img -> mfactor, sizeof(int), 1, fp) != 1) return ERROR_RW;
360 if (fread (& img -> mwidth, sizeof(double), 1, fp) != 1) return ERROR_RW;
361 if (fread (& img -> m_is_pressed, sizeof(double), 1, fp) != 1) return ERROR_RW;
362
363 // Model box and axis
364 if (fread (img -> box_axis, sizeof(int), 2, fp) != 2) return ERROR_RW;
365 if (fread (img -> box_axis_rad, sizeof(double), 2, fp) != 2) return ERROR_RW;
366 if (fread (img -> box_axis_line, sizeof(double), 2, fp) != 2) return ERROR_RW;
367 if (fread (& img -> box_color, sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
368 if (fread (img -> extra_cell, sizeof(int), 3, fp) != 3) return ERROR_RW;
369
370 // Axis
371 if (fread (& img -> axispos, sizeof(int), 1, fp) != 1) return ERROR_RW;
372 if (fread (& img -> axis_length, sizeof(double), 1, fp) != 1) return ERROR_RW;
373 if (fread (img -> axis_pos, sizeof(double), 3, fp) != 3) return ERROR_RW;
374
375 if (fread (& val, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
376 if (val)
377 {
378 img -> axis_color = g_malloc (3*sizeof*img -> axis_color);
379 for (i=0; i<3; i++)
380 {
381 if (fread (& img -> axis_color[i], sizeof(ColRGBA), 1, fp) != 1) return ERROR_RW;
382 }
383 }
384 if (fread (& img -> axis_labels, sizeof(int), 1, fp) != 1) return ERROR_RW;
385 for (i=0; i<3; i++)
386 {
388 if (img -> axis_title[i] == NULL) return ERROR_RW;
389 }
390 // OpenGL
391 if (fread (& img -> p_depth, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
392 if (fread (& img -> gnear, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
393 if (fread (& img -> gfar, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
394 if (fread (& img -> gleft, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
395 if (fread (& img -> gright, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
396 if (fread (& img -> gtop, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
397 if (fread (& img -> gbottom, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
398 if (fread (& img -> rotation_quaternion, sizeof(vec4_t), 1, fp) != 1) return ERROR_RW;
399 if (fread (& img -> rotation_mode, sizeof(int), 1, fp) != 1) return ERROR_RW;
400 if (fread (& img -> zoom, sizeof(GLdouble), 1, fp) != 1) return ERROR_RW;
401 if (fread (img -> c_shift, sizeof(GLdouble), 2, fp) != 2) return ERROR_RW;
402 if (fread (& img -> style, sizeof(int), 1, fp) != 1) return ERROR_RW;
403 if (fread (& img -> quality, sizeof(GLint), 1, fp) != 1) return ERROR_RW;
404 if (fread (& img -> render, sizeof(GLint), 1, fp) != 1) return ERROR_RW;
405 if (fread (& img -> lights, sizeof(int), 1, fp) != 1) return ERROR_RW;
406 if (img -> l_ght != NULL)
407 {
408 g_free (img -> l_ght);
409 img -> l_ght = NULL;
410 }
411 img -> l_ght = g_malloc0 (img -> lights*sizeof*img -> l_ght);
412 for (i=0; i<img -> lights; i++)
413 {
414 if (fread (& img -> l_ght[i].type, sizeof(int), 1, fp) != 1) return ERROR_RW;
415 if (fread (& img -> l_ght[i].fix, sizeof(int), 1, fp) != 1) return ERROR_RW;
416 if (fread (& img -> l_ght[i].show, sizeof(int), 1, fp) != 1) return ERROR_RW;
417 if (fread (& img -> l_ght[i].position, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
418 if (fread (& img -> l_ght[i].direction, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
419 if (fread (& img -> l_ght[i].intensity, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
420 if (fread (& img -> l_ght[i].attenuation, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
421 if (fread (& img -> l_ght[i].spot_data, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
422 }
423 if (fread (& img -> m_terial.predefine, sizeof(int), 1, fp) != 1) return ERROR_RW;
424 if (fread (& img -> m_terial.albedo, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
425 if (fread (img -> m_terial.param, sizeof(GLfloat), 6, fp) != 6) return ERROR_RW;
426 if (fread (& img -> f_g.mode, sizeof(int), 1, fp) != 1) return ERROR_RW;
427 if (fread (& img -> f_g.based, sizeof(int), 1, fp) != 1) return ERROR_RW;
428 if (fread (& img -> f_g.density, sizeof(float), 1, fp) != 1) return ERROR_RW;
429 if (fread (& img -> f_g.depth, sizeof(float), 2, fp) != 2) return ERROR_RW;
430 if (fread (& img -> f_g.color, sizeof(vec3_t), 1, fp) != 1) return ERROR_RW;
431
432 if (fread (& img -> filled_type, sizeof(int), 1, fp) != 1) return ERROR_RW;
433 if (fread (& img -> step, sizeof(int), 1, fp) != 1) return ERROR_RW;
434 if (fread (& img -> rep, sizeof(int), 1, fp) != 1) return ERROR_RW;
435
436 for (i=0; i<4; i++)
437 {
438 if (i < 2)
439 {
440 for (j=0; j<sid; j++)
441 {
442 if (fread (img -> spcolor[i][j], sizeof(ColRGBA), this_proj -> coord -> ntg[i][j], fp) != this_proj -> coord -> ntg[i][j]) return ERROR_RW;
443 }
444 }
445 else
446 {
447 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
448 if (j)
449 {
450 if (j != this_proj -> coord -> totcoord[i])
451 {
452 g_warning ("READING OPENGL:: this should not happen !\n i= %d, totcoord[i]= %d, j= %d", i, this_proj -> coord -> totcoord[i], j);
453 return ERROR_RW;
454 }
455 if (fread (img -> spcolor[i][0], sizeof(ColRGBA), this_proj -> coord -> totcoord[i], fp) != this_proj -> coord -> totcoord[i]) return ERROR_RW;
456 }
457 }
458 }
459 active_glwin = this_proj -> modelgl;
460 active_image = this_proj -> modelgl -> anim -> last -> img;
461 active_coord = this_proj -> coord;
462 if (fread (& this_proj -> modelgl -> rings, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
463 if (this_proj -> modelgl -> rings)
464 {
465 for (i=0; i<5; i++)
466 {
467 if (read_rings_chains_data (fp, this_proj -> modelgl, 0, i, this_proj -> rsparam[i][1], this_proj -> steps) != OK) return ERROR_RINGS;
468 }
469 }
470 if (fread (& this_proj -> modelgl -> chains, sizeof(gboolean), 1, fp) != 1) return ERROR_RW;
471 if (this_proj -> modelgl -> chains)
472 {
473 if (read_rings_chains_data (fp, this_proj -> modelgl, 1, 0, this_proj -> csparam[5], this_proj -> steps) != OK) return ERROR_CHAINS;
474 }
475
476 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
477 if (i)
478 {
479 this_proj -> modelgl -> create_shaders[VOLMS] = TRUE;
480 this_proj -> modelgl -> volumes = TRUE;
481 for (i=0; i<FILLED_STYLES; i++)
482 {
483 this_proj -> modelgl -> atoms_volume[i] = allocdouble (this_proj -> steps);
484 this_proj -> modelgl -> atoms_ppvolume[i] = allocdouble (this_proj -> steps);
485 if (fread (this_proj -> modelgl -> atoms_volume[i], sizeof(double), this_proj -> steps, fp) != this_proj -> steps) return ERROR_RW;
486 if (fread (this_proj -> modelgl -> atoms_ppvolume[i], sizeof(double), this_proj -> steps, fp) != this_proj -> steps) return ERROR_RW;
487 this_proj -> modelgl -> volume_box[i] = allocddouble (this_proj -> steps, 9);
488 for (j=0; j<this_proj -> steps; j++)
489 {
490 if (fread (this_proj -> modelgl -> volume_box[i][j], sizeof(double), 9, fp) != 9) return ERROR_RW;
491 }
492 }
493 if (fread (this_proj -> modelgl -> comp_vol, sizeof(gboolean), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
494 if (fread (active_image -> show_vol, sizeof(gboolean), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
495 if (fread (active_image -> vol_col, sizeof(ColRGBA), FILLED_STYLES, fp) != FILLED_STYLES) return ERROR_RW;
496 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
497 if (i)
498 {
499 for (j=0; j<FILLED_STYLES; j++)
500 {
501 if (fread (& k, sizeof(int), 1, fp) != 1) return ERROR_RW;
502 if (k)
503 {
504 this_proj -> modelgl -> frag_mol_volume[0][j] = allocddouble (this_proj -> steps, i);
505 this_proj -> modelgl -> frag_mol_ppvolume[0][j] = allocddouble (this_proj -> steps, i);
506 this_proj -> modelgl -> fm_comp_vol[0][j] = allocdbool (this_proj -> steps, i);
507 active_image -> fm_show_vol[0][j] = allocbool (i);
508 this_proj -> modelgl -> frag_box[j] = alloctdouble (this_proj -> steps, i, 9);
509 for (l=0; l<k; l++)
510 {
511 if (fread (& m, sizeof(int), 1, fp) != 1) return ERROR_RW;
512 if (fread (& n, sizeof(int), 1, fp) != 1) return ERROR_RW;
513 if (fread (& this_proj -> modelgl -> frag_mol_ppvolume[0][j][m][n], sizeof(double), 1, fp) != 1) return ERROR_RW;
514 if (fread (this_proj -> modelgl -> frag_box[j][m][n], sizeof(double), 9, fp) != 9) return ERROR_RW;
515 this_proj -> modelgl -> fm_comp_vol[0][j][m][n] = TRUE;
516 }
517 active_image -> fm_vol_col[0][j] = g_malloc0 (i*sizeof*active_image -> fm_vol_col[0][j]);
518 if (fread (active_image -> fm_show_vol[0][j], sizeof(gboolean), i, fp) != i) return ERROR_RW;
519 if (fread (active_image -> fm_vol_col[0][j], sizeof(ColRGBA), i, fp) != i) return ERROR_RW;
520 }
521 }
522 if (fread (& i, sizeof(int), 1, fp) != 1) return ERROR_RW;
523 if (i)
524 {
525 for (j=0; j<FILLED_STYLES; j++)
526 {
527 if (fread (& k, sizeof(int), 1, fp) != 1) return ERROR_RW;
528 if (k)
529 {
530 this_proj -> modelgl -> frag_mol_volume[1][j] = allocddouble (this_proj -> steps, i);
531 this_proj -> modelgl -> frag_mol_ppvolume[1][j] = allocddouble (this_proj -> steps, i);
532 this_proj -> modelgl -> fm_comp_vol[1][j] = allocdbool (this_proj -> steps, i);
533 active_image -> fm_show_vol[1][j] = allocbool (i);
534 for (l=0; l<k; l++)
535 {
536 if (fread (& m, sizeof(int), 1, fp) != 1) return ERROR_RW;
537 if (fread (& n, sizeof(int), 1, fp) != 1) return ERROR_RW;
538 if (fread (& this_proj -> modelgl -> frag_mol_ppvolume[1][j][m][n], sizeof(double), 1, fp) != 1) return ERROR_RW;
539 this_proj -> modelgl -> fm_comp_vol[1][j][m][n] = TRUE;
540 }
541 if (fread (active_image -> fm_show_vol[1][j], sizeof(gboolean), i, fp) != i) return ERROR_RW;
542 active_image -> fm_vol_col[1][j] = g_malloc0 (i*sizeof*active_image -> fm_vol_col[1][j]);
543 if (fread (active_image -> fm_vol_col[1][j], sizeof(ColRGBA), i, fp) != i) return ERROR_RW;
544 }
545 }
546 }
547 }
548 }
549
550 for (i=0; i<this_proj -> steps; i++)
551 {
552 for (j=0; j< this_proj -> natomes; j++)
553 {
554 if (read_atom_b (fp, this_proj, i, j) != OK) return ERROR_ATOM_B;
555 }
556 }
557 // Finally selection lists, bonds, angles and dihedrals
558 for (i=0; i<2; i++)
559 {
560 if (fread (& j, sizeof(int), 1, fp) != 1) return ERROR_RW;
561 if (j)
562 {
563 for (k=0; k<j; k++)
564 {
565 if (fread (& l, sizeof(int), 1, fp) != 1) return ERROR_RW;
566 process_selected_atom (this_proj, this_proj -> modelgl, l, 0, 0, i);
567 }
568 update_all_selections (this_proj -> modelgl, i);
569 if (img -> selected[i] -> selected >= 2 && img -> selected[i] -> selected <= 20)
570 {
571 j = num_bonds (img -> selected[i] -> selected);
572 if (fread (img -> selected[i] -> selected_bonds, sizeof(int), j, fp) != j) return ERROR_RW;
573 if (img -> selected[i] -> selected >= 3)
574 {
575 j = num_angles (img -> selected[i] -> selected);
576 if (fread (img -> selected[i] -> selected_angles, sizeof(int), j, fp) != j) return ERROR_RW;
577 if (img -> selected[i] -> selected >= 4 && img -> selected[i] -> selected <= 10)
578 {
579 j = num_dihedrals (img -> selected[i] -> selected);
580 if (fread (img -> selected[i] -> selected_dihedrals, sizeof(int), j, fp) != j) return ERROR_RW;
581 }
582 }
583 }
584 }
585 }
586 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
587#ifdef GTK3
588 // GTK3 Menu Action To Check
589 for (i=0; i<2; i++)
590 {
591 for (j=0; j<sid; j++)
592 {
593 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_spec[i][j]))
594 {
595 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j]) != img -> show_atom[i][j])
596 {
597 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j], img -> show_atom[i][j]);
598 }
599 }
600 }
601 }
602 for (i=0; i<10; i++)
603 {
604 if (this_proj -> modelgl -> ogl_poly[0][i] != NULL)
605 {
606 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
607 {
608 if (i < 2 || (i > 3 && i < 9))
609 {
610 if (this_proj -> modelgl -> ogl_poly[0][i][j] != NULL)
611 {
612 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_poly[0][i][j]))
613 {
614 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j]) != img -> show_poly[i][j])
615 {
616 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][i][j], img -> show_poly[i][j]);
617 }
618 }
619 }
620 }
621 }
622 }
623 if (this_proj -> modelgl -> ogl_geom[0][i] != NULL)
624 {
625 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
626 {
627 if (this_proj -> modelgl -> ogl_geom[0][i][j] != NULL)
628 {
629 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_geom[0][i][j]))
630 {
631 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j]) != img -> show_coord[i][j])
632 {
633 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][i][j], img -> show_coord[i][j]);
634 }
635 }
636 }
637 }
638 }
639 }
640 show_the_widgets (this_proj -> modelgl -> ogl_coord[0]);
641 update_all_menus (this_proj -> modelgl, this_proj -> natomes);
642#endif
643 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, 2);
644#ifdef GTK4
645 update_menu_bar (this_proj -> modelgl);
646 for (i=0; i<2; i++)
647 {
648 for (j=0; j<sid; j++)
649 {
650 if (! img -> show_atom[i][j])
651 {
652 show_hide_atoms (NULL, NULL, & this_proj -> modelgl -> colorp[i][j]);
653 }
654 }
655 }
656 for (i=0; i<10; i++)
657 {
658 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
659 {
660 if (i < 2 || (i > 3 && i < 9))
661 {
662 if (img -> show_poly[i][j])
663 {
664 show_hide_poly (NULL, NULL, & this_proj -> modelgl -> gcid[i][j][i]);
665 }
666 }
667 }
668 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
669 {
670 if (! img -> show_coord[i][j])
671 {
672 show_hide_coord (NULL, NULL, & this_proj -> modelgl -> gcid[i][j][i]);
673 }
674 }
675 }
676#endif
677 return OK;
678}
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]
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 atoms[NUM_STYLES][2]
float val
Definition dlp_init.c:117
dint rep
Definition dlp_edit.c:2239
gboolean * duplicate_bool(int num, gboolean *old_val)
copy a list of gboolean
Definition global.c:588
FILE * fp
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:342
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:266
double ** allocddouble(int xal, int yal)
allocate a double ** pointer
Definition global.c:487
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:471
double *** alloctdouble(int xal, int yal, int zal)
allocate a double *** pointer
Definition global.c:510
int * allocint(int val)
allocate an int * pointer
Definition global.c:326
gboolean ** allocdbool(int xal, int yal)
allocate a gboolean ** pointer
Definition global.c:282
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:410
Global variable declarations Global convenience function declarations Global data structure defin...
#define ERROR_CHAINS
Definition global.h:262
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:257
#define ERROR_RW
Definition global.h:252
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:261
#define OK
Definition global.h:251
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:169
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1003
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:239
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:182
int step
Definition ogl_draw.c:70
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:105
@ 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:659
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:570
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:47
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
gchar * read_this_string(FILE *fp)
is there a string to read in this file ? yes do it
Definition open_p.c:95
Function declarations for reading atomes project file Function declarations for saving atomes proje...
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:77
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:55
Definition glwin.h:875
Definition glwin.h:277
int a
Definition tab-1.c:95
GtkWidget * axis_title
Definition tab-4.c:101
GtkWidget * img
Definition workspace.c:70