atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_volumes.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
23/*
24* This file: 'w_volumes.c'
25*
26* Contains:
27*
28
29 - The functions to create the 'Volumes' window
30 - The functions to compute system / fragment / molecular volumes
31
32*
33* List of functions:
34
35 double cap_volume (double ht, double dh);
36 double get_sphere_caps_volume (double dab, double rad, double rbd);
37 double sphere_volume (double rad);
38 double get_atoms_volume (project * this_proj, int rid, int sid, int gid, int gcid);
39 double molecular_volume (int nats, atom * ats_vol, double baryc[3], double * rvdws, double a_ang, double b_ang, double c_ang);
40 double get_atoms_box (project * this_proj, int rid, int sid, int geo, int gid);
41
42 void clean_volumes_data (glwin * view);
43 void adjust_vol_md_step (project * this_proj, int geo);
44 void add_frag_mol_vol_data (GtkWidget * vbox, project * this_proj, glwin * view, int geo);
45
46 G_MODULE_EXPORT void molecular_volumes (GtkButton * but, gpointer data);
47 G_MODULE_EXPORT void fm_molecular_volumes (GtkButton * but, gpointer data);
48 G_MODULE_EXPORT void show_volumes (GtkCheckButton * but, gpointer data);
49 G_MODULE_EXPORT void show_volumes (GtkToggleButton * but, gpointer data);
50 G_MODULE_EXPORT void fm_show_volumes (GtkCheckButton * but, gpointer data);
51 G_MODULE_EXPORT void fm_show_volumes (GtkToggleButton * but, gpointer data);
52 G_MODULE_EXPORT void set_volume_color (GtkColorChooser * colob, gpointer data);
53 G_MODULE_EXPORT void fm_set_volume_color (GtkColorChooser * colob, gpointer data);
54 G_MODULE_EXPORT void set_md_step_vol (GtkSpinButton * res, gpointer data);
55 G_MODULE_EXPORT void update_vol_frag_mol_search (GtkEntry * res, gpointer data);
56 G_MODULE_EXPORT void set_angular_precision (GtkComboBox * box, gpointer data);
57 G_MODULE_EXPORT void window_volumes (GtkWidget * widg, gpointer data);
58
59 GtkWidget * frag_mol_volume_search (project * this_proj, int g);
60 GtkWidget * frag_mol_volume_tab (glwin * view, int geo);
61 GtkWidget * vol_model_tab (glwin * view);
62
63*/
64
65#include "global.h"
66#include "bind.h"
67#include "interface.h"
68#include "callbacks.h"
69#include "project.h"
70#include "glview.h"
71#include "atom_edit.h"
72
73extern void center_this_molecule (glwin * view);
74extern double draw_cuboid (gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha);
75
84{
85 if (view -> volume_win)
86 {
87 if (view -> volume_win -> win)
88 {
89 destroy_this_widget (view -> volume_win -> win);
90 }
91 g_free (view -> volume_win);
92 view -> volume_win = NULL;
93 }
94 int i, j;
95 for (i=0; i<FILLED_STYLES; i++)
96 {
97 if (view -> atoms_volume[i]) g_free (view -> atoms_volume[i]);
98 view -> atoms_volume[i] = NULL;
99 if (view -> atoms_ppvolume[i]) g_free (view -> atoms_ppvolume[i]);
100 view -> atoms_ppvolume[i] = NULL;
101 if (view -> volume_box[i]) g_free (view -> volume_box[i]);
102 view -> volume_box[i] = NULL;
103 view -> comp_vol[i] = FALSE;
104 view -> anim -> last -> img -> show_vol[i] = FALSE;
105 }
106 for (i=0; i<2; i++)
107 {
108 for (j=0; j<FILLED_STYLES; j++)
109 {
110 if (view -> frag_mol_volume[i][j]) g_free (view -> frag_mol_volume[i][j]);
111 view -> frag_mol_volume[i][j] = NULL;
112 if (view -> frag_mol_ppvolume[i][j]) g_free (view -> frag_mol_ppvolume[i][j]);
113 view -> frag_mol_ppvolume[i][j] = NULL;
114 if (! i)
115 {
116 if (view -> frag_box[j]) g_free (view -> frag_box[j]);
117 view -> frag_box[j] = NULL;
118 }
119 if (view -> fm_comp_vol[i][j]) g_free (view -> fm_comp_vol[i][j]);
120 view -> fm_comp_vol[i][j] = NULL;
121 if (view -> anim -> last -> img -> fm_show_vol[i][j]) g_free (view -> anim -> last -> img -> fm_show_vol[i][j]);
122 view -> anim -> last -> img -> fm_show_vol[i][j] = NULL;
123 if (view -> anim -> last -> img -> fm_vol_col[i][j]) g_free (view -> anim -> last -> img -> fm_vol_col[i][j]);
124 view -> anim -> last -> img -> fm_vol_col[i][j] = NULL;
125 }
126 }
127 int shaders[1] = {VOLMS};
129}
130
139double cap_volume (double ht, double dh)
140{
141 return (pi/3.0)*ht*ht*(3*dh-ht);
142}
143
153double get_sphere_caps_volume (double dab, double rad, double rbd)
154{
155 double h1, h2;
156 double px;
157 double rmi, rma;
158 rmi = min (rad, rbd);
159 rma = max (rad, rbd);
160 px = (dab*dab - rmi*rmi + rma*rma) / (2.0*dab);
161 h1 = rma - px;
162 h2 = rmi - (dab - px);
163 return cap_volume (h1, rma) + cap_volume (h2, rmi);
164}
165
173double sphere_volume (double rad)
174{
175 return ((4.0*pi)/3.0)*rad*rad*rad;
176}
177
189double get_atoms_volume (project * this_proj, int rid, int sid, int gid, int gcid)
190{
191 int i, j, k, l, m, n, o;
192 double vol = 0.0;
193 double cap_vol = 0.0;
194 double * rvdws = allocdouble (this_proj -> nspec);
196 for (i=0; i<this_proj -> nspec; i++)
197 {
198 j = (int)this_proj -> chemistry -> chem_prop[CHEM_Z][i];
199 rvdws[i] = set_radius_ (& j, & rid);
200 }
201 for (j=0; j<2; j++)
202 {
203 for (k=0; k<this_proj -> modelgl -> bonds[sid][j]; k++)
204 {
205 l = this_proj -> modelgl -> bondid[sid][j][k][0];
206 m = this_proj -> atoms[sid][l].sp;
207 n = this_proj -> modelgl -> bondid[sid][j][k][1];
208 o = this_proj -> atoms[sid][n].sp;
209 if (gid < 0 || this_proj -> atoms[sid][l].coord[gid] == gcid)
210 {
211 dist = distance_3d (& this_proj -> cell, (this_proj -> cell.npt) ? sid : 0, & this_proj -> atoms[sid][l], & this_proj -> atoms[sid][n]);
212 if (dist.length < rvdws[m]+rvdws[o]) cap_vol += get_sphere_caps_volume (dist.length, rvdws[m], rvdws[o]);
213 }
214 }
215 }
216 vol = 0.0;
217 if (gid < 0)
218 {
219 for (i=0; i<this_proj -> nspec; i++)
220 {
221 vol += this_proj -> chemistry -> nsps[i] * sphere_volume (rvdws[i]);
222 }
223 vol -= cap_vol;
224 }
225 else
226 {
227 if (gid == 3)
228 {
229 for (i=0; i<this_proj -> nspec; i++)
230 {
231 vol += this_proj -> modelfc -> mols[sid][gcid].species[i] * sphere_volume (rvdws[i]);
232 }
233 vol *= this_proj -> modelfc -> mols[sid][gcid].multiplicity;
234 vol -= cap_vol;
235 vol /= this_proj -> modelfc -> mols[sid][gcid].multiplicity;
236 }
237 else
238 {
239 for (i=0; i<this_proj -> natomes; i++)
240 {
241 if (this_proj -> atoms[sid][i].coord[gid] == gcid)
242 {
243 j = this_proj -> atoms[sid][i].sp;
244 vol += sphere_volume (rvdws[j]);
245 }
246 }
247 vol -= cap_vol;
248 }
249 }
250 g_free (rvdws);
251 return vol;
252}
253
254double vamin[3], vamax[3];
255
269double molecular_volume (int nats, atom * ats_vol, double baryc[3], double * rvdws, double a_ang, double b_ang, double c_ang)
270{
271 double paral[3][3];
272 mat4_t rot;
273 vec3_t c_old, c_new;
274 rot = m4_rotation_xyz (a_ang, b_ang, c_ang);
275 int i, j, k;
276 k = 0;
277 for (i=0; i<nats; i++)
278 {
279 j = ats_vol[i].sp;
280 c_old = vec3(ats_vol[i].x+baryc[0], ats_vol[i].y+baryc[1], ats_vol[i].z+baryc[2]);
281 c_new = m4_mul_pos (rot, c_old);
282 if (! k)
283 {
284 vamin[0] = c_new.x - rvdws[j];
285 vamax[0] = c_new.x + rvdws[j];
286 vamin[1] = c_new.y - rvdws[j];
287 vamax[1] = c_new.y + rvdws[j];
288 vamin[2] = c_new.z - rvdws[j];
289 vamax[2] = c_new.z + rvdws[j];
290 k ++;
291 }
292 else
293 {
294 vamin[0] = min(vamin[0], c_new.x - rvdws[j]);
295 vamax[0] = max(vamax[0], c_new.x + rvdws[j]);
296 vamin[1] = min(vamin[1], c_new.y - rvdws[j]);
297 vamax[1] = max(vamax[1], c_new.y + rvdws[j]);
298 vamin[2] = min(vamin[2], c_new.z - rvdws[j]);
299 vamax[2] = max(vamax[2], c_new.z + rvdws[j]);
300 }
301 }
302 paral[0][0] = vamax[0] - vamin[0];
303 paral[0][1] = 0.0;
304 paral[0][2] = 0.0;
305 paral[1][0] = 0.0;
306 paral[1][1] = vamax[1] - vamin[1];
307 paral[1][2] = 0.0;
308 paral[2][0] = 0.0;
309 paral[2][1] = 0.0;
310 paral[2][2] = vamax[2] - vamin[2];
311 ColRGBA null; // Not used
312 return draw_cuboid (FALSE, VOLMS, 0, m4_identity (), vec3(0.0,0.0,0.0), paral, null, 1.0);
313}
314
326double get_atoms_box (project * this_proj, int rid, int sid, int geo, int gid)
327{
328 int i, j;
329 double * rvdws = allocdouble (this_proj -> nspec);
330 for (i=0; i<this_proj -> nspec; i++)
331 {
332 j = (int)this_proj -> chemistry -> chem_prop[CHEM_Z][i];
333 rvdws[i] = set_radius_ (& j, & rid);
334 }
335 if (geo < 0) center_this_molecule (this_proj -> modelgl);
336 int a_ang, b_ang, c_ang;
337 double val, vbl;
338 int finess = pow (10, this_proj -> modelgl -> volume_win -> angp);
339 int nats;
340 atom * ats_vol = NULL;
341 atomic_object * object = NULL;
342 gboolean rtmp;
343 double * baryc;
344 switch (geo)
345 {
346 case 2:
347 object_motion = TRUE;
348 rtmp = this_proj -> modelgl -> rebuild[0][0];
349 this_proj -> modelgl -> rebuild[0][0] = TRUE;
350 object = create_object_from_frag_mol (this_proj, geo, gid, NULL);
351 object_motion = FALSE;
352 this_proj -> modelgl -> rebuild[0][0] = rtmp;
353 nats = object -> atoms;
354 baryc = duplicate_double (3, object -> baryc);
355 ats_vol = object -> at_list;
356 break;
357 default:
358 nats = this_proj -> natomes;
359 ats_vol = this_proj -> atoms[sid];
360 baryc = allocdouble (3);
361 break;
362 }
363
364 for (a_ang=0; a_ang < 90*finess; a_ang ++)
365 {
366 for (b_ang=0; b_ang < 90*finess; b_ang ++)
367 {
368 for (c_ang=0; c_ang < 90*finess; c_ang ++)
369 {
370 val = molecular_volume (nats, ats_vol, baryc, rvdws, a_ang/finess, b_ang/finess, c_ang/finess);
371 if (a_ang == 0 && b_ang == 0 && c_ang == 0)
372 {
373 vbl = val;
374 if (geo < 0)
375 {
376 for (i=0; i<3; i++)
377 {
378 this_proj -> modelgl -> volume_box[rid][sid][i] = vamax[i] - vamin[i];
379 this_proj -> modelgl -> volume_box[rid][sid][i+6] = (vamax[i] + vamin[i]) / 2.0;
380 }
381 this_proj -> modelgl -> volume_box[rid][sid][3] = a_ang/finess;
382 this_proj -> modelgl -> volume_box[rid][sid][4] = b_ang/finess;
383 this_proj -> modelgl -> volume_box[rid][sid][5] = c_ang/finess;
384 }
385 else
386 {
387 for (i=0; i<3; i++)
388 {
389 this_proj -> modelgl -> frag_box[rid][sid][gid][i] = vamax[i] - vamin[i];
390 this_proj -> modelgl -> frag_box[rid][sid][gid][i+6] = (vamax[i] + vamin[i]) / 2.0;
391 }
392 this_proj -> modelgl -> frag_box[rid][sid][gid][3] = a_ang/finess;
393 this_proj -> modelgl -> frag_box[rid][sid][gid][4] = b_ang/finess;
394 this_proj -> modelgl -> frag_box[rid][sid][gid][5] = c_ang/finess;
395 }
396 }
397 else if (val < vbl)
398 {
399 vbl = val;
400 if (geo < 0)
401 {
402 for (i=0; i<3; i++)
403 {
404 this_proj -> modelgl -> volume_box[rid][sid][i] = vamax[i] - vamin[i];
405 this_proj -> modelgl -> volume_box[rid][sid][i+6] = (vamax[i] + vamin[i]) / 2.0;
406 }
407 this_proj -> modelgl -> volume_box[rid][sid][3] = a_ang/finess;
408 this_proj -> modelgl -> volume_box[rid][sid][4] = b_ang/finess;
409 this_proj -> modelgl -> volume_box[rid][sid][5] = c_ang/finess;
410 }
411 else
412 {
413 for (i=0; i<3; i++)
414 {
415 this_proj -> modelgl -> frag_box[rid][sid][gid][i] = vamax[i] - vamin[i];
416 this_proj -> modelgl -> frag_box[rid][sid][gid][i+6] = (vamax[i] + vamin[i]) / 2.0;
417 }
418 this_proj -> modelgl -> frag_box[rid][sid][gid][3] = a_ang/finess;
419 this_proj -> modelgl -> frag_box[rid][sid][gid][4] = b_ang/finess;
420 this_proj -> modelgl -> frag_box[rid][sid][gid][5] = c_ang/finess;
421 }
422 }
423 else
424 {
425 break;
426 }
427 }
428 }
429 }
430 ats_vol = NULL;
431 g_free (rvdws);
432 g_free (baryc);
433 if (geo == 2) g_free (object);
434 return vbl;
435}
436
445G_MODULE_EXPORT void molecular_volumes (GtkButton * but, gpointer data)
446{
447 tint * dat = (tint *)data;
448 project * this_proj = get_project_by_id (dat -> a);
449 int i;
450 for (i=0; i<this_proj -> steps; i++) this_proj -> modelgl -> atoms_ppvolume[dat -> b][i] = get_atoms_box (this_proj, dat -> b, i, -1, 0);
451 this_proj -> modelgl -> comp_vol[dat -> b] = TRUE;
452 widget_set_sensitive (this_proj -> modelgl -> volume_win -> hbvol[dat -> b], this_proj -> modelgl -> comp_vol[dat -> b]);
453 double movol = 0.0;
454 for (i=0; i<this_proj -> steps; i++) movol += this_proj -> modelgl -> atoms_ppvolume[dat -> b][i];
455 movol /= this_proj -> steps;
456 gchar * str = g_strdup_printf ("%15.3f", movol);
457 gtk_label_set_text ((GtkLabel *)this_proj -> modelgl -> volume_win -> lab_vol[dat -> b], str);
458 g_free (str);
459 if (this_proj -> modelgl -> comp_vol[dat -> b])
460 {
461 hide_the_widgets (this_proj -> modelgl -> volume_win -> compb[dat -> b]);
462 show_the_widgets (this_proj -> modelgl -> volume_win -> hboxv[dat -> b]);
463 }
464 this_proj -> modelgl -> volumes = TRUE;
465}
466
475void adjust_vol_md_step (project * this_proj, int geo)
476{
477 int i, j, k;
478 k = this_proj -> modelgl -> volume_win -> sid[geo-2];
479 gchar * str;
480 if (this_proj -> coord -> totcoord[geo] <= 10000)
481 {
482 for (i=0; i<FILLED_STYLES; i++)
483 {
484 for (j=0; j<this_proj -> coord -> totcoord[geo]; j++)
485 {
486 if (this_proj -> modelgl -> fm_comp_vol[geo-2][i][k][j])
487 {
488 hide_the_widgets (this_proj -> modelgl -> volume_win -> fm_compb[geo-2][i][j]);
489 str = g_strdup_printf ("%15.3f", this_proj -> modelgl -> frag_mol_ppvolume[geo-2][i][k][j]);
490 gtk_label_set_text ((GtkLabel *)this_proj -> modelgl -> volume_win -> fm_lab_vol[geo-2][i][j], str);
491 g_free (str);
492 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_hboxv[geo-2][i][j]);
493 }
494 else
495 {
496 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_compb[geo-2][i][j]);
497 hide_the_widgets (this_proj -> modelgl -> volume_win -> fm_hboxv[geo-2][i][j]);
498 }
499 }
500 }
501 }
502 else
503 {
504 for (i=0; i<FILLED_STYLES; i++)
505 {
506 for (j=0; j<this_proj -> modelgl -> volume_win -> ngeov[geo-2]; j++)
507 {
508 k = this_proj -> modelgl -> volume_win -> geov_id[geo-2][j];
509 if (this_proj -> modelgl -> fm_comp_vol[geo-2][i][0][k])
510 {
511 hide_the_widgets (this_proj -> modelgl -> volume_win -> fm_compb[geo-2][i][k]);
512 str = g_strdup_printf ("%15.3f", this_proj -> modelgl -> frag_mol_ppvolume[geo-2][i][0][k]);
513 gtk_label_set_text ((GtkLabel *)this_proj -> modelgl -> volume_win -> fm_lab_vol[geo-2][i][k], str);
514 g_free (str);
515 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_hboxv[geo-2][i][k]);
516 }
517 else
518 {
519 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_compb[geo-2][i][k]);
520 hide_the_widgets (this_proj -> modelgl -> volume_win -> fm_hboxv[geo-2][i][k]);
521 }
522 }
523 }
524 }
525}
526
535G_MODULE_EXPORT void fm_molecular_volumes (GtkButton * but, gpointer data)
536{
537 int i, j;
538 qint * dat = (qint *)data;
539 project * this_proj = get_project_by_id (dat -> a);
540 int sid = this_proj -> modelgl -> volume_win -> sid[dat -> b-2];
541 if (dat -> b == 2)
542 {
543 this_proj -> modelgl -> frag_mol_ppvolume[dat -> b-2][dat -> d][sid][dat -> c] = get_atoms_box (this_proj, dat -> d, sid, dat -> b, dat -> c);
544 }
545 else
546 {
547 this_proj -> modelgl -> frag_mol_ppvolume[dat -> b-2][dat -> d][sid][dat -> c] = 0.0;
548 for (i=0; i<this_proj -> modelfc -> mols[sid][dat -> c].multiplicity; i++)
549 {
550 j = this_proj -> modelfc -> mols[sid][dat -> c].fragments[i];
551 if (! this_proj -> modelgl -> fm_comp_vol[0][dat -> d][sid][j])
552 {
553 this_proj -> modelgl -> frag_mol_ppvolume[0][dat -> d][sid][j] = get_atoms_box (this_proj, dat -> d, sid, 2, j);
554 this_proj -> modelgl -> fm_comp_vol[0][dat -> d][sid][j] = TRUE;
555 widget_set_sensitive (this_proj -> modelgl -> volume_win -> fm_hbvol[0][dat -> d][j], this_proj -> modelgl -> fm_comp_vol[0][dat -> d][sid][j]);
556 }
557 this_proj -> modelgl -> frag_mol_ppvolume[dat -> b-2][dat -> d][sid][dat -> c] += this_proj -> modelgl -> frag_mol_ppvolume[0][dat -> d][sid][j];
558 }
559 this_proj -> modelgl -> frag_mol_ppvolume[dat -> b-2][dat -> d][sid][dat -> c] /= this_proj -> modelfc -> mols[sid][dat -> c].multiplicity;
560 }
561 center_molecule (this_proj);
562 for (i=0; i<2; i++) this_proj -> modelgl -> saved_coord[i] = save_coordinates (this_proj, i);
563 init_default_shaders (this_proj -> modelgl);
564 update (this_proj -> modelgl);
565 this_proj -> modelgl -> fm_comp_vol[dat -> b-2][dat -> d][sid][dat -> c] = TRUE;
566 widget_set_sensitive (this_proj -> modelgl -> volume_win -> fm_hbvol[dat -> b-2][dat -> d][dat -> c], this_proj -> modelgl -> fm_comp_vol[dat -> b-2][dat -> d][sid][dat -> c]);
567 gchar * str = g_strdup_printf ("%15.3f", this_proj -> modelgl -> frag_mol_ppvolume[dat -> b-2][dat -> d][sid][dat -> c]);
568 gtk_label_set_text ((GtkLabel *)this_proj -> modelgl -> volume_win -> fm_lab_vol[dat -> b-2][dat -> d][dat -> c], str);
569 g_free (str);
570 if (this_proj -> modelgl -> fm_comp_vol[dat -> b-2][dat -> d][sid][dat -> c])
571 {
572 hide_the_widgets (this_proj -> modelgl -> volume_win -> fm_compb[dat -> b-2][dat -> d][dat -> c]);
573 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_hboxv[dat -> b-2][dat -> d][dat -> c]);
574 }
575 if (dat -> b == 3)
576 {
577 adjust_vol_md_step (this_proj, 2);
578 }
579 this_proj -> modelgl -> volumes = TRUE;
580}
581
582#ifdef GTK4
591G_MODULE_EXPORT void show_volumes (GtkCheckButton * but, gpointer data)
592#else
601G_MODULE_EXPORT void show_volumes (GtkToggleButton * but, gpointer data)
602#endif
603{
604 tint * dat = (tint *)data;
605 project * this_proj = get_project_by_id (dat -> a);
606#ifdef GTK4
607 this_proj -> modelgl -> anim -> last -> img -> show_vol[dat -> b] = gtk_check_button_get_active (but);
608#else
609 this_proj -> modelgl -> anim -> last -> img -> show_vol[dat -> b] = gtk_toggle_button_get_active (but);
610#endif
611 int shaders[1] = {VOLMS};
612 re_create_md_shaders (1, shaders, this_proj);
613 update (this_proj -> modelgl);
614}
615
616#ifdef GTK4
625G_MODULE_EXPORT void fm_show_volumes (GtkCheckButton * but, gpointer data)
626#else
635G_MODULE_EXPORT void fm_show_volumes (GtkToggleButton * but, gpointer data)
636#endif
637{
638 qint * dat = (qint *)data;
639 project * this_proj = get_project_by_id (dat -> a);
640#ifdef GTK4
641 this_proj -> modelgl -> anim -> last -> img -> fm_show_vol[dat -> b-2][dat -> d][dat -> c] = gtk_check_button_get_active (but);
642#else
643 this_proj -> modelgl -> anim -> last -> img -> fm_show_vol[dat -> b-2][dat -> d][dat -> c] = gtk_toggle_button_get_active (but);
644#endif
645 int shaders[1] = {VOLMS};
646 re_create_md_shaders (1, shaders, this_proj);
647 update (this_proj -> modelgl);
648}
649
658G_MODULE_EXPORT void set_volume_color (GtkColorChooser * colob, gpointer data)
659{
660 tint * id = (tint *) data;
661 project * this_proj = get_project_by_id(id -> a);
662 this_proj -> modelgl -> anim -> last -> img -> vol_col[id -> b] = get_button_color (colob);
663 int shaders[1] = {VOLMS};
664 re_create_md_shaders (1, shaders, this_proj);
665 update (this_proj -> modelgl);
666}
667
676G_MODULE_EXPORT void fm_set_volume_color (GtkColorChooser * colob, gpointer data)
677{
678 qint * dat = (qint *)data;
679 project * this_proj = get_project_by_id (dat -> a);
680 this_proj -> modelgl -> anim -> last -> img -> fm_vol_col[dat -> b-2][dat -> d][dat -> c] = get_button_color (colob);
681 int shaders[1] = {VOLMS};
682 re_create_md_shaders (1, shaders, this_proj);
683 update (this_proj -> modelgl);
684}
685
694G_MODULE_EXPORT void set_md_step_vol (GtkSpinButton * res, gpointer data)
695{
696 qint * dat = (qint *)data;
697 project * this_proj = get_project_by_id (dat -> a);
698 this_proj -> modelgl -> volume_win -> sid[dat -> b-2] = gtk_spin_button_get_value_as_int(res);
699 adjust_vol_md_step (this_proj, dat -> b);
700}
701
712void add_frag_mol_vol_data (GtkWidget * vbox, project * this_proj, glwin * view, int geo)
713{
714 gchar * name_geo[2] = {"fragment", "molecule"};
715 gchar * fmo[2] = {"Fragment", "Molecule"};
716 GtkWidget * hbox;
717 GtkWidget * hhbox;
718 GtkWidget * fragtab;
719 gchar * str;
720 int i, j;
721 int ngeov = (this_proj -> coord -> totcoord[geo] > 10000) ? view -> volume_win -> ngeov[geo-2] : this_proj -> coord -> totcoord[geo];
722 if (geo == 3)
723 {
724 str = g_strdup_printf ("<u>Mean volume(s) occupied by the atom(s) for each %s:</u>", name_geo[geo-2]);
725 }
726 else
727 {
728 str = g_strdup_printf ("<u>Volume(s) occupied by the atom(s) for each %s:</u>", name_geo[geo-2]);
729 }
730 abox (vbox, str, 5);
731 g_free (str);
732 fragtab = create_scroll (vbox, -1, -1, GTK_SHADOW_NONE);
733 gtk_widget_set_hexpand (fragtab, TRUE);
734 gtk_widget_set_vexpand (fragtab, TRUE);
735 GtkWidget * vvbox = create_vbox (BSEP);
736 add_container_child (CONTAINER_SCR, fragtab, vvbox);
737 double vof;
738 int geoid;
739 for (i=0; i<ngeov; i++)
740 {
741 geoid = (this_proj -> coord -> totcoord[geo] > 10000) ? view -> volume_win -> geov_id[geo-2][i] : i;
742 str = g_strdup_printf ("%s N°%d", fmo[geo-2], geoid+1);
744 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 20);
745 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 5);
746 g_free (str);
747 for (j=0; j<FILLED_STYLES; j++)
748 {
750 str = g_strdup_printf ("using <b>%s</b>: ", text_filled[j]);
751 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 30);
752 g_free (str);
753 view -> frag_mol_volume[geo-2][j][0][geoid] = get_atoms_volume (this_proj, j, 0, geo, i);
754 str = g_strdup_printf ("%15.3f", view -> frag_mol_volume[geo-2][j][0][geoid]);
755 hhbox = create_hbox (BSEP);
756 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 100, -1, 1.0, 0.5), FALSE, FALSE, 0);
757 g_free (str);
758 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label ("<b>&#xC5;<sup>3</sup></b>", 50, -1, 0.0, 0.5), FALSE, FALSE, 20);
759 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 5);
760 }
761 }
762 if (geo == 3)
763 {
764 str = g_strdup_printf ("<u>Mean smallest rectangle parallepiped volume(s) to englobe the atom(s) for each %s:</u>", name_geo[geo-2]);
765 }
766 else
767 {
768 str = g_strdup_printf ("<u>Smallest rectangle parallepiped volume(s) to englobe the atom(s) for each %s:</u>", name_geo[geo-2]);
769 }
770 abox (vbox, str, 5);
771 g_free (str);
772 fragtab = create_scroll (vbox, -1, -1, GTK_SHADOW_NONE);
773 gtk_widget_set_hexpand (fragtab, TRUE);
774 gtk_widget_set_vexpand (fragtab, TRUE);
775 vvbox = create_vbox (BSEP);
776 add_container_child (CONTAINER_SCR, fragtab, vvbox);
777 for (i=0; i<ngeov; i++)
778 {
779 geoid = (this_proj -> coord -> totcoord[geo] > 10000) ? view -> volume_win -> geov_id[geo-2][i] : i;
780 str = g_strdup_printf ("%s N°%d", fmo[geo-2], geoid+1);
782 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 20);
783 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 5);
784 g_free (str);
785 for (j=0; j<FILLED_STYLES; j++)
786 {
788 str = g_strdup_printf ("using <b>%s</b>: ", text_filled[j]);
789 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 30);
790 g_free (str);
791 hhbox = create_hbox (BSEP);
792 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hhbox, FALSE, FALSE, 0);
793 view -> volume_win -> fm_compb[geo-2][j][geoid] = create_button ("Compute", IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(fm_molecular_volumes), & view -> gcid[geo][geoid][j]);
794 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, view -> volume_win -> fm_compb[geo-2][j][geoid], FALSE, FALSE, 20);
795 vof = 0.0;
796 if (view -> frag_mol_ppvolume[geo-2][j]) vof = view -> frag_mol_ppvolume[geo-2][j][0][geoid];
797 str = g_strdup_printf ("%15.3f", vof);
798 view -> volume_win -> fm_hboxv[geo-2][j][geoid] = create_hbox (BSEP);
799 view -> volume_win -> fm_lab_vol[geo-2][j][geoid] = markup_label (str, 100, -1, 1.0, 0.5);
800 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> fm_hboxv[geo-2][j][geoid] , view -> volume_win -> fm_lab_vol[geo-2][j][geoid], FALSE, FALSE, 20);
801 g_free (str);
802 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> fm_hboxv[geo-2][j][geoid] , markup_label ("<b>&#xC5;<sup>3</sup></b>", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
803 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, view -> volume_win -> fm_hboxv[geo-2][j][geoid] , FALSE, FALSE, 0);
804 view -> volume_win -> fm_hbvol[geo-2][j][geoid] = create_hbox (BSEP);
805 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> fm_hbvol[geo-2][j][geoid], check_button ("Show/Hide", 100, -1, view -> anim -> last -> img -> fm_show_vol[geo-2][j][geoid], G_CALLBACK(fm_show_volumes), & view -> gcid[geo][geoid][j]), FALSE, FALSE, 0);
806 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> fm_hbvol[geo-2][j][geoid], color_button (view -> anim -> last -> img -> fm_vol_col[geo-2][j][geoid], TRUE, 50, -1, G_CALLBACK(fm_set_volume_color), & view -> gcid[geo][geoid][j]), FALSE, FALSE, 5);
807 widget_set_sensitive (view -> volume_win -> fm_hbvol[geo-2][j][geoid], view -> fm_comp_vol[geo-2][j][0][geoid]);
808 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, view -> volume_win -> fm_hbvol[geo-2][j][geoid], FALSE, FALSE, 5);
809 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 0);
810 }
811 }
812}
813
822G_MODULE_EXPORT void update_vol_frag_mol_search (GtkEntry * res, gpointer data)
823{
824 tint * dat = (tint * )data;
825 const gchar * m = entry_get_text (res);
826 int v = (int)string_to_double ((gpointer)m);
827 project * this_proj = get_project_by_id(dat -> a);
828 int g = dat -> b;
829 if (v > 0 && v <= this_proj -> coord -> totcoord[g])
830 {
831 int i;
832 gboolean update = TRUE;
833 for (i=0; i<this_proj -> modelgl -> volume_win -> ngeov[g-2]; i++)
834 {
835 if (this_proj -> modelgl -> volume_win -> geov_id[g-2][i] == v-1)
836 {
837 update = FALSE;
838 break;
839 }
840 }
841 if (update)
842 {
843 int * sdata = duplicate_int (this_proj -> modelgl -> volume_win -> ngeov[g-2], this_proj -> modelgl -> volume_win -> geov_id[g-2]);
844 g_free (this_proj -> modelgl -> volume_win -> geov_id[g-2]);
845 this_proj -> modelgl -> volume_win -> geov_id[g-2] = allocint (this_proj -> modelgl -> volume_win -> ngeov[g-2]+1);
846 for (i=0; i<this_proj -> modelgl -> volume_win -> ngeov[g-2]; i++)
847 {
848 this_proj -> modelgl -> volume_win -> geov_id[g-2][i] = sdata[i];
849 }
850 this_proj -> modelgl -> volume_win -> geov_id[g-2][i] = v-1;
851 this_proj -> modelgl -> volume_win -> ngeov[g-2] ++;
852
853 destroy_this_widget (this_proj -> modelgl -> volume_win -> fm_vvbox[g-2]);
854 this_proj -> modelgl -> volume_win -> fm_vvbox[g-2] = create_vbox (BSEP);
855 add_frag_mol_vol_data (this_proj -> modelgl -> volume_win -> fm_vvbox[g-2], this_proj, this_proj -> modelgl, g);
856 add_box_child_start (GTK_ORIENTATION_VERTICAL, this_proj -> modelgl -> volume_win -> fm_vbox[g-2], this_proj -> modelgl -> volume_win -> fm_vvbox[g-2], TRUE, TRUE, 0);
857 show_the_widgets (this_proj -> modelgl -> volume_win -> fm_vvbox[g-2]);
858 adjust_vol_md_step (this_proj, g);
859 }
860 }
861 else
862 {
864 }
865}
866
875GtkWidget * frag_mol_volume_search (project * this_proj, int g)
876{
877 GtkWidget * frag_mol_search = create_vbox (BSEP);
878 gchar * obj[2] = {"fragment", "molecule"};
879 gchar * str = g_strdup_printf ("Too many <b>%ss</b> in your model !\n"
880 " It is impossible to display the entire list ...\n"
881 "... instead you can look for %s(s) 'manually':\n", obj[g-2], obj[g-2]);
882 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
883 g_free (str);
884 gchar * search_item[2]={"Fragment ID:", "Molecule ID:"};
885 GtkWidget * hbox;
886 GtkWidget * entry;
887 GtkWidget * label;
888 hbox = create_hbox (0);
889 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, hbox, FALSE, FALSE, 0);
890 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(search_item[g-2], 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
891 entry = create_entry (G_CALLBACK(update_vol_frag_mol_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[g][0]);
892 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
893 str = g_strdup_printf ("in [%d - %d]", 1, this_proj -> coord -> totcoord[g]);
894 label = markup_label (str, 50, -1, 0.0, 0.5);
895 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,label, FALSE, FALSE, 20);
896 g_free (str);
897 return frag_mol_search;
898}
899
908GtkWidget * frag_mol_volume_tab (glwin * view, int geo)
909{
910 GtkWidget * vbox = create_vbox (BSEP);
911 project * this_proj = get_project_by_id (view -> proj);
912 GtkWidget * hbox;
913 gchar * str;
914 if (this_proj -> steps > 1)
915 {
916 // MD step box
917 GtkWidget * sbut = spin_button (G_CALLBACK(set_md_step_vol), view -> volume_win -> sid[geo-2], 1.0, this_proj -> steps, 1.0, 0, 1000, & view -> gcid[geo][0][geo]);
918 gtk_widget_set_size_request (sbut, 25, -1);
919 GtkWidget * fix = gtk_fixed_new ();
920 gtk_fixed_put (GTK_FIXED (fix), sbut, 0, 10);
921 str = g_strdup_printf ("<u>Select MD step [1-%d]:</u>", this_proj -> steps);
922 hbox = abox (vbox, str, 5);
923 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fix, FALSE, FALSE, 20);
924 }
925
926 int i, j;
927 for (i=0; i<FILLED_STYLES; i++)
928 {
929 if (! view -> fm_comp_vol[geo-2][i])
930 {
931 view -> fm_comp_vol[geo-2][i] = allocdbool (this_proj -> steps, this_proj -> coord -> totcoord[geo]);
932 }
933 if (! view -> anim -> last -> img -> fm_show_vol[geo-2][i])
934 {
935 view -> anim -> last -> img -> fm_show_vol[geo-2][i] = allocbool (this_proj -> coord -> totcoord[geo]);
936 }
937 if (! view -> anim -> last -> img -> fm_vol_col[geo-2][i])
938 {
939 view -> anim -> last -> img -> fm_vol_col[geo-2][i] = g_malloc0(this_proj -> coord -> totcoord[geo]*sizeof*view -> anim -> last -> img -> fm_vol_col[geo-2][i]);
940 for (j=0; j<this_proj -> coord -> totcoord[geo]; j++)
941 {
942 view -> anim -> last -> img -> fm_vol_col[geo-2][i][j] = init_color (j+i*this_proj -> coord -> totcoord[geo], FILLED_STYLES*this_proj -> coord -> totcoord[geo]);
943 view -> anim -> last -> img -> fm_vol_col[geo-2][i][j].alpha = 0.75;
944 }
945 }
946 if (! view -> frag_box[i])
947 {
948 view -> frag_box[i] = alloctdouble (this_proj -> steps, this_proj -> coord -> totcoord[geo], 9);
949 }
950 if (! view -> frag_mol_volume[geo-2][i])
951 {
952 view -> frag_mol_volume[geo-2][i] = allocddouble (this_proj -> steps, this_proj -> coord -> totcoord[geo]);
953 }
954 if (! view -> frag_mol_ppvolume[geo-2][i])
955 {
956 view -> frag_mol_ppvolume[geo-2][i] = allocddouble (this_proj -> steps, this_proj -> coord -> totcoord[geo]);
957 }
958 if (! view -> volume_win -> fm_compb[geo-2][i])
959 {
960 view -> volume_win -> fm_compb[geo-2][i] = g_malloc0 (this_proj -> coord -> totcoord[geo]*sizeof*view -> volume_win ->fm_compb[geo-2][i]);
961 }
962 if (! view -> volume_win -> fm_hbvol[geo-2][i])
963 {
964 view -> volume_win -> fm_hbvol[geo-2][i] = g_malloc0 (this_proj -> coord -> totcoord[geo]*sizeof*view -> volume_win -> fm_hbvol[geo-2][i]);
965 }
966 if (! view -> volume_win -> fm_hboxv[geo-2][i])
967 {
968 view -> volume_win -> fm_hboxv[geo-2][i] = g_malloc0 (this_proj -> coord -> totcoord[geo]*sizeof*view -> volume_win -> fm_hboxv[geo-2][i]);
969 }
970 if (! view -> volume_win -> fm_lab_vol[geo-2][i])
971 {
972 view -> volume_win -> fm_lab_vol[geo-2][i] = g_malloc0 (this_proj -> coord -> totcoord[geo]*sizeof*view -> volume_win -> fm_lab_vol[geo-2][i]);
973 }
974 }
975 GtkWidget * fragtab;
976 if (this_proj -> coord -> totcoord[geo] > 10000)
977 {
978 fragtab = create_scroll (vbox, -1, -1, GTK_SHADOW_NONE);
979 gtk_widget_set_hexpand (fragtab, TRUE);
980 gtk_widget_set_vexpand (fragtab, TRUE);
981 add_container_child (CONTAINER_SCR, fragtab, frag_mol_volume_search(this_proj, geo));
982 }
983 view -> volume_win -> fm_vbox[geo-2] = create_vbox (BSEP);
984 view -> volume_win -> fm_vvbox[geo-2] = create_vbox (BSEP);
985 add_frag_mol_vol_data (view -> volume_win -> fm_vvbox[geo-2], this_proj, view, geo);
986 add_box_child_start (GTK_ORIENTATION_VERTICAL, view -> volume_win -> fm_vbox[geo-2], view -> volume_win -> fm_vvbox[geo-2], TRUE, TRUE, 0);
987 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> volume_win -> fm_vbox[geo-2], TRUE, TRUE, 0);
988 return vbox;
989}
990
999G_MODULE_EXPORT void set_angular_precision (GtkComboBox * box, gpointer data)
1000{
1001 glwin * view = (glwin *)data;
1002 int i = gtk_combo_box_get_active (box);
1003 if (i != view -> volume_win -> angp)
1004 {
1005 project * this_proj = get_project_by_id (view -> proj);
1006 view -> volume_win -> angp = i;
1007 int j, k;
1008 for (i=0; i<FILLED_STYLES; i++)
1009 {
1010 show_the_widgets (view -> volume_win -> compb[i]);
1011 hide_the_widgets (view -> volume_win -> hboxv[i]);
1012 view -> comp_vol[i] = FALSE;
1013 widget_set_sensitive (view -> volume_win -> hbvol[i], view -> comp_vol[i]);
1014 view -> anim -> last -> img -> show_vol[i] = FALSE;
1015 for (j=0; j<2; j++)
1016 {
1017 for (k=0; k<this_proj -> coord -> totcoord[j+2]; k++)
1018 {
1019 show_the_widgets (view -> volume_win -> fm_compb[j][i][k]);
1020 hide_the_widgets (view -> volume_win -> fm_hboxv[j][i][k]);
1021 view -> fm_comp_vol[j][i][0][k] = FALSE;
1022 widget_set_sensitive (view -> volume_win -> fm_hbvol[j][i][k], view -> fm_comp_vol[j][i][0][k]);
1023 view -> anim -> last -> img -> fm_show_vol[j][i][k] = FALSE;
1024 }
1025 }
1026 }
1027 this_proj -> modelgl -> volumes = FALSE;
1028 int shaders[1] = {VOLMS};
1029 re_create_md_shaders (1, shaders, this_proj);
1030 update (view);
1031 }
1032}
1033
1041GtkWidget * vol_model_tab (glwin * view)
1042{
1043 GtkWidget * vbox = create_vbox (BSEP);
1044 abox (vbox, "<u>Volume(s) occupied by all the atom(s):</u>", 5);
1045 GtkWidget * hbox;
1046 int i, j;
1047 project * this_proj = get_project_by_id (view -> proj);
1048 GtkWidget * hhbox;
1049 gchar * str;
1050 double vof;
1051 for (i=0; i<FILLED_STYLES; i++)
1052 {
1053 hbox = create_hbox (BSEP);
1054 str = g_strdup_printf ("using <b>%s</b>: ", text_filled[i]);
1055 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 30);
1056 g_free (str);
1057 if (! view -> atoms_volume[i]) view -> atoms_volume[i] = allocdouble (this_proj -> steps);
1058 for (j=0; j<this_proj -> steps; j++) view -> atoms_volume[i][j] = get_atoms_volume (this_proj, i, j, -1, 0);
1059 vof = 0.0;
1060 for (j=0; j<this_proj -> steps; j++) vof += view -> atoms_volume[i][j];
1061 vof /= this_proj -> steps;
1062 str = g_strdup_printf ("%15.3f", vof);
1063 hhbox = create_hbox (BSEP);
1064 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 100, -1, 1.0, 0.5), FALSE, FALSE, 0);
1065 g_free (str);
1066 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label ("<b>&#xC5;<sup>3</sup></b>", 50, -1, 0.0, 0.5), FALSE, FALSE, 20);
1067 if (this_proj -> steps > 1)
1068 {
1069 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label ("average by MD step", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
1070 }
1071 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
1072 }
1073 abox (vbox, "<u>Smallest rectangle parallepiped volume(s) to englobe all atom(s):</u>", 5);
1074 hbox = create_hbox (BSEP);
1075 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new("Angular precision: "), FALSE, FALSE, 10);
1076 GtkWidget * ang_combo = create_combo ();
1077 gchar * angpr[4] = {"°", "°/10", "°/100", "°/1000"};
1078 for (i=0; i<4; i++) combo_text_append (ang_combo, angpr[i]);
1079 gtk_combo_box_set_active (GTK_COMBO_BOX(ang_combo), view -> volume_win -> angp);
1080 g_signal_connect (G_OBJECT (ang_combo), "changed", G_CALLBACK(set_angular_precision), view);
1081 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ang_combo, FALSE, FALSE, 0);
1082
1083 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 5);
1084 for (i=0; i<FILLED_STYLES; i++)
1085 {
1086 hbox = create_hbox (BSEP);
1087 str = g_strdup_printf ("using <b>%s</b>: ", text_filled[i]);
1088 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 30);
1089 g_free (str);
1090 hhbox = create_hbox (BSEP);
1091 if (! view -> comp_vol[i])
1092 {
1093 view -> anim -> last -> img -> vol_col[i].red = (i+1.0)/FILLED_STYLES;
1094 view -> anim -> last -> img -> vol_col[i].green = 1.0;
1095 view -> anim -> last -> img -> vol_col[i].blue = 0.0;
1096 view -> anim -> last -> img -> vol_col[i].alpha = 0.75;
1097 }
1098 if (! view -> atoms_ppvolume[i]) view -> atoms_ppvolume[i] = allocdouble (this_proj -> steps);
1099 if (! view -> volume_box[i]) view -> volume_box[i] = allocddouble (this_proj -> steps, 9);
1100 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, hhbox, FALSE, FALSE, 0);
1101 view -> volume_win -> compb[i] = create_button ("Compute", IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(molecular_volumes), & view -> colorp[i][0]);
1102 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, view -> volume_win -> compb[i], FALSE, FALSE, 20);
1103 vof = 0.0;
1104 for (j=0; j<this_proj -> steps; j++) vof += view -> atoms_ppvolume[i][j];
1105 vof /= this_proj -> steps;
1106 str = g_strdup_printf ("%15.3f", vof);
1107 view -> volume_win -> hboxv[i] = create_hbox (BSEP);
1108 view -> volume_win -> lab_vol[i] = markup_label (str, 100, -1, 1.0, 0.5);
1109 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> hboxv[i], view -> volume_win -> lab_vol[i], FALSE, FALSE, 20);
1110 g_free (str);
1111 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> hboxv[i], markup_label ("<b>&#xC5;<sup>3</sup></b>", 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
1112 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hhbox, view -> volume_win -> hboxv[i], FALSE, FALSE, 0);
1113 view -> volume_win -> hbvol[i] = create_hbox (BSEP);
1114 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> hbvol[i], check_button ("Show/Hide", 100, -1, view -> anim -> last -> img -> show_vol[i], G_CALLBACK(show_volumes), & view -> colorp[i][0]), FALSE, FALSE, 0);
1115 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> volume_win -> hbvol[i], color_button (view -> anim -> last -> img -> vol_col[i], TRUE, 50, -1, G_CALLBACK(set_volume_color), & view -> colorp[i][0]), FALSE, FALSE, 5);
1116 widget_set_sensitive (view -> volume_win -> hbvol[i], view -> comp_vol[i]);
1117 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, view -> volume_win -> hbvol[i], FALSE, FALSE, 5);
1118 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1119 }
1120 return vbox;
1121}
1122
1131G_MODULE_EXPORT void window_volumes (GtkWidget * widg, gpointer data)
1132{
1133 glwin * view = (glwin *) data;
1134 if (view -> volume_win == NULL)
1135 {
1136 view -> volume_win = g_malloc0 (sizeof*view -> volume_win);
1137 project * this_proj = get_project_by_id (view -> proj);
1138 gchar * str = g_strdup_printf ("%s - volumes", this_proj -> name);
1139 view -> volume_win -> win = create_win (str, view -> win, FALSE, FALSE);
1140 gtk_widget_set_size_request (view -> volume_win -> win, 450, 420);
1141 g_free (str);
1142 GtkWidget * vbox = create_vbox (BSEP);
1143 add_container_child (CONTAINER_WIN, view -> volume_win -> win, vbox);
1144 GtkWidget * notebook = gtk_notebook_new ();
1145 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, notebook, TRUE, TRUE, 0);
1146 gtk_notebook_append_page (GTK_NOTEBOOK(notebook), vol_model_tab (view), gtk_label_new ("Model"));
1147 if (view -> adv_bonding[0]) gtk_notebook_append_page (GTK_NOTEBOOK(notebook), frag_mol_volume_tab (view, 2), gtk_label_new ("Fragment(s)"));
1148 if (view -> adv_bonding[1]) gtk_notebook_append_page (GTK_NOTEBOOK(notebook), frag_mol_volume_tab (view, 3), gtk_label_new ("Molecule(s)"));
1149 add_gtk_close_event (view -> volume_win -> win, G_CALLBACK(hide_this_window), NULL);
1150 show_the_widgets (view -> volume_win -> win);
1151 int i;
1152 for (i=0; i<FILLED_STYLES; i++)
1153 {
1154 if (view -> comp_vol[i])
1155 {
1156 hide_the_widgets (view -> volume_win -> compb[i]);
1157 }
1158 else
1159 {
1160 hide_the_widgets (view -> volume_win -> hboxv[i]);
1161 }
1162 }
1163 if (view -> adv_bonding[0]) adjust_vol_md_step (this_proj, 2);
1164 if (view -> adv_bonding[1]) adjust_vol_md_step (this_proj, 3);
1165 }
1166 else
1167 {
1168 show_the_widgets (view -> volume_win -> win);
1169 }
1170}
Function declarations for the mode edition window.
atomic_object * create_object_from_frag_mol(project *this_proj, int coord, int geo, atom_search *remove)
create object from a fragment or a molecule
double ** save_coordinates(project *this_proj, int status)
save atomic coordinates
Definition atom_move.c:91
void center_molecule(project *this_proj)
center atomic coordinates around (0,0,0)
Definition glview.c:1441
Binding to the Fortran90 subroutines.
double set_radius_(int *, int *)
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
double dist
Definition d_measures.c:73
int atoms[NUM_STYLES][2]
int bonds[NUM_STYLES][2]
float val
Definition dlp_init.c:117
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:608
double pi
Definition global.c:195
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 object_motion
Definition global.c:186
gboolean ** allocdbool(int xal, int yal)
allocate a gboolean ** pointer
Definition global.c:270
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:445
project * proj
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
#define BSEP
Definition global.h:245
G_MODULE_EXPORT gboolean hide_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
hide a GtkWindow
Definition gtk-misc.c:2371
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2387
GtkWidget * spin_button(GCallback handler, double value, double start, double end, double step, int digits, int dim, gpointer data)
create a spin button
Definition gtk-misc.c:1772
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
@ CONTAINER_WIN
Definition global.h:250
@ CONTAINER_SCR
Definition global.h:251
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1863
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:299
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2236
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1728
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:671
#define min(a, b)
Definition global.h:81
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
#define CHEM_Z
Definition global.h:297
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
Definition gtk-misc.c:1912
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
#define max(a, b)
Definition global.h:80
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void draw(glwin *view)
main drawing subroutine for the OpenGL window
Definition ogl_draw.c:461
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
#define FILLED_STYLES
Definition glwin.h:105
char * text_filled[FILLED_STYLES]
Definition m_style.c:61
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ VOLMS
Definition glwin.h:102
Messaging function declarations.
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:886
int sp
Definition global.h:888
Definition glwin.h:875
Definition global.h:112
Definition global.h:104
float y
Definition math_3d.h:130
float x
Definition math_3d.h:130
float z
Definition math_3d.h:130
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int d
Definition tab-1.c:95
int a
Definition tab-1.c:95
gchar * cpos[3]
Definition w_advance.c:138
GtkWidget * res[2]
Definition w_encode.c:212
G_MODULE_EXPORT void set_md_step_vol(GtkSpinButton *res, gpointer data)
change MD step spin callback
Definition w_volumes.c:694
GtkWidget * vol_model_tab(glwin *view)
create the 'Model' volume tab
Definition w_volumes.c:1041
G_MODULE_EXPORT void fm_molecular_volumes(GtkButton *but, gpointer data)
compute fragment / molecule volume
Definition w_volumes.c:535
double cap_volume(double ht, double dh)
compute cap volume
Definition w_volumes.c:139
double get_atoms_box(project *this_proj, int rid, int sid, int geo, int gid)
find volume box parameters for object
Definition w_volumes.c:326
double get_atoms_volume(project *this_proj, int rid, int sid, int gid, int gcid)
compute exact atomic volume for all system or fragment or molecule
Definition w_volumes.c:189
G_MODULE_EXPORT void set_angular_precision(GtkComboBox *box, gpointer data)
change angular precision
Definition w_volumes.c:999
void add_frag_mol_vol_data(GtkWidget *vbox, project *this_proj, glwin *view, int geo)
add fragment / molecule volume data to the search tab
Definition w_volumes.c:712
double vamin[3]
Definition w_volumes.c:254
double molecular_volume(int nats, atom *ats_vol, double baryc[3], double *rvdws, double a_ang, double b_ang, double c_ang)
compute volume
Definition w_volumes.c:269
double get_sphere_caps_volume(double dab, double rad, double rbd)
compute sphere cap volume
Definition w_volumes.c:153
GtkWidget * frag_mol_volume_tab(glwin *view, int geo)
create the fragment(s) / molecule(s) tab
Definition w_volumes.c:908
G_MODULE_EXPORT void window_volumes(GtkWidget *widg, gpointer data)
create the 'Volumes' window callback
Definition w_volumes.c:1131
double draw_cuboid(gboolean draw, int SHADID, int shadnum, mat4_t rot, vec3_t cpos, double paral[3][3], ColRGBA col, double slab_alpha)
draw cuboid vertices
Definition d_box.c:523
G_MODULE_EXPORT void update_vol_frag_mol_search(GtkEntry *res, gpointer data)
update fragment / molecule search entry
Definition w_volumes.c:822
double vamax[3]
Definition w_volumes.c:254
G_MODULE_EXPORT void molecular_volumes(GtkButton *but, gpointer data)
compute volume
Definition w_volumes.c:445
G_MODULE_EXPORT void fm_set_volume_color(GtkColorChooser *colob, gpointer data)
change fragment / molecule volume color
Definition w_volumes.c:676
void adjust_vol_md_step(project *this_proj, int geo)
update volume value labels
Definition w_volumes.c:475
void clean_volumes_data(glwin *view)
clean volume data
Definition w_volumes.c:83
double sphere_volume(double rad)
compute sphere volume
Definition w_volumes.c:173
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
Definition glview.c:1522
G_MODULE_EXPORT void set_volume_color(GtkColorChooser *colob, gpointer data)
change volume color
Definition w_volumes.c:658
GtkWidget * frag_mol_volume_search(project *this_proj, int g)
create the fragment(s) / molecule(s) search widget
Definition w_volumes.c:875
G_MODULE_EXPORT void fm_show_volumes(GtkToggleButton *but, gpointer data)
toggle show / hide fragment / molecule volume callback GTK3
Definition w_volumes.c:635
G_MODULE_EXPORT void show_volumes(GtkToggleButton *but, gpointer data)
toggle show / hide volume callback GTK3
Definition w_volumes.c:601
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72