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