atomes 1.1.14
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-rshow-%d.%d.0", this_proj -> coord -> geolist[g][0][c], 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-p.%d.0", this_proj -> coord -> geolist[g][0][c], 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
555 GtkWidget * box = create_vbox (BSEP);
556 GtkWidget * coord = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
557 gtk_widget_set_hexpand (coord, TRUE);
558 gtk_widget_set_vexpand (coord, TRUE);
559 n = 0;
560 if (geo > 3 && ! poly)
561 {
562 n = (geo == 9) ? 11 : 10;
563 gtk_widget_set_size_request (coord, -1, 475);
564 if (geo < 9)
565 {
566 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label(" * for the polyhedra only", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
567 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);
568 }
569 else
570 {
571 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);
572 }
573 }
574 GtkWidget * vbox = create_vbox (BSEP);
576 l = 0;
577 if (poly)
578 {
579 l = 1;
580 }
581 wb = create_hbox (0);
582 gtk_widget_set_size_request (wb, 350, -1);
583 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
584 for (i=0; i<5-2*l-geo/9; i++)
585 {
586 if (geo == 9)
587 {
588 j = 11 + i;
589 }
590 else if (i == 0 && geo > 3)
591 {
592 j = 10;
593 }
594 else if (i > 0 && geo > 3 && ! poly)
595 {
596 j = i+5;
597 }
598 else if (i == 1 && poly)
599 {
600 j = 5;
601 }
602 else
603 {
604 j = i;
605 }
606 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
607 }
608 k = 0;
609 project * this_proj = get_project_by_id(p);
610 m = (geo < 2) ? this_proj -> nspec : 1;
611 if ((geo < 2 || (geo == 9 && view -> chain_max) || (geo > 3 && geo < 9 && view -> ring_max[geo-4])) && this_proj -> coord -> totcoord[geo] > 0)
612 {
613 for (i=0; i < m; i++)
614 {
615 if (geo == 0)
616 {
617 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++)
618 {
619 if (add_geo(poly, this_proj, geo, i, j))
620 {
621 str = g_strdup_printf (" <b>%s</b>", this_proj -> chemistry -> label[i]);
622 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
623 g_free (str);
624 break;
625 }
626 }
627 }
628 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++, k++)
629 {
630 if (add_geo(poly, this_proj, geo, i, j))
631 {
632 wb = create_hbox (0);
633 gtk_widget_set_size_request (wb, 350, -1);
634 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
635 if (geo == 0)
636 {
637 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[geo][i][j]);
638 }
639 else if (geo == 1)
640 {
641 str = exact_name(env_name (this_proj, j, i, 1, NULL));
642 }
643 else
644 {
645 str = g_strdup_printf ("%d atoms", this_proj -> coord -> geolist[geo][i][j]);
646 }
647 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.5, 0.5), FALSE, FALSE, 5);
648 g_free (str);
649 if (poly)
650 {
651 but = create_hscale (0.0, 1.0, 0.01, view -> anim -> last -> img -> spcolor[geo][i][j].alpha, GTK_POS_LEFT, 3, 160,
652 G_CALLBACK(set_poly_alpha), G_CALLBACK(scroll_set_poly_alpha), & view -> gcid[geo][k][geo]);
653 }
654 else if (geo != 9)
655 {
656 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][i][j];
657 col.alpha = 1.0;
658 but = color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_coord), & view -> gcid[geo][k][geo]);
659 }
660 if (poly || geo != 9) add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 5);
661
662 if (poly)
663 {
664 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]);
665 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
666 }
667 else
668 {
669 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]);
670 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
671 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][k][geo]);
672 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n);
673 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][k][geo]);
674 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n/2);
675 }
676 }
677 }
678 }
679 }
680 return box;
681}
682
692G_MODULE_EXPORT void on_select_frag_mol (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
693{
694 int i, g, v, act;
695 tint * dat = (tint * )data;
696 GtkTreeIter iter;
698 coord_edition * coord = opengl_project -> modelgl -> coord_win;
699 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
700 g = (dat -> b < 30) ? 2 : 3;
701 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
702 {
703 v = 0;
704 }
705 else
706 {
707 v = 1;
708 }
709 gtk_tree_model_get_iter (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, path);
710 act = dat -> b - 10*g;
711 gtk_list_store_set (coord -> frag_mol_model[g-2], & iter, act, v, -1);
712 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
713 frag_mol_status = v;
714 switch (act)
715 {
716 case 1:
717 // Viz
718 toggled_show_hide_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
719 break;
720 case 3:
721 // Label
722 toggled_label_unlabel_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
723 break;
724 case 4:
725 // Pick
726 toggled_select_unselect_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
727 break;
728 }
729}
730
740void set_frag_mol_cell_background (GtkListStore * store, GtkTreeIter iter, ColRGBA col)
741{
742 cairo_surface_t * surface;
743 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 70, 50);
744 cairo_t * cr = cairo_create (surface);
745 cairo_set_source_rgba (cr, col.red, col.green, col.blue, 1.0);
746 cairo_paint (cr);
747 GdkPixbuf * pix = convert_to_pixbuf (surface);
748 cairo_surface_destroy (surface);
749 cairo_destroy(cr);
750 gtk_list_store_set (store, & iter, 2, pix, -1);
751}
752
762void add_this_frag_mol_to_search_tree (project * this_proj, int geo, int gid)
763{
764 GtkTreeIter id_level;
765 GtkTreeIter new_level;
766 gboolean valid;
767 int i;
768 int prepend = 0;
769 coord_edition * coord = this_proj -> modelgl -> coord_win;
770 GtkListStore * store = (GtkListStore *) coord -> frag_mol_model[geo-2];
771 GtkTreeModel * mod = GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]);
772 valid = gtk_tree_model_get_iter_first(mod, & id_level);
773 while (valid)
774 {
775 gtk_tree_model_get (mod, & id_level, 0, & i, -1);
776 if (i > gid)
777 {
778 prepend = 1;
779 valid = FALSE;
780 }
781 else if (i == gid)
782 {
783 prepend = 2;
784 valid = FALSE;
785 }
786 else
787 {
788 valid = gtk_tree_model_iter_next(mod, & id_level);
789 }
790 }
791 if (prepend < 2)
792 {
793 switch (prepend)
794 {
795 case 0:
796 gtk_list_store_append (store, & id_level);
797 gtk_list_store_set (store, & id_level, 0, gid,
798 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
799 3, FALSE,
800 4, FALSE, -1);
801 set_frag_mol_cell_background (store, id_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
802 break;
803 case 1:
804 gtk_list_store_insert_before (store, & new_level, & id_level);
805 gtk_list_store_set (store, & new_level, 0, gid,
806 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
807 3, FALSE,
808 4, FALSE, -1);
809 set_frag_mol_cell_background (store, new_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
810 break;
811 }
812 }
813}
814
824G_MODULE_EXPORT void run_set_this_frag_mol_color (GtkDialog * win, gint response_id, gpointer data)
825{
826 tint * dat = (tint * )data;
827 int i, g;
828 if (response_id == GTK_RESPONSE_OK)
829 {
830 g = (dat -> b < 30) ? 2 : 3;
831 GtkTreeIter fm_iter;
832 gtk_tree_model_get (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & fm_iter, 0, & i, -1);
833 opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1] = get_window_color (GTK_WIDGET(win));
834 int shaders[3] = {ATOMS, BONDS, LABEL};
836 update (opengl_project -> modelgl);
837 }
839}
840
849void set_this_frag_mol_color (gpointer data, GtkTreePath * path)
850{
851 int i, g;
852 tint * dat = (tint * )data;
854 g = (dat -> b < 30) ? 2 : 3;
855 GtkTreeIter iter;
856 gtk_tree_model_get_iter (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & iter, path);
857 coord_edition * coord = opengl_project -> modelgl -> coord_win;
858 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
859 gchar * ctitle[2] = {"Fragment", "Molecule"};
860 gchar * str = g_strdup_printf ("%s N°%d color", ctitle[g-2], i);
861 GtkWidget * widg = gtk_color_chooser_dialog_new (str, GTK_WINDOW(coord -> win));
862 g_free (str);
863 set_color_chooser_color (widg, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
864 run_this_gtk_dialog (widg, G_CALLBACK(run_set_this_frag_mol_color), data);
865 set_frag_mol_cell_background ((GtkListStore *) coord -> frag_mol_model[g-2], iter, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
866}
867
878G_MODULE_EXPORT void to_set_this_frag_mol_color (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
879{
880 gchar * title;
881 g_object_get (column, "title", & title, NULL, NULL);
882 if (g_strcmp0(title, "Color") == 0)
883 {
885 }
886}
887
896GtkWidget * create_frag_mol_tree (project * this_proj, int geo)
897{
898 int i;
899 GtkTreeViewColumn * frag_mol_col[7];
900 GtkCellRenderer * frag_mol_cell[7];
901 gchar * ctitle[5]={"Id.", "Show", "Color", "Label", "Pick"};
902 gchar * ctype[5]={"text", "active", "pixbuf", "active", "active"};
903 GType col_type[5]={G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN};
904 coord_edition * coord = this_proj -> modelgl -> coord_win;
905 coord -> frag_mol_model[geo-2] = gtk_list_store_newv (5, col_type);
906 GtkWidget * frag_mol_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]));
907 for (i=0; i<5; i++)
908 {
909 if (! i)
910 {
911 frag_mol_cell[i] = gtk_cell_renderer_text_new ();
912 }
913 else if (i == 2)
914 {
915 frag_mol_cell[i] = gtk_cell_renderer_pixbuf_new ();
916 }
917 else
918 {
919 frag_mol_cell[i] = gtk_cell_renderer_toggle_new ();
920 g_signal_connect (G_OBJECT(frag_mol_cell[i]), "toggled", G_CALLBACK(on_select_frag_mol), & this_proj -> modelgl -> colorp[geo*10+i][0]);
921 }
922 gtk_cell_renderer_set_fixed_size (frag_mol_cell[i], 70, 25);
923 frag_mol_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[i], frag_mol_cell[i], ctype[i], i, NULL);
924 gtk_tree_view_append_column(GTK_TREE_VIEW(frag_mol_tree), frag_mol_col[i]);
925 gtk_tree_view_column_set_alignment (frag_mol_col[i], 0.5);
926 }
927 g_object_set (frag_mol_tree, "activate-on-single-click", TRUE, NULL, NULL);
928 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]);
929 return frag_mol_tree;
930}
931
940G_MODULE_EXPORT void update_frag_mol_search (GtkEntry * res, gpointer data)
941{
942 tint * dat = (tint * )data;
943 const gchar * m = entry_get_text (res);
944 int v = (int)atof(m);
945 project * this_proj = get_project_by_id(dat -> a);
946 int g = dat -> b;
947 if (v > 0 && v <= this_proj -> coord -> totcoord[g])
948 {
949 add_this_frag_mol_to_search_tree (this_proj, g, v);
950 }
951 else
952 {
954 }
955}
956
965GtkWidget * create_frag_mol_search (project * this_proj, int geo)
966{
967 GtkWidget * frag_mol_search = create_vbox (BSEP);
968 gchar * obj[2] = {"fragment", "molecule"};
969 gchar * str = g_strdup_printf ("Too many <b>%ss</b> in your model !\n"
970 " It is impossible to display the entire list ...\n"
971 "... instead you can look for %s(s) 'manually':\n", obj[geo-2], obj[geo-2]);
972 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
973 g_free (str);
974 gchar * search_item[2]={"Fragment ID:", "Molecule ID:"};
975 GtkWidget * hbox;
976 GtkWidget * entry;
977 GtkWidget * label;
978 hbox = create_hbox (0);
979 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, hbox, FALSE, FALSE, 0);
980 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(search_item[geo-2], 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
981 entry = create_entry (G_CALLBACK(update_frag_mol_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[geo][0]);
982 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
983 str = g_strdup_printf ("in [%d - %d]", 1, this_proj -> coord -> totcoord[geo]);
984 label = markup_label (str, 50, -1, 0.0, 0.5);
985 g_free (str);
986 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, label, FALSE, FALSE, 5);
987 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);
988 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, create_frag_mol_tree (this_proj, geo), FALSE, FALSE, 0);
989 return frag_mol_search;
990}
991
1000GtkWidget * fragmol_tab (glwin * view, int geo)
1001{
1002 int i, j;
1003 GtkWidget * wb;
1004 gchar * str;
1005 int scol[5] = {70, 70, 65, 40, 40};
1006 gchar * col[5] = {"<b>Id</b>", "<b>Color</b>", "<b>Show</b>", "<b>Label</b>", "<b>Pick</b>"};
1007
1008 GtkWidget * box = create_vbox (BSEP);
1009 GtkWidget * fragmol = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
1010 gtk_widget_set_hexpand (fragmol, TRUE);
1011 gtk_widget_set_vexpand (fragmol, TRUE);
1012 project * this_proj = get_project_by_id(view -> proj);
1013 i = this_proj -> coord -> totcoord[geo];
1014 if (i > 10000)
1015 {
1016 add_container_child (CONTAINER_SCR, fragmol, create_frag_mol_search(this_proj, geo));
1017 }
1018 else
1019 {
1020 GtkWidget * vbox = create_vbox (BSEP);
1022 wb = create_hbox (0);
1023 gtk_widget_set_size_request (wb, 350, -1);
1024 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1025 for (j=0; j<5; j++)
1026 {
1027 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
1028 }
1029 for (j=0; j<i; j++)
1030 {
1031 wb = create_hbox (0);
1032 gtk_widget_set_size_request (wb, 300, -1);
1033 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1034
1035 str = g_strdup_printf ("N°%d", j+1);
1036 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.25, 0.5), FALSE, FALSE, 5);
1037 g_free (str);
1038 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][0][j];
1039 col.alpha = 1.0;
1040 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1041 color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_frag_mol), & view -> gcid[geo][j][0]),
1042 FALSE, FALSE, 5);
1043
1044 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1045 check_button(NULL, -1, -1, view -> anim -> last -> img -> show_coord[geo][j], G_CALLBACK(toggled_show_hide_coord), & view -> gcid[geo][j][geo]),
1046 FALSE, FALSE, 20);
1047
1048 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1049 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][j][geo]),
1050 FALSE, FALSE, 15);
1051
1052 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1053 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][j][geo]),
1054 FALSE, FALSE, 15);
1055 }
1056 }
1057 return box;
1058}
1059
1068G_MODULE_EXPORT void set_atom_color_map_box (GtkComboBox * box, gpointer data)
1069{
1070 glwin * view = (glwin *)data;
1071 int i = gtk_combo_box_get_active (box);
1072 int j = view -> cmap[i];
1073#ifdef GTK4
1074 gchar * variant = g_strdup_printf ("set-amap.%d.0", j);
1075 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-amap", g_variant_new_string((const gchar *)variant));
1076 g_free (variant);
1077#else
1078 // GTK3 Menu Action To Check
1079 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1080#endif
1081}
1082
1091G_MODULE_EXPORT void set_poly_color_map_box (GtkComboBox * box, gpointer data)
1092{
1093 glwin * view = (glwin *)data;
1094 int i = gtk_combo_box_get_active (box);
1095 int j = view -> cmap[i] + ATOM_MAPS;
1096#ifdef GTK4
1097 gchar * variant = g_strdup_printf ("set-pmap.%d.0", j);
1098 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-pmap", g_variant_new_string((const gchar *)variant));
1099 g_free (variant);
1100#else
1101 // GTK3 Menu Action To Check
1102 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1103#endif
1104}
1105
1106#ifdef GTK4
1115G_MODULE_EXPORT void on_cloned_poly_toggled (GtkCheckButton * Button, gpointer data)
1116#else
1125G_MODULE_EXPORT void on_cloned_poly_toggled (GtkToggleButton * Button, gpointer data)
1126#endif
1127{
1128 glwin * view = (glwin *)data;
1129#ifdef GTK4
1130 view -> anim -> last -> img -> cloned_poly = gtk_check_button_get_active (Button);
1131 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-cloned-poly.0.0", NULL);
1132 /* int shaders[2] = {POLYS, RINGS};
1133 re_create_md_shaders (2, shaders, get_project_by_id(view -> proj));
1134 update (view); */
1135#else
1136 // GTK3 Menu Action To Check
1137 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[5], gtk_toggle_button_get_active (Button));
1138#endif
1139}
1140
1148GtkWidget * param_tab (glwin * view)
1149{
1150 int i, j, k, l;
1151 GtkWidget * vbox = create_vbox (BSEP);
1152 /*gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(fragmol), vbox); */
1153 GtkWidget * hbox = create_hbox (0);
1154 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1155 GtkWidget * lab = gtk_label_new ("<b>Atom(s) and bond(s) color map:</b>");
1156 gtk_label_set_use_markup (GTK_LABEL(lab), 1);
1157 gtk_label_align (lab, 0.0, 0.5);
1158 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1159 hbox = create_hbox (0);
1160 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1161 GtkWidget * color_box = create_combo ();
1162 j = 0;
1163 for (i=0; i<ATOM_MAPS; i++)
1164 {
1165 if (i == 1 || i == 2)
1166 {
1167 view -> cmap[j] = i;
1168 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1169 j ++;
1170 }
1171 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1172 {
1173 view -> cmap[j] = i;
1174 combo_text_append (color_box, "Force field (DL_POLY)");
1175 j ++;
1176 }
1177 else if (i == 6 && view -> custom_map != NULL)
1178 {
1179 view -> cmap[j] = i;
1180 combo_text_append (color_box, "Custom");
1181 j ++;
1182 }
1183 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1184 {
1185 view -> cmap[j] = i;
1187 j ++;
1188 }
1189 }
1190 l = 0;
1191 for (k=0; k<j; k++)
1192 {
1193 if (view -> anim -> last -> img -> color_map[0] == view -> cmap[k])
1194 {
1195 l = k;
1196 break;
1197 }
1198 }
1199 gtk_combo_box_set_active (GTK_COMBO_BOX(color_box), l);
1200 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_atom_color_map_box), view);
1201 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1202
1203 hbox = create_hbox (0);
1204 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1205 lab = gtk_label_new ("<b>Polyhedra color map:</b>");
1206 gtk_label_set_use_markup (GTK_LABEL(lab), 1);
1207 gtk_label_align (lab, 0.0, 0.5);
1208 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1209 hbox = create_hbox (0);
1210 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1212 for (i=0; i<POLY_MAPS; i++)
1213 {
1214 if (i == 1 || i == 2)
1215 {
1216 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1217 }
1218 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1219 {
1221 }
1222 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1223 {
1224 combo_text_append (color_box, "Force field (DL_POLY)");
1225 }
1226 else if (i == 6 && view -> custom_map != NULL)
1227 {
1228 combo_text_append (color_box, "Use atom(s) custom map");
1229 }
1230 }
1231 l = 0;
1232 for (k=0; k<j; k++)
1233 {
1234 if (view -> anim -> last -> img -> color_map[1] == view -> cmap[k])
1235 {
1236 l = k; // + ATOM_MAPS;
1237 break;
1238 }
1239 }
1240 gtk_combo_box_set_active (GTK_COMBO_BOX(color_box), l);
1241 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_poly_color_map_box), view);
1242 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1244
1245 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("\n<b>Display polyhedra at the edges of the model box\n"
1246 "using the PBC even if the clones are not shown:</b>", -1, -1, 0.5, 0.5),
1247 FALSE, FALSE, 15);
1248 GtkWidget * cloned_p = check_button ("Cloned polyhedra", -1, 40, view -> anim -> last -> img -> cloned_poly,
1249 G_CALLBACK(on_cloned_poly_toggled), view);
1250 widget_set_sensitive ((cloned_p), get_project_by_id(view -> proj) -> cell.pbc);
1251 hbox = create_hbox (0);
1252 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 0);
1253 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cloned_p, FALSE, FALSE, 50);
1254 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("This is automatic if the clones are shown.\n"
1255 "The clones are the replica of the atoms linked by PBC.", -1, -1, 0.5, 0.5),
1256 FALSE, FALSE, 5);
1257 return vbox;
1258}
1259
1268G_MODULE_EXPORT void close_coord (GtkButton * but, gpointer data)
1269{
1270 glwin * view = (glwin *)data;
1271 view -> coord_win -> win = destroy_this_widget (view -> coord_win -> win);
1272 g_free (view -> coord_win);
1273 view -> coord_win = NULL;
1274}
1275
1276#ifdef GTK4
1285G_MODULE_EXPORT gboolean close_event_coord (GtkWindow * widg, gpointer data)
1286#else
1296G_MODULE_EXPORT gboolean close_event_coord (GtkWidget * widg, GdkEvent * event, gpointer data)
1297#endif
1298{
1299 close_coord (NULL, data);
1300 return FALSE;
1301}
1302
1311GtkWidget * advanced_coord_properties (glwin * view, int page)
1312{
1313 gchar * str = g_strdup_printf ("Environments configuration - %s", get_project_by_id(view -> proj)->name);
1314 GtkWidget * win = create_win (str, view -> win, FALSE, FALSE);
1315 g_free (str);
1316 char * rings_short[5] = {"AR", "KR", "GR", "PR", "SR"};
1317 GtkWidget * vbox = create_vbox (5);
1319 gtk_widget_set_size_request (win, 625, 600);
1320 view -> coord_win -> notebook = gtk_notebook_new ();
1321 gtk_notebook_set_scrollable (GTK_NOTEBOOK(view -> coord_win -> notebook), TRUE);
1322 gtk_notebook_set_tab_pos (GTK_NOTEBOOK(view -> coord_win -> notebook), GTK_POS_LEFT);
1323 gtk_widget_show (view -> coord_win -> notebook);
1324 gtk_widget_set_size_request (view -> coord_win -> notebook, 600, 550);
1325 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> coord_win -> notebook, FALSE, FALSE, 0);
1326 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), param_tab (view), gtk_label_new ("Parameters"));
1327 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));
1328 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));
1329
1330 int i, j, k;
1331 j = 2;
1332 k = 0;
1333 if (view -> rings)
1334 {
1335 for (i=0; i<5; i++)
1336 {
1337 if (view -> ring_max[i])
1338 {
1339 j ++;
1340 k ++;
1341 str = g_strdup_printf ("%s ring(s) <b>[%s]</b>", rings_type[i], rings_short[i]);
1342 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));
1343 g_free (str);
1344 }
1345 }
1346 }
1347 if (view -> chains && view -> chain_max)
1348 {
1349 j ++;
1350 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));
1351 }
1352
1353 j ++;
1354 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));
1355 j ++;
1356 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));
1357 if (view -> rings)
1358 {
1359 for (i=0; i<5; i++)
1360 {
1361 if (view -> ring_max[i])
1362 {
1363 j ++;
1364 str = g_strdup_printf ("Polyhedra from <b>%s</b>", rings_short[i]);
1365 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));
1366 g_free (str);
1367 }
1368 }
1369 }
1370
1371 if (view -> adv_bonding[0])
1372 {
1373 j ++;
1374 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 2), markup_label ("Fragment(s)", -1, -1, 0.0, 0.5));
1375 }
1376 if (view -> adv_bonding[1])
1377 {
1378 j ++;
1379 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 3), markup_label ("Molecule(s)", -1, -1, 0.0, 0.5));
1380 }
1381
1382 if (view -> rings)
1383 {
1384 for (i=0; i<5; i++)
1385 {
1386 if (view -> ring_max[i])
1387 {
1388 j ++;
1389 str = g_strdup_printf ("Isolated ring(s) from <b>%s</b>", rings_short[i]);
1390 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), rings_tab (view, i), markup_label(str, -1, -1, 0.0, 0.5));
1391 g_free (str);
1392 }
1393 }
1394 }
1395
1396 if (view -> chains && view -> chain_max)
1397 {
1398 j ++;
1399 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), chains_tab (view), markup_label("Isolated chain(s)", -1, -1, 0.0, 0.5));
1400 }
1401
1402 GtkWidget * hbox = create_hbox (5);
1403 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, TRUE, FALSE, 0);
1404 GtkWidget * but = create_button ("Close", IMG_STOCK, FCLOSE, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(close_coord), view);
1405 add_box_child_end (hbox, but, FALSE, FALSE, 0);
1406 add_gtk_close_event (win, G_CALLBACK(close_event_coord), view);
1407 show_the_widgets (win);
1408 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1409 return win;
1410}
1411
1421int get_page_from_geo_coord (glwin * view, int geo, int coord)
1422{
1423 int i, j;
1424 if (geo == 30) return 0;
1425 if (! coord)
1426 {
1427 i = (geo < 2) ? 3 : 0;
1428 if (view -> rings)
1429 {
1430 for (j=0; j<5; j++)
1431 {
1432 if (view -> ring_max[j]) i ++;
1433 }
1434 }
1435 i = (geo < 2) ? i + geo : 4 + 2*i;
1436 }
1437 else
1438 {
1439 if (geo > 1)
1440 {
1441 i = 0;
1442 if (view -> rings)
1443 {
1444 for (j=0; j<5; j++)
1445 {
1446 if (view -> ring_max[j]) i ++;
1447 }
1448 }
1449 if (geo < 4)
1450 {
1451 i = 2*(i+2) + geo - 1;
1452 }
1453 else
1454 {
1455 i = 0;
1456 for (j=0; j<5; j++)
1457 {
1458 if (view -> ring_max[j])
1459 {
1460 if (geo == 4 + j) break;
1461 i ++;
1462 }
1463 }
1464 i = 3 + i;
1465 }
1466 }
1467 else
1468 {
1469 i = geo + 1;
1470 }
1471 }
1472 return i;
1473}
1474
1483G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data)
1484{
1485 tint * id = (tint *) data;
1486 glwin * view = get_project_by_id(id -> a) -> modelgl;
1487 int page = get_page_from_geo_coord(view, id -> b, id -> c);
1488 if (view -> coord_win == NULL)
1489 {
1490 view -> coord_win = g_malloc0 (sizeof*view -> coord_win);
1491 view -> coord_win -> win = advanced_coord_properties (view, page);
1492 }
1493 else if (GTK_IS_WIDGET(view -> coord_win -> win))
1494 {
1495 gtk_widget_show (view -> coord_win -> win);
1496 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1497 }
1498 else
1499 {
1500 show_warning ("Error impossible to display the coordination window !", view -> win);
1501 }
1502}
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
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:1244
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:472
@ IMG_STOCK
Definition global.h:236
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1294
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1940
void set_color_chooser_color(GtkWidget *color_win, ColRGBA col)
set the color of a color selection window
Definition gtk-misc.c:2241
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:425
ColRGBA get_window_color(GtkWidget *color_win)
get the ColRGBA color from a color selection window
Definition gtk-misc.c:2226
project * proj
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:577
#define BSEP
Definition global.h:217
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:2363
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1779
@ CONTAINER_WIN
Definition global.h:222
@ CONTAINER_SCR
Definition global.h:223
G_MODULE_EXPORT void label_unlabel_coord(GtkWidget *widg, gpointer data)
label / unlabel a type of coordination callback GTK3
Definition popup.c:1840
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:1843
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:903
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1565
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:279
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2212
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:186
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2041
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
void gtk_label_align(GtkWidget *lab, float ax, float ay)
set text alignment in a GtkLabel
Definition gtk-misc.c:681
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:880
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2010
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1708
G_MODULE_EXPORT void select_unselect_coord(GtkWidget *widg, gpointer data)
select / unselect a type of coordination callback GTK3
Definition popup.c:1916
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:724
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:257
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:651
G_MODULE_EXPORT void show_hide_the_coord(GtkWidget *widg, gpointer data)
show / hide a type of coordination callback GTK3
Definition popup.c:1787
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:206
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:781
#define FCLOSE
Definition global.h:183
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
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:118
float alpha
Definition global.h:119
float red
Definition global.h:116
float green
Definition global.h:117
Definition glwin.h:875
Definition global.h:106
Definition global.h:98
int b
Definition global.h:100
int c
Definition global.h:101
int a
Definition global.h:99
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:762
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:1296
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:1483
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:1000
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:878
G_MODULE_EXPORT void set_poly_color_map_box(GtkComboBox *box, gpointer data)
change polyhedra color map
Definition w_coord.c:1091
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:896
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:1148
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:824
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:740
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:940
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:692
GtkWidget * create_frag_mol_search(project *this_proj, int geo)
create the frgament(s)/molecule(s) search widget
Definition w_coord.c:965
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:1311
G_MODULE_EXPORT void close_coord(GtkButton *but, gpointer data)
environments configuration window close button
Definition w_coord.c:1268
void set_this_frag_mol_color(gpointer data, GtkTreePath *path)
set fragment / molecule color - creating the dialog
Definition w_coord.c:849
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:179
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:1421
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:1125
G_MODULE_EXPORT void set_atom_color_map_box(GtkComboBox *box, gpointer data)
change atom color map
Definition w_coord.c:1068
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