atomes 1.3.1
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-2026 by CNRS and University of Strasbourg */
15
21
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] = {i18n("Atomic Species"),
91 i18n("Total"),
92 i18n("Partial"),
93 i18n("Fragment(s)"),
94 i18n("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 k = (widg) ? button_get_status ((GtkWidget *)widg) : frag_mol_status;
141 if (k != this_proj -> modelgl -> anim -> last -> img -> show_coord[g][j])
142 {
143 if (is_coord_in_menu(g, this_proj))
144 {
145#ifdef GTK4
146 gchar * name;
147 gchar * str, * env;
148 if (g < 2)
149 {
150 if (g)
151 {
152 env = env_name (this_proj, c, s, 1, NULL);
153 str = exact_name (env);
154 g_free (env);
155 }
156 else
157 {
158 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
159 }
160 name = g_strdup_printf ("set-%s-s.%d.0", str, j);
161 g_free (str);
162 }
163 else if (g > 1 && g < 4)
164 {
165 name = g_strdup_printf ("set-%s-%d.%d.0", (g == 2) ? "frag" : "mol", c+1, c);
166 }
167 else if (g > 3 && g < 9)
168 {
169 name = g_strdup_printf ("set-%d-%d-coord.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
170 }
171 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
172 g_free (name);
173#else
174 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][g][j], k);
175#endif
176 }
177 else
178 {
179 tint pointer;
180 pointer.a = g;
181 pointer.b = c;
182 pointer.c = k;
183 opengl_project_changed (the_data -> a);
184#ifdef GTK4
185 show_hide_the_coord (NULL, NULL, & pointer);
186#else
187 show_hide_the_coord (NULL, & pointer);
188#endif // GTK4
189 }
190 }
191 init_default_shaders (this_proj -> modelgl);
192}
193
194#ifdef GTK4
203G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkCheckButton * widg, gpointer data)
204#else
213G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkToggleButton * widg, gpointer data)
214#endif
215{
216 qint * the_data = (qint *)data;
217 tint pointer;
218 pointer.a = the_data -> d;
219 pointer.b = the_data -> c;
220 pointer.c = (widg) ? button_get_status ((GtkWidget *)widg) : frag_mol_status;
221 selected_aspec = the_data -> b;
222#ifdef DEBUG
223 g_debug ("Toggle label/unlabel coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
224#endif
225 opengl_project_changed (the_data -> a);
226#ifdef GTK4
227 label_unlabel_coord (NULL, NULL, & pointer);
228#else
229 label_unlabel_coord (NULL, & pointer);
230#endif // GTK4
231}
232
233#ifdef GTK4
242G_MODULE_EXPORT void toggled_select_unselect_coord (GtkCheckButton * widg, gpointer data)
243#else
252G_MODULE_EXPORT void toggled_select_unselect_coord (GtkToggleButton * widg, gpointer data)
253#endif
254{
255 qint * the_data = (qint *)data;
256 tint pointer;
257 pointer.a = the_data -> d;
258 pointer.b = the_data -> c;
259 pointer.c = (widg) ? button_get_status ((GtkWidget *)widg) : frag_mol_status;
260 selected_aspec = the_data -> b;
261#ifdef DEBUG
262 g_debug ("Toggle select/unselect coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
263#endif
264 opengl_project_changed (the_data -> a);
265#ifdef GTK4
266 select_unselect_coord (NULL, NULL, & pointer);
267#else
268 select_unselect_coord (NULL, & pointer);
269#endif
270}
271
272#ifdef GTK4
281G_MODULE_EXPORT void toggled_show_hide_poly (GtkCheckButton * widg, gpointer data)
282#else
291G_MODULE_EXPORT void toggled_show_hide_poly (GtkToggleButton * widg, gpointer data)
292#endif
293{
294 qint * the_data = (qint *)data;
295 int i, j, k;
296 int s, g, c;
297 project * this_proj = get_project_by_id(the_data -> a);
298 s = the_data -> b;
299 g = the_data -> d;
300 c = the_data -> c;
301 j = c;
302 if (g < 2)
303 {
304 for (i=0; i<s; i++)
305 {
306 j += this_proj -> coord -> ntg[g][i];
307 }
308 }
309 k = button_get_status ((GtkWidget *)widg);
310#ifdef GTK4
311 if (k != this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j])
312 {
313 gchar * str, * env;
314 gchar * name;
315 if (g < 2)
316 {
317 if (g)
318 {
319 env = env_name (this_proj, c, s, 1, NULL);
320 str = exact_name (env);
321 g_free (env);
322 }
323 else
324 {
325 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
326 }
327 name = g_strdup_printf ("set-%s-%d-p.%d.0", str, g, j);
328 g_free (str);
329 }
330 else if (g > 3 && g < 9)
331 {
332 name = g_strdup_printf ("set-%d-%d-p.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
333 }
334 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
335 g_free (name);
336 }
337#else
338 // GTK3 Menu Action To Check
339 if (is_coord_in_menu(g, this_proj))
340 {
341 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][g][j], k);
342 }
343 this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j] = k;
344 int shaders[2] = {POLYS, RINGS};
345 re_create_md_shaders (2, shaders, this_proj);
346 update (this_proj -> modelgl);
347#endif
348}
349
358G_MODULE_EXPORT void set_color_frag_mol (GtkColorChooser * colob, gpointer data)
359{
360 qint * cid = (qint *)data;
361 int c, g;
362 project * this_proj = get_project_by_id(cid -> a);
363 g = cid -> b;
364 c = cid -> c;
365 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][0][c] = get_button_color (colob);
366 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
367 re_create_md_shaders (4, shaders, this_proj);
368 update (this_proj -> modelgl);
369}
370
379G_MODULE_EXPORT void set_color_coord (GtkColorChooser * colob, gpointer data)
380{
381 qint * cid = (qint *)data;
382 int c, g, s;
383 project * this_proj = get_project_by_id(cid -> a);
384 s = cid -> b;
385 c = cid -> c;
386 g = cid -> d;
387 if (g > 3) s = 0;
388 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c] = get_button_color (colob);
389 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
390 re_create_md_shaders (4, shaders, this_proj);
391 update (this_proj -> modelgl);
392}
393
402void poly_alpha_has_changed (gpointer data, GLfloat v)
403{
404 qint * cid = (qint *)data;
405 int c, g, s;
406 project * this_proj = get_project_by_id(cid -> a);
407 s = cid -> b;
408 c = cid -> c;
409 g = cid -> d;
410 if (g > 1) s = 0;
411 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c].alpha = v;
412 int shaders[2] = {POLYS, RINGS};
413 re_create_md_shaders (2, shaders, this_proj);
414 update (this_proj -> modelgl);
415}
416
427G_MODULE_EXPORT gboolean scroll_set_poly_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
428{
429 poly_alpha_has_changed (data, (GLfloat) value);
430 return FALSE;
431}
432
441G_MODULE_EXPORT void set_poly_alpha (GtkRange * range, gpointer data)
442{
443 poly_alpha_has_changed (data, (GLfloat) gtk_range_get_value (range));
444}
445
457gboolean add_geo (int poly, project * this_proj, int g, int i, int j)
458{
459 if (! poly)
460 {
461 if (g == 0)
462 {
463 if (this_proj -> coord -> geolist[g][i][j] != -1)
464 {
465 return TRUE;
466 }
467 else
468 {
469 return FALSE;
470 }
471 }
472 else if (g == 1)
473 {
474 return TRUE;
475 }
476 else
477 {
478 if (this_proj -> coord -> geolist[g][i][j])
479 {
480 return TRUE;
481 }
482 else
483 {
484 return FALSE;
485 }
486 }
487 }
488 else
489 {
490 if (g == 0 || g > 3)
491 {
492 if (this_proj -> coord -> geolist[g][i][j] > 2)
493 {
494 return TRUE;
495 }
496 else
497 {
498 return FALSE;
499 }
500 }
501 else
502 {
503 int l, m;
504 m = 0;
505 for (l=0; l<this_proj -> nspec; l++)
506 {
507 m += this_proj -> coord -> partial_geo[i][j][l];
508 }
509 if (m > 2)
510 {
511 return TRUE;
512 }
513 else
514 {
515 return FALSE;
516 }
517 }
518 }
519}
520
530GtkWidget * coord_tab (glwin * view, int geo, int poly)
531{
532 int i, j, k, l, m, n;
533 int p = view -> proj;
534 gchar * str, * env;
535 GtkWidget * wb;
536 GtkWidget * but;
537 gchar * coln[15] = {" ", i18n("Color"), i18n("Show"), i18n("Label"), i18n("Pick"), i18n("Alpha"),
538 i18n("Color <sup>*</sup>"), i18n("Show <sup>**</sup>"), i18n("Label <sup>**</sup>"), i18n("Pick <sup>**</sup>"),
539 i18n("Ring(s) size"),
540 i18n("Chain(s) size"), i18n("Show <sup>*</sup>"), i18n("Label <sup>*</sup>"), i18n("Pick <sup>*</sup>")};
541 int scol[15] = {100, 70, 65, 40, 40, 150, 70, 75, 55, 55, 100, 100, 60, 50, 55};
542 GtkWidget * box = create_vbox (BSEP);
543 GtkWidget * coord = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
544 gtk_widget_set_hexpand (coord, TRUE);
545 gtk_widget_set_vexpand (coord, TRUE);
546 n = 0;
547 if (geo > 3 && ! poly)
548 {
549 n = (geo == 9) ? 11 : 10;
550 gtk_widget_set_size_request (coord, -1, 475);
551 if (geo < 9)
552 {
553 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label(_(" * for the polyhedra only"), -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
554 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);
555 }
556 else
557 {
558 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);
559 }
560 }
561 GtkWidget * vbox = create_vbox (BSEP);
563 l = 0;
564 if (poly)
565 {
566 l = 1;
567 }
568 wb = create_hbox (0);
569 gtk_widget_set_size_request (wb, 350, -1);
570 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
571 for (i=0; i<5-2*l-geo/9; i++)
572 {
573 if (geo == 9)
574 {
575 j = 11 + i;
576 }
577 else if (i == 0 && geo > 3)
578 {
579 j = 10;
580 }
581 else if (i > 0 && geo > 3 && ! poly)
582 {
583 j = i+5;
584 }
585 else if (i == 1 && poly)
586 {
587 j = 5;
588 }
589 else
590 {
591 j = i;
592 }
593 str = g_strdup_printf ("<b>%s</b>", _(coln[j]));
594 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
595 g_free (str);
596 }
597 k = 0;
598 project * this_proj = get_project_by_id(p);
599 m = (geo < 2) ? this_proj -> nspec : 1;
600 if ((geo < 2 || (geo == 9 && view -> chain_max) || (geo > 3 && geo < 9 && view -> ring_max[geo-4])) && this_proj -> coord -> totcoord[geo] > 0)
601 {
602 for (i=0; i < m; i++)
603 {
604 if (geo == 0)
605 {
606 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++)
607 {
608 if (add_geo(poly, this_proj, geo, i, j))
609 {
610 str = g_strdup_printf (" <b>%s</b>", this_proj -> chemistry -> label[i]);
611 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
612 g_free (str);
613 break;
614 }
615 }
616 }
617 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++, k++)
618 {
619 if (add_geo(poly, this_proj, geo, i, j))
620 {
621 wb = create_hbox (0);
622 gtk_widget_set_size_request (wb, 350, -1);
623 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
624 if (geo == 0)
625 {
626 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[geo][i][j]);
627 }
628 else if (geo == 1)
629 {
630 env = env_name (this_proj, j, i, 1, NULL);
631 str = exact_name(env);
632 g_free (env);
633 }
634 else
635 {
636 str = g_strdup_printf (_("%d atoms"), this_proj -> coord -> geolist[geo][i][j]);
637 }
638 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.5, 0.5), FALSE, FALSE, 5);
639 g_free (str);
640 if (poly)
641 {
642 but = create_hscale (0.0, 1.0, 0.01, view -> anim -> last -> img -> spcolor[geo][i][j].alpha, GTK_POS_LEFT, 3, 160,
643 G_CALLBACK(set_poly_alpha), G_CALLBACK(scroll_set_poly_alpha), & view -> gcid[geo][k][geo]);
644 }
645 else if (geo != 9)
646 {
647 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][i][j];
648 col.alpha = 1.0;
649 but = color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_coord), & view -> gcid[geo][k][geo]);
650 }
651 if (poly || geo != 9) add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 5);
652
653 if (poly)
654 {
655 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]);
656 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
657 }
658 else
659 {
660 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]);
661 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
662 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][k][geo]);
663 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n);
664 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][k][geo]);
665 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n/2);
666 }
667 }
668 }
669 }
670 }
671 return box;
672}
673
683G_MODULE_EXPORT void on_select_frag_mol (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
684{
685 int i, g, v, act;
686 tint * dat = (tint * )data;
687 GtkTreeIter iter;
688 opengl_project_changed(dat -> a);
689 coord_edition * coord = opengl_project -> modelgl -> coord_win;
690 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
691 g = (dat -> b < 30) ? 2 : 3;
692 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
693 {
694 v = 0;
695 }
696 else
697 {
698 v = 1;
699 }
700 gtk_tree_model_get_iter (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, path);
701 act = dat -> b - 10*g;
702 gtk_list_store_set (coord -> frag_mol_model[g-2], & iter, act, v, -1);
703 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
704 frag_mol_status = v;
705 switch (act)
706 {
707 case 1:
708 // Viz
709 toggled_show_hide_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
710 break;
711 case 3:
712 // Label
713 toggled_label_unlabel_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
714 break;
715 case 4:
716 // Pick
717 toggled_select_unselect_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
718 break;
719 }
720}
721
731void set_frag_mol_cell_background (GtkListStore * store, GtkTreeIter iter, ColRGBA col)
732{
733 cairo_surface_t * surface;
734 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 70, 50);
735 cairo_t * cr = cairo_create (surface);
736 cairo_set_source_rgba (cr, col.red, col.green, col.blue, 1.0);
737 cairo_paint (cr);
738 GdkPixbuf * pix = convert_to_pixbuf (surface);
739 cairo_surface_destroy (surface);
740 cairo_destroy(cr);
741 gtk_list_store_set (store, & iter, 2, pix, -1);
742}
743
753void add_this_frag_mol_to_search_tree (project * this_proj, int geo, int gid)
754{
755 GtkTreeIter id_level;
756 GtkTreeIter new_level;
757 gboolean valid;
758 int i;
759 int prepend = 0;
760 coord_edition * coord = this_proj -> modelgl -> coord_win;
761 GtkListStore * store = (GtkListStore *) coord -> frag_mol_model[geo-2];
762 GtkTreeModel * mod = GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]);
763 valid = gtk_tree_model_get_iter_first(mod, & id_level);
764 while (valid)
765 {
766 gtk_tree_model_get (mod, & id_level, 0, & i, -1);
767 if (i > gid)
768 {
769 prepend = 1;
770 valid = FALSE;
771 }
772 else if (i == gid)
773 {
774 prepend = 2;
775 valid = FALSE;
776 }
777 else
778 {
779 valid = gtk_tree_model_iter_next(mod, & id_level);
780 }
781 }
782 if (prepend < 2)
783 {
784 switch (prepend)
785 {
786 case 0:
787 gtk_list_store_append (store, & id_level);
788 gtk_list_store_set (store, & id_level, 0, gid,
789 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
790 3, FALSE,
791 4, FALSE, -1);
792 set_frag_mol_cell_background (store, id_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
793 break;
794 case 1:
795 gtk_list_store_insert_before (store, & new_level, & id_level);
796 gtk_list_store_set (store, & new_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, new_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
801 break;
802 }
803 }
804}
805
815G_MODULE_EXPORT void run_set_this_frag_mol_color (GtkDialog * win, gint response_id, gpointer data)
816{
817 tint * dat = (tint * )data;
818 int i, g;
819 if (response_id == GTK_RESPONSE_OK)
820 {
821 g = (dat -> b < 30) ? 2 : 3;
822 GtkTreeIter fm_iter;
823 gtk_tree_model_get (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & fm_iter, 0, & i, -1);
824 opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1] = get_window_color (GTK_WIDGET(win));
825 int shaders[3] = {ATOMS, BONDS, LABEL};
827 update (opengl_project -> modelgl);
828 }
830}
831
840void set_this_frag_mol_color (gpointer data, GtkTreePath * path)
841{
842 int i, g;
843 tint * dat = (tint * )data;
844 opengl_project_changed(dat -> a);
845 g = (dat -> b < 30) ? 2 : 3;
846 GtkTreeIter iter;
847 gtk_tree_model_get_iter (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & iter, path);
848 coord_edition * coord = opengl_project -> modelgl -> coord_win;
849 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
850 gchar * ctitle[2] = {i18n("Fragment"), i18n("Molecule")};
851 gchar * str = g_strdup_printf (_("%s N°%d color"), _(ctitle[g-2]), i);
852 GtkWidget * widg = gtk_color_chooser_dialog_new (str, GTK_WINDOW(coord -> win));
853 g_free (str);
854 set_color_chooser_color (widg, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
855 run_this_gtk_dialog (widg, G_CALLBACK(run_set_this_frag_mol_color), data);
856 set_frag_mol_cell_background ((GtkListStore *) coord -> frag_mol_model[g-2], iter, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
857}
858
869G_MODULE_EXPORT void to_set_this_frag_mol_color (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
870{
871 gchar * title;
872 g_object_get (column, "title", & title, NULL, NULL);
873 if (g_strcmp0(title, _("Color")) == 0)
874 {
876 }
877}
878
887GtkWidget * create_frag_mol_tree (project * this_proj, int geo)
888{
889 int i;
890 GtkTreeViewColumn * frag_mol_col[7];
891 GtkCellRenderer * frag_mol_cell[7];
892 gchar * ctitle[5]={i18n("Id."), i18n("Show"), i18n("Color"), i18n("Label"), i18n("Pick")};
893 gchar * ctype[5]={"text", "active", "pixbuf", "active", "active"};
894 GType col_type[5]={G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN};
895 coord_edition * coord = this_proj -> modelgl -> coord_win;
896 coord -> frag_mol_model[geo-2] = gtk_list_store_newv (5, col_type);
897 GtkWidget * frag_mol_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]));
898 for (i=0; i<5; i++)
899 {
900 if (! i)
901 {
902 frag_mol_cell[i] = gtk_cell_renderer_text_new ();
903 }
904 else if (i == 2)
905 {
906 frag_mol_cell[i] = gtk_cell_renderer_pixbuf_new ();
907 }
908 else
909 {
910 frag_mol_cell[i] = gtk_cell_renderer_toggle_new ();
911 g_signal_connect (G_OBJECT(frag_mol_cell[i]), "toggled", G_CALLBACK(on_select_frag_mol), & this_proj -> modelgl -> colorp[geo*10+i][0]);
912 }
913 gtk_cell_renderer_set_fixed_size (frag_mol_cell[i], 70, 25);
914 frag_mol_col[i] = gtk_tree_view_column_new_with_attributes (_(ctitle[i]), frag_mol_cell[i], ctype[i], i, NULL);
915 gtk_tree_view_append_column(GTK_TREE_VIEW(frag_mol_tree), frag_mol_col[i]);
916 gtk_tree_view_column_set_alignment (frag_mol_col[i], 0.5);
917 }
918 g_object_set (frag_mol_tree, "activate-on-single-click", TRUE, NULL, NULL);
919 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]);
920 return frag_mol_tree;
921}
922
931G_MODULE_EXPORT void update_frag_mol_search (GtkEntry * res, gpointer data)
932{
933 tint * dat = (tint * )data;
934 const gchar * m = entry_get_text (res);
935 int v = (int)string_to_double ((gpointer)m);
936 project * this_proj = get_project_by_id(dat -> a);
937 int g = dat -> b;
938 if (v > 0 && v <= this_proj -> coord -> totcoord[g])
939 {
940 add_this_frag_mol_to_search_tree (this_proj, g, v);
941 }
942 else
943 {
945 }
946}
947
956GtkWidget * create_frag_mol_search (project * this_proj, int geo)
957{
958 GtkWidget * frag_mol_search = create_vbox (BSEP);
959 gchar * obj[2] = {i18n("fragment"), i18n("molecule")};
960 gchar * str = g_strdup_printf (_("Too many <b>%ss</b> in your model !\n"
961 " It is impossible to display the entire list ...\n"
962 "... instead you can look for %s(s) individually:\n"), _(obj[geo-2]), _(obj[geo-2]));
963 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
964 g_free (str);
965 gchar * search_item[2]={i18n("Fragment Id.:"), i18n("Molecule Id.:")};
966 GtkWidget * hbox;
967 GtkWidget * entry;
968 GtkWidget * label;
969 hbox = create_hbox (0);
970 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, hbox, FALSE, FALSE, 0);
971 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_(search_item[geo-2]), 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
972 entry = create_entry (G_CALLBACK(update_frag_mol_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[geo][0]);
973 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
974 str = g_strdup_printf ("&#x2208; [%d - %d]", 1, this_proj -> coord -> totcoord[geo]);
975 label = markup_label (str, 50, -1, 0.0, 0.5);
976 g_free (str);
977 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, label, FALSE, FALSE, 5);
978 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);
979 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, create_frag_mol_tree (this_proj, geo), FALSE, FALSE, 0);
980 return frag_mol_search;
981}
982
991GtkWidget * fragmol_tab (glwin * view, int geo)
992{
993 int i, j;
994 GtkWidget * wb;
995 gchar * str;
996 int scol[5] = {70, 70, 65, 40, 40};
997 gchar * coln[5] = {i18n("Id."), i18n("Color"), i18n("Show"), i18n("Label"), i18n("Pick")};
998
999 GtkWidget * box = create_vbox (BSEP);
1000 GtkWidget * fragmol = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
1001 gtk_widget_set_hexpand (fragmol, TRUE);
1002 gtk_widget_set_vexpand (fragmol, TRUE);
1003 project * this_proj = get_project_by_id(view -> proj);
1004 i = this_proj -> coord -> totcoord[geo];
1005 if (i >= GTK_LIMIT)
1006 {
1007 add_container_child (CONTAINER_SCR, fragmol, create_frag_mol_search(this_proj, geo));
1008 }
1009 else
1010 {
1011 GtkWidget * vbox = create_vbox (BSEP);
1013 wb = create_hbox (0);
1014 gtk_widget_set_size_request (wb, 350, -1);
1015 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1016 for (j=0; j<5; j++)
1017 {
1018 str = g_strdup_printf ("<b>%s</b>", _(coln[j]));
1019 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
1020 g_free (str);
1021 }
1022 for (j=0; j<i; j++)
1023 {
1024 wb = create_hbox (0);
1025 gtk_widget_set_size_request (wb, 300, -1);
1026 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1027
1028 str = g_strdup_printf ("N°%d", j+1);
1029 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.25, 0.5), FALSE, FALSE, 5);
1030 g_free (str);
1031 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][0][j];
1032 col.alpha = 1.0;
1033 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1034 color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_frag_mol), & view -> gcid[geo][j][geo]),
1035 FALSE, FALSE, 5);
1036
1037 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1038 check_button(NULL, -1, -1, view -> anim -> last -> img -> show_coord[geo][j], G_CALLBACK(toggled_show_hide_coord), & view -> gcid[geo][j][geo]),
1039 FALSE, FALSE, 20);
1040
1041 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1042 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][j][geo]),
1043 FALSE, FALSE, 15);
1044
1045 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1046 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][j][geo]),
1047 FALSE, FALSE, 15);
1048 }
1049 }
1050 return box;
1051}
1052
1061G_MODULE_EXPORT void set_atom_color_map_box (GtkComboBox * box, gpointer data)
1062{
1063 glwin * view = (glwin *)data;
1064 int i = combo_get_active ((GtkWidget *)box);
1065 int j = view -> cmap[i];
1066#ifdef GTK4
1067 gchar * variant = g_strdup_printf ("set-amap.%d.0", j);
1068 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-amap", g_variant_new_string((const gchar *)variant));
1069 g_free (variant);
1070#else
1071 // GTK3 Menu Action To Check
1072 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1073#endif
1074}
1075
1084G_MODULE_EXPORT void set_poly_color_map_box (GtkComboBox * box, gpointer data)
1085{
1086 glwin * view = (glwin *)data;
1087 int i = combo_get_active ((GtkWidget *)box);
1088 int j = view -> cmap[i] + ATOM_MAPS;
1089#ifdef GTK4
1090 gchar * variant = g_strdup_printf ("set-pmap.%d.0", j);
1091 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-pmap", g_variant_new_string((const gchar *)variant));
1092 g_free (variant);
1093#else
1094 // GTK3 Menu Action To Check
1095 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1096#endif
1097}
1098
1099#ifdef GTK4
1108G_MODULE_EXPORT void on_cloned_poly_toggled (GtkCheckButton * Button, gpointer data)
1109#else
1118G_MODULE_EXPORT void on_cloned_poly_toggled (GtkToggleButton * Button, gpointer data)
1119#endif
1120{
1121 glwin * view = (glwin *)data;
1122#ifdef GTK4
1123 view -> anim -> last -> img -> cloned_poly = button_get_status ((GtkWidget *)Button);
1124 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-cloned-poly.0.0", NULL);
1125 /* int shaders[2] = {POLYS, RINGS};
1126 re_create_md_shaders (2, shaders, get_project_by_id(view -> proj));
1127 update (view); */
1128#else
1129 // GTK3 Menu Action To Check
1130 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[5], gtk_toggle_button_get_active (Button));
1131#endif
1132}
1133
1141GtkWidget * param_tab (glwin * view)
1142{
1143 int i, j, k, l;
1144 GtkWidget * vbox = create_vbox (BSEP);
1145 /*gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(fragmol), vbox); */
1146 GtkWidget * hbox = create_hbox (0);
1147 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1148 GtkWidget * lab = markup_label (_("<b>Atom(s) and bond(s) color map:</b>"), -1, -1, 0.0, 0.5);
1149 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1150 hbox = create_hbox (0);
1151 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1152 GtkWidget * color_box = create_combo ();
1153 j = 0;
1154 for (i=0; i<ATOM_MAPS; i++)
1155 {
1156 if (i == 1 || i == 2)
1157 {
1158 view -> cmap[j] = i;
1159 combo_text_append (color_box, g_strdup_printf (_("%s coordination(s)"), _(text_maps[i])));
1160 j ++;
1161 }
1162 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1163 {
1164 view -> cmap[j] = i;
1165 combo_text_append (color_box, _("Force field (DL_POLY)"));
1166 j ++;
1167 }
1168 else if (i == 6 && view -> custom_map != NULL)
1169 {
1170 view -> cmap[j] = i;
1171 combo_text_append (color_box, _("Custom"));
1172 j ++;
1173 }
1174 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1175 {
1176 view -> cmap[j] = i;
1178 j ++;
1179 }
1180 }
1181 l = 0;
1182 for (k=0; k<j; k++)
1183 {
1184 if (view -> anim -> last -> img -> color_map[0] == view -> cmap[k])
1185 {
1186 l = k;
1187 break;
1188 }
1189 }
1191 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_atom_color_map_box), view);
1192 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1193
1194 hbox = create_hbox (0);
1195 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1196 lab = markup_label (_("<b>Polyhedra color map:</b>"), -1, -1, 0.0, 0.5);
1197 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1198 hbox = create_hbox (0);
1199 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1201 for (i=0; i<POLY_MAPS; i++)
1202 {
1203 if (i == 1 || i == 2)
1204 {
1205 combo_text_append (color_box, g_strdup_printf (_("%s coordination(s)"), _(text_maps[i])));
1206 }
1207 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1208 {
1210 }
1211 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1212 {
1213 combo_text_append (color_box, _("Force field (DL_POLY)"));
1214 }
1215 else if (i == 6 && view -> custom_map != NULL)
1216 {
1217 combo_text_append (color_box, _("Use atom(s) custom map"));
1218 }
1219 }
1220 l = 0;
1221 for (k=0; k<j; k++)
1222 {
1223 if (view -> anim -> last -> img -> color_map[1] == view -> cmap[k])
1224 {
1225 l = k; // + ATOM_MAPS;
1226 break;
1227 }
1228 }
1230 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_poly_color_map_box), view);
1231 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1233
1234 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_("\n<b>Display polyhedra at the edges of the model box\n"
1235 "using the PBC even if the clones are not shown:</b>"), -1, -1, 0.5, 0.5), FALSE, FALSE, 15);
1236 GtkWidget * cloned_p = check_button (_("Cloned polyhedra"), -1, 40, view -> anim -> last -> img -> cloned_poly,
1237 G_CALLBACK(on_cloned_poly_toggled), view);
1238 widget_set_sensitive ((cloned_p), get_project_by_id(view -> proj) -> cell.pbc);
1239 hbox = create_hbox (0);
1240 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 0);
1241 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cloned_p, FALSE, FALSE, 50);
1242 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_("This is automatic if the clones are shown.\n"
1243 "The clones are the replica of the atoms linked by PBC."), -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
1244 return vbox;
1245}
1246
1255G_MODULE_EXPORT void close_coord (GtkButton * but, gpointer data)
1256{
1257 glwin * view = (glwin *)data;
1258 view -> coord_win -> win = destroy_this_widget (view -> coord_win -> win);
1259 g_free (view -> coord_win);
1260 view -> coord_win = NULL;
1261}
1262
1263#ifdef GTK4
1272G_MODULE_EXPORT gboolean close_event_coord (GtkWindow * widg, gpointer data)
1273#else
1283G_MODULE_EXPORT gboolean close_event_coord (GtkWidget * widg, GdkEvent * event, gpointer data)
1284#endif
1285{
1286 close_coord (NULL, data);
1287 return FALSE;
1288}
1289
1298GtkWidget * advanced_coord_properties (glwin * view, int page)
1299{
1300 gchar * str = g_strdup_printf (_("Environments configuration - %s"), get_project_by_id(view -> proj)->name);
1301 GtkWidget * win = create_win (str, view -> win, FALSE, FALSE);
1302 g_free (str);
1303 char * rings_short[5] = {"AR", "KR", "GR", "PR", "SR"};
1304 GtkWidget * vbox = create_vbox (5);
1306 gtk_widget_set_size_request (win, 625, 600);
1307 view -> coord_win -> notebook = gtk_notebook_new ();
1308 gtk_notebook_set_scrollable (GTK_NOTEBOOK(view -> coord_win -> notebook), TRUE);
1309 gtk_notebook_set_tab_pos (GTK_NOTEBOOK(view -> coord_win -> notebook), GTK_POS_LEFT);
1310 show_the_widgets (view -> coord_win -> notebook);
1311 gtk_widget_set_size_request (view -> coord_win -> notebook, 600, 550);
1312 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> coord_win -> notebook, FALSE, FALSE, 0);
1313 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), param_tab (view), gtk_label_new (_("Parameters")));
1314 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));
1315 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));
1316
1317 int i;
1318 if (view -> rings)
1319 {
1320 for (i=1; i<5; i++)
1321 {
1322 if (view -> ring_max[i])
1323 {
1324 str = (i) ? g_strdup_printf (_("%s ring(s) <b>[%s]</b>"), _(rings_type[i]), rings_short[i]) : g_strdup_printf (_("All ring(s) (no rule) <b>[%s]</b>"), rings_short[i]);
1325 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));
1326 g_free (str);
1327 }
1328 }
1329 }
1330 if (view -> chains && view -> chain_max)
1331 {
1332 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));
1333 }
1334 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));
1335 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));
1336 if (view -> rings)
1337 {
1338 for (i=0; i<5; i++)
1339 {
1340 if (view -> ring_max[i])
1341 {
1342 str = g_strdup_printf (_("Polyhedra from <b>%s</b>"), rings_short[i]);
1343 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));
1344 g_free (str);
1345 }
1346 }
1347 }
1348
1349 if (view -> adv_bonding[0])
1350 {
1351 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 2), markup_label (_("Fragment(s)"), -1, -1, 0.0, 0.5));
1352 }
1353 if (view -> adv_bonding[1])
1354 {
1355 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 3), markup_label (_("Molecule(s)"), -1, -1, 0.0, 0.5));
1356 }
1357
1358 if (view -> rings)
1359 {
1360 for (i=0; i<5; i++)
1361 {
1362 if (view -> ring_max[i])
1363 {
1364 str = g_strdup_printf (_("Isolated ring(s) from <b>%s</b>"), rings_short[i]);
1365 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), rings_tab (view, i), markup_label(str, -1, -1, 0.0, 0.5));
1366 g_free (str);
1367 }
1368 }
1369 }
1370
1371 if (view -> chains && view -> chain_max)
1372 {
1373 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), chains_tab (view), markup_label(_("Isolated chain(s)"), -1, -1, 0.0, 0.5));
1374 }
1375
1376 GtkWidget * hbox = create_hbox (5);
1377 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, TRUE, FALSE, 0);
1378 GtkWidget * but = create_button (_("Close"), IMG_STOCK, FCLOSE, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(close_coord), view);
1379 add_box_child_end (hbox, but, FALSE, FALSE, 0);
1380 add_gtk_close_event (win, G_CALLBACK(close_event_coord), view);
1381 show_the_widgets (win);
1382 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1383 return win;
1384}
1385
1395int get_page_from_geo_coord (glwin * view, int geo, int coord)
1396{
1397 int i, j;
1398 if (geo == 30) return 0;
1399 if (! coord)
1400 {
1401 i = (geo < 2) ? 3 : 0;
1402 if (view -> rings)
1403 {
1404 for (j=0; j<5; j++)
1405 {
1406 if (view -> ring_max[j]) i ++;
1407 }
1408 }
1409 i = (geo < 2) ? i + geo : 4 + 2*i;
1410 }
1411 else
1412 {
1413 if (geo > 1)
1414 {
1415 i = 0;
1416 if (view -> rings)
1417 {
1418 for (j=0; j<5; j++)
1419 {
1420 if (view -> ring_max[j]) i ++;
1421 }
1422 }
1423 if (geo < 4)
1424 {
1425 i = 2*(i+2) + geo - 1;
1426 }
1427 else
1428 {
1429 i = 0;
1430 for (j=0; j<5; j++)
1431 {
1432 if (view -> ring_max[j])
1433 {
1434 if (geo == 4 + j) break;
1435 i ++;
1436 }
1437 }
1438 i = 3 + i;
1439 }
1440 }
1441 else
1442 {
1443 i = geo + 1;
1444 }
1445 }
1446 return i;
1447}
1448
1457G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data)
1458{
1459 tint * id = (tint *) data;
1460 glwin * view = get_project_by_id(id -> a) -> modelgl;
1461 int page = get_page_from_geo_coord(view, id -> b, id -> c);
1462 if (view -> coord_win == NULL)
1463 {
1464 view -> coord_win = g_malloc0(sizeof*view -> coord_win);
1465 view -> coord_win -> win = advanced_coord_properties (view, page);
1466 }
1467 else if (GTK_IS_WIDGET(view -> coord_win -> win))
1468 {
1469 show_the_widgets (view -> coord_win -> win);
1470 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1471 }
1472 else
1473 {
1474 show_warning (_("Error impossible to display the environments window !"), view -> win);
1475 }
1476}
Binding to the Fortran90 subroutines.
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
int selected_aspec
Definition popup.c:179
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:259
color colorp[64]
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:924
GType col_type[MAXDATA][12]
Definition dlp_field.c:946
char * rings_type[5]
Definition global.c:147
#define i18n(String)
Definition global.c:80
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
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:1351
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
@ IMG_STOCK
Definition global.h:280
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
#define GTK_LIMIT
maximum number of elements in GTK widgets like GtkTreeView, GtkTreeStore or similar rendering widgets...
Definition global.h:77
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2139
void set_color_chooser_color(GtkWidget *color_win, ColRGBA col)
set the color of a color selection window
Definition gtk-misc.c:2435
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:486
ColRGBA get_window_color(GtkWidget *color_win)
get the ColRGBA color from a color selection window
Definition gtk-misc.c:2420
project * proj
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:958
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
#define BSEP
Definition global.h:261
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
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:2557
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
@ CONTAINER_WIN
Definition global.h:266
@ CONTAINER_SCR
Definition global.h:267
G_MODULE_EXPORT void label_unlabel_coord(GtkWidget *widg, gpointer data)
label / unlabel a type of coordination callback GTK3
Definition popup.c:1858
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:1999
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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:340
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2406
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2235
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2213
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1833
G_MODULE_EXPORT void select_unselect_coord(GtkWidget *widg, gpointer data)
select / unselect a type of coordination callback GTK3
Definition popup.c:1934
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:780
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:318
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:726
G_MODULE_EXPORT void show_hide_the_coord(GtkWidget *widg, gpointer data)
show / hide a type of coordination callback GTK3
Definition popup.c:1807
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:267
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
#define FCLOSE
Definition global.h:227
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:202
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:461
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:266
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
output the name of a coordination sphere
Definition interface.c:1022
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:434
Messaging function declarations.
G_MODULE_EXPORT void cloned_poly(GtkWidget *widg, gpointer data)
cloned polyehdra callback - GTK3
Definition m_poly.c:181
double y
Definition ogl_draw.c:63
double x
Definition ogl_draw.c:63
Definition glwin.h:350
Definition glwin.h:967
Definition global.h:126
Definition global.h:118
int b
Definition global.h:120
int c
Definition global.h:121
int a
Definition global.h:119
GtkWidget * chains_tab(glwin *view)
create the chain(s) tab for the advanced environments window
Definition w_chains.c:983
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:753
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:1283
G_MODULE_EXPORT void toggled_select_unselect_coord(GtkToggleButton *widg, gpointer data)
toggle select / unselect coordination callback GTK3
Definition w_coord.c:252
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
Definition w_coord.c:1457
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:991
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:869
G_MODULE_EXPORT void set_poly_color_map_box(GtkComboBox *box, gpointer data)
change polyhedra color map
Definition w_coord.c:1084
G_MODULE_EXPORT void set_color_frag_mol(GtkColorChooser *colob, gpointer data)
set fragment or molecule color
Definition w_coord.c:358
GtkWidget * create_frag_mol_tree(project *this_proj, int geo)
create the fragment(s) / molecule(s) search tree store
Definition w_coord.c:887
GtkWidget * coord_tab(glwin *view, int geo, int poly)
create coordination(s) and polyhedra tab
Definition w_coord.c:530
GtkWidget * param_tab(glwin *view)
environments configuration window parameters tab
Definition w_coord.c:1141
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:815
G_MODULE_EXPORT void toggled_label_unlabel_coord(GtkToggleButton *widg, gpointer data)
toggle label / unlabel coordination callback GTK3
Definition w_coord.c:213
G_MODULE_EXPORT void set_color_coord(GtkColorChooser *colob, gpointer data)
set coordination color
Definition w_coord.c:379
void set_frag_mol_cell_background(GtkListStore *store, GtkTreeIter iter, ColRGBA col)
set tree store cell background color
Definition w_coord.c:731
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:89
G_MODULE_EXPORT void update_frag_mol_search(GtkEntry *res, gpointer data)
update the fragment(s) / molecule(s) search widget
Definition w_coord.c:931
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:683
GtkWidget * create_frag_mol_search(project *this_proj, int geo)
create the frgament(s)/molecule(s) search widget
Definition w_coord.c:956
void poly_alpha_has_changed(gpointer data, GLfloat v)
change polyhedra opacity
Definition w_coord.c:402
GtkWidget * chains_tab(glwin *view)
create the chain(s) tab for the advanced environments window
Definition w_chains.c:983
GtkWidget * advanced_coord_properties(glwin *view, int page)
create the environments configuration window
Definition w_coord.c:1298
G_MODULE_EXPORT void close_coord(GtkButton *but, gpointer data)
environments configuration window close button
Definition w_coord.c:1255
void set_this_frag_mol_color(gpointer data, GtkTreePath *path)
set fragment / molecule color - creating the dialog
Definition w_coord.c:840
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:427
G_MODULE_EXPORT void toggled_show_hide_poly(GtkToggleButton *widg, gpointer data)
toggle show / hide polyhedra callback GTK3
Definition w_coord.c:291
GtkWidget * rings_tab(glwin *view, int g)
create the ring(s) tab for the advanced environments window
Definition w_rings.c:1124
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:1395
G_MODULE_EXPORT void set_poly_alpha(GtkRange *range, gpointer data)
set polyhedra opacity - range callback
Definition w_coord.c:441
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:457
G_MODULE_EXPORT void on_cloned_poly_toggled(GtkToggleButton *Button, gpointer data)
toggle show / hide cloned polyhedra callback GTK3
Definition w_coord.c:1118
G_MODULE_EXPORT void set_atom_color_map_box(GtkComboBox *box, gpointer data)
change atom color map
Definition w_coord.c:1061
GtkWidget * res[2]
Definition w_encode.c:342
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