atomes 1.2.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-2025 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 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;
148 if (g < 2)
149 {
150 if (g)
151 {
152 str = exact_name (env_name (this_proj, c, s, 1, NULL));
153 }
154 else
155 {
156 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
157 }
158 name = g_strdup_printf ("set-%s-s.%d.0", str, j);
159 g_free (str);
160 }
161 else if (g > 1 && g < 4)
162 {
163 name = g_strdup_printf ("set-%s-%d.%d.0", (g == 2) ? "frag" : "mol", c+1, c);
164 }
165 else if (g > 3 && g < 9)
166 {
167 name = g_strdup_printf ("set-%d-%d-coord.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
168 }
169 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
170 g_free (name);
171#else
172 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[0][g][j], k);
173#endif
174 }
175 else
176 {
177 tint pointer;
178 pointer.a = g;
179 pointer.b = c;
180 pointer.c = k;
181 opengl_project_changed (the_data -> a);
182#ifdef GTK4
183 show_hide_the_coord (NULL, NULL, & pointer);
184#else
185 show_hide_the_coord (NULL, & pointer);
186#endif // GTK4
187 }
188 }
189 init_default_shaders (this_proj -> modelgl);
190}
191
192#ifdef GTK4
201G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkCheckButton * widg, gpointer data)
202#else
211G_MODULE_EXPORT void toggled_label_unlabel_coord (GtkToggleButton * widg, gpointer data)
212#endif
213{
214 qint * the_data = (qint *)data;
215 tint pointer;
216 pointer.a = the_data -> d;
217 pointer.b = the_data -> c;
218 pointer.c = (widg) ? button_get_status ((GtkWidget *)widg) : frag_mol_status;
219 selected_aspec = the_data -> b;
220#ifdef DEBUG
221 g_debug ("Toggle label/unlabel coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
222#endif
223 opengl_project_changed (the_data -> a);
224#ifdef GTK4
225 label_unlabel_coord (NULL, NULL, & pointer);
226#else
227 label_unlabel_coord (NULL, & pointer);
228#endif // GTK4
229}
230
231#ifdef GTK4
240G_MODULE_EXPORT void toggled_select_unselect_coord (GtkCheckButton * widg, gpointer data)
241#else
250G_MODULE_EXPORT void toggled_select_unselect_coord (GtkToggleButton * widg, gpointer data)
251#endif
252{
253 qint * the_data = (qint *)data;
254 tint pointer;
255 pointer.a = the_data -> d;
256 pointer.b = the_data -> c;
257 pointer.c = (widg) ? button_get_status ((GtkWidget *)widg) : frag_mol_status;
258 selected_aspec = the_data -> b;
259#ifdef DEBUG
260 g_debug ("Toggle select/unselect coord:: s= %d, g= %d, c= %d, selec_sp= %d", pointer.a, pointer.b, pointer.c, selected_aspec);
261#endif
262 opengl_project_changed (the_data -> a);
263#ifdef GTK4
264 select_unselect_coord (NULL, NULL, & pointer);
265#else
266 select_unselect_coord (NULL, & pointer);
267#endif
268}
269
270#ifdef GTK4
279G_MODULE_EXPORT void toggled_show_hide_poly (GtkCheckButton * widg, gpointer data)
280#else
289G_MODULE_EXPORT void toggled_show_hide_poly (GtkToggleButton * widg, gpointer data)
290#endif
291{
292 qint * the_data = (qint *)data;
293 int i, j, k;
294 int s, g, c;
295 project * this_proj = get_project_by_id(the_data -> a);
296 s = the_data -> b;
297 g = the_data -> d;
298 c = the_data -> c;
299 j = c;
300 if (g < 2)
301 {
302 for (i=0; i<s; i++)
303 {
304 j += this_proj -> coord -> ntg[g][i];
305 }
306 }
307 k = button_get_status ((GtkWidget *)widg);
308#ifdef GTK4
309 if (k != this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j])
310 {
311 gchar * str;
312 gchar * name;
313 if (g < 2)
314 {
315 if (g)
316 {
317 str = exact_name (env_name (this_proj, c, s, 1, NULL));
318 }
319 else
320 {
321 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[g][s][c]);
322 }
323 name = g_strdup_printf ("set-%s-%d-p.%d.0", str, g, j);
324 g_free (str);
325 }
326 else if (g > 3 && g < 9)
327 {
328 name = g_strdup_printf ("set-%d-%d-p.%d.0", g, this_proj -> coord -> geolist[g][0][j], j);
329 }
330 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
331 g_free (name);
332 }
333#else
334 // GTK3 Menu Action To Check
335 if (is_coord_in_menu(g, this_proj))
336 {
337 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_poly[0][g][j], k);
338 }
339 this_proj -> modelgl -> anim -> last -> img -> show_poly[g][j] = k;
340 int shaders[2] = {POLYS, RINGS};
341 re_create_md_shaders (2, shaders, this_proj);
342 update (this_proj -> modelgl);
343#endif
344}
345
354G_MODULE_EXPORT void set_color_frag_mol (GtkColorChooser * colob, gpointer data)
355{
356 qint * cid = (qint *)data;
357 int c, g;
358 project * this_proj = get_project_by_id(cid -> a);
359 g = cid -> b;
360 c = cid -> c;
361 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][0][c] = get_button_color (colob);
362 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
363 re_create_md_shaders (4, shaders, this_proj);
364 update (this_proj -> modelgl);
365}
366
375G_MODULE_EXPORT void set_color_coord (GtkColorChooser * colob, gpointer data)
376{
377 qint * cid = (qint *)data;
378 int c, g, s;
379 project * this_proj = get_project_by_id(cid -> a);
380 s = cid -> b;
381 c = cid -> c;
382 g = cid -> d;
383 if (g > 3) s = 0;
384 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c] = get_button_color (colob);
385 int shaders[4] = {ATOMS, BONDS, POLYS, RINGS};
386 re_create_md_shaders (4, shaders, this_proj);
387 update (this_proj -> modelgl);
388}
389
398void poly_alpha_has_changed (gpointer data, GLfloat v)
399{
400 qint * cid = (qint *)data;
401 int c, g, s;
402 project * this_proj = get_project_by_id(cid -> a);
403 s = cid -> b;
404 c = cid -> c;
405 g = cid -> d;
406 if (g > 1) s = 0;
407 this_proj -> modelgl -> anim -> last -> img -> spcolor[g][s][c].alpha = v;
408 int shaders[2] = {POLYS, RINGS};
409 re_create_md_shaders (2, shaders, this_proj);
410 update (this_proj -> modelgl);
411}
412
423G_MODULE_EXPORT gboolean scroll_set_poly_alpha (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
424{
425 poly_alpha_has_changed (data, (GLfloat) value);
426 return FALSE;
427}
428
437G_MODULE_EXPORT void set_poly_alpha (GtkRange * range, gpointer data)
438{
439 poly_alpha_has_changed (data, (GLfloat) gtk_range_get_value (range));
440}
441
453gboolean add_geo (int poly, project * this_proj, int g, int i, int j)
454{
455 if (! poly)
456 {
457 if (g == 0)
458 {
459 if (this_proj -> coord -> geolist[g][i][j] != -1)
460 {
461 return TRUE;
462 }
463 else
464 {
465 return FALSE;
466 }
467 }
468 else if (g == 1)
469 {
470 return TRUE;
471 }
472 else
473 {
474 if (this_proj -> coord -> geolist[g][i][j])
475 {
476 return TRUE;
477 }
478 else
479 {
480 return FALSE;
481 }
482 }
483 }
484 else
485 {
486 if (g == 0 || g > 3)
487 {
488 if (this_proj -> coord -> geolist[g][i][j] > 2)
489 {
490 return TRUE;
491 }
492 else
493 {
494 return FALSE;
495 }
496 }
497 else
498 {
499 int l, m;
500 m = 0;
501 for (l=0; l<this_proj -> nspec; l++)
502 {
503 m += this_proj -> coord -> partial_geo[i][j][l];
504 }
505 if (m > 2)
506 {
507 return TRUE;
508 }
509 else
510 {
511 return FALSE;
512 }
513 }
514 }
515}
516
526GtkWidget * coord_tab (glwin * view, int geo, int poly)
527{
528 int i, j, k, l, m, n;
529 int p = view -> proj;
530 gchar * str;
531 GtkWidget * wb;
532 GtkWidget * but;
533 gchar * col[15] = {" ", "<b>Color</b>", "<b>Show</b>", "<b>Label</b>", "<b>Pick</b>", "<b>Alpha</b>",
534 "<b>Color <sup>*</sup></b>", "<b>Show <sup>**</sup></b>", "<b>Label <sup>**</sup></b>", "<b>Pick <sup>**</sup></b>",
535 "<b>Ring(s) size</b>",
536 "<b>Chain(s) size</b>", "<b>Show <sup>*</sup></b>", "<b>Label <sup>*</sup></b>", "<b>Pick <sup>*</sup></b>"};
537 int scol[15] = {100, 70, 65, 40, 40, 150, 70, 75, 55, 55, 100, 100, 60, 50, 55};
538 GtkWidget * box = create_vbox (BSEP);
539 GtkWidget * coord = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
540 gtk_widget_set_hexpand (coord, TRUE);
541 gtk_widget_set_vexpand (coord, TRUE);
542 n = 0;
543 if (geo > 3 && ! poly)
544 {
545 n = (geo == 9) ? 11 : 10;
546 gtk_widget_set_size_request (coord, -1, 475);
547 if (geo < 9)
548 {
549 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label(" * for the polyhedra only", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
550 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);
551 }
552 else
553 {
554 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);
555 }
556 }
557 GtkWidget * vbox = create_vbox (BSEP);
559 l = 0;
560 if (poly)
561 {
562 l = 1;
563 }
564 wb = create_hbox (0);
565 gtk_widget_set_size_request (wb, 350, -1);
566 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
567 for (i=0; i<5-2*l-geo/9; i++)
568 {
569 if (geo == 9)
570 {
571 j = 11 + i;
572 }
573 else if (i == 0 && geo > 3)
574 {
575 j = 10;
576 }
577 else if (i > 0 && geo > 3 && ! poly)
578 {
579 j = i+5;
580 }
581 else if (i == 1 && poly)
582 {
583 j = 5;
584 }
585 else
586 {
587 j = i;
588 }
589 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
590 }
591 k = 0;
592 project * this_proj = get_project_by_id(p);
593 m = (geo < 2) ? this_proj -> nspec : 1;
594 if ((geo < 2 || (geo == 9 && view -> chain_max) || (geo > 3 && geo < 9 && view -> ring_max[geo-4])) && this_proj -> coord -> totcoord[geo] > 0)
595 {
596 for (i=0; i < m; i++)
597 {
598 if (geo == 0)
599 {
600 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++)
601 {
602 if (add_geo(poly, this_proj, geo, i, j))
603 {
604 str = g_strdup_printf (" <b>%s</b>", this_proj -> chemistry -> label[i]);
605 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
606 g_free (str);
607 break;
608 }
609 }
610 }
611 for (j=0 ; j < this_proj -> coord -> ntg[geo][i]; j++, k++)
612 {
613 if (add_geo(poly, this_proj, geo, i, j))
614 {
615 wb = create_hbox (0);
616 gtk_widget_set_size_request (wb, 350, -1);
617 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, FALSE, 0);
618 if (geo == 0)
619 {
620 str = g_strdup_printf ("%d", this_proj -> coord -> geolist[geo][i][j]);
621 }
622 else if (geo == 1)
623 {
624 str = exact_name(env_name (this_proj, j, i, 1, NULL));
625 }
626 else
627 {
628 str = g_strdup_printf ("%d atoms", this_proj -> coord -> geolist[geo][i][j]);
629 }
630 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.5, 0.5), FALSE, FALSE, 5);
631 g_free (str);
632 if (poly)
633 {
634 but = create_hscale (0.0, 1.0, 0.01, view -> anim -> last -> img -> spcolor[geo][i][j].alpha, GTK_POS_LEFT, 3, 160,
635 G_CALLBACK(set_poly_alpha), G_CALLBACK(scroll_set_poly_alpha), & view -> gcid[geo][k][geo]);
636 }
637 else if (geo != 9)
638 {
639 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][i][j];
640 col.alpha = 1.0;
641 but = color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_coord), & view -> gcid[geo][k][geo]);
642 }
643 if (poly || geo != 9) add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 5);
644
645 if (poly)
646 {
647 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]);
648 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
649 }
650 else
651 {
652 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]);
653 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 20);
654 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][k][geo]);
655 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n);
656 but = check_button (NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][k][geo]);
657 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, but, FALSE, FALSE, 15+n/2);
658 }
659 }
660 }
661 }
662 }
663 return box;
664}
665
675G_MODULE_EXPORT void on_select_frag_mol (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
676{
677 int i, g, v, act;
678 tint * dat = (tint * )data;
679 GtkTreeIter iter;
681 coord_edition * coord = opengl_project -> modelgl -> coord_win;
682 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
683 g = (dat -> b < 30) ? 2 : 3;
684 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
685 {
686 v = 0;
687 }
688 else
689 {
690 v = 1;
691 }
692 gtk_tree_model_get_iter (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, path);
693 act = dat -> b - 10*g;
694 gtk_list_store_set (coord -> frag_mol_model[g-2], & iter, act, v, -1);
695 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
696 frag_mol_status = v;
697 switch (act)
698 {
699 case 1:
700 // Viz
701 toggled_show_hide_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
702 break;
703 case 3:
704 // Label
705 toggled_label_unlabel_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
706 break;
707 case 4:
708 // Pick
709 toggled_select_unselect_coord (NULL, & opengl_project -> modelgl -> gcid[g][i-1][g]);
710 break;
711 }
712}
713
723void set_frag_mol_cell_background (GtkListStore * store, GtkTreeIter iter, ColRGBA col)
724{
725 cairo_surface_t * surface;
726 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 70, 50);
727 cairo_t * cr = cairo_create (surface);
728 cairo_set_source_rgba (cr, col.red, col.green, col.blue, 1.0);
729 cairo_paint (cr);
730 GdkPixbuf * pix = convert_to_pixbuf (surface);
731 cairo_surface_destroy (surface);
732 cairo_destroy(cr);
733 gtk_list_store_set (store, & iter, 2, pix, -1);
734}
735
745void add_this_frag_mol_to_search_tree (project * this_proj, int geo, int gid)
746{
747 GtkTreeIter id_level;
748 GtkTreeIter new_level;
749 gboolean valid;
750 int i;
751 int prepend = 0;
752 coord_edition * coord = this_proj -> modelgl -> coord_win;
753 GtkListStore * store = (GtkListStore *) coord -> frag_mol_model[geo-2];
754 GtkTreeModel * mod = GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]);
755 valid = gtk_tree_model_get_iter_first(mod, & id_level);
756 while (valid)
757 {
758 gtk_tree_model_get (mod, & id_level, 0, & i, -1);
759 if (i > gid)
760 {
761 prepend = 1;
762 valid = FALSE;
763 }
764 else if (i == gid)
765 {
766 prepend = 2;
767 valid = FALSE;
768 }
769 else
770 {
771 valid = gtk_tree_model_iter_next(mod, & id_level);
772 }
773 }
774 if (prepend < 2)
775 {
776 switch (prepend)
777 {
778 case 0:
779 gtk_list_store_append (store, & id_level);
780 gtk_list_store_set (store, & id_level, 0, gid,
781 1, this_proj -> modelgl -> anim -> last -> img -> show_coord[geo][gid-1],
782 3, FALSE,
783 4, FALSE, -1);
784 set_frag_mol_cell_background (store, id_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
785 break;
786 case 1:
787 gtk_list_store_insert_before (store, & new_level, & id_level);
788 gtk_list_store_set (store, & new_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, new_level, this_proj -> modelgl -> anim -> last -> img -> spcolor[geo][0][gid-1]);
793 break;
794 }
795 }
796}
797
807G_MODULE_EXPORT void run_set_this_frag_mol_color (GtkDialog * win, gint response_id, gpointer data)
808{
809 tint * dat = (tint * )data;
810 int i, g;
811 if (response_id == GTK_RESPONSE_OK)
812 {
813 g = (dat -> b < 30) ? 2 : 3;
814 GtkTreeIter fm_iter;
815 gtk_tree_model_get (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & fm_iter, 0, & i, -1);
816 opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1] = get_window_color (GTK_WIDGET(win));
817 int shaders[3] = {ATOMS, BONDS, LABEL};
819 update (opengl_project -> modelgl);
820 }
822}
823
832void set_this_frag_mol_color (gpointer data, GtkTreePath * path)
833{
834 int i, g;
835 tint * dat = (tint * )data;
837 g = (dat -> b < 30) ? 2 : 3;
838 GtkTreeIter iter;
839 gtk_tree_model_get_iter (GTK_TREE_MODEL(opengl_project -> modelgl -> coord_win -> frag_mol_model[g-2]), & iter, path);
840 coord_edition * coord = opengl_project -> modelgl -> coord_win;
841 gtk_tree_model_get (GTK_TREE_MODEL(coord -> frag_mol_model[g-2]), & iter, 0, & i, -1);
842 gchar * ctitle[2] = {"Fragment", "Molecule"};
843 gchar * str = g_strdup_printf ("%s N°%d color", ctitle[g-2], i);
844 GtkWidget * widg = gtk_color_chooser_dialog_new (str, GTK_WINDOW(coord -> win));
845 g_free (str);
846 set_color_chooser_color (widg, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
847 run_this_gtk_dialog (widg, G_CALLBACK(run_set_this_frag_mol_color), data);
848 set_frag_mol_cell_background ((GtkListStore *) coord -> frag_mol_model[g-2], iter, opengl_project -> modelgl -> anim -> last -> img -> spcolor[g][0][i-1]);
849}
850
861G_MODULE_EXPORT void to_set_this_frag_mol_color (GtkTreeView * tree_view, GtkTreePath * path, GtkTreeViewColumn * column, gpointer data)
862{
863 gchar * title;
864 g_object_get (column, "title", & title, NULL, NULL);
865 if (g_strcmp0(title, "Color") == 0)
866 {
868 }
869}
870
879GtkWidget * create_frag_mol_tree (project * this_proj, int geo)
880{
881 int i;
882 GtkTreeViewColumn * frag_mol_col[7];
883 GtkCellRenderer * frag_mol_cell[7];
884 gchar * ctitle[5]={"Id.", "Show", "Color", "Label", "Pick"};
885 gchar * ctype[5]={"text", "active", "pixbuf", "active", "active"};
886 GType col_type[5]={G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_OBJECT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN};
887 coord_edition * coord = this_proj -> modelgl -> coord_win;
888 coord -> frag_mol_model[geo-2] = gtk_list_store_newv (5, col_type);
889 GtkWidget * frag_mol_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(coord -> frag_mol_model[geo-2]));
890 for (i=0; i<5; i++)
891 {
892 if (! i)
893 {
894 frag_mol_cell[i] = gtk_cell_renderer_text_new ();
895 }
896 else if (i == 2)
897 {
898 frag_mol_cell[i] = gtk_cell_renderer_pixbuf_new ();
899 }
900 else
901 {
902 frag_mol_cell[i] = gtk_cell_renderer_toggle_new ();
903 g_signal_connect (G_OBJECT(frag_mol_cell[i]), "toggled", G_CALLBACK(on_select_frag_mol), & this_proj -> modelgl -> colorp[geo*10+i][0]);
904 }
905 gtk_cell_renderer_set_fixed_size (frag_mol_cell[i], 70, 25);
906 frag_mol_col[i] = gtk_tree_view_column_new_with_attributes (ctitle[i], frag_mol_cell[i], ctype[i], i, NULL);
907 gtk_tree_view_append_column(GTK_TREE_VIEW(frag_mol_tree), frag_mol_col[i]);
908 gtk_tree_view_column_set_alignment (frag_mol_col[i], 0.5);
909 }
910 g_object_set (frag_mol_tree, "activate-on-single-click", TRUE, NULL, NULL);
911 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]);
912 return frag_mol_tree;
913}
914
923G_MODULE_EXPORT void update_frag_mol_search (GtkEntry * res, gpointer data)
924{
925 tint * dat = (tint * )data;
926 const gchar * m = entry_get_text (res);
927 int v = (int)string_to_double ((gpointer)m);
928 project * this_proj = get_project_by_id(dat -> a);
929 int g = dat -> b;
930 if (v > 0 && v <= this_proj -> coord -> totcoord[g])
931 {
932 add_this_frag_mol_to_search_tree (this_proj, g, v);
933 }
934 else
935 {
937 }
938}
939
948GtkWidget * create_frag_mol_search (project * this_proj, int geo)
949{
950 GtkWidget * frag_mol_search = create_vbox (BSEP);
951 gchar * obj[2] = {"fragment", "molecule"};
952 gchar * str = g_strdup_printf ("Too many <b>%ss</b> in your model !\n"
953 " It is impossible to display the entire list ...\n"
954 "... instead you can look for %s(s) 'manually':\n", obj[geo-2], obj[geo-2]);
955 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, markup_label(str, 200, -1, 0.5, 0.5), FALSE, FALSE, 10);
956 g_free (str);
957 gchar * search_item[2]={"Fragment ID:", "Molecule ID:"};
958 GtkWidget * hbox;
959 GtkWidget * entry;
960 GtkWidget * label;
961 hbox = create_hbox (0);
962 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, hbox, FALSE, FALSE, 0);
963 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(search_item[geo-2], 100, -1, 0.0, 0.5), FALSE, FALSE, 20);
964 entry = create_entry (G_CALLBACK(update_frag_mol_search), 100, 15, FALSE, & this_proj -> modelgl -> colorp[geo][0]);
965 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox,entry, FALSE, FALSE, 0);
966 str = g_strdup_printf ("in [%d - %d]", 1, this_proj -> coord -> totcoord[geo]);
967 label = markup_label (str, 50, -1, 0.0, 0.5);
968 g_free (str);
969 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, label, FALSE, FALSE, 5);
970 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);
971 add_box_child_start (GTK_ORIENTATION_VERTICAL, frag_mol_search, create_frag_mol_tree (this_proj, geo), FALSE, FALSE, 0);
972 return frag_mol_search;
973}
974
983GtkWidget * fragmol_tab (glwin * view, int geo)
984{
985 int i, j;
986 GtkWidget * wb;
987 gchar * str;
988 int scol[5] = {70, 70, 65, 40, 40};
989 gchar * col[5] = {"<b>Id</b>", "<b>Color</b>", "<b>Show</b>", "<b>Label</b>", "<b>Pick</b>"};
990
991 GtkWidget * box = create_vbox (BSEP);
992 GtkWidget * fragmol = create_scroll (box, -1, -1, GTK_SHADOW_NONE);
993 gtk_widget_set_hexpand (fragmol, TRUE);
994 gtk_widget_set_vexpand (fragmol, TRUE);
995 project * this_proj = get_project_by_id(view -> proj);
996 i = this_proj -> coord -> totcoord[geo];
997 if (i > 10000)
998 {
999 add_container_child (CONTAINER_SCR, fragmol, create_frag_mol_search(this_proj, geo));
1000 }
1001 else
1002 {
1003 GtkWidget * vbox = create_vbox (BSEP);
1005 wb = create_hbox (0);
1006 gtk_widget_set_size_request (wb, 350, -1);
1007 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1008 for (j=0; j<5; j++)
1009 {
1010 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(col[j], scol[j], -1, 0.5, 0.5), FALSE, FALSE, 5);
1011 }
1012 for (j=0; j<i; j++)
1013 {
1014 wb = create_hbox (0);
1015 gtk_widget_set_size_request (wb, 300, -1);
1016 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, wb, FALSE, TRUE, 0);
1017
1018 str = g_strdup_printf ("N°%d", j+1);
1019 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb, markup_label(str, scol[0], -1, 0.25, 0.5), FALSE, FALSE, 5);
1020 g_free (str);
1021 ColRGBA col = view -> anim -> last -> img -> spcolor[geo][0][j];
1022 col.alpha = 1.0;
1023 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1024 color_button (col, TRUE, 80, -1, G_CALLBACK(set_color_frag_mol), & view -> gcid[geo][j][0]),
1025 FALSE, FALSE, 5);
1026
1027 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1028 check_button(NULL, -1, -1, view -> anim -> last -> img -> show_coord[geo][j], G_CALLBACK(toggled_show_hide_coord), & view -> gcid[geo][j][geo]),
1029 FALSE, FALSE, 20);
1030
1031 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1032 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_label_unlabel_coord), & view -> gcid[geo][j][geo]),
1033 FALSE, FALSE, 15);
1034
1035 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, wb,
1036 check_button(NULL, -1, -1, FALSE, G_CALLBACK(toggled_select_unselect_coord), & view -> gcid[geo][j][geo]),
1037 FALSE, FALSE, 15);
1038 }
1039 }
1040 return box;
1041}
1042
1051G_MODULE_EXPORT void set_atom_color_map_box (GtkComboBox * box, gpointer data)
1052{
1053 glwin * view = (glwin *)data;
1054 int i = combo_get_active ((GtkWidget *)box);
1055 int j = view -> cmap[i];
1056#ifdef GTK4
1057 gchar * variant = g_strdup_printf ("set-amap.%d.0", j);
1058 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-amap", g_variant_new_string((const gchar *)variant));
1059 g_free (variant);
1060#else
1061 // GTK3 Menu Action To Check
1062 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1063#endif
1064}
1065
1074G_MODULE_EXPORT void set_poly_color_map_box (GtkComboBox * box, gpointer data)
1075{
1076 glwin * view = (glwin *)data;
1077 int i = combo_get_active ((GtkWidget *)box);
1078 int j = view -> cmap[i] + ATOM_MAPS;
1079#ifdef GTK4
1080 gchar * variant = g_strdup_printf ("set-pmap.%d.0", j);
1081 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-pmap", g_variant_new_string((const gchar *)variant));
1082 g_free (variant);
1083#else
1084 // GTK3 Menu Action To Check
1085 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
1086#endif
1087}
1088
1089#ifdef GTK4
1098G_MODULE_EXPORT void on_cloned_poly_toggled (GtkCheckButton * Button, gpointer data)
1099#else
1108G_MODULE_EXPORT void on_cloned_poly_toggled (GtkToggleButton * Button, gpointer data)
1109#endif
1110{
1111 glwin * view = (glwin *)data;
1112#ifdef GTK4
1113 view -> anim -> last -> img -> cloned_poly = button_get_status ((GtkWidget *)Button);
1114 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-cloned-poly.0.0", NULL);
1115 /* int shaders[2] = {POLYS, RINGS};
1116 re_create_md_shaders (2, shaders, get_project_by_id(view -> proj));
1117 update (view); */
1118#else
1119 // GTK3 Menu Action To Check
1120 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[5], gtk_toggle_button_get_active (Button));
1121#endif
1122}
1123
1131GtkWidget * param_tab (glwin * view)
1132{
1133 int i, j, k, l;
1134 GtkWidget * vbox = create_vbox (BSEP);
1135 /*gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(fragmol), vbox); */
1136 GtkWidget * hbox = create_hbox (0);
1137 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1138 GtkWidget * lab = markup_label ("<b>Atom(s) and bond(s) color map:</b>", -1, -1, 0.0, 0.5);
1139 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1140 hbox = create_hbox (0);
1141 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1142 GtkWidget * color_box = create_combo ();
1143 j = 0;
1144 for (i=0; i<ATOM_MAPS; i++)
1145 {
1146 if (i == 1 || i == 2)
1147 {
1148 view -> cmap[j] = i;
1149 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1150 j ++;
1151 }
1152 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1153 {
1154 view -> cmap[j] = i;
1155 combo_text_append (color_box, "Force field (DL_POLY)");
1156 j ++;
1157 }
1158 else if (i == 6 && view -> custom_map != NULL)
1159 {
1160 view -> cmap[j] = i;
1161 combo_text_append (color_box, "Custom");
1162 j ++;
1163 }
1164 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1165 {
1166 view -> cmap[j] = i;
1168 j ++;
1169 }
1170 }
1171 l = 0;
1172 for (k=0; k<j; k++)
1173 {
1174 if (view -> anim -> last -> img -> color_map[0] == view -> cmap[k])
1175 {
1176 l = k;
1177 break;
1178 }
1179 }
1181 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_atom_color_map_box), view);
1182 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1183
1184 hbox = create_hbox (0);
1185 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 25);
1186 lab = markup_label ("<b>Polyhedra color map:</b>", -1, -1, 0.0, 0.5);
1187 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 20);
1188 hbox = create_hbox (0);
1189 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1191 for (i=0; i<POLY_MAPS; i++)
1192 {
1193 if (i == 1 || i == 2)
1194 {
1195 combo_text_append (color_box, g_strdup_printf ("%s coordination(s)", text_maps[i]));
1196 }
1197 else if (i == 0 || (i == 3 && view -> adv_bonding[0]) || (i == 4 && view -> adv_bonding[1]))
1198 {
1200 }
1201 else if (i == 5 && get_project_by_id(view -> proj) -> force_field[0])
1202 {
1203 combo_text_append (color_box, "Force field (DL_POLY)");
1204 }
1205 else if (i == 6 && view -> custom_map != NULL)
1206 {
1207 combo_text_append (color_box, "Use atom(s) custom map");
1208 }
1209 }
1210 l = 0;
1211 for (k=0; k<j; k++)
1212 {
1213 if (view -> anim -> last -> img -> color_map[1] == view -> cmap[k])
1214 {
1215 l = k; // + ATOM_MAPS;
1216 break;
1217 }
1218 }
1220 g_signal_connect (G_OBJECT (color_box), "changed", G_CALLBACK(set_poly_color_map_box), view);
1221 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, color_box, FALSE, FALSE, 100);
1223
1224 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("\n<b>Display polyhedra at the edges of the model box\n"
1225 "using the PBC even if the clones are not shown:</b>", -1, -1, 0.5, 0.5),
1226 FALSE, FALSE, 15);
1227 GtkWidget * cloned_p = check_button ("Cloned polyhedra", -1, 40, view -> anim -> last -> img -> cloned_poly,
1228 G_CALLBACK(on_cloned_poly_toggled), view);
1229 widget_set_sensitive ((cloned_p), get_project_by_id(view -> proj) -> cell.pbc);
1230 hbox = create_hbox (0);
1231 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, TRUE, 0);
1232 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, cloned_p, FALSE, FALSE, 50);
1233 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("This is automatic if the clones are shown.\n"
1234 "The clones are the replica of the atoms linked by PBC.", -1, -1, 0.5, 0.5),
1235 FALSE, FALSE, 5);
1236 return vbox;
1237}
1238
1247G_MODULE_EXPORT void close_coord (GtkButton * but, gpointer data)
1248{
1249 glwin * view = (glwin *)data;
1250 view -> coord_win -> win = destroy_this_widget (view -> coord_win -> win);
1251 g_free (view -> coord_win);
1252 view -> coord_win = NULL;
1253}
1254
1255#ifdef GTK4
1264G_MODULE_EXPORT gboolean close_event_coord (GtkWindow * widg, gpointer data)
1265#else
1275G_MODULE_EXPORT gboolean close_event_coord (GtkWidget * widg, GdkEvent * event, gpointer data)
1276#endif
1277{
1278 close_coord (NULL, data);
1279 return FALSE;
1280}
1281
1290GtkWidget * advanced_coord_properties (glwin * view, int page)
1291{
1292 gchar * str = g_strdup_printf ("Environments configuration - %s", get_project_by_id(view -> proj)->name);
1293 GtkWidget * win = create_win (str, view -> win, FALSE, FALSE);
1294 g_free (str);
1295 char * rings_short[5] = {"AR", "KR", "GR", "PR", "SR"};
1296 GtkWidget * vbox = create_vbox (5);
1298 gtk_widget_set_size_request (win, 625, 600);
1299 view -> coord_win -> notebook = gtk_notebook_new ();
1300 gtk_notebook_set_scrollable (GTK_NOTEBOOK(view -> coord_win -> notebook), TRUE);
1301 gtk_notebook_set_tab_pos (GTK_NOTEBOOK(view -> coord_win -> notebook), GTK_POS_LEFT);
1302 show_the_widgets (view -> coord_win -> notebook);
1303 gtk_widget_set_size_request (view -> coord_win -> notebook, 600, 550);
1304 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> coord_win -> notebook, FALSE, FALSE, 0);
1305 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), param_tab (view), gtk_label_new ("Parameters"));
1306 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));
1307 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));
1308
1309 int i;
1310 if (view -> rings)
1311 {
1312 for (i=0; i<5; i++)
1313 {
1314 if (view -> ring_max[i])
1315 {
1316 str = g_strdup_printf ("%s ring(s) <b>[%s]</b>", rings_type[i], rings_short[i]);
1317 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));
1318 g_free (str);
1319 }
1320 }
1321 }
1322 if (view -> chains && view -> chain_max)
1323 {
1324 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));
1325 }
1326 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));
1327 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));
1328 if (view -> rings)
1329 {
1330 for (i=0; i<5; i++)
1331 {
1332 if (view -> ring_max[i])
1333 {
1334 str = g_strdup_printf ("Polyhedra from <b>%s</b>", rings_short[i]);
1335 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));
1336 g_free (str);
1337 }
1338 }
1339 }
1340
1341 if (view -> adv_bonding[0])
1342 {
1343 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 2), markup_label ("Fragment(s)", -1, -1, 0.0, 0.5));
1344 }
1345 if (view -> adv_bonding[1])
1346 {
1347 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), fragmol_tab (view, 3), markup_label ("Molecule(s)", -1, -1, 0.0, 0.5));
1348 }
1349
1350 if (view -> rings)
1351 {
1352 for (i=0; i<5; i++)
1353 {
1354 if (view -> ring_max[i])
1355 {
1356 str = g_strdup_printf ("Isolated ring(s) from <b>%s</b>", rings_short[i]);
1357 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), rings_tab (view, i), markup_label(str, -1, -1, 0.0, 0.5));
1358 g_free (str);
1359 }
1360 }
1361 }
1362
1363 if (view -> chains && view -> chain_max)
1364 {
1365 gtk_notebook_append_page (GTK_NOTEBOOK(view -> coord_win -> notebook), chains_tab (view), markup_label("Isolated chain(s)", -1, -1, 0.0, 0.5));
1366 }
1367
1368 GtkWidget * hbox = create_hbox (5);
1369 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, TRUE, FALSE, 0);
1370 GtkWidget * but = create_button ("Close", IMG_STOCK, FCLOSE, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(close_coord), view);
1371 add_box_child_end (hbox, but, FALSE, FALSE, 0);
1372 add_gtk_close_event (win, G_CALLBACK(close_event_coord), view);
1373 show_the_widgets (win);
1374 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1375 return win;
1376}
1377
1387int get_page_from_geo_coord (glwin * view, int geo, int coord)
1388{
1389 int i, j;
1390 if (geo == 30) return 0;
1391 if (! coord)
1392 {
1393 i = (geo < 2) ? 3 : 0;
1394 if (view -> rings)
1395 {
1396 for (j=0; j<5; j++)
1397 {
1398 if (view -> ring_max[j]) i ++;
1399 }
1400 }
1401 i = (geo < 2) ? i + geo : 4 + 2*i;
1402 }
1403 else
1404 {
1405 if (geo > 1)
1406 {
1407 i = 0;
1408 if (view -> rings)
1409 {
1410 for (j=0; j<5; j++)
1411 {
1412 if (view -> ring_max[j]) i ++;
1413 }
1414 }
1415 if (geo < 4)
1416 {
1417 i = 2*(i+2) + geo - 1;
1418 }
1419 else
1420 {
1421 i = 0;
1422 for (j=0; j<5; j++)
1423 {
1424 if (view -> ring_max[j])
1425 {
1426 if (geo == 4 + j) break;
1427 i ++;
1428 }
1429 }
1430 i = 3 + i;
1431 }
1432 }
1433 else
1434 {
1435 i = geo + 1;
1436 }
1437 }
1438 return i;
1439}
1440
1449G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data)
1450{
1451 tint * id = (tint *) data;
1452 glwin * view = get_project_by_id(id -> a) -> modelgl;
1453 int page = get_page_from_geo_coord(view, id -> b, id -> c);
1454 if (view -> coord_win == NULL)
1455 {
1456 view -> coord_win = g_malloc0 (sizeof*view -> coord_win);
1457 view -> coord_win -> win = advanced_coord_properties (view, page);
1458 }
1459 else if (GTK_IS_WIDGET(view -> coord_win -> win))
1460 {
1461 show_the_widgets (view -> coord_win -> win);
1462 gtk_notebook_set_current_page (GTK_NOTEBOOK (view -> coord_win -> notebook), page);
1463 }
1464 else
1465 {
1466 show_warning ("Error impossible to display the coordination window !", view -> win);
1467 }
1468}
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:259
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:144
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
GdkPixbuf * convert_to_pixbuf(cairo_surface_t *surf)
convert cairo surface to GdkPixbuf
Definition gtk-misc.c:1325
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:501
@ IMG_STOCK
Definition global.h:266
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1375
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2095
void set_color_chooser_color(GtkWidget *color_win, ColRGBA col)
set the color of a color selection window
Definition gtk-misc.c:2400
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:454
ColRGBA get_window_color(GtkWidget *color_win)
get the ColRGBA color from a color selection window
Definition gtk-misc.c:2385
project * proj
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
#define BSEP
Definition global.h:247
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:2522
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
@ CONTAINER_WIN
Definition global.h:252
@ CONTAINER_SCR
Definition global.h:253
G_MODULE_EXPORT void label_unlabel_coord(GtkWidget *widg, gpointer data)
label / unlabel a type of coordination callback GTK3
Definition popup.c:1838
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:1955
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
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:308
ColRGBA get_button_color(GtkColorChooser *colob)
get the ColRGBA color from a GtkColorChooser button
Definition gtk-misc.c:2371
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2200
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
GtkWidget * color_button(ColRGBA col, gboolean alpha, int dimx, int dimy, GCallback handler, gpointer data)
create a color selection button
Definition gtk-misc.c:1789
G_MODULE_EXPORT void select_unselect_coord(GtkWidget *widg, gpointer data)
select / unselect a type of coordination callback GTK3
Definition popup.c:1914
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:754
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:286
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:681
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:235
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
#define FCLOSE
Definition global.h:213
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
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:450
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
struct box box
box layout data structure
Definition glwin.h:349
#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:950
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:61
double x
Definition ogl_draw.c:61
float blue
Definition global.h:126
float alpha
Definition global.h:127
float red
Definition global.h:124
float green
Definition global.h:125
Definition glwin.h:351
Definition glwin.h:965
Definition global.h:114
Definition global.h:106
int b
Definition global.h:108
int c
Definition global.h:109
int a
Definition global.h:107
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int 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:745
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:1275
G_MODULE_EXPORT void toggled_select_unselect_coord(GtkToggleButton *widg, gpointer data)
toggle select / unselect coordination callback GTK3
Definition w_coord.c:250
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
Definition w_coord.c:1449
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:983
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:861
G_MODULE_EXPORT void set_poly_color_map_box(GtkComboBox *box, gpointer data)
change polyhedra color map
Definition w_coord.c:1074
G_MODULE_EXPORT void set_color_frag_mol(GtkColorChooser *colob, gpointer data)
set fragment or molecule color
Definition w_coord.c:354
GtkWidget * create_frag_mol_tree(project *this_proj, int geo)
create the fragment(s) / molecule(s) search tree store
Definition w_coord.c:879
GtkWidget * coord_tab(glwin *view, int geo, int poly)
create coordination(s) and polyhedra tab
Definition w_coord.c:526
GtkWidget * param_tab(glwin *view)
environments configuration window parameters tab
Definition w_coord.c:1131
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:807
G_MODULE_EXPORT void toggled_label_unlabel_coord(GtkToggleButton *widg, gpointer data)
toggle label / unlabel coordination callback GTK3
Definition w_coord.c:211
G_MODULE_EXPORT void set_color_coord(GtkColorChooser *colob, gpointer data)
set coordination color
Definition w_coord.c:375
void set_frag_mol_cell_background(GtkListStore *store, GtkTreeIter iter, ColRGBA col)
set tree store cell background color
Definition w_coord.c:723
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:923
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:675
GtkWidget * create_frag_mol_search(project *this_proj, int geo)
create the frgament(s)/molecule(s) search widget
Definition w_coord.c:948
void poly_alpha_has_changed(gpointer data, GLfloat v)
change polyhedra opacity
Definition w_coord.c:398
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:1290
G_MODULE_EXPORT void close_coord(GtkButton *but, gpointer data)
environments configuration window close button
Definition w_coord.c:1247
void set_this_frag_mol_color(gpointer data, GtkTreePath *path)
set fragment / molecule color - creating the dialog
Definition w_coord.c:832
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:423
G_MODULE_EXPORT void toggled_show_hide_poly(GtkToggleButton *widg, gpointer data)
toggle show / hide polyhedra callback GTK3
Definition w_coord.c:289
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:1387
G_MODULE_EXPORT void set_poly_alpha(GtkRange *range, gpointer data)
set polyhedra opacity - range callback
Definition w_coord.c:437
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:453
G_MODULE_EXPORT void on_cloned_poly_toggled(GtkToggleButton *Button, gpointer data)
toggle show / hide cloned polyhedra callback GTK3
Definition w_coord.c:1108
G_MODULE_EXPORT void set_atom_color_map_box(GtkComboBox *box, gpointer data)
change atom color map
Definition w_coord.c:1051
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