atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
dlp_viz.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2025 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'dlp_viz.c'
24*
25* Contains:
26*
27
28 - The functions to handle the visualization events when creating a classical force field
29
30*
31* List of functions:
32
33 int get_field_objects (int id, int jd);
34
35 gboolean show_field_object (int id, int jd, int kd);
36
37 void field_selection (int i, int viz, int lab, int aid);
38 void viz_fragment (field_molecule * fmol, int id, int viz);
39 void field_unselect_all ();
40 void visualize_bonds (int viz, int aid,
41 field_atom* at,
42 field_atom* bt);
43 void visualize_angles (int viz, int aid,
44 field_atom* at,
45 field_atom* bt,
46 field_atom* ct);
47 void visualize_dihedrals (int viz, int did,
48 field_atom* at,
49 field_atom* bt,
50 field_atom* ct,
51 field_atom* dt);
52 void visualize_imp_inv (int viz, int dih, int iid,
53 field_atom* at,
54 field_atom* bt,
55 field_atom* ct,
56 field_atom* dt);
57 void visualize_body (int viz, int bd, field_nth_body * body);
58 void select_object (int id, int jd, int kd);
59 void visualize_single_struct (int id, int jd, int kd, int * ids);
60 void visualize_object (int id, int jd, int kd);
61 void check_to_visualize_properties_for_this_field_mol (int pid, int mol);
62 void check_to_visualize_properties (int pid);
63 void update_mol_tree (int a, int b);
64
65 G_MODULE_EXPORT void on_toggle_visualize_or_select_object (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
66 G_MODULE_EXPORT void visualize_or_select_all_elements (GtkTreeViewColumn * col, gpointer data);
67
68*/
69
70#include "dlp_field.h"
71#include "project.h"
72#include "glwindow.h"
73#include "glview.h"
74
76
77extern int is_special[MAXDATA][11];
78extern void update_selection_list (atom_selection * at_list, atom * at, gboolean add);
79extern void init_default_shaders (glwin * view);
80
91void field_selection (int i, int viz, int lab, int aid)
92{
93 if (viz && tmp_proj -> atoms[0][i].pick[0] != viz)
94 {
95 tmp_view -> picked ++;
96 }
97 else if (! viz && tmp_proj -> atoms[0][i].pick[0] != viz)
98 {
99 tmp_view -> picked --;
100 }
101 tmp_proj -> atoms[0][i].pick[0] = viz;
102 tmp_proj -> atoms[0][i].label[0] = lab;
103 tmp_proj -> atoms[0][i].coord[4] = aid;
104}
105
115void viz_fragment (field_molecule * fmol, int id, int viz)
116{
117 int i;
118 for (i=0; i<tmp_proj -> natomes; i++)
119 {
120 if (tmp_proj -> atoms[0][i].coord[2] == fmol -> fragments[id]) field_selection (i, viz, viz, id);
121 }
123}
124
131{
132 int i;
133 for (i=0; i<tmp_proj -> natomes; i++) field_selection (i, FALSE, FALSE, 0);
135}
136
137extern gboolean in_bond (int at, int bd[2]);
138
149void visualize_bonds (int viz, int bid,
150 field_atom* at,
151 field_atom* bt)
152{
153 int i, j, k, l;
154 for (i=0; i<at -> num; i++)
155 {
156 j = at -> list[i];
157 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
158 {
159 l = tmp_proj -> atoms[0][j].vois[k];
160 if (tmp_proj -> atoms[0][l].faid == bt -> id)
161 {
162 field_selection (j, viz, FALSE, bid);
163 field_selection (l, viz, FALSE, bid);
164 }
165 }
166 }
167}
168
183void visualize_angles (int viz, int aid,
184 field_atom* at,
185 field_atom* bt,
186 field_atom* ct)
187{
188 int i, j, k, l, m, n;
189 for (i=0; i<at -> num; i++)
190 {
191 j = at -> list[i];
192 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
193 {
194 l = tmp_proj -> atoms[0][j].vois[k];
195 if (tmp_proj -> atoms[0][l].faid == bt -> id)
196 {
197 for (m=0; m<tmp_proj -> atoms[0][l].numv; m++)
198 {
199 n = tmp_proj -> atoms[0][l].vois[m];
200 if (n != j && tmp_proj -> atoms[0][n].faid == ct -> id)
201 {
202 field_selection (j, viz, FALSE, aid);
203 field_selection (l, viz, FALSE, aid);
204 field_selection (n, viz, FALSE, aid);
205 }
206 }
207 }
208 }
209 }
210}
211
228void visualize_dihedrals (int viz, int did,
229 field_atom* at,
230 field_atom* bt,
231 field_atom* ct,
232 field_atom* dt)
233{
234 int i, j, k, l, m, n, o, p;
235 for (i=0; i<tmp_fat -> num; i++)
236 {
237 j = tmp_fat -> list[i];
238 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
239 {
240 l = tmp_proj -> atoms[0][j].vois[k];
241 if (tmp_proj -> atoms[0][l].faid == tmp_fbt -> id)
242 {
243 for (m=0; m<tmp_proj -> atoms[0][l].numv; m++)
244 {
245 n = tmp_proj -> atoms[0][l].vois[m];
246 if (n != j && tmp_proj -> atoms[0][n].faid == tmp_fct -> id)
247 {
248 for (o=0; o<tmp_proj -> atoms[0][n].numv; o++)
249 {
250 p = tmp_proj -> atoms[0][n].vois[o];
251 if (p != j && p != l && tmp_proj -> atoms[0][p].faid == tmp_fdt -> id)
252 {
253 field_selection (j, viz, FALSE, did);
254 field_selection (l, viz, FALSE, did);
255 field_selection (n, viz, FALSE, did);
256 field_selection (p, viz, FALSE, did);
257 }
258 }
259 }
260 }
261 }
262 }
263 }
264}
265
283void visualize_imp_inv (int viz, int dih, int iid,
284 field_atom* at,
285 field_atom* bt,
286 field_atom* ct,
287 field_atom* dt)
288{
289 int i, j, k, l, m, n, o, p;
290 for (i=0; i<tmp_fat -> num; i++)
291 {
292 j = tmp_fat -> list[i];
293 if ((tmp_proj -> atoms[0][j].numv > 2 && dih == 6) || (tmp_proj -> atoms[0][j].numv == 3 && dih == 7))
294 {
295 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
296 {
297 l = tmp_proj -> atoms[0][j].vois[k];
298 if (tmp_proj -> atoms[0][l].faid == tmp_fbt -> id)
299 {
300 for (m=0; m<tmp_proj -> atoms[0][j].numv; m++)
301 {
302 if (m != k)
303 {
304 n = tmp_proj -> atoms[0][j].vois[m];
305 if (tmp_proj -> atoms[0][n].faid == tmp_fct -> id)
306 {
307 for (o=0; o<tmp_proj -> atoms[0][j].numv; o++)
308 {
309 if (o != k && o != m)
310 {
311 p = tmp_proj -> atoms[0][j].vois[o];
312 if (tmp_proj -> atoms[0][p].faid == tmp_fdt -> id)
313 {
314 field_selection (j, viz, FALSE, iid);
315 field_selection (l, viz, FALSE, iid);
316 field_selection (n, viz, FALSE, iid);
317 field_selection (p, viz, FALSE, iid);
318 }
319 }
320 }
321 }
322 }
323 }
324 }
325 }
326 }
327 }
328}
329
339void visualize_body (int viz, int bd, field_nth_body * body)
340{
341 int h, i, j, k, l;
342 l = body_at (body -> bd);
343 for (h=0; h<l; h++)
344 {
345 for (i=0; i < body -> na[h]; i++)
346 {
347 tmp_fat = get_active_atom (body -> ma[h][i], body -> a[h][i]);
348 for (j=0; j < tmp_fat -> num; j++)
349 {
350 k = tmp_fat -> list[j];
351 field_selection (k, viz, viz, bd);
352 }
353 }
354 }
355}
356
365int get_field_objects (int id, int jd)
366{
367 int kd;
368 int i;
369 switch (id)
370 {
371 case -1:
372 kd = 0;
373 for (i=0; i<tmp_field -> molecules; i++) kd = max(kd, get_active_field_molecule (i) -> mol -> natoms);
374 break;
375 case 0:
376 kd = tmp_field -> molecules;
377 break;
378 case 1:
379 kd = 0;
380 for (i=0; i<tmp_field -> molecules; i++) kd = max(kd, get_active_field_molecule (i) -> atoms);
381 break;
382 case 2:
383 kd = get_active_field_molecule (jd) -> shells;
384 break;
385 case 3:
386 kd = get_active_field_molecule (jd) -> constraints;
387 break;
388 case 4:
389 kd = get_active_field_molecule (jd) -> pmfs;
390 break;
391 case 5:
392 kd = get_active_field_molecule (jd) -> rigids;
393 break;
394 case 6:
395 kd = get_active_field_molecule (jd) -> tethered;
396 break;
397 case SEXTERN:
398 kd = tmp_field -> extern_fields;
399 break;
400 default:
401 if (id < MOLIMIT)
402 {
403 kd = get_active_field_molecule (jd) -> nstruct[id-7];
404 }
405 else
406 {
407 kd = tmp_field -> nbody[id - MOLIMIT];
408 }
409 break;
410 }
411 return kd;
412}
413
423void select_object (int id, int jd, int kd)
424{
425 int i;
426 field_object = id;
428 switch (id)
429 {
430 case 2:
431 // Select a core-shell unit in a molecule
432 tmp_fshell = get_active_shell (kd, jd);
433 if (tmp_fshell -> ia[0] < 0 || tmp_fshell -> ia[1] < 0) toviz.c = FALSE;
434 tmp_fshell -> use = toviz.c;
435 break;
436 case 3:
437 // Select a contraint bond in a molecule
439 if (! tmp_fcons -> ia[0] || ! tmp_fcons -> ia[1]) toviz.c = FALSE;
440 tmp_fcons -> use = toviz.c;
441 break;
442 case 4:
443 // Select a PMF in a molecule
444 tmp_fpmf = get_active_field_molecule (kd) -> first_pmf;
445 for (i=0; i < get_active_field_molecule(kd) -> pmfs; i++)
446 {
447 tmp_fpmf -> use = FALSE;
448 if (tmp_fpmf -> next != NULL) tmp_fpmf = tmp_fpmf -> next;
449 }
450 tmp_fpmf = get_active_pmf (kd, jd);
451 if (tmp_fpmf -> num[0] > 0 && tmp_fpmf -> num[1] > 0) tmp_fpmf -> use = toviz.c;
452 break;
453 case SEXTERN:
454 tmp_fext = tmp_field -> first_external;
455 for (i=0; i < tmp_field -> extern_fields; i++)
456 {
457 tmp_fext -> use = FALSE;
458 if (tmp_fext -> next != NULL) tmp_fext = tmp_fext -> next;
459 }
461 tmp_fext -> use = toviz.c;
462 break;
463 default:
464 if (id < MOLIMIT)
465 {
466 get_active_struct (id-7, kd, jd) -> def -> use = toviz.c;
467 }
468 else
469 {
470 get_active_body (jd, id - MOLIMIT) -> use = toviz.c;
471 }
472 break;
473 }
474}
475
486void visualize_single_struct (int id, int jd, int kd, int * ids)
487{
488 int i, j, k, l, m, n, o, p;
489 int * idat;
490 i = struct_id(id);
491 idat = allocint (i);
492 for (j=0; j<i; j++)
493 {
494 k = ids[j];
495 idat[j] = get_active_atom (kd, tmp_fmol -> atoms_id[k][0].a) -> id;
496 }
497 for (j=0; j<i; j++)
498 {
499 k = ids[j];
500 for (l=0; l< tmp_fmol -> multi; l++)
501 {
502 m = tmp_fmol -> atoms_id[k][l].b;
503 n = get_active_atom (kd, tmp_fmol -> atoms_id[k][l].a) -> list[m];
504 field_selection (n, 0, 0, k);
505 }
506 }
507 g_free (idat);
508 i = ids[0];
509 j = ids[1];
510 for (l=0; l< tmp_fmol -> multi; l++)
511 {
512 m = tmp_fmol -> atoms_id[i][l].b;
513 n = get_active_atom (kd, tmp_fmol -> atoms_id[i][l].a) -> list[m];
514 field_selection (n, toviz.c, 0, jd);
515 o = tmp_fmol -> atoms_id[j][l].b;
516 p = get_active_atom (kd, tmp_fmol -> atoms_id[j][l].a) -> list[o];
517 field_selection (p, toviz.c, 0, jd);
518 }
519 if (id > 8 && id < 15)
520 {
521 k = ids[2];
522 for (l=0; l< tmp_fmol -> multi; l++)
523 {
524 o = tmp_fmol -> atoms_id[k][l].b;
525 p = get_active_atom (kd, tmp_fmol -> atoms_id[k][l].a) -> list[o];
526 field_selection (p, toviz.c, 0, jd);
527 }
528 if (id > 10)
529 {
530 i = ids[3];
531 for (l=0; l< tmp_fmol -> multi; l++)
532 {
533 o = tmp_fmol -> atoms_id[i][l].b;
534 p = get_active_atom (kd, tmp_fmol -> atoms_id[i][l].a) -> list[o];
535 field_selection (p, toviz.c, 0, jd);
536 }
537 }
538 }
539}
540
550void visualize_object (int id, int jd, int kd)
551{
552 int l, m, n, o, p, q, r, s;
553 field_atom* tshell;
554 field_object = id;
556 switch (id)
557 {
558 case -1:
559 // View molecule atoms id
561 tmp_fmol -> show_id = toviz.c;
562 tmp_fat = tmp_fmol -> first_atom;
563 for (m=0; m < tmp_fmol -> atoms; m++)
564 {
565 for (n=0; n < tmp_fat -> num; n++)
566 {
567 field_selection (tmp_fat -> list[n], toviz.c, toviz.c, tmp_fat -> list_id[n]);
568 }
569 if (tmp_fat -> next != NULL) tmp_fat = tmp_fat -> next;
570 }
571 break;
572 case 0:
573 // View an entire molecule
575 tmp_fmol -> show = toviz.c;
576 for (m=0; m<tmp_fmol -> multi; m++)
577 {
578 toviz.a = 2;
579 toviz.b = tmp_fmol -> fragments[m];
580 for (n=0; n<tmp_proj -> natomes; n++)
581 {
582 if (tmp_proj -> atoms[0][n].coord[2] == toviz.b) field_selection (n, toviz.c, toviz.c, jd);
583 }
584 }
585 break;
586 case 1:
587 // View a type of atoms in a molecule
588 tmp_fat = get_active_atom (kd, jd);
589 tmp_fat -> show = toviz.c;
590 for (m=0; m<tmp_fat -> num; m++)
591 {
592 n = tmp_fat -> list[m];
593 field_selection (n, toviz.c, toviz.c, jd);
594 }
595 break;
596 case 2:
597 // View a type of Core-shell unit in a molecule
598 tmp_fshell = get_active_shell (kd, jd);
599 tmp_fshell -> show = toviz.c;
600 for (m=0; m<2; m++)
601 {
602 if (tmp_fshell -> ia[m])
603 {
604 n = tmp_fshell -> ia[0]-1;
605 tshell = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[0][n].a);
606 for (o=0; o<tmp_fmol -> multi; o++)
607 {
608 p = tmp_fmol -> atoms_id[n][o].b;
609 field_selection (tshell -> list[p], toviz.c, toviz.c, jd);
610 }
611 }
612 }
613 break;
614 case 3:
615 // View a type of bond constraint in a molecule
617 tmp_fcons -> show = toviz.c;
618 for (l=0; l<2; l++)
619 {
620 if (tmp_fcons -> ia[l])
621 {
622 for (m=0; m<tmp_fmol -> multi; m++)
623 {
624 n = tmp_fmol -> atoms_id[tmp_fcons -> ia[l]-1][m].a;
625 o = tmp_fmol -> atoms_id[tmp_fcons -> ia[l]-1][m].b;
626 p = get_active_atom (tmp_fmol -> id, n) -> list[o];
627 field_selection (p, toviz.c, toviz.c, jd);
628 }
629 }
630 }
631 break;
632 case 4:
633 tmp_fpmf = get_active_pmf (kd, jd);
634 tmp_fpmf -> show = toviz.c;
635 for (m=0; m<2; m++)
636 {
637 if (tmp_fpmf -> num[m] > 0)
638 {
639 for (n=0; n<tmp_fpmf -> num[m]; n++)
640 {
641 o = tmp_fpmf -> list[m][n];
642 for (p=0; p<tmp_fmol -> multi;p++)
643 {
644 q = tmp_fmol -> atoms_id[o][p].a;
645 r = tmp_fmol -> atoms_id[o][p].b;
646 s = get_active_atom (tmp_fmol -> id, q) -> list[r];
647 field_selection (s, toviz.c, toviz.c, jd);
648 }
649 }
650 }
651 }
652 break;
653 case 5:
654 tmp_frig = get_active_rigid (kd, jd);
655 tmp_frig -> show = toviz.c;
656 if (tmp_frig -> num > 0)
657 {
658 for (n=0; n<tmp_frig -> num; n++)
659 {
660 o = tmp_frig -> list[n];
661 for (p=0; p<tmp_fmol -> multi;p++)
662 {
663 q = tmp_fmol -> atoms_id[o][p].a;
664 r = tmp_fmol -> atoms_id[o][p].b;
665 s = get_active_atom (tmp_fmol -> id, q) -> list[r];
666 field_selection (s, toviz.c, toviz.c, jd);
667 }
668 }
669 }
670 break;
671 case 6:
672 tmp_ftet = get_active_tethered (kd, jd);
673 tmp_ftet -> show = toviz.c;
674 if (tmp_ftet -> num)
675 {
676 o = tmp_ftet -> num-1;
677 p = tmp_fmol -> atoms_id[o][0].a;
678 for (q=0; q<tmp_fmol -> multi;q++)
679 {
680 r = tmp_fmol -> atoms_id[o][q].b;
681 s = get_active_atom (tmp_fmol -> id, p) -> list[r];
682 field_selection (s, toviz.c, toviz.c, jd);
683 }
684 }
685 break;
686 case SEXTERN:
687
688 break;
689 default:
690 if (id < MOLIMIT)
691 {
692 // View a type of bond / angles / dihedral / improper / inversion in a molecule
693 tmp_fstr = get_active_struct (id-7, kd, jd);
694 tmp_fat = get_active_atom (kd, tmp_fstr -> aid[0]);
695 tmp_fbt = get_active_atom (kd, tmp_fstr -> aid[1]);
696 if (id > 8) tmp_fct = get_active_atom (kd, tmp_fstr -> aid[2]);
697 if (id > 10) tmp_fdt = get_active_atom (kd, tmp_fstr -> aid[3]);
698 tmp_fstr -> def -> show = toviz.c;
699 if (id < 9)
700 {
701 visualize_bonds (tmp_fstr -> def -> show, jd, tmp_fat, tmp_fbt);
702 }
703 else if (id < 11)
704 {
705 visualize_angles (tmp_fstr -> def -> show, jd, tmp_fat, tmp_fbt, tmp_fct);
706 }
707 else if (id < 13)
708 {
710 }
711 else if (id < 15)
712 {
713 visualize_imp_inv (tmp_fstr -> def -> show, id-7, jd, tmp_fat, tmp_fbt, tmp_fct, tmp_fdt);
714 }
715 }
716 else
717 {
718 // View a non-bonded interaction
719 tmp_fbody = get_active_body (jd, id - MOLIMIT);
720 tmp_fbody -> show = toviz.c;
721 visualize_body (tmp_fbody -> show, jd, tmp_fbody);
722 }
723 break;
724 }
725}
726
736{
737 int h, i, j;
738 field_prop * propv;
739 h = toviz.c;
740 toviz.c = 1;
742 i = get_field_objects (pid, mol);
743 for (j=0; j<i; j++)
744 {
745 if (show_field_object (pid, j, mol)) visualize_object (pid, j, mol);
746 if (pid > 6 && pid < MOLIMIT)
747 {
748 propv = get_active_struct (pid-7, mol, j) -> other;
749 while (propv)
750 {
751 if (propv -> show) visualize_single_struct (pid, j, mol, propv -> aid);
752 propv = propv -> next;
753 }
754 }
755 }
756 toviz.c = h;
757}
758
767{
768 int i, j;
769 i = (pid < MOLIMIT) ? tmp_field -> molecules : 1;
770 for (j=0; j<i; j++)
771 {
773 }
775}
776
785void update_mol_tree (int a, int b)
786{
787 int i, j;
788 j = toviz.c;
789 for (i=0; i<tmp_field -> molecules; i++)
790 {
791 if (get_active_field_molecule (i) -> show_id && ! a)
792 {
793 toviz.c = 0;
794 visualize_object (-1, i, 0);
796 toviz.c = j;
797 }
798 else if (get_active_field_molecule (i) -> show && a)
799 {
800 toviz.c = 0;
801 visualize_object (0, i, 0);
803 toviz.c = j;
804 }
805 }
806 if (a)
807 {
808 get_active_field_molecule (b) -> show_id = j;
809 }
810 else
811 {
812 get_active_field_molecule (b) -> show = j;
813 }
814 gtk_tree_store_clear (field_model[0]);
816 fill_field_model (field_model[0], 0, -1);
817}
818
828G_MODULE_EXPORT void on_toggle_visualize_or_select_object (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
829{
830 int i, j, k, l, m, n;
831 int * ids = NULL;
832 tint * dat = (tint * )data;
833 GtkTreeIter iter;
834 gboolean forall;
835
836 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
837 {
838 toviz.c = 0;
839 }
840 else
841 {
842 toviz.c = 1;
843 }
844
845 i = dat -> b;
846 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
847 gtk_tree_model_get_iter (GTK_TREE_MODEL(field_model[i]), & iter, path);
848 forall = TRUE;
849 if (i > 6 && i < MOLIMIT)
850 {
851 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, 0, & k, -1);
852 if (! k)
853 {
854 gchar * str;
855 forall = FALSE;
856 j = combo_get_active (combo_mol[i-1]);
858 l = struct_id(i);
859 ids = allocint (l);
860 if (dat -> c == 0)
861 {
862 field_object = i;
864 }
865 for (m=1; m<l+1; m++)
866 {
867 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, m, & str, -1);
868 n = (int) string_to_double ((gpointer)str) - 1;
869 ids[m-1] = n;
870 }
871 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, field_v[i]+1, & m, -1);
872 tmp_fstr = get_active_struct (i-7, j, m);
873 if (ids[0] < 0)
874 {
875 tmp_fprop = tmp_fstr -> def;
876 }
877 else
878 {
879 if (tmp_fstr -> other)
880 {
882 if (! tmp_fprop)
883 {
884 tmp_fprop = tmp_fstr -> other;
885 while (tmp_fprop -> next) tmp_fprop = tmp_fprop -> next;
886 tmp_fprop -> next = duplicate_field_prop (tmp_fstr -> def, i-7);
887 tmp_fprop = tmp_fprop -> next;
888 for (n=0; n<l; n++) tmp_fprop -> aid[n] = ids[n];
889 }
890 }
891 else
892 {
893 tmp_fstr -> other = duplicate_field_prop (tmp_fstr -> def, i-7);
894 for (n=0; n<l; n++) tmp_fstr -> other -> aid[n] = ids[n];
895 tmp_fprop = tmp_fstr -> other;
896 }
897 }
898 if (dat -> c) tmp_fprop -> use = toviz.c;
899 if (! dat -> c) tmp_fprop -> show = toviz.c;
900 adjust_field_prop (i-7, l, NULL, ids, tmp_fprop -> key);
901 j = m-1;
902 }
903 else
904 {
905 j = k-1;
906 }
907 }
908 else
909 {
910 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, 0, & k, -1);
911 j = k-1;
912 }
913
914 if (forall)
915 {
916 k = -1;
917 if (i > 0 && i < MOLIMIT)
918 {
919 k = combo_get_active (combo_mol[i-1]);
921 }
922 if (i == 0 && dat -> c == 1)
923 {
924 update_mol_tree (1, j);
925 visualize_object (-1, j, k);
927 }
928 else if (dat -> c == 0)
929 {
930 if (i == 0) update_mol_tree (0, j);
931 visualize_object (i, j, k);
933 }
934 else
935 {
936 select_object (i, j, k);
937 }
938 }
939 else if (dat -> c == 0)
940 {
941 k = combo_get_active (combo_mol[i-1]);
942 visualize_single_struct (i, j+1, k, ids);
944 }
945
946 if (ids) g_free (ids);
947 if (forall || i == 4 || i == SEXTERN)
948 {
949 gtk_tree_store_clear (field_model[i]);
950 fill_field_model (field_model[i], i, k);
951 }
952 else if (! forall && i > 0 && i != 4 && i != SEXTERN)
953 {
954 for (l=0; l<field_v[i]; l++)
955 {
956 if (is_special[i][l] - 2 == dat -> c) break;
957 }
958 gtk_tree_store_set (field_model[i], & iter, l, toviz.c, -1);
959 }
960}
961
971gboolean show_field_object (int id, int jd, int kd)
972{
973 gboolean show = FALSE;
974 switch (id)
975 {
976 case -1:
977 show = get_active_field_molecule (jd) -> show;
978 break;
979 case 0:
980 show = get_active_field_molecule (jd) -> show;
981 break;
982 case 1:
983 show = (jd < get_active_field_molecule (kd) -> atoms) ? get_active_atom (kd, jd) -> show : FALSE;
984 break;
985 case 2:
986 show = get_active_shell (kd, jd) -> show;
987 break;
988 case 3:
989 show = get_active_constraint (kd, jd) -> show;
990 break;
991 case 4:
992 show = get_active_pmf (kd, jd) -> show;
993 break;
994 case 5:
995 show = get_active_rigid (kd, jd) -> show;
996 break;
997 case 6:
998 show = get_active_tethered (kd, jd) -> show;
999 break;
1000 default:
1001 if (id < MOLIMIT)
1002 {
1003 show = get_active_struct (id-7, kd, jd) -> def -> show;
1004 }
1005 else
1006 {
1007 show = get_active_body (jd, id - MOLIMIT) -> show;
1008 }
1009 break;
1010 }
1011 return show;
1012}
1013
1022G_MODULE_EXPORT void visualize_or_select_all_elements (GtkTreeViewColumn * col, gpointer data)
1023{
1024 int i, j, k, l;
1025 tint * dat = (tint *)data;
1026 i = dat -> b;
1027 j = -1;
1028 if (i > 0 && i < MOLIMIT) j = combo_get_active (combo_mol[i-1]);
1030 if (i < 7)
1031 {
1032 switch (i)
1033 {
1034 case 0:
1035 toviz.c = (dat -> c) ? get_active_field_molecule (0) -> show_id : get_active_field_molecule (0) -> show;
1036 break;
1037 case 1:
1038 toviz.c = get_active_field_molecule (j) -> first_atom -> show;
1039 break;
1040 case 2:
1041 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_shell -> use : get_active_field_molecule (j) -> first_shell -> show;
1042 break;
1043 case 3:
1044 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_constraint -> use : get_active_field_molecule (j) -> first_constraint -> show;
1045 break;
1046 case 4:
1047 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_pmf -> use : get_active_field_molecule (j) -> first_pmf -> show;
1048 break;
1049 case 5:
1050 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_rigid -> use : get_active_field_molecule (j) -> first_rigid -> show;
1051 break;
1052 case 6:
1053 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_tethered-> use : get_active_field_molecule (j) -> first_tethered -> show;
1054 break;
1055 }
1056 toviz.c = ! toviz.c;
1057 }
1058 else if (i > 6 && i < MOLIMIT)
1059 {
1061 {
1063 tmp_fstr = tmp_fmol -> first_struct[i-7];
1064 toviz.c = (dat -> c == 0) ? ! tmp_fstr -> def -> show : ! tmp_fstr -> def -> use;
1065 while (tmp_fstr)
1066 {
1067 if (dat -> c) tmp_fstr -> def -> use = toviz.c;
1068 if (! dat -> c) tmp_fstr -> def -> show = toviz.c;
1069 if (tmp_fstr -> other)
1070 {
1071 tmp_fprop = tmp_fstr -> other;
1072 while (tmp_fprop)
1073 {
1074 if (dat -> c) tmp_fprop -> use = toviz.c;
1075 if (! dat -> c) tmp_fprop -> show = toviz.c;
1076 tmp_fprop = tmp_fprop -> next;
1077 }
1078 }
1079 tmp_fstr = tmp_fstr -> next;
1080 }
1081 }
1082 }
1083 else
1084 {
1085 tmp_fbody = tmp_field -> first_body[i - MOLIMIT];
1086 toviz.c = (dat -> c == 0) ? ! tmp_fbody -> show : ! tmp_fbody -> use;
1087 while (tmp_fbody)
1088 {
1089 if (dat -> c) tmp_fbody -> use = toviz.c;
1090 if (! dat -> c) tmp_fbody -> show = toviz.c;
1091 tmp_fbody = tmp_fbody -> next;
1092 }
1093 }
1094
1096 {
1097 if (i == 0 && dat -> c == 1)
1098 {
1101 for (k=0; k<l; k++)
1102 {
1103 field_object = k;
1104 update_mol_tree (1, k);
1105 visualize_object (-1, k, -1);
1106 }
1108 }
1109 else if (dat -> c == 0)
1110 {
1111 for (k=0; k<num_field_objects; k++)
1112 {
1113 field_object = k;
1114 if (i == 0) update_mol_tree (0, k);
1115 visualize_object (i, k, j);
1116 }
1118 }
1119 else
1120 {
1121 for (k=0; k<num_field_objects; k++)
1122 {
1123 select_object (i, k, j);
1124 }
1125 }
1126 gtk_tree_store_clear (field_model[i]);
1127 fill_field_model (field_model[i], i, j);
1128 }
1129}
insertion_menu mol[]
Definition w_library.c:193
ColRGBA col
Definition d_measures.c:77
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
field_constraint * get_active_constraint(int a, int b)
retrieve constraint property
Definition dlp_active.c:185
field_molecule * get_active_field_molecule(int a)
retrieve field molecule
Definition dlp_active.c:87
field_rigid * get_active_rigid(int a, int b)
retrieve rigid property
Definition dlp_active.c:225
field_prop * get_active_prop_using_atoms(struct field_prop *pr, int ti, int *ids)
retrieve field molecule structural property using atoms
Definition dlp_active.c:286
field_struct * get_active_struct(int s, int a, int b)
retrieve field structural property
Definition dlp_active.c:318
field_shell * get_active_shell(int a, int b)
retrieve shell property
Definition dlp_active.c:165
field_atom * get_active_atom(int a, int b)
retrieve field atom
Definition dlp_active.c:145
field_external * get_active_external(int a)
retrieve external field property
Definition dlp_active.c:125
field_nth_body * get_active_body(int a, int b)
retrieve field nth body interaction
Definition dlp_active.c:106
field_pmf * get_active_pmf(int a, int b)
retrieve PMF property
Definition dlp_active.c:205
field_tethered * get_active_tethered(int a, int b)
retrieve tethered property
Definition dlp_active.c:245
field_prop * duplicate_field_prop(field_prop *old_prop, int ti)
create a copy of a field property
Definition dlp_copy.c:218
void adjust_field_prop(int fil, int sti, field_prop *tmp, int *ids, int key)
adjust field property
Definition dlp_edit.c:163
int * atoms_id
glwin * tmp_view
Definition dlp_field.c:952
field_constraint * tmp_fcons
Definition dlp_field.c:959
int field_object
Definition dlp_field.c:979
field_nth_body * tmp_fbody
Definition dlp_field.c:965
project * tmp_proj
Definition dlp_field.c:953
field_shell * tmp_fshell
Definition dlp_field.c:958
field_rigid * tmp_frig
Definition dlp_field.c:961
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1022
int num_field_objects
Definition dlp_field.c:981
field_pmf * tmp_fpmf
Definition dlp_field.c:960
field_external * tmp_fext
Definition dlp_field.c:967
field_atom * tmp_fat
Definition dlp_field.c:957
GtkTreeStore * field_model[MAXDATA]
Definition dlp_field.c:947
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:999
void fill_field_model(GtkTreeStore *store, int f, int m)
classical force field fill the tree store
Definition dlp_field.c:1264
field_struct * tmp_fstr
Definition dlp_field.c:964
field_molecule * tmp_fmol
Definition dlp_field.c:955
field_atom * tmp_fdt
Definition dlp_field.c:957
field_prop * tmp_fprop
Definition dlp_field.c:963
field_tethered * tmp_ftet
Definition dlp_field.c:962
field_atom * tmp_fct
Definition dlp_field.c:957
int field_v[MAXDATA]
Definition dlp_field.c:830
field_atom * tmp_fbt
Definition dlp_field.c:957
classical_field * tmp_field
Definition dlp_field.c:951
GtkWidget * combo_mol[MOLIMIT-1]
Definition dlp_field.c:944
Variable declarations for the creation of the DL_POLY input file(s)
#define MOLIMIT
Definition dlp_field.h:117
#define SEXTERN
Definition dlp_field.h:118
int multi
Definition dlp_init.c:121
void select_object(int id, int jd, int kd)
select structural element
Definition dlp_viz.c:423
void visualize_angles(int viz, int aid, field_atom *at, field_atom *bt, field_atom *ct)
show / hide angle / angle restraint
Definition dlp_viz.c:183
void field_unselect_all()
unselect all atoms
Definition dlp_viz.c:130
void visualize_dihedrals(int viz, int did, field_atom *at, field_atom *bt, field_atom *ct, field_atom *dt)
show / hide dihedral / dihedral restraint
Definition dlp_viz.c:228
void viz_fragment(field_molecule *fmol, int id, int viz)
show / hide fragment
Definition dlp_viz.c:115
void visualize_single_struct(int id, int jd, int kd, int *ids)
visualize single structural element
Definition dlp_viz.c:486
tint toviz
Definition dlp_viz.c:75
void visualize_bonds(int viz, int bid, field_atom *at, field_atom *bt)
show / hide bond / bond restraint
Definition dlp_viz.c:149
void update_mol_tree(int a, int b)
update the field molecule tree model
Definition dlp_viz.c:785
void update_selection_list(atom_selection *at_list, atom *at, gboolean add)
update the selection list adding or removing an atom
Definition selection.c:445
void check_to_visualize_properties_for_this_field_mol(int pid, int mol)
check if rendering is required for object in molecule
Definition dlp_viz.c:735
void field_selection(int i, int viz, int lab, int aid)
select / unselect atom
Definition dlp_viz.c:91
void check_to_visualize_properties(int pid)
check if it is requried to update rendering
Definition dlp_viz.c:766
void visualize_object(int id, int jd, int kd)
visualize object and update OpenGL rendering
Definition dlp_viz.c:550
gboolean in_bond(int at, int bd[2])
is atom at in bond bd
Definition dlp_init.c:892
void visualize_imp_inv(int viz, int dih, int iid, field_atom *at, field_atom *bt, field_atom *ct, field_atom *dt)
show / hide improper or inversion
Definition dlp_viz.c:283
G_MODULE_EXPORT void visualize_or_select_all_elements(GtkTreeViewColumn *col, gpointer data)
select all element(s) in the column for visualization
Definition dlp_viz.c:1022
G_MODULE_EXPORT void on_toggle_visualize_or_select_object(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
on visualize force field object toggle callback
Definition dlp_viz.c:828
void visualize_body(int viz, int bd, field_nth_body *body)
show / hide non bonded interaction
Definition dlp_viz.c:339
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
gboolean show_field_object(int id, int jd, int kd)
is the field object visible ?
Definition dlp_viz.c:971
int get_field_objects(int id, int jd)
get the number of this type of field object
Definition dlp_viz.c:365
int is_special[MAXDATA][11]
Definition dlp_field.c:883
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:703
#define max(a, b)
Definition global.h:80
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
gboolean pick
Function declarations for the creation of the OpenGL window.
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:891
Definition glwin.h:965
coord_info * coord
Definition global.h:961
Definition global.h:106
int b
Definition global.h:108
int c
Definition global.h:109
int a
Definition global.h:107
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
GtkWidget * lab
Definition workspace.c:73