atomes 1.1.15
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-2024 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
151void visualize_bonds (int viz, int bid,
152 field_atom* at,
153 field_atom* bt)
154{
155 int i, j, k, l;
156 for (i=0; i<at -> num; i++)
157 {
158 j = at -> list[i];
159 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
160 {
161 l = tmp_proj -> atoms[0][j].vois[k];
162 if (tmp_proj -> atoms[0][l].faid == bt -> id)
163 {
164 field_selection (j, viz, FALSE, bid);
165 field_selection (l, viz, FALSE, bid);
166 }
167 }
168 }
169}
170
185void visualize_angles (int viz, int aid,
186 field_atom* at,
187 field_atom* bt,
188 field_atom* ct)
189{
190 int i, j, k, l, m, n;
191 for (i=0; i<at -> num; i++)
192 {
193 j = at -> list[i];
194 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
195 {
196 l = tmp_proj -> atoms[0][j].vois[k];
197 if (tmp_proj -> atoms[0][l].faid == bt -> id)
198 {
199 for (m=0; m<tmp_proj -> atoms[0][l].numv; m++)
200 {
201 n = tmp_proj -> atoms[0][l].vois[m];
202 if (n != j && tmp_proj -> atoms[0][n].faid == ct -> id)
203 {
204 field_selection (j, viz, FALSE, aid);
205 field_selection (l, viz, FALSE, aid);
206 field_selection (n, viz, FALSE, aid);
207 }
208 }
209 }
210 }
211 }
212}
213
230void visualize_dihedrals (int viz, int did,
231 field_atom* at,
232 field_atom* bt,
233 field_atom* ct,
234 field_atom* dt)
235{
236 int i, j, k, l, m, n, o, p;
237 for (i=0; i<tmp_fat -> num; i++)
238 {
239 j = tmp_fat -> list[i];
240 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
241 {
242 l = tmp_proj -> atoms[0][j].vois[k];
243 if (tmp_proj -> atoms[0][l].faid == tmp_fbt -> id)
244 {
245 for (m=0; m<tmp_proj -> atoms[0][l].numv; m++)
246 {
247 n = tmp_proj -> atoms[0][l].vois[m];
248 if (n != j && tmp_proj -> atoms[0][n].faid == tmp_fct -> id)
249 {
250 for (o=0; o<tmp_proj -> atoms[0][n].numv; o++)
251 {
252 p = tmp_proj -> atoms[0][n].vois[o];
253 if (p != j && p != l && tmp_proj -> atoms[0][p].faid == tmp_fdt -> id)
254 {
255 field_selection (j, viz, FALSE, did);
256 field_selection (l, viz, FALSE, did);
257 field_selection (n, viz, FALSE, did);
258 field_selection (p, viz, FALSE, did);
259 }
260 }
261 }
262 }
263 }
264 }
265 }
266}
267
285void visualize_imp_inv (int viz, int dih, int iid,
286 field_atom* at,
287 field_atom* bt,
288 field_atom* ct,
289 field_atom* dt)
290{
291 int i, j, k, l, m, n, o, p;
292 for (i=0; i<tmp_fat -> num; i++)
293 {
294 j = tmp_fat -> list[i];
295 if ((tmp_proj -> atoms[0][j].numv > 2 && dih == 6) || (tmp_proj -> atoms[0][j].numv == 3 && dih == 7))
296 {
297 for (k=0; k<tmp_proj -> atoms[0][j].numv; k++)
298 {
299 l = tmp_proj -> atoms[0][j].vois[k];
300 if (tmp_proj -> atoms[0][l].faid == tmp_fbt -> id)
301 {
302 for (m=0; m<tmp_proj -> atoms[0][j].numv; m++)
303 {
304 if (m != k)
305 {
306 n = tmp_proj -> atoms[0][j].vois[m];
307 if (tmp_proj -> atoms[0][n].faid == tmp_fct -> id)
308 {
309 for (o=0; o<tmp_proj -> atoms[0][j].numv; o++)
310 {
311 if (o != k && o != m)
312 {
313 p = tmp_proj -> atoms[0][j].vois[o];
314 if (tmp_proj -> atoms[0][p].faid == tmp_fdt -> id)
315 {
316 field_selection (j, viz, FALSE, iid);
317 field_selection (l, viz, FALSE, iid);
318 field_selection (n, viz, FALSE, iid);
319 field_selection (p, viz, FALSE, iid);
320 }
321 }
322 }
323 }
324 }
325 }
326 }
327 }
328 }
329 }
330}
331
341void visualize_body (int viz, int bd, field_nth_body * body)
342{
343 int h, i, j, k, l;
344 l = body_at (body -> bd);
345 for (h=0; h<l; h++)
346 {
347 for (i=0; i < body -> na[h]; i++)
348 {
349 tmp_fat = get_active_atom (body -> ma[h][i], body -> a[h][i]);
350 for (j=0; j < tmp_fat -> num; j++)
351 {
352 k = tmp_fat -> list[j];
353 field_selection (k, viz, viz, bd);
354 }
355 }
356 }
357}
358
367int get_field_objects (int id, int jd)
368{
369 int kd;
370 int i;
371 switch (id)
372 {
373 case -1:
374 kd = 0;
375 for (i=0; i<tmp_field -> molecules; i++) kd = max(kd, get_active_field_molecule (i) -> mol -> natoms);
376 break;
377 case 0:
378 kd = tmp_field -> molecules;
379 break;
380 case 1:
381 kd = 0;
382 for (i=0; i<tmp_field -> molecules; i++) kd = max(kd, get_active_field_molecule (i) -> atoms);
383 break;
384 case 2:
385 kd = get_active_field_molecule (jd) -> shells;
386 break;
387 case 3:
388 kd = get_active_field_molecule (jd) -> constraints;
389 break;
390 case 4:
391 kd = get_active_field_molecule (jd) -> pmfs;
392 break;
393 case 5:
394 kd = get_active_field_molecule (jd) -> rigids;
395 break;
396 case 6:
397 kd = get_active_field_molecule (jd) -> tethered;
398 break;
399 case SEXTERN:
400 kd = tmp_field -> extern_fields;
401 break;
402 default:
403 if (id < MOLIMIT)
404 {
405 kd = get_active_field_molecule (jd) -> nstruct[id-7];
406 }
407 else
408 {
409 kd = tmp_field -> nbody[id - MOLIMIT];
410 }
411 break;
412 }
413 return kd;
414}
415
425void select_object (int id, int jd, int kd)
426{
427 int i;
428 field_object = id;
430 switch (id)
431 {
432 case 2:
433 // Select a core-shell unit in a molecule
434 tmp_fshell = get_active_shell (kd, jd);
435 if (tmp_fshell -> ia[0] < 0 || tmp_fshell -> ia[1] < 0) toviz.c = FALSE;
436 tmp_fshell -> use = toviz.c;
437 break;
438 case 3:
439 // Select a contraint bond in a molecule
441 if (! tmp_fcons -> ia[0] || ! tmp_fcons -> ia[1]) toviz.c = FALSE;
442 tmp_fcons -> use = toviz.c;
443 break;
444 case 4:
445 // Select a PMF in a molecule
446 tmp_fpmf = get_active_field_molecule (kd) -> first_pmf;
447 for (i=0; i < get_active_field_molecule(kd) -> pmfs; i++)
448 {
449 tmp_fpmf -> use = FALSE;
450 if (tmp_fpmf -> next != NULL) tmp_fpmf = tmp_fpmf -> next;
451 }
452 tmp_fpmf = get_active_pmf (kd, jd);
453 if (tmp_fpmf -> num[0] > 0 && tmp_fpmf -> num[1] > 0) tmp_fpmf -> use = toviz.c;
454 break;
455 case SEXTERN:
456 tmp_fext = tmp_field -> first_external;
457 for (i=0; i < tmp_field -> extern_fields; i++)
458 {
459 tmp_fext -> use = FALSE;
460 if (tmp_fext -> next != NULL) tmp_fext = tmp_fext -> next;
461 }
463 tmp_fext -> use = toviz.c;
464 break;
465 default:
466 if (id < MOLIMIT)
467 {
468 get_active_struct (id-7, kd, jd) -> def -> use = toviz.c;
469 }
470 else
471 {
472 get_active_body (jd, id - MOLIMIT) -> use = toviz.c;
473 }
474 break;
475 }
476}
477
488void visualize_single_struct (int id, int jd, int kd, int * ids)
489{
490 int i, j, k, l, m, n, o, p;
491 int * idat;
492 i = struct_id(id);
493 idat = allocint (i);
494 for (j=0; j<i; j++)
495 {
496 k = ids[j];
497 idat[j] = get_active_atom (kd, tmp_fmol -> atoms_id[k][0].a) -> id;
498 }
499 for (j=0; j<i; j++)
500 {
501 k = ids[j];
502 for (l=0; l< tmp_fmol -> multi; l++)
503 {
504 m = tmp_fmol -> atoms_id[k][l].b;
505 n = get_active_atom (kd, tmp_fmol -> atoms_id[k][l].a) -> list[m];
506 field_selection (n, 0, 0, k);
507 }
508 }
509 g_free (idat);
510 i = ids[0];
511 j = ids[1];
512 for (l=0; l< tmp_fmol -> multi; l++)
513 {
514 m = tmp_fmol -> atoms_id[i][l].b;
515 n = get_active_atom (kd, tmp_fmol -> atoms_id[i][l].a) -> list[m];
516 field_selection (n, toviz.c, 0, jd);
517 o = tmp_fmol -> atoms_id[j][l].b;
518 p = get_active_atom (kd, tmp_fmol -> atoms_id[j][l].a) -> list[o];
519 field_selection (p, toviz.c, 0, jd);
520 }
521 if (id > 8 && id < 15)
522 {
523 k = ids[2];
524 for (l=0; l< tmp_fmol -> multi; l++)
525 {
526 o = tmp_fmol -> atoms_id[k][l].b;
527 p = get_active_atom (kd, tmp_fmol -> atoms_id[k][l].a) -> list[o];
528 field_selection (p, toviz.c, 0, jd);
529 }
530 if (id > 10)
531 {
532 i = ids[3];
533 for (l=0; l< tmp_fmol -> multi; l++)
534 {
535 o = tmp_fmol -> atoms_id[i][l].b;
536 p = get_active_atom (kd, tmp_fmol -> atoms_id[i][l].a) -> list[o];
537 field_selection (p, toviz.c, 0, jd);
538 }
539 }
540 }
541}
542
552void visualize_object (int id, int jd, int kd)
553{
554 int l, m, n, o, p, q, r, s;
555 field_atom* tshell;
556 field_object = id;
558 switch (id)
559 {
560 case -1:
561 // View molecule atoms id
563 tmp_fmol -> show_id = toviz.c;
564 tmp_fat = tmp_fmol -> first_atom;
565 for (m=0; m < tmp_fmol -> atoms; m++)
566 {
567 for (n=0; n < tmp_fat -> num; n++)
568 {
569 field_selection (tmp_fat -> list[n], toviz.c, toviz.c, tmp_fat -> list_id[n]);
570 }
571 if (tmp_fat -> next != NULL) tmp_fat = tmp_fat -> next;
572 }
573 break;
574 case 0:
575 // View an entire molecule
577 tmp_fmol -> show = toviz.c;
578 for (m=0; m<tmp_fmol -> multi; m++)
579 {
580 toviz.a = 2;
581 toviz.b = tmp_fmol -> fragments[m];
582 for (n=0; n<tmp_proj -> natomes; n++)
583 {
584 if (tmp_proj -> atoms[0][n].coord[2] == toviz.b) field_selection (n, toviz.c, toviz.c, jd);
585 }
586 }
587 break;
588 case 1:
589 // View a type of atoms in a molecule
590 tmp_fat = get_active_atom (kd, jd);
591 tmp_fat -> show = toviz.c;
592 for (m=0; m<tmp_fat -> num; m++)
593 {
594 n = tmp_fat -> list[m];
595 field_selection (n, toviz.c, toviz.c, jd);
596 }
597 break;
598 case 2:
599 // View a type of Core-shell unit in a molecule
600 tmp_fshell = get_active_shell (kd, jd);
601 tmp_fshell -> show = toviz.c;
602 for (m=0; m<2; m++)
603 {
604 if (tmp_fshell -> ia[m])
605 {
606 n = tmp_fshell -> ia[0]-1;
607 tshell = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[0][n].a);
608 for (o=0; o<tmp_fmol -> multi; o++)
609 {
610 p = tmp_fmol -> atoms_id[n][o].b;
611 field_selection (tshell -> list[p], toviz.c, toviz.c, jd);
612 }
613 }
614 }
615 break;
616 case 3:
617 // View a type of bond constraint in a molecule
619 tmp_fcons -> show = toviz.c;
620 for (l=0; l<2; l++)
621 {
622 if (tmp_fcons -> ia[l])
623 {
624 for (m=0; m<tmp_fmol -> multi; m++)
625 {
626 n = tmp_fmol -> atoms_id[tmp_fcons -> ia[l]-1][m].a;
627 o = tmp_fmol -> atoms_id[tmp_fcons -> ia[l]-1][m].b;
628 p = get_active_atom (tmp_fmol -> id, n) -> list[o];
629 field_selection (p, toviz.c, toviz.c, jd);
630 }
631 }
632 }
633 break;
634 case 4:
635 tmp_fpmf = get_active_pmf (kd, jd);
636 tmp_fpmf -> show = toviz.c;
637 for (m=0; m<2; m++)
638 {
639 if (tmp_fpmf -> num[m] > 0)
640 {
641 for (n=0; n<tmp_fpmf -> num[m]; n++)
642 {
643 o = tmp_fpmf -> list[m][n];
644 for (p=0; p<tmp_fmol -> multi;p++)
645 {
646 q = tmp_fmol -> atoms_id[o][p].a;
647 r = tmp_fmol -> atoms_id[o][p].b;
648 s = get_active_atom (tmp_fmol -> id, q) -> list[r];
649 field_selection (s, toviz.c, toviz.c, jd);
650 }
651 }
652 }
653 }
654 break;
655 case 5:
656 tmp_frig = get_active_rigid (kd, jd);
657 tmp_frig -> show = toviz.c;
658 if (tmp_frig -> num > 0)
659 {
660 for (n=0; n<tmp_frig -> num; n++)
661 {
662 o = tmp_frig -> list[n];
663 for (p=0; p<tmp_fmol -> multi;p++)
664 {
665 q = tmp_fmol -> atoms_id[o][p].a;
666 r = tmp_fmol -> atoms_id[o][p].b;
667 s = get_active_atom (tmp_fmol -> id, q) -> list[r];
668 field_selection (s, toviz.c, toviz.c, jd);
669 }
670 }
671 }
672 break;
673 case 6:
674 tmp_ftet = get_active_tethered (kd, jd);
675 tmp_ftet -> show = toviz.c;
676 if (tmp_ftet -> num)
677 {
678 o = tmp_ftet -> num-1;
679 p = tmp_fmol -> atoms_id[o][0].a;
680 for (q=0; q<tmp_fmol -> multi;q++)
681 {
682 r = tmp_fmol -> atoms_id[o][q].b;
683 s = get_active_atom (tmp_fmol -> id, p) -> list[r];
684 field_selection (s, toviz.c, toviz.c, jd);
685 }
686 }
687 break;
688 case SEXTERN:
689
690 break;
691 default:
692 if (id < MOLIMIT)
693 {
694 // View a type of bond / angles / dihedral / improper / inversion in a molecule
695 tmp_fstr = get_active_struct (id-7, kd, jd);
696 tmp_fat = get_active_atom (kd, tmp_fstr -> aid[0]);
697 tmp_fbt = get_active_atom (kd, tmp_fstr -> aid[1]);
698 if (id > 8) tmp_fct = get_active_atom (kd, tmp_fstr -> aid[2]);
699 if (id > 10) tmp_fdt = get_active_atom (kd, tmp_fstr -> aid[3]);
700 tmp_fstr -> def -> show = toviz.c;
701 if (id < 9)
702 {
703 visualize_bonds (tmp_fstr -> def -> show, jd, tmp_fat, tmp_fbt);
704 }
705 else if (id < 11)
706 {
707 visualize_angles (tmp_fstr -> def -> show, jd, tmp_fat, tmp_fbt, tmp_fct);
708 }
709 else if (id < 13)
710 {
712 }
713 else if (id < 15)
714 {
715 visualize_imp_inv (tmp_fstr -> def -> show, id-7, jd, tmp_fat, tmp_fbt, tmp_fct, tmp_fdt);
716 }
717 }
718 else
719 {
720 // View a non-bonded interaction
721 tmp_fbody = get_active_body (jd, id - MOLIMIT);
722 tmp_fbody -> show = toviz.c;
723 visualize_body (tmp_fbody -> show, jd, tmp_fbody);
724 }
725 break;
726 }
727}
728
738{
739 int h, i, j;
740 field_prop * propv;
741 h = toviz.c;
742 toviz.c = 1;
744 i = get_field_objects (pid, mol);
745 for (j=0; j<i; j++)
746 {
747 if (show_field_object (pid, j, mol)) visualize_object (pid, j, mol);
748 if (pid > 6 && pid < MOLIMIT)
749 {
750 propv = get_active_struct (pid-7, mol, j) -> other;
751 while (propv)
752 {
753 if (propv -> show) visualize_single_struct (pid, j, mol, propv -> aid);
754 propv = propv -> next;
755 }
756 }
757 }
758 toviz.c = h;
759}
760
769{
770 int i, j;
771 i = (pid < MOLIMIT) ? tmp_field -> molecules : 1;
772 for (j=0; j<i; j++)
773 {
775 }
777}
778
787void update_mol_tree (int a, int b)
788{
789 int i, j;
790 j = toviz.c;
791 for (i=0; i<tmp_field -> molecules; i++)
792 {
793 if (get_active_field_molecule (i) -> show_id && ! a)
794 {
795 toviz.c = 0;
796 visualize_object (-1, i, 0);
798 toviz.c = j;
799 }
800 else if (get_active_field_molecule (i) -> show && a)
801 {
802 toviz.c = 0;
803 visualize_object (0, i, 0);
805 toviz.c = j;
806 }
807 }
808 if (a)
809 {
810 get_active_field_molecule (b) -> show_id = j;
811 }
812 else
813 {
814 get_active_field_molecule (b) -> show = j;
815 }
816 gtk_tree_store_clear (field_model[0]);
818 fill_field_model (field_model[0], 0, -1);
819}
820
830G_MODULE_EXPORT void on_toggle_visualize_or_select_object (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
831{
832 int i, j, k, l, m, n;
833 int * ids = NULL;
834 tint * dat = (tint * )data;
835 GtkTreeIter iter;
836 gboolean forall;
837
838 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
839 {
840 toviz.c = 0;
841 }
842 else
843 {
844 toviz.c = 1;
845 }
846
847 i = dat -> b;
848 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
849 gtk_tree_model_get_iter (GTK_TREE_MODEL(field_model[i]), & iter, path);
850 forall = TRUE;
851 if (i > 6 && i < MOLIMIT)
852 {
853 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, 0, & k, -1);
854 if (! k)
855 {
856 gchar * str;
857 forall = FALSE;
858 j = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
860 l = struct_id(i);
861 ids = allocint (l);
862 if (dat -> c == 0)
863 {
864 field_object = i;
866 }
867 for (m=1; m<l+1; m++)
868 {
869 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, m, & str, -1);
870 n = (int) string_to_double ((gpointer)str) - 1;
871 ids[m-1] = n;
872 }
873 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, field_v[i]+1, & m, -1);
874 tmp_fstr = get_active_struct (i-7, j, m);
875 if (ids[0] < 0)
876 {
877 tmp_fprop = tmp_fstr -> def;
878 }
879 else
880 {
881 if (tmp_fstr -> other)
882 {
884 if (! tmp_fprop)
885 {
886 tmp_fprop = tmp_fstr -> other;
887 while (tmp_fprop -> next) tmp_fprop = tmp_fprop -> next;
888 tmp_fprop -> next = duplicate_field_prop (tmp_fstr -> def, i-7);
889 tmp_fprop = tmp_fprop -> next;
890 for (n=0; n<l; n++) tmp_fprop -> aid[n] = ids[n];
891 }
892 }
893 else
894 {
895 tmp_fstr -> other = duplicate_field_prop (tmp_fstr -> def, i-7);
896 for (n=0; n<l; n++) tmp_fstr -> other -> aid[n] = ids[n];
897 tmp_fprop = tmp_fstr -> other;
898 }
899 }
900 if (dat -> c) tmp_fprop -> use = toviz.c;
901 if (! dat -> c) tmp_fprop -> show = toviz.c;
902 adjust_field_prop (i-7, l, NULL, ids, tmp_fprop -> key);
903 j = m-1;
904 }
905 else
906 {
907 j = k-1;
908 }
909 }
910 else
911 {
912 gtk_tree_model_get (GTK_TREE_MODEL(field_model[i]), & iter, 0, & k, -1);
913 j = k-1;
914 }
915
916 if (forall)
917 {
918 k = -1;
919 if (i > 0 && i < MOLIMIT)
920 {
921 k = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
923 }
924 if (i == 0 && dat -> c == 1)
925 {
926 update_mol_tree (1, j);
927 visualize_object (-1, j, k);
929 }
930 else if (dat -> c == 0)
931 {
932 if (i == 0) update_mol_tree (0, j);
933 visualize_object (i, j, k);
935 }
936 else
937 {
938 select_object (i, j, k);
939 }
940 }
941 else if (dat -> c == 0)
942 {
943 k = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
944 visualize_single_struct (i, j+1, k, ids);
946 }
947
948 if (ids) g_free (ids);
949 if (forall || i == 4 || i == SEXTERN)
950 {
951 gtk_tree_store_clear (field_model[i]);
952 fill_field_model (field_model[i], i, k);
953 }
954 else if (! forall && i > 0 && i != 4 && i != SEXTERN)
955 {
956 for (l=0; l<field_v[i]; l++)
957 {
958 if (is_special[i][l] - 2 == dat -> c) break;
959 }
960 gtk_tree_store_set (field_model[i], & iter, l, toviz.c, -1);
961 }
962}
963
973gboolean show_field_object (int id, int jd, int kd)
974{
975 gboolean show = FALSE;
976 switch (id)
977 {
978 case -1:
979 show = get_active_field_molecule (jd) -> show;
980 break;
981 case 0:
982 show = get_active_field_molecule (jd) -> show;
983 break;
984 case 1:
985 show = (jd < get_active_field_molecule (kd) -> atoms) ? get_active_atom (kd, jd) -> show : FALSE;
986 break;
987 case 2:
988 show = get_active_shell (kd, jd) -> show;
989 break;
990 case 3:
991 show = get_active_constraint (kd, jd) -> show;
992 break;
993 case 4:
994 show = get_active_pmf (kd, jd) -> show;
995 break;
996 case 5:
997 show = get_active_rigid (kd, jd) -> show;
998 break;
999 case 6:
1000 show = get_active_tethered (kd, jd) -> show;
1001 break;
1002 default:
1003 if (id < MOLIMIT)
1004 {
1005 show = get_active_struct (id-7, kd, jd) -> def -> show;
1006 }
1007 else
1008 {
1009 show = get_active_body (jd, id - MOLIMIT) -> show;
1010 }
1011 break;
1012 }
1013 return show;
1014}
1015
1024G_MODULE_EXPORT void visualize_or_select_all_elements (GtkTreeViewColumn * col, gpointer data)
1025{
1026 int i, j, k, l;
1027 tint * dat = (tint *)data;
1028 i = dat -> b;
1029 j = -1;
1030 if (i > 0 && i < MOLIMIT) j = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_mol[i-1]));
1032 if (i < 7)
1033 {
1034 switch (i)
1035 {
1036 case 0:
1037 toviz.c = (dat -> c) ? get_active_field_molecule (0) -> show_id : get_active_field_molecule (0) -> show;
1038 break;
1039 case 1:
1040 toviz.c = get_active_field_molecule (j) -> first_atom -> show;
1041 break;
1042 case 2:
1043 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_shell -> use : get_active_field_molecule (j) -> first_shell -> show;
1044 break;
1045 case 3:
1046 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_constraint -> use : get_active_field_molecule (j) -> first_constraint -> show;
1047 break;
1048 case 4:
1049 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_pmf -> use : get_active_field_molecule (j) -> first_pmf -> show;
1050 break;
1051 case 5:
1052 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_rigid -> use : get_active_field_molecule (j) -> first_rigid -> show;
1053 break;
1054 case 6:
1055 toviz.c = (dat -> c) ? get_active_field_molecule (j) -> first_tethered-> use : get_active_field_molecule (j) -> first_tethered -> show;
1056 break;
1057 }
1058 toviz.c = ! toviz.c;
1059 }
1060 else if (i > 6 && i < MOLIMIT)
1061 {
1063 {
1065 tmp_fstr = tmp_fmol -> first_struct[i-7];
1066 toviz.c = (dat -> c == 0) ? ! tmp_fstr -> def -> show : ! tmp_fstr -> def -> use;
1067 while (tmp_fstr)
1068 {
1069 if (dat -> c) tmp_fstr -> def -> use = toviz.c;
1070 if (! dat -> c) tmp_fstr -> def -> show = toviz.c;
1071 if (tmp_fstr -> other)
1072 {
1073 tmp_fprop = tmp_fstr -> other;
1074 while (tmp_fprop)
1075 {
1076 if (dat -> c) tmp_fprop -> use = toviz.c;
1077 if (! dat -> c) tmp_fprop -> show = toviz.c;
1078 tmp_fprop = tmp_fprop -> next;
1079 }
1080 }
1081 tmp_fstr = tmp_fstr -> next;
1082 }
1083 }
1084 }
1085 else
1086 {
1087 tmp_fbody = tmp_field -> first_body[i - MOLIMIT];
1088 toviz.c = (dat -> c == 0) ? ! tmp_fbody -> show : ! tmp_fbody -> use;
1089 while (tmp_fbody)
1090 {
1091 if (dat -> c) tmp_fbody -> use = toviz.c;
1092 if (! dat -> c) tmp_fbody -> show = toviz.c;
1093 tmp_fbody = tmp_fbody -> next;
1094 }
1095 }
1096
1098 {
1099 if (i == 0 && dat -> c == 1)
1100 {
1103 for (k=0; k<l; k++)
1104 {
1105 field_object = k;
1106 update_mol_tree (1, k);
1107 visualize_object (-1, k, -1);
1108 }
1110 }
1111 else if (dat -> c == 0)
1112 {
1113 for (k=0; k<num_field_objects; k++)
1114 {
1115 field_object = k;
1116 if (i == 0) update_mol_tree (0, k);
1117 visualize_object (i, k, j);
1118 }
1120 }
1121 else
1122 {
1123 for (k=0; k<num_field_objects; k++)
1124 {
1125 select_object (i, k, j);
1126 }
1127 }
1128 gtk_tree_store_clear (field_model[i]);
1129 fill_field_model (field_model[i], i, j);
1130 }
1131}
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:425
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:185
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:230
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:488
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:151
void update_mol_tree(int a, int b)
update the field molecule tree model
Definition dlp_viz.c:787
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:737
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:768
void visualize_object(int id, int jd, int kd)
visualize object and update OpenGL rendering
Definition dlp_viz.c:552
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:285
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:1024
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:830
void visualize_body(int viz, int bd, field_nth_body *body)
show / hide non bonded interaction
Definition dlp_viz.c:341
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:973
int get_field_objects(int id, int jd)
get the number of this type of field object
Definition dlp_viz.c:367
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
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:698
#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:886
Definition glwin.h:875
coord_info * coord
Definition global.h:956
Definition global.h:104
int b
Definition global.h:106
int c
Definition global.h:107
int a
Definition global.h:105
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