atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_coord.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: 'w_coord.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'Environments configuration' window
29
30*
31* List of functions:
32
33 int get_page_from_geo_coord (glwin * view, int geo, int coord);
34
35 gboolean add_geo (int poly, project * this_proj, int g, int i, int j);
36
37 G_MODULE_EXPORT gboolean scroll_set_poly_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data);
38 G_MODULE_EXPORT gboolean close_event_coord (GtkWindow * widg, gpointer data);
39 G_MODULE_EXPORT gboolean close_event_coord (GtkWidget * widg, GdkEvent * event, gpointer data);
40
41 void poly_alpha_has_changed (gpointer data, GLfloat v);
42 void set_frag_mol_cell_background (GtkListStore * store, GtkTreeIter iter, ColRGBA col);
43 void add_this_frag_mol_to_search_tree (project * this_proj, int geo, int gid);
44 void set_this_frag_mol_color (gpointer data, GtkTreePath * path);
45
46 G_MODULE_EXPORT void toggled_show_hide_coord (GtkCheckButton * widg, gpointer data);
47 G_MODULE_EXPORT void toggled_show_hide_coord (GtkToggleButton * widg, gpointer data);
48 G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkCheckButton * widg, gpointer data);
49 G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkToggleButton * widg, gpointer data);
50 G_MODULE_EXPORT void toggled_select_unselect_coord (GtkCheckButton * widg, gpointer data);
51 G_MODULE_EXPORT void toggled_select_unselect_coord (GtkToggleButton * widg, gpointer data);
52 G_MODULE_EXPORT void toggled_show_hide_poly (GtkCheckButton * widg, gpointer data);
53 G_MODULE_EXPORT void toggled_show_hide_poly (GtkToggleButton * widg, gpointer data);
54 G_MODULE_EXPORT void set_color_frag_mol (GtkColorChooser * colob, gpointer data);
55 G_MODULE_EXPORT void set_color_coord (GtkColorChooser * colob, gpointer data);
56 G_MODULE_EXPORT void set_poly_alpha (GtkRange * range, gpointer data);
57 G_MODULE_EXPORT void on_select_frag_mol (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
58 G_MODULE_EXPORT void run_set_this_frag_mol_color (GtkDialog * win, gint response_id, gpointer data);
59 G_MODULE_EXPORT void to_set_this_frag_mol_color (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data);
60 G_MODULE_EXPORT void update_frag_mol_search (GtkEntry * res, gpointer data);
61 G_MODULE_EXPORT void set_atom_color_map_box (GtkComboBox * box, gpointer data);
62 G_MODULE_EXPORT void set_poly_color_map_box (GtkComboBox * box, gpointer data);
63 G_MODULE_EXPORT void on_cloned_poly_toggled (GtkCheckButton * Button, gpointer data);
64 G_MODULE_EXPORT void on_cloned_poly_toggled (GtkToggleButton * Button, gpointer data);
65 G_MODULE_EXPORT void close_coord (GtkButton * but, gpointer data);
66 G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data);
67
68 GtkWidget * coord_tab (glwin * view, int geo, int poly);
69 GtkWidget * create_frag_mol_tree (project * this_proj, int geo);
70 GtkWidget * create_frag_mol_search (project * this_proj, int geo);
71 GtkWidget * fragmol_tab (glwin * view, int geo);
72 GtkWidget * param_tab (glwin * view);
73 GtkWidget * advanced_coord_properties (glwin * view, int page);
74
75*/
76
77#include "global.h"
78#include "interface.h"
79#include "glview.h"
80#include "glwindow.h"
81#include "bind.h"
82
83extern cairo_surface_t * col_surface (double r, double g, double b, int x, int y);
84extern G_MODULE_EXPORT void set_color_map (GtkWidget * widg, gpointer data);
85extern G_MODULE_EXPORT void cloned_poly (GtkWidget * widg, gpointer data);
86extern int selected_aspec;
87extern GtkWidget * rings_tab (glwin * view, int g);
88extern GtkWidget * chains_tab (glwin * view);
89
90char * text_maps[ATOM_MAPS] = {"Atomic species",
91 "Total",
92 "Partial",
93 "Fragment(s)",
94 "Molecule(s)"};
95
97
98#ifdef GTK4
107G_MODULE_EXPORT void toggled_show_hide_coord (GtkCheckButton * widg, gpointer data)
108#else
117G_MODULE_EXPORT void toggled_show_hide_coord (GtkToggleButton * widg, gpointer data)
118#endif
119{
120 qint * the_data = (qint *)data;
121 int i, j, k;
122 int s, g, c;
123 project * this_proj = get_project_by_id (the_data -> a);
124 s = the_data -> b;
125 g = the_data -> d;
126 c = the_data -> c;
127#ifdef DEBUG
128 g_debug ("Toggle show/hide coord:: s= %d, g= %d, c= %d", s, g, c);
129#endif
130 j = 0;
131 if (g < 2)
132 {
133 for (i=0; i<s; i++)
134 {
135 j += this_proj -> coord -> ntg[g][i];
136 }
137 }
138 j += c;
139
140
141#ifdef GTK4
142 k = (widg) ? gtk_check_button_get_active (widg) : frag_mol_status;
143#else
144// GTK3 Menu Action To Check
145 k = (widg) ? gtk_toggle_button_get_active (widg) : frag_mol_status;
146#endif
147
148 if (k != this_proj -> modelgl -> anim -> last -> img -> show_coord[g][j])
149 {
150 if (is_coord_in_menu(g, this_proj))
151 {
152#ifdef GTK4
153 gchar * name;
154 gchar * str;
155 if (g < 2)
156 {
157 if (g)
158 {
159 str = exact_name (env_name (this_proj, c, s, 1, NULL));
160 }
161 else
162 {
163 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
164 }
165 name = g_strdup_printf ("set-%s-s.%d.0", str, j);
166 g_free (str);
167 }
168 else if (g > 1 && g < 4)
169 {
170 name = g_strdup_printf ("set-%s-%d.%d.0", (g == 2) ? "frag" : "mol", c+1, c);
171 }
172 else if (g > 3 && g < 9)
173 {
174 name = g_strdup_printf ("set-%d-%d-coord.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
175 }
176 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
177 g_free (name);
178#else
179 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][g][j], k);
180#endif
181 }
182 else
183 {
184 tint pointer;
185 pointer.a = g;
186 pointer.b = c;
187 pointer.c = k;
188 opengl_project_changed (the_data -> a);
189#ifdef GTK4
190 show_hide_the_coord (NULL, NULL, & pointer);
191#else
192 show_hide_the_coord (NULL, & pointer);
193#endif // GTK4
194 }
195 }
196 init_default_shaders (this_proj -> modelgl);
197}
198
199#ifdef GTK4
208G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkCheckButton * widg, gpointer data)
209#else
218G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkToggleButton * widg, gpointer data)
219#endif
220{
221 qint * the_data = (qint *)data;
222 tint pointer;
223 pointer.a = the_data -> d;
224 pointer.b = the_data -> c;
225#ifdef GTK4
226 pointer.c = (widg) ? gtk_check_button_get_active (widg) : frag_mol_status;
227#else
228 pointer.c = (widg) ? gtk_toggle_button_get_active (widg) : frag_mol_status;
229#endif
230 selected_aspec = the_data -> b;
231#ifdef DEBUG
232 g_debug ("Toggle label/unlabel coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
233#endif
234 opengl_project_changed (the_data -> a);
235#ifdef GTK4
236 label_unlabel_coord (NULL, NULL, & pointer);
237#else
238 label_unlabel_coord (NULL, & pointer);
239#endif // GTK4
240}
241
242#ifdef GTK4
251G_MODULE_EXPORT void toggled_select_unselect_coord (GtkCheckButton * widg, gpointer data)
252#else
261G_MODULE_EXPORT void toggled_select_unselect_coord (GtkToggleButton * widg, gpointer data)
262#endif
263{
264 qint * the_data = (qint *)data;
265 tint pointer;
266 pointer.a = the_data -> d;
267 pointer.b = the_data -> c;
268#ifdef GTK4
269 pointer.c = (widg) ? gtk_check_button_get_active (widg) : frag_mol_status;
270#else
271 pointer.c = (widg) ? gtk_toggle_button_get_active (widg) : frag_mol_status;
272#endif
273 selected_aspec = the_data -> b;
274#ifdef DEBUG
275 g_debug ("Toggle select/unselect coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
276#endif
277 opengl_project_changed (the_data -> a);
278#ifdef GTK4
279 select_unselect_coord (NULL, NULL, & pointer);
280#else
281 select_unselect_coord (NULL, & pointer);
282#endif
283}
284
285#ifdef GTK4
294G_MODULE_EXPORT void toggled_show_hide_poly (GtkCheckButton * widg, gpointer data)
295#else
304G_MODULE_EXPORT void toggled_show_hide_poly (GtkToggleButton * widg, gpointer data)
305#endif
306{
307 qint * the_data = (qint *)data;
308 int i, j, k;
309 int s, g, c;
310 project * this_proj = get_project_by_id(the_data -> a);
311 s = the_data -> b;
312 g = the_data -> d;
313 c = the_data -> c;
314 j = c;
315 if (g < 2)
316 {
317 for (i=0; i<s; i++)
318 {
319 j += this_proj -> coord -> ntg[g][i];
320 }
321 }
322#ifdef GTK4
323 k = gtk_check_button_get_active (widg);
324 if (k != this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j])
325 {
326 gchar * str;
327 gchar * name;
328 if (g < 2)
329 {
330 if (g)
331 {
332 str = exact_name (env_name (this_proj, c, s, 1, NULL));
333 }
334 else
335 {
336 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
337 }
338 name = g_strdup_printf ("set-%s-%d-p.%d.0", str, g, j);
339 g_free (str);
340 }
341 else if (g > 3 && g < 9)
342 {
343 name = g_strdup_printf ("set-%d-%d-p.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
344 }
345 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
346 g_free (name);
347 }
348#else
349 // GTK3 Menu Action To Check
350 k = gtk_toggle_button_get_active (widg);
351 if (is_coord_in_menu(g, this_proj))
352 {
353 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][g][j], k);
354 }
355 this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j] = k;
356 int shaders[2] = {POLYS, RINGS};
357 re_create_md_shaders (2, shaders, this_proj);
358 update (this_proj -> modelgl);
359#endif
360}
361
370G_MODULE_EXPORT void set_color_frag_mol (GtkColorChooser * colob, gpointer data)
371{
372 qint * cid = (qint *)data;
373 int c, g;
374 project * this_proj = get_project_by_id(cid -> a);
375 g = cid -> b;
376 c = cid -> c;
377 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][0][c] = get_button_color (colob);
378 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
379 re_create_md_shaders (4, shaders, this_proj);
380 update (this_proj -> modelgl);
381}
382
391G_MODULE_EXPORT void set_color_coord (GtkColorChooser * colob, gpointer data)
392{
393 qint * cid = (qint *)data;
394 int c, g, s;
395 project * this_proj = get_project_by_id(cid -> a);
396 s = cid -> b;
397 c = cid -> c;
398 g = cid -> d;
399 if (g > 3) s = 0;
400 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c] = get_button_color (colob);
401 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
402 re_create_md_shaders (4, shaders, this_proj);
403 update (this_proj -> modelgl);
404}
405
414void poly_alpha_has_changed (gpointer data, GLfloat v)
415{
416 qint * cid = (qint *)data;
417 int c, g, s;
418 project * this_proj = get_project_by_id(cid -> a);
419 s = cid -> b;
420 c = cid -> c;
421 g = cid -> d;
422 if (g > 1) s = 0;
423 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c].alpha = v;
424 int shaders[2] = {POLYS, RINGS};
425 re_create_md_shaders (2, shaders, this_proj);
426 update (this_proj -> modelgl);
427}
428
439G_MODULE_EXPORT gboolean scroll_set_poly_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
440{
441 poly_alpha_has_changed (data, (GLfloat) value);
442 return FALSE;
443}
444
453G_MODULE_EXPORT void set_poly_alpha (GtkRange * range, gpointer data)
454{
455 poly_alpha_has_changed (data, (GLfloat) gtk_range_get_value (range));
456}
457
469gboolean add_geo (int poly, project * this_proj, int g, int i, int j)
470{
471 if (! poly)
472 {
473 if (g == 0)
474 {
475 if (this_proj -> coord -> geolist[g][i][j] != -1)
476 {
477 return TRUE;
478 }
479 else
480 {
481 return FALSE;
482 }
483 }
484 else if (g == 1)
485 {
486 return TRUE;
487 }
488 else
489 {
490 if (this_proj -> coord -> geolist[g][i][j])
491 {
492 return TRUE;
493 }
494 else
495 {
496 return FALSE;
497 }
498 }
499 }
500 else
501 {
502 if (g == 0 || g > 3)
503 {
504 if (this_proj -> coord -> geolist[g][i][j] > 2)
505 {
506 return TRUE;
507 }
508 else
509 {
510 return FALSE;
511 }
512 }
513 else
514 {
515 int l, m;
516 m = 0;
517 for (l=0; l<this_proj -> nspec; l++)
518 {
519 m += this_proj -> coord -> partial_geo[i][j][l];
520 }
521 if (m > 2)
522 {
523 return TRUE;
524 }
525 else
526 {
527 return FALSE;
528 }
529 }
530 }
531}
532
542GtkWidget * coord_tab (glwin * view, int geo, int poly)
543{
544 int i, j, k, l, m, n;
545 int p = view -> proj;
546 gchar * str;
547 GtkWidget * wb;
548 GtkWidget * but;
549 gchar * col[15] = {" ", "<b>Color</b>", "<b>Show</b>", "<b>Label</b>", "<b>Pick</b>", "<b>Alpha</b>",
550 "<b>Color <sup>*</sup></b>", "<b>Show <sup>**</sup></b>", "<b>Label <sup>**</sup></b>", "<b>Pick <sup>**</sup></b>",
551 "<b>Ring(s) size</b>",
552 "<b>Chain(s) size</b>", "<b>Show <sup>*</sup></b>", "<b>Label <sup>*</sup></b>", "<b>Pick <sup>*</sup></b>"};
553 int scol[15] = {100, 70, 65, 40, 40, 150, 70, 75, 55, 55, 100, 100, 60, 50, 55};
554 GtkWidget * box = create_vbox (BSEP);
555 GtkWidget * coord = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
556 gtk_widget_set_hexpand (coord, TRUE);
557 gtk_widget_set_vexpand (coord, TRUE);
558 n = 0;
559 if (geo > 3 && ! poly)
560 {
561 n = (geo == 9) ? 11 : 10;
562 gtk_widget_set_size_request (coord, -1, 475);
563 if (geo < 9)
564 {
565 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label(" * for the polyhedra only", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
566 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label("** affect all atoms that belong to ring(s) of this size", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
567 }
568 else
569 {
570 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label("* affect all atoms that belong to chain(s) of this size", -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
571 }
572 }
573 GtkWidget * vbox = create_vbox (BSEP);
575 l = 0;
576 if (poly)
577 {
578 l = 1;
579 }
580 wb = create_hbox (0);
581 gtk_widget_set_size_request (wb, 350, -1);
582 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
583 for (i=0; i<5-2*l-geo/9; i++)
584 {
585 if (geo == 9)
586 {
587 j = 11 + i;
588 }
589 else if (i == 0 && geo > 3)
590 {
591 j = 10;
592 }
593 else if (i > 0 && geo > 3 && ! poly)
594 {
595 j = i+5;
596 }
597 else if (i == 1 && poly)
598 {
599 j = 5;
600 }
601 else
602 {
603 j = i;
604 }
605 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
606 }
607 k = 0;
608 project * this_proj = get_project_by_id(p);
609 m = (geo < 2) ? this_proj -> nspec : 1;
610 if ((geo < 2 || (geo == 9 && view -> chain_max) || (geo > 3 && geo < 9 && view -> ring_max[geo-4])) && this_proj -> coord -> totcoord[geo] > 0)
611 {
612 for (i=0; i < m; i++)
613 {
614 if (geo == 0)
615 {
616 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++)
617 {
618 if (add_geo(poly, this_proj, geo, i, j))
619 {
620 str = g_strdup_printf (" <b>%s</b>", this_proj -> chemistry -> label[i]);
621 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
622 g_free (str);
623 break;
624 }
625 }
626 }
627 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++, k++)
628 {
629 if (add_geo(poly, this_proj, geo, i, j))
630 {
631 wb = create_hbox (0);
632 gtk_widget_set_size_request (wb, 350, -1);
633 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
634 if (geo == 0)
635 {
636 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[geo][i][j]);
637 }
638 else if (geo == 1)
639 {
640 str = exact_name(env_name (this_proj, j, i, 1, NULL));
641 }
642 else
643 {
644 str = g_strdup_printf ("%d atoms", this_proj -> coord -> geolist[geo][i][j]);
645 }
646 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.5, 0.5), FALSE, FALSE, 5);
647 g_free (str);
648 if (poly)
649 {
650 but = create_hscale (0.0, 1.0, 0.01, view -> anim -> last -> img -> spcolor[geo][i][j].alpha, GTK_POS_LEFT, 3, 160,
651 G_CALLBACK(set_poly_alpha), G_CALLBACK(scroll_set_poly_alpha), & view -> gcid[geo][k][geo]);
652 }
653 else if (geo != 9)
654 {
655 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][i][j];
656 col.alpha = 1.0;
657 but = color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_coord), & view -> gcid[geo][k][geo]);
658 }
659 if (poly || geo != 9) add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 5);
660
661 if (poly)
662 {
663 but = check_button (NULL, -1, -1, view -> anim -> last -> img -> show_poly[geo][k], G_CALLBACK(toggled_show_hide_poly), & view -> gcid[geo][k][geo]);
664 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
665 }
666 else
667 {
668 but = check_button (NULL, -1, -1, view -> anim -> last -> img -> show_coord[geo][k], G_CALLBACK(toggled_show_hide_coord), & view -> gcid[geo][k][geo]);
669 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
670 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][k][geo]);
671 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n);
672 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][k][geo]);
673 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n/2);
674 }
675 }
676 }
677 }
678 }
679 return box;
680}
681
691G_MODULE_EXPORT void on_select_frag_mol (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
692{
693 int i, g, v, act;
694 tint * dat = (tint * )data;
695 GtkTreeIter iter;
697 coord_edition * coord = opengl_project -> modelgl -> coord_win;
698 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
699 g = (dat -> b < 30) ? 2 : 3;
700 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
701 {
702 v = 0;
703 }
704 else
705 {
706 v = 1;
707 }
708 gtk_tree_model_get_iter (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, path);
709 act = dat -> b - 10*g;
710 gtk_list_store_set (coord -> frag_mol_model[g-2], & iter, act, v, -1);
711 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
712 frag_mol_status = v;
713 switch (act)
714 {
715 case 1:
716 // Viz
717 toggled_show_hide_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
718 break;
719 case 3:
720 // Label
721 toggled_label_unlabel_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
722 break;
723 case 4:
724 // Pick
725 toggled_select_unselect_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
726 break;
727 }
728}
729
739void set_frag_mol_cell_background (GtkListStore * store, GtkTreeIter iter, ColRGBA col)
740{
741 cairo_surface_t * surface;
742 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 70, 50);
743 cairo_t * cr = cairo_create (surface);
744 cairo_set_source_rgba (cr, col.red, col.green, col.blue, 1.0);
745 cairo_paint (cr);
746 GdkPixbuf * pix = convert_to_pixbuf (surface);
747 cairo_surface_destroy (surface);
748 cairo_destroy(cr);
749 gtk_list_store_set (store, & iter, 2, pix, -1);
750}
751
761void add_this_frag_mol_to_search_tree (project * this_proj, int geo, int gid)
762{
763 GtkTreeIter id_level;
764 GtkTreeIter new_level;
765 gboolean valid;
766 int i;
767 int prepend = 0;
768 coord_edition * coord = this_proj -> modelgl -> coord_win;
769 GtkListStore * store = (GtkListStore *) coord -> frag_mol_model[geo-2];
770 GtkTreeModel * mod = GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]);
771 valid = gtk_tree_model_get_iter_first(mod, & id_level);
772 while (valid)
773 {
774 gtk_tree_model_get (mod, & id_level, 0, & i, -1);
775 if (i > gid)
776 {
777 prepend = 1;
778 valid = FALSE;
779 }
780 else if (i == gid)
781 {
782 prepend = 2;
783 valid = FALSE;
784 }
785 else
786 {
787 valid = gtk_tree_model_iter_next(mod, & id_level);
788 }
789 }
790 if (prepend < 2)
791 {
792 switch (prepend)
793 {
794 case 0:
795 gtk_list_store_append (store, & id_level);
796 gtk_list_store_set (store, & id_level, 0, gid,
797 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
798 3, FALSE,
799 4, FALSE, -1);
800 set_frag_mol_cell_background (store, id_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
801 break;
802 case 1:
803 gtk_list_store_insert_before (store, & new_level, & id_level);
804 gtk_list_store_set (store, & new_level, 0, gid,
805 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
806 3, FALSE,
807 4, FALSE, -1);
808 set_frag_mol_cell_background (store, new_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
809 break;
810 }
811 }
812}
813
823G_MODULE_EXPORT void run_set_this_frag_mol_color (GtkDialog * win, gint response_id, gpointer data)
824{
825 tint * dat = (tint * )data;
826 int i, g;
827 if (response_id == GTK_RESPONSE_OK)
828 {
829 g = (dat -> b < 30) ? 2 : 3;
830 GtkTreeIter fm_iter;
831 gtk_tree_model_get (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & fm_iter, 0, & i, -1);
832 opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1] = get_window_color (GTK_WIDGET(win));
833 int shaders[3] = {ATOMS, BONDS, LABEL};
835 update (opengl_project -> modelgl);
836 }
838}
839
848void set_this_frag_mol_color (gpointer data, GtkTreePath * path)
849{
850 int i, g;
851 tint * dat = (tint * )data;
853 g = (dat -> b < 30) ? 2 : 3;
854 GtkTreeIter iter;
855 gtk_tree_model_get_iter (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & iter, path);
856 coord_edition * coord = opengl_project -> modelgl -> coord_win;
857 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
858 gchar * ctitle[2] = {"Fragment", "Molecule"};
859 gchar * str = g_strdup_printf ("%s N°%d color", ctitle[g-2], i);
860 GtkWidget * widg = gtk_color_chooser_dialog_new (str, GTK_WINDOW(coord -> win));
861 g_free (str);
862 set_color_chooser_color (widg, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
863 run_this_gtk_dialog (widg, G_CALLBACK(run_set_this_frag_mol_color), data);
864 set_frag_mol_cell_background ((GtkListStore *) coord -> frag_mol_model[g-2], iter, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
865}
866
877G_MODULE_EXPORT void to_set_this_frag_mol_color (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
878{
879 gchar * title;
880 g_object_get (column, "title", & title, NULL, NULL);
881 if (g_strcmp0(title, "Color") == 0)
882 {
884 }
885}
886
895GtkWidget * create_frag_mol_tree (project * this_proj, int geo)
896{
897 int i;
898 GtkTreeViewColumn * frag_mol_col[7];
899 GtkCellRenderer * frag_mol_cell[7];
900 gchar * ctitle[5]={"Id.", "Show", "Color", "Label", "Pick"};
901 gchar * ctype[5]={"text", "active", "pixbuf", "active", "active"};
902 GType col_type[5]={G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN};
903 coord_edition * coord = this_proj -> modelgl -> coord_win;
904 coord -> frag_mol_model[geo-2] = gtk_list_store_newv (5, col_type);
905 GtkWidget * frag_mol_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]));
906 for (i=0; i<5; i++)
907 {
908 if (! i)
909 {
910 frag_mol_cell[i] = gtk_cell_renderer_text_new ();
911 }
912 else if (i == 2)
913 {
914 frag_mol_cell[i] = gtk_cell_renderer_pixbuf_new ();
915 }
916 else
917 {
918 frag_mol_cell[i] = gtk_cell_renderer_toggle_new ();
919 g_signal_connect (G_OBJECT(frag_mol_cell[i]), "toggled", G_CALLBACK(on_select_frag_mol), & this_proj -> modelgl -> colorp[geo*10+i][0]);
920 }
921 gtk_cell_renderer_set_fixed_size (frag_mol_cell[i], 70, 25);
922 frag_mol_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[i], frag_mol_cell[i], ctype[i], i, NULL);
923 gtk_tree_view_append_column(GTK_TREE_VIEW(frag_mol_tree), frag_mol_col[i]);
924 gtk_tree_view_column_set_alignment (frag_mol_col[i], 0.5);
925 }
926 g_object_set (frag_mol_tree, "activate-on-single-click", TRUE, NULL, NULL);
927 g_signal_connect (G_OBJECT(frag_mol_tree), "row-activated", G_CALLBACK(to_set_this_frag_mol_color), & this_proj -> modelgl -> colorp[geo*10+i][0]);
928 return frag_mol_tree;
929}
930
939G_MODULE_EXPORT void update_frag_mol_search (GtkEntry * res, gpointer data)
940{
941 tint * dat = (tint * )data;
942 const gchar * m = entry_get_text (res);
943 int v = (int)string_to_double ((gpointer)m);
944 project * this_proj = get_project_by_id(dat -> a);
945 int g = dat -> b;
946 if (v > 0 && v <= this_proj -> coord -> totcoord[g])
947 {
948 add_this_frag_mol_to_search_tree (this_proj, g, v);
949 }
950 else
951 {
953 }
954}
955
964GtkWidget * create_frag_mol_search (project * this_proj, int geo)
965{
966 GtkWidget * frag_mol_search = create_vbox (BSEP);
967 gchar * obj[2] = {"fragment", "molecule"};
968 gchar * str = g_strdup_printf ("Too many <b>%ss</b> in your model !\n"
969 " It is impossible to display the entire list ...\n"
970 "... instead you can look for %s(s) 'manually':\n", obj[geo-2], obj[geo-2]);
971 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
972 g_free (str);
973 gchar * search_item[2]={"Fragment ID:", "Molecule ID:"};
974 GtkWidget * hbox;
975 GtkWidget * entry;
976 GtkWidget * label;
977 hbox = create_hbox (0);
978 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, hbox, FALSE, FALSE, 0);
979 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(search_item[geo-2], 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
980 entry = create_entry (G_CALLBACK(update_frag_mol_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[geo][0]);
981 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
982 str = g_strdup_printf ("in [%d - %d]", 1, this_proj -> coord -> totcoord[geo]);
983 label = markup_label (str, 50, -1, 0.0, 0.5);
984 g_free (str);
985 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, label, FALSE, FALSE, 5);
986 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label("<b>Search result(s)</b>", 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
987 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, create_frag_mol_tree (this_proj, geo), FALSE, FALSE, 0);
988 return frag_mol_search;
989}
990
999GtkWidget * fragmol_tab (glwin * view, int geo)
1000{
1001 int i, j;
1002 GtkWidget * wb;
1003 gchar * str;
1004 int scol[5] = {70, 70, 65, 40, 40};
1005 gchar * col[5] = {"<b>Id</b>", "<b>Color</b>", "<b>Show</b>", "<b>Label</b>", "<b>Pick</b>"};
1006
1007 GtkWidget * box = create_vbox (BSEP);
1008 GtkWidget * fragmol = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
1009 gtk_widget_set_hexpand (fragmol, TRUE);
1010 gtk_widget_set_vexpand (fragmol, TRUE);
1011 project * this_proj = get_project_by_id(view -> proj);
1012 i = this_proj -> coord -> totcoord[geo];
1013 if (i > 10000)
1014 {
1015 add_container_child (CONTAINER_SCR, fragmol, create_frag_mol_search(this_proj, geo));
1016 }
1017 else
1018 {
1019 GtkWidget * vbox = create_vbox (BSEP);
1021 wb = create_hbox (0);
1022 gtk_widget_set_size_request (wb, 350, -1);
1023 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1024 for (j=0; j<5; j++)
1025 {
1026 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
1027 }
1028 for (j=0; j<i; j++)
1029 {
1030 wb = create_hbox (0);
1031 gtk_widget_set_size_request (wb, 300, -1);
1032 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1033
1034 str = g_strdup_printf ("N°%d", j+1);
1035 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.25, 0.5), FALSE, FALSE, 5);
1036 g_free (str);
1037 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][0][j];
1038 col.alpha = 1.0;
1039 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1040 color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_frag_mol), & view -> gcid[geo][j][0]),
1041 FALSE, FALSE, 5);
1042
1043 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1044 check_button(NULL, -1, -1, view -> anim -> last -> img -> show_coord[geo][j], G_CALLBACK(toggled_show_hide_coord), & view -> gcid[geo][j][geo]),
1045 FALSE, FALSE, 20);
1046
1047 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1048 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][j][geo]),
1049 FALSE, FALSE, 15);
1050
1051 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1052 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][j][geo]),
1053 FALSE, FALSE, 15);
1054 }
1055 }
1056 return box;
1057}
1058
1067G_MODULE_EXPORT void set_atom_color_map_box (GtkComboBox * box, gpointer data)
1068{
1069 glwin * view = (glwin *)data;
1070 int i = gtk_combo_box_get_active (box);
1071 int j = view -> cmap[i];
1072#ifdef GTK4
1073 gchar * variant = g_strdup_printf ("set-amap.%d.0", j);
1074 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-amap", g_variant_new_string((const gchar *)variant));
1075 g_free (variant);
1076#else
1077 // GTK3 Menu Action To Check
1078 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1079#endif
1080}
1081
1090G_MODULE_EXPORT void set_poly_color_map_box (GtkComboBox * box, gpointer data)
1091{
1092 glwin * view = (glwin *)data;
1093 int i = gtk_combo_box_get_active (box);
1094 int j = view -> cmap[i] + ATOM_MAPS;
1095#ifdef GTK4
1096 gchar * variant = g_strdup_printf ("set-pmap.%d.0", j);
1097 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-pmap", g_variant_new_string((const gchar *)variant));
1098 g_free (variant);
1099#else
1100 // GTK3 Menu Action To Check
1101 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1102#endif
1103}
1104
1105#ifdef GTK4
1114G_MODULE_EXPORT void on_cloned_poly_toggled (GtkCheckButton * Button, gpointer data)
1115#else
1124G_MODULE_EXPORT void on_cloned_poly_toggled (GtkToggleButton * Button, gpointer data)
1125#endif
1126{
1127 glwin * view = (glwin *)data;
1128#ifdef GTK4
1129 view -> anim -> last -> img -> cloned_poly = gtk_check_button_get_active (Button);
1130 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-cloned-poly.0.0", NULL);
1131 /* int shaders[2] = {POLYS, RINGS};
1132 re_create_md_shaders (2, shaders, get_project_by_id(view -> proj));
1133 update (view); */
1134#else
1135 // GTK3 Menu Action To Check
1136 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[5], gtk_toggle_button_get_active (Button));
1137#endif
1138}
1139
1147GtkWidget * param_tab (glwin * view)
1148{
1149 int i, j, k, l;
1150 GtkWidget * vbox = create_vbox (BSEP);
1151 /*gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(fragmol), vbox); */
1152 GtkWidget * hbox = create_hbox (0);
1153 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1154 GtkWidget * lab = gtk_label_new ("<b>Atom(s) and bond(s) color map:</b>");
1155 gtk_label_set_use_markup (GTK_LABEL(lab), 1);
1156 gtk_label_align (lab, 0.0, 0.5);
1157 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1158 hbox = create_hbox (0);
1159 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1160 GtkWidget * color_box = create_combo ();
1161 j = 0;
1162 for (i=0; i<ATOM_MAPS; i++)
1163 {
1164 if (i == 1 || i == 2)
1165 {
1166 view -> cmap[j] = i;
1167 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1168 j ++;
1169 }
1170 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1171 {
1172 view -> cmap[j] = i;
1173 combo_text_append (color_box, "Force field (DL_POLY)");
1174 j ++;
1175 }
1176 else if (i == 6 && view -> custom_map != NULL)
1177 {
1178 view -> cmap[j] = i;
1179 combo_text_append (color_box, "Custom");
1180 j ++;
1181 }
1182 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1183 {
1184 view -> cmap[j] = i;
1186 j ++;
1187 }
1188 }
1189 l = 0;
1190 for (k=0; k<j; k++)
1191 {
1192 if (view -> anim -> last -> img -> color_map[0] == view -> cmap[k])
1193 {
1194 l = k;
1195 break;
1196 }
1197 }
1198 gtk_combo_box_set_active (GTK_COMBO_BOX(color_box), l);
1199 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_atom_color_map_box), view);
1200 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1201
1202 hbox = create_hbox (0);
1203 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1204 lab = gtk_label_new ("<b>Polyhedra color map:</b>");
1205 gtk_label_set_use_markup (GTK_LABEL(lab), 1);
1206 gtk_label_align (lab, 0.0, 0.5);
1207 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1208 hbox = create_hbox (0);
1209 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1211 for (i=0; i<POLY_MAPS; i++)
1212 {
1213 if (i == 1 || i == 2)
1214 {
1215 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1216 }
1217 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1218 {
1220 }
1221 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1222 {
1223 combo_text_append (color_box, "Force field (DL_POLY)");
1224 }
1225 else if (i == 6 && view -> custom_map != NULL)
1226 {
1227 combo_text_append (color_box, "Use atom(s) custom map");
1228 }
1229 }
1230 l = 0;
1231 for (k=0; k<j; k++)
1232 {
1233 if (view -> anim -> last -> img -> color_map[1] == view -> cmap[k])
1234 {
1235 l = k; // + ATOM_MAPS;
1236 break;
1237 }
1238 }
1239 gtk_combo_box_set_active (GTK_COMBO_BOX(color_box), l);
1240 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_poly_color_map_box), view);
1241 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1243
1244 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("\n<b>Display polyhedra at the edges of the model box\n"
1245 "using the PBC even if the clones are not shown:</b>", -1, -1, 0.5, 0.5),
1246 FALSE, FALSE, 15);
1247 GtkWidget * cloned_p = check_button ("Cloned polyhedra", -1, 40, view -> anim -> last -> img -> cloned_poly,
1248 G_CALLBACK(on_cloned_poly_toggled), view);
1249 widget_set_sensitive ((cloned_p), get_project_by_id(view -> proj) -> cell.pbc);
1250 hbox = create_hbox (0);
1251 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 0);
1252 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cloned_p, FALSE, FALSE, 50);
1253 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("This is automatic if the clones are shown.\n"
1254 "The clones are the replica of the atoms linked by PBC.", -1, -1, 0.5, 0.5),
1255 FALSE, FALSE, 5);
1256 return vbox;
1257}
1258
1267G_MODULE_EXPORT void close_coord (GtkButton * but, gpointer data)
1268{
1269 glwin * view = (glwin *)data;
1270 view -> coord_win -> win = destroy_this_widget (view -> coord_win -> win);
1271 g_free (view -> coord_win);
1272 view -> coord_win = NULL;
1273}
1274
1275#ifdef GTK4
1284G_MODULE_EXPORT gboolean close_event_coord (GtkWindow * widg, gpointer data)
1285#else
1295G_MODULE_EXPORT gboolean close_event_coord (GtkWidget * widg, GdkEvent * event, gpointer data)
1296#endif
1297{
1298 close_coord (NULL, data);
1299 return FALSE;
1300}
1301
1310GtkWidget * advanced_coord_properties (glwin * view, int page)
1311{
1312 gchar * str = g_strdup_printf ("Environments configuration - %s", get_project_by_id(view -> proj)->name);
1313 GtkWidget * win = create_win (str, view -> win, FALSE, FALSE);
1314 g_free (str);
1315 char * rings_short[5] = {"AR", "KR", "GR", "PR", "SR"};
1316 GtkWidget * vbox = create_vbox (5);
1318 gtk_widget_set_size_request (win, 625, 600);
1319 view -> coord_win -> notebook = gtk_notebook_new ();
1320 gtk_notebook_set_scrollable (GTK_NOTEBOOK(view -> coord_win -> notebook), TRUE);
1321 gtk_notebook_set_tab_pos (GTK_NOTEBOOK(view -> coord_win -> notebook), GTK_POS_LEFT);
1322 show_the_widgets (view -> coord_win -> notebook);
1323 gtk_widget_set_size_request (view -> coord_win -> notebook, 600, 550);
1324 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> coord_win -> notebook, FALSE, FALSE, 0);
1325 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), param_tab (view), gtk_label_new ("Parameters"));
1326 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, 0, 0), markup_label("Total coordination(s) <b>[TC]</b>", -1, -1, 0.0, 0.5));
1327 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, 1, 0), markup_label("Partial coordination(s) <b>[PC]</b>", -1, -1, 0.0, 0.5));
1328
1329 int i;
1330 if (view -> rings)
1331 {
1332 for (i=0; i<5; i++)
1333 {
1334 if (view -> ring_max[i])
1335 {
1336 str = g_strdup_printf ("%s ring(s) <b>[%s]</b>", rings_type[i], rings_short[i]);
1337 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, i+4, 0), markup_label(str, -1, -1, 0.0, 0.5));
1338 g_free (str);
1339 }
1340 }
1341 }
1342 if (view -> chains && view -> chain_max)
1343 {
1344 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, 9, 0), markup_label("Chain(s)", -1, -1, 0.0, 0.5));
1345 }
1346 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, 0, 1), markup_label("Polyhedra from <b>TC</b>", -1, -1, 0.0, 0.5));
1347 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, 1, 1), markup_label("Polyhedra from <b>PC</b>", -1, -1, 0.0, 0.5));
1348 if (view -> rings)
1349 {
1350 for (i=0; i<5; i++)
1351 {
1352 if (view -> ring_max[i])
1353 {
1354 str = g_strdup_printf ("Polyhedra from <b>%s</b>", rings_short[i]);
1355 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), coord_tab (view, i+4, 1), markup_label(str, -1, -1, 0.0, 0.5));
1356 g_free (str);
1357 }
1358 }
1359 }
1360
1361 if (view -> adv_bonding[0])
1362 {
1363 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 2), markup_label ("Fragment(s)", -1, -1, 0.0, 0.5));
1364 }
1365 if (view -> adv_bonding[1])
1366 {
1367 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 3), markup_label ("Molecule(s)", -1, -1, 0.0, 0.5));
1368 }
1369
1370 if (view -> rings)
1371 {
1372 for (i=0; i<5; i++)
1373 {
1374 if (view -> ring_max[i])
1375 {
1376 str = g_strdup_printf ("Isolated ring(s) from <b>%s</b>", rings_short[i]);
1377 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), rings_tab (view, i), markup_label(str, -1, -1, 0.0, 0.5));
1378 g_free (str);
1379 }
1380 }
1381 }
1382
1383 if (view -> chains && view -> chain_max)
1384 {
1385 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), chains_tab (view), markup_label("Isolated chain(s)", -1, -1, 0.0, 0.5));
1386 }
1387
1388 GtkWidget * hbox = create_hbox (5);
1389 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, TRUE, FALSE, 0);
1390 GtkWidget * but = create_button ("Close", IMG_STOCK, FCLOSE, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(close_coord), view);
1391 add_box_child_end (hbox, but, FALSE, FALSE, 0);
1392 add_gtk_close_event (win, G_CALLBACK(close_event_coord), view);
1393 show_the_widgets (win);
1394 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1395 return win;
1396}
1397
1407int get_page_from_geo_coord (glwin * view, int geo, int coord)
1408{
1409 int i, j;
1410 if (geo == 30) return 0;
1411 if (! coord)
1412 {
1413 i = (geo < 2) ? 3 : 0;
1414 if (view -> rings)
1415 {
1416 for (j=0; j<5; j++)
1417 {
1418 if (view -> ring_max[j]) i ++;
1419 }
1420 }
1421 i = (geo < 2) ? i + geo : 4 + 2*i;
1422 }
1423 else
1424 {
1425 if (geo > 1)
1426 {
1427 i = 0;
1428 if (view -> rings)
1429 {
1430 for (j=0; j<5; j++)
1431 {
1432 if (view -> ring_max[j]) i ++;
1433 }
1434 }
1435 if (geo < 4)
1436 {
1437 i = 2*(i+2) + geo - 1;
1438 }
1439 else
1440 {
1441 i = 0;
1442 for (j=0; j<5; j++)
1443 {
1444 if (view -> ring_max[j])
1445 {
1446 if (geo == 4 + j) break;
1447 i ++;
1448 }
1449 }
1450 i = 3 + i;
1451 }
1452 }
1453 else
1454 {
1455 i = geo + 1;
1456 }
1457 }
1458 return i;
1459}
1460
1469G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data)
1470{
1471 tint * id = (tint *) data;
1472 glwin * view = get_project_by_id(id -> a) -> modelgl;
1473 int page = get_page_from_geo_coord(view, id -> b, id -> c);
1474 if (view -> coord_win == NULL)
1475 {
1476 view -> coord_win = g_malloc0 (sizeof*view -> coord_win);
1477 view -> coord_win -> win = advanced_coord_properties (view, page);
1478 }
1479 else if (GTK_IS_WIDGET(view -> coord_win -> win))
1480 {
1481 show_the_widgets (view -> coord_win -> win);
1482 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1483 }
1484 else
1485 {
1486 show_warning ("Error impossible to display the coordination window !", view -> win);
1487 }
1488}
Binding to the Fortran90 subroutines.
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
integer function chains()
Definition chains.F90:54
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
GtkWidget * color_box(glwin *view, int ideo, int spec, int geo)
create the color palette pointers and menus GTK3 version
Definition color_box.c:254
color colorp[64]
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
GtkTreePath * path
Definition datab.c:103
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
gchar * ctitle[MAXDATA][12]
Definition dlp_field.c:834
GType col_type[MAXDATA][12]
Definition dlp_field.c:856
char * rings_type[5]
Definition global.c:143
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...
GdkPixbuf * convert_to_pixbuf(cairo_surface_t *surf)
convert cairo surface to GdkPixbuf
Definition gtk-misc.c:1264
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:492
@ IMG_STOCK
Definition global.h:264
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
void set_color_chooser_color(GtkWidget *color_win, ColRGBA col)
set the color of a color selection window
Definition gtk-misc.c:2265
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:445
ColRGBA get_window_color(GtkWidget *color_win)
get the ColRGBA color from a color selection window
Definition gtk-misc.c:2250
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
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
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 * 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
G_MODULE_EXPORT void label_unlabel_coord(GtkWidget *widg, gpointer data)
label / unlabel a type of coordination callback GTK3
Definition popup.c:1839
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
project * opengl_project
Definition project.c:54
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
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2065
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void gtk_label_align(GtkWidget *lab, float ax, float ay)
set text alignment in a GtkLabel
Definition gtk-misc.c:701
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
G_MODULE_EXPORT void select_unselect_coord(GtkWidget *widg, gpointer data)
select / unselect a type of coordination callback GTK3
Definition popup.c:1915
GtkWidget * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
Definition gtk-misc.c:744
void add_box_child_end(GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the end position.
Definition gtk-misc.c:277
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:671
G_MODULE_EXPORT void show_hide_the_coord(GtkWidget *widg, gpointer data)
show / hide a type of coordination callback GTK3
Definition popup.c:1788
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
#define FCLOSE
Definition global.h:211
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
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 re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
gboolean is_coord_in_menu(int id, project *this_proj)
is this coordination in a menu ?
Definition m_coord.c:74
#define POLY_MAPS
Definition glwin.h:62
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ LABEL
Definition glwin.h:98
@ POLYS
Definition glwin.h:92
@ ATOMS
Definition glwin.h:89
@ RINGS
Definition glwin.h:96
#define ATOM_MAPS
Definition glwin.h:61
Function declarations for the creation of the OpenGL window.
void show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:260
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
float blue
Definition global.h:124
float alpha
Definition global.h:125
float red
Definition global.h:122
float green
Definition global.h:123
Definition glwin.h:875
Definition global.h:112
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 d
Definition tab-1.c:95
int a
Definition tab-1.c:95
void add_this_frag_mol_to_search_tree(project *this_proj, int geo, int gid)
add fragment or molecule in the search tree
Definition w_coord.c:761
char * text_maps[ATOM_MAPS]
Definition w_coord.c:90
int frag_mol_status
Definition w_coord.c:96
G_MODULE_EXPORT gboolean close_event_coord(GtkWidget *widg, GdkEvent *event, gpointer data)
environments configuration window close event callback GTK3
Definition w_coord.c:1295
G_MODULE_EXPORT void toggled_select_unselect_coord(GtkToggleButton *widg, gpointer data)
toggle select / unselect coordination callback GTK3
Definition w_coord.c:261
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
Definition w_coord.c:1469
G_MODULE_EXPORT void cloned_poly(GtkWidget *widg, gpointer data)
cloned polyehdra callback - GTK3
Definition m_poly.c:181
GtkWidget * fragmol_tab(glwin *view, int geo)
create fragment(s) or molecule(s) tab
Definition w_coord.c:999
G_MODULE_EXPORT void to_set_this_frag_mol_color(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data)
set fragment/molecule color tree view callback
Definition w_coord.c:877
G_MODULE_EXPORT void set_poly_color_map_box(GtkComboBox *box, gpointer data)
change polyhedra color map
Definition w_coord.c:1090
G_MODULE_EXPORT void set_color_frag_mol(GtkColorChooser *colob, gpointer data)
set fragment or molecule color
Definition w_coord.c:370
GtkWidget * create_frag_mol_tree(project *this_proj, int geo)
create the fragment(s) / molecule(s) search tree store
Definition w_coord.c:895
GtkWidget * coord_tab(glwin *view, int geo, int poly)
create coordination(s) and polyhedra tab
Definition w_coord.c:542
GtkWidget * param_tab(glwin *view)
environments configuration window parameters tab
Definition w_coord.c:1147
G_MODULE_EXPORT void run_set_this_frag_mol_color(GtkDialog *win, gint response_id, gpointer data)
set fragment / molecule color - running the dialog
Definition w_coord.c:823
G_MODULE_EXPORT void toggled_label_unlabel_coord(GtkToggleButton *widg, gpointer data)
toggle label / unlabel coordination callback GTK3
Definition w_coord.c:218
G_MODULE_EXPORT void set_color_coord(GtkColorChooser *colob, gpointer data)
set coordination color
Definition w_coord.c:391
void set_frag_mol_cell_background(GtkListStore *store, GtkTreeIter iter, ColRGBA col)
set tree store cell background color
Definition w_coord.c:739
cairo_surface_t * col_surface(double r, double g, double b, int x, int y)
create a cairo sufrace painted with the appropriate color
Definition color_box.c:87
G_MODULE_EXPORT void update_frag_mol_search(GtkEntry *res, gpointer data)
update the fragment(s) / molecule(s) search widget
Definition w_coord.c:939
G_MODULE_EXPORT void on_select_frag_mol(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
tree store action on cell selection
Definition w_coord.c:691
GtkWidget * create_frag_mol_search(project *this_proj, int geo)
create the frgament(s)/molecule(s) search widget
Definition w_coord.c:964
void poly_alpha_has_changed(gpointer data, GLfloat v)
change polyhedra opacity
Definition w_coord.c:414
GtkWidget * chains_tab(glwin *view)
create the chain(s) tab for the advanced environments window
Definition w_chains.c:784
GtkWidget * advanced_coord_properties(glwin *view, int page)
create the environments configuration window
Definition w_coord.c:1310
G_MODULE_EXPORT void close_coord(GtkButton *but, gpointer data)
environments configuration window close button
Definition w_coord.c:1267
void set_this_frag_mol_color(gpointer data, GtkTreePath *path)
set fragment / molecule color - creating the dialog
Definition w_coord.c:848
G_MODULE_EXPORT gboolean scroll_set_poly_alpha(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
set polyhedra opacity - scroll callback
Definition w_coord.c:439
G_MODULE_EXPORT void toggled_show_hide_poly(GtkToggleButton *widg, gpointer data)
toggle show / hide polyhedra callback GTK3
Definition w_coord.c:304
GtkWidget * rings_tab(glwin *view, int g)
create the ring(s) tab for the advanced environments window
Definition w_rings.c:906
int selected_aspec
Definition popup.c:180
G_MODULE_EXPORT void set_color_map(GtkWidget *widg, gpointer data)
set color map callback
Definition m_map.c:1011
G_MODULE_EXPORT void toggled_show_hide_coord(GtkToggleButton *widg, gpointer data)
toggle show / hide coordination callback GTK3
Definition w_coord.c:117
int get_page_from_geo_coord(glwin *view, int geo, int coord)
find the proper page to display in the notebook
Definition w_coord.c:1407
G_MODULE_EXPORT void set_poly_alpha(GtkRange *range, gpointer data)
set polyhedra opacity - range callback
Definition w_coord.c:453
gboolean add_geo(int poly, project *this_proj, int g, int i, int j)
test add this geometry data to the tree store or not ?
Definition w_coord.c:469
G_MODULE_EXPORT void on_cloned_poly_toggled(GtkToggleButton *Button, gpointer data)
toggle show / hide cloned polyhedra callback GTK3
Definition w_coord.c:1124
G_MODULE_EXPORT void set_atom_color_map_box(GtkComboBox *box, gpointer data)
change atom color map
Definition w_coord.c:1067
GtkWidget * res[2]
Definition w_encode.c:212
GdkPixbuf * pix
Definition workspace.c:69
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73