atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
interface.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: 'interface.c'
24*
25* Contains:
26*
27
28 - General messaging functions
29
30*
31* List of functions:
32
33 int dummy_ask_ (char * question);
34 int iask (char * question, char * lab, int id, GtkWidget * win);
35
36 gboolean ask_yes_no (gchar * title, gchar * text, int type, GtkWidget * widg);
37
38 G_MODULE_EXPORT gboolean leaving_question (GtkWindow * widget, gpointer data);
39 G_MODULE_EXPORT gboolean leaving_question (GtkWidget * widget, GdkEvent * event, gpointer data);
40
41 gchar * exact_name (gchar * name);
42 gchar * cask (char * question, char * lab, int id, char * old, GtkWidget * win);
43 gchar * textcolor (int i);
44 gchar * env_name (project * this_proj, int g, int s, int f, GtkTextBuffer * buffer);
45
46 void show_web (GtkWidget * dialog, int id);
47 void show_info (char * information, int val, GtkWidget * win);
48 void show_warning (char * warning, GtkWidget * win);
49 void show_warning_ (char * warning, char * sub, char * tab);
50 void show_error (char * error, int val, GtkWidget * win);
51 void show_error_ (char * error, char * sub, char * tab);
52 void init_data_ (int * nats, int * nspc, int * stps, int * cid);
53 void print_info (gchar * str, gchar * stag, GtkTextBuffer * buffer);
54 void lattice_info_ (int * bid, double * volume, double * density,
55 double dvects[3][3], double rvects[3][3], double mod[3], double ang[3],
56 double f_to_c[3][3], double c_to_f[3][3]);
57 void send_chem_info_ (int prop[active_project -> nspec]);
58 void update_after_calc (int calc);
59
60 G_MODULE_EXPORT void create_about_dialog (GtkWidget * widg, gpointer data);
61 G_MODULE_EXPORT void run_yes_no (GtkDialog * dial, gint response_id, gpointer data);
62 G_MODULE_EXPORT void on_answer_changed (GtkWidget * widg, gpointer data);
63 G_MODULE_EXPORT void run_iask (GtkDialog * iask, gint response_id, gpointer data);
64 G_MODULE_EXPORT void run_cask (GtkDialog * cask, gint response_id, gpointer data);
65
66 GtkWidget * addweb (int id);
67 GtkWidget * show_pop (char * pop, GtkWidget * pwin);
68
69*/
70
71#include "global.h"
72#include "bind.h"
73#include "callbacks.h"
74#include "project.h"
75#include "curve.h"
76#include "affero.h"
77
78extern gchar * substitute_string (gchar * init, gchar * o_motif, gchar * n_motif);
79
80GtkWidget * answer;
81
82/* Old version to make url/email in about dialog clickable */
83/* void about_dialog_handle_url (GtkAboutDialog * dialog, const gchar * link, gpointer data)
84{
85 GtkWidget * error_dialog;
86 gchar * url, * escaped;
87 g_return_if_fail (GTK_IS_ABOUT_DIALOG (dialog));
88 g_return_if_fail (link != NULL);
89
90/ * simple check if this is an email address * /
91 if (! g_str_has_prefix (link, "mailto:") && strchr (link, '@') != NULL)
92 {
93 escaped = g_uri_escape_string (link, NULL, FALSE);
94 url = g_strdup_printf ("mailto:%s", escaped);
95 g_free (escaped);
96 }
97 else
98 {
99 url = g_strdup_printf ("%s", link);
100 }
101
102#ifdef G_OS_WIN32
103 HINSTANCE h;
104 h = ShellExecute (NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
105 if ((int)h <= 32)
106#else
107#ifdef GTK4
108 // gtk_show_uri (GTK_WINDOW (dialog), url, gtk_event_controller_get_current_event_time ( , ));
109#else
110 GError * error = NULL;
111 gtk_show_uri_on_window (GTK_WINDOW (dialog), url, gtk_get_current_event_time (), & error);
112 if (error != NULL)
113#endif
114#endif
115 {
116 gchar * uri = g_strdup_printf ("Failed to open link:\n%s", url);
117 error_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
118 GTK_DIALOG_DESTROY_WITH_PARENT,
119 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
120 "Impossible to open link: ");
121 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", uri);
122 run_this_gtk_dialog (error_dialog, G_CALLBACK(run_destroy_dialog), NULL);
123 g_free (uri);
124 }
125 g_free (url);
126} */
127
135GtkWidget * addweb (int id)
136{
137 GtkWidget * web;
138 const gchar * contact = " Please contact me at:\n";
139 const gchar * seb = " Dr. Sébastien Le Roux ";
140 GtkWidget * eseb;
141 GtkWidget * vbox;
142 GtkWidget * hbox;
143 const gchar * or = "\n Or check the website for information\n";
144 if (id)
145 {
146 web = gtk_link_button_new_with_label (ATOMES_URL, "Visit the project's website");
147 }
148 gchar * mailto = g_strdup_printf ("mailo:%s", PACKAGE_BUGREPORT);
149 gchar * mailsh = g_strdup_printf ("<%s>",PACKAGE_BUGREPORT);
150 eseb = gtk_link_button_new_with_label (mailto, mailsh);
151 g_free (mailto);
152 g_free (mailsh);
154 if (id) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new (contact), FALSE, FALSE, 0);
155 hbox = create_hbox (0);
156 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
157 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new (seb), FALSE, FALSE, 10);
158 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, eseb, FALSE, FALSE, 0);
159 if (id)
160 {
161 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, gtk_label_new (or), FALSE, FALSE, 0);
162 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, web, FALSE, FALSE, 0);
163 }
164 return (vbox);
165}
166
175G_MODULE_EXPORT void create_about_dialog (GtkWidget * widg, gpointer data)
176{
177 GtkWidget * aboutdialog;
178#ifdef GTK4
179 GdkPaintable * atomes_logo = gtk_image_get_paintable (GTK_IMAGE(gtk_image_new_from_file(PACKAGE_LAGPL)));
180#else
181 GdkPixbuf * atomes_logo = gdk_pixbuf_new_from_file (PACKAGE_LAGPL, NULL);
182#endif
183 const gchar *authors[] = {"Dr. Sébastien Le Roux <sebastien.leroux@ipcms.unistra.fr>", "", NULL};
184 const gchar * weblabel = "https://atomes.ipcms.fr";
185 const gchar * comments = "Visualization, analyzis, creation/edition and post-processing of atomistic models !";
186 const gchar * copyrights = "Copyright © 2025 \nDr. Sébastien Le Roux";
187
188 // gtk_about_dialog_set_url_hook (about_dialog_handle_url, NULL, NULL);
189 // gtk_about_dialog_set_email_hook (about_dialog_handle_url, NULL, NULL);
190
191 aboutdialog = gtk_about_dialog_new ();
192 gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(aboutdialog), atomes_logo);
193 gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(aboutdialog), VERSION);
194 gchar * str = g_strdup_printf ("%s", PACKAGE);
195 gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(aboutdialog), str);
196 g_free (str);
197 gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(aboutdialog), comments);
198 gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(aboutdialog), g_strdup_printf("%s", ATOMES_URL));
199 gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG(aboutdialog), weblabel);
200 gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(aboutdialog), authors);
201 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(aboutdialog), copyrights);
202 gtk_about_dialog_set_license (GTK_ABOUT_DIALOG(aboutdialog), affero_license);
203 gtk_about_dialog_set_license_type (GTK_ABOUT_DIALOG(aboutdialog), GTK_LICENSE_CUSTOM);
204 gtk_about_dialog_set_wrap_license (GTK_ABOUT_DIALOG(aboutdialog), FALSE);
205 run_this_gtk_dialog (aboutdialog, G_CALLBACK(destroy_this_dialog), NULL);
206}
207
216void show_web (GtkWidget * dialog, int id)
217{
218 GtkWidget * box = dialog_get_content_area (dialog);
219 GtkWidget * theweb = addweb (id);
220 show_the_widgets (theweb);
221 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, theweb, FALSE, FALSE, 0);
223}
224
234void show_info (char * information, int val, GtkWidget * win)
235{
236 gchar * info=NULL;
237 if (val < 0)
238 {
239 info = g_strdup_printf ("%s\n%s", information, ifbug);
240 }
241 else
242 {
243 info = g_strdup_printf ("%s", information);
244 }
245
246 GtkWidget * dialog = message_dialogmodal (info, "Information", GTK_MESSAGE_INFO, GTK_BUTTONS_OK, win);
247 if (val != 0) show_web (dialog, (val < 0) ? 0 : val);
248 run_this_gtk_dialog (dialog, G_CALLBACK(run_destroy_dialog), NULL);
249 g_free (info);
250}
251
260void show_warning (char * warning, GtkWidget * win)
261{
262 GtkWidget * dialog = message_dialogmodal (warning, "Warning", GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, win);
263 run_this_gtk_dialog (dialog, G_CALLBACK(run_destroy_dialog), NULL);
264}
265
275void show_warning_ (char * warning, char * sub, char * tab)
276{
277 /* This function is called from fortran 90 */
278 gchar * wtot=NULL;
279 wtot = g_strdup_printf ("%s\n%s\n%s", warning, sub, tab);
280 show_warning (wtot, MainWindow);
281 g_free (wtot);
282}
283
293void show_error (char * error, int val, GtkWidget * win)
294{
295 gchar * etot=NULL;
296 if (val)
297 {
298 etot = g_strdup_printf ("%s", error);
299 }
300 else
301 {
302 etot = g_strdup_printf ("%s\n%s", error, ifbug);
303 }
304 GtkWidget * dialog = message_dialogmodal (etot, "Error", GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, win);
305 show_web (dialog, val);
306 g_warning ("%s", etot);
307 run_this_gtk_dialog (dialog, G_CALLBACK(run_destroy_dialog), NULL);
308 g_free (etot);
309}
310
320void show_error_ (char * error, char * sub, char * tab)
321{
322 /* This function is called from fortran 90 */
323 gchar * etot=NULL;
324 etot = g_strdup_printf ("%s\n\t%s\n\t%s", error, sub, tab);
325 show_error (etot, 0, MainWindow);
326 g_free (etot);
327}
328
329gboolean res_yes_no;
330
340G_MODULE_EXPORT void run_yes_no (GtkDialog * dial, gint response_id, gpointer data)
341{
342 res_yes_no = (response_id == GTK_RESPONSE_YES) ? TRUE : FALSE;
343 destroy_this_dialog (dial);
344}
345
356gboolean ask_yes_no (gchar * title, gchar * text, int type, GtkWidget * widg)
357{
358 GtkWidget * dialog = message_dialogmodal (text, title, type, GTK_BUTTONS_YES_NO, widg);
359 run_this_gtk_dialog (dialog, G_CALLBACK(run_yes_no), NULL);
360 return res_yes_no;
361}
362
370gchar * exact_name (gchar * name)
371{
372 return substitute_string (name, " ", NULL);
373}
374
383GtkWidget * show_pop (char * pop, GtkWidget * pwin)
384{
385 GtkWidget * wpop = create_win ("Information", pwin, TRUE, FALSE);
386 gtk_widget_set_size_request (wpop, 600, 80);
387#ifdef GTK3
388 gtk_window_set_position (GTK_WINDOW (wpop), GTK_WIN_POS_CENTER);
389#endif
390 GtkWidget * hpop = create_hbox (0);
392 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hpop, stock_image(EXECUTE), TRUE, TRUE, 0);
393 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hpop, gtk_label_new (pop), TRUE, TRUE, 0);
394 show_the_widgets (wpop);
395 return (wpop);
396}
397
398#ifdef GTK4
407G_MODULE_EXPORT gboolean leaving_question (GtkWindow * widget, gpointer data)
408#else
418G_MODULE_EXPORT gboolean leaving_question (GtkWidget * widget, GdkEvent * event, gpointer data)
419#endif
420{
421 if (ask_yes_no ("Leaving ?!", "Are you sure you want to quit ?", GTK_MESSAGE_QUESTION, MainWindow))
422 {
423 quit_gtk ();
424 }
425 else
426 {
428 }
429 return TRUE;
430}
431
439int dummy_ask_ (char * question)
440{
441 GtkWidget * dask = message_dialogmodal (question, "Parameter required", GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO, MainWindow);
442 run_this_gtk_dialog (dask, G_CALLBACK(run_yes_no), NULL);
443 return (res_yes_no) ? 0 : -1;
444}
445
446extern gchar * field_init[3];
447gchar * coord_type[3]={"Cartesian",
448 "Atomic units",
449 "Fractional"};
450gchar * npt_type[4]={"A\tB\tC\t&#x3B1;\t&#x3B2;\t&#x263;",
451 "A\tB\tC\n&#x3B1;\t&#x3B2;\t&#x263;",
452 "a<sub>x</sub>\ta<sub>y</sub>\ta<sub>z</sub>\tb<sub>x</sub>\tb<sub>y</sub>\tb<sub>z</sub>\tc<sub>x</sub>\tc<sub>y</sub>\tc<sub>z</sub>",
453 "a<sub>x</sub>\ta<sub>y</sub>\ta<sub>z</sub>\nb<sub>x</sub>\tb<sub>y</sub>\tb<sub>z</sub>\nc<sub>x</sub>\tc<sub>y</sub>\tc<sub>z</sub>"};
454gchar * npt_info[3]={"1 line by step, as many lines as MD steps",
455 "2 lines by step, twice as many lines as MD steps",
456 "3 lines by step, three times as many lines as MD steps"};
457gchar * cif_configurations[3]={"Single step chemical reaction",
458 "MD trajectory",
459 "Single configuration"};
460gchar * cif_occupancies[3]={"Round up to lowest integer",
461 "Round up to highest integer",
462 "Round up to nearest integer"};
463gchar * cif_config_legends={"\t<b>Single step chemical reaction</b>\n"
464 "\t\tConsider each configuration as a step in a chemical reaction:\n"
465 "\t\t\t- Atomic coordinates are sorted based on occupancy or disorder site\n"
466 "\t\t\t- Each describeing the proportion of a reactant\n"
467 "\t\t\t- A super lattice is build to respect these proportions\n\n"
468 "\t<b>MD trajectory</b>\n"
469 "\t\tConsider the CIF file a MD trajectory\n\n"
470 "\t\tNumber of atom(s) must not change between configuration(s)\n\n"
471 "\t<b>Single configuration </b>\n"
472 "\t\tSelect a single configuration in the CIF file"};
473gchar * cif_config_leg={"\t<b>MD trajectory</b>\n"
474 "\t\tConsider the CIF file a MD trajectory\n\n"
475 "\t\tNumber of atom(s) must not change between configuration(s)\n\n"
476 "\t<b>Single configuration </b>\n"
477 "\t\tSelect a single configuration in the CIF file"};
478gchar * cif_occ[3]={"to lowest integer: <b>⌊</b>n<sub>sites</sub> x occupancy<b>⌋</b>",
479 "to highest integer: <b>⌈</b>n<sub>sites</sub> x occupancy<b>⌉</b>",
480 "to nearest integer: <b>⌊</b>n<sub>sites</sub> x occupancy<b>⌉</b>"};
481gchar * cif_sites[2]={"with n<sub>sites</sub> = f(space group, crystalline positions)",
482 "with n<sub>sites</sub> = f(symmetry positions, crystalline positions)"};
483
484GtkWidget * answer_info;
485
494G_MODULE_EXPORT void on_answer_changed (GtkWidget * widg, gpointer data)
495{
496 int i, j;
497 i = combo_get_active (widg);
498 j = (! i || i == 2) ? 0 : (i == 1) ? 1 : 2;
499 gtk_label_set_text (GTK_LABEL(answer_info), npt_info[j]);
500}
501
503
513G_MODULE_EXPORT void run_iask (GtkDialog * iask, gint response_id, gpointer data)
514{
515 int i = GPOINTER_TO_INT(data);
516 gboolean done = FALSE;
517 const gchar * riask;
518 if (response_id == GTK_RESPONSE_OK)
519 {
520 if (i == 0 || i > 5)
521 {
522 riask = entry_get_text (GTK_ENTRY(answer));
523 res_int = string_to_double ((gpointer)riask);
524 if (i > 5)
525 {
526 if (res_int > 0 && res_int < i+1)
527 {
528 done = TRUE;
529 res_int --;
530 }
531 }
532 else if (res_int > 0)
533 {
534 done = TRUE;
535 }
536 }
537 else
538 {
539 done = TRUE;
541 }
542 }
543 if (done) destroy_this_dialog (iask);
544}
545
556int iask (char * question, char * lab, int id, GtkWidget * win)
557{
558 GtkWidget * iask;
559 GtkWidget * vbox;
560 GtkWidget * hboxa;
561 GtkWidget * quest;
562 int i;
563 iask = message_dialogmodal (question, "Parameter Required", GTK_MESSAGE_INFO, GTK_BUTTONS_OK, win);
565 gtk_box_set_spacing (GTK_BOX(vbox), 15);
566 hboxa = create_hbox (0);
567 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hboxa, TRUE, TRUE, 0);
568 quest = gtk_label_new (lab);
569 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, quest, TRUE, TRUE, 0);
570
571 if (id == 0 || id > 6)
572 {
573 answer = gtk_entry_new ();
574 gtk_widget_set_size_request (answer, 100, -1);
575 gtk_entry_set_alignment (GTK_ENTRY(answer), 1.0);
576 }
577 else
578 {
579 if (id < 6)
580 {
581 answer = create_combo ();
582 gtk_widget_set_size_request (answer, -1, 30);
583 switch (id)
584 {
585 case 1:
586 for (i=0; i<3; i++) combo_text_append (answer, coord_type[i]);
587 break;
588 case 2:
589 for (i=0; i<NCFORMATS; i++) combo_text_append (answer, coord_files[i]);
590 break;
591 case 3:
592 for (i=0; i<3; i++) combo_text_append (answer, cif_configurations[i]);
593 break;
594 case 4:
595 for (i=1; i<3; i++) combo_text_append (answer, cif_configurations[i]);
596 break;
597 case 5:
598 for (i=0; i<3; i++) combo_text_append (answer, cif_occupancies[i]);
599 break;
600 default:
601 // id < 0
602 for (i=0; i<3; i++) combo_text_append (answer, field_init[i]);
603 break;
604 }
605 }
606 else
607 {
608 GtkTreeIter iter;
609 GtkTreeStore * store = store = gtk_tree_store_new (1, G_TYPE_STRING);
610 for (i=0; i<4; i++)
611 {
612 gtk_tree_store_append (store, & iter, NULL);
613 gtk_tree_store_set (store, & iter, 0, npt_type[i], -1);
614 }
615 answer = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
616 GtkCellRenderer * renderer = gtk_cell_renderer_combo_new ();
617 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (answer), renderer, TRUE);
618 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (answer), renderer, "text", 0, NULL);
619 }
622 }
623 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, answer, FALSE, FALSE, 10);
624 if (id == 3)
625 {
626 answer_info = markup_label (cif_config_legends, 450, -1, 0.5, 0.5);
627 }
628 if (id == 4)
629 {
630 answer_info = markup_label (cif_config_leg, 450, -1, 0.5, 0.5);
631 }
632 if (id == 5)
633 {
634 gchar * str = g_strdup_printf ("\t<b>Lowest integer: </b>\n"
635 "\t\t Occupancy %s\n\t\t\t ex:\t ⌊8.76⌋ = 8\n\n"
636 "\t<b>Highest integer: </b>\n"
637 "\t\t Occupancy %s\n\t\t\t ex:\t ⌈5.39⌉ = 6\n\n"
638 "\t<b>Nearest integer: </b>\n"
639 "\t\t Occupancy %s\n\t\t\t ex:\t ⌊6.82⌉ = 7\t\t and\t ⌊4.31⌉ = 4\n\n"
641 answer_info = markup_label (str, 450, -1, 0.5, 0.5);
642 g_free (str);
643 }
644 if (id == 6)
645 {
646 answer_info = markup_label (npt_info[0], -1, -1, 0.5, 0.5);
647 g_signal_connect(G_OBJECT(answer), "changed", G_CALLBACK(on_answer_changed), NULL);
648 }
649 if (id > 2 && id < 7) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, answer_info, FALSE, FALSE, 5);
650 run_this_gtk_dialog (iask, G_CALLBACK(run_iask), GINT_TO_POINTER(id));
651 return res_int;
652}
653
654gchar * res_char;
655
665G_MODULE_EXPORT void run_cask (GtkDialog * cask, gint response_id, gpointer data)
666{
667 int i = GPOINTER_TO_INT(data);
668 gboolean done = FALSE;
669 if (i < 0)
670 {
671 while (! done)
672 {
673 if (response_id == GTK_RESPONSE_OK)
674 {
675 res_char = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(answer)));
676 done = TRUE;
677 }
678 }
679 }
680 else
681 {
682 if (response_id == GTK_RESPONSE_OK)
683 {
684 res_char = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(answer)));
685 }
686 else
687 {
688 res_char = NULL;
689 }
690 done = TRUE;
691 }
692 if (done) destroy_this_dialog (cask);
693}
694
706gchar * cask (char * question, char * lab, int id, char * old, GtkWidget * win)
707{
708 GtkWidget * cask;
709 GtkWidget * dialog_ask;
710 GtkWidget * hboxa;
711 GtkWidget * quest;
712 res_char = NULL;
713 cask = message_dialogmodal (question, "Parameter required", GTK_MESSAGE_INFO, GTK_BUTTONS_OK, win);
714 dialog_ask = dialog_get_content_area (cask);
715 gtk_box_set_spacing (GTK_BOX(dialog_ask), 15);
716
717 hboxa = create_hbox (0);
718 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_ask, hboxa, TRUE, TRUE, 0);
719 show_the_widgets (hboxa);
720 quest = gtk_label_new (lab);
721 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, quest, TRUE, TRUE, 0);
722 show_the_widgets (quest);
723 answer = gtk_entry_new ();
724 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, answer, TRUE, TRUE, 0);
725 gtk_widget_set_size_request (answer, 50, -1);
726 gtk_entry_set_alignment (GTK_ENTRY(answer), 1.0);
727 update_entry_text (GTK_ENTRY(answer), old);
728 run_this_gtk_dialog (cask, G_CALLBACK(run_cask), GINT_TO_POINTER(id));
729
730 return (res_char);
731}
732
743void init_data_ (int * nats, int * nspc, int * stps, int * cid)
744{
745 active_project -> natomes = * nats;
746 active_project -> nspec = * nspc;
747 active_project -> steps = * stps;
749 if (* cid) active_chem = active_project -> chemistry;
750}
751
771void spec_data_ (int * status, int * ind, int * atd, int * nsp,
772 char * lbel, char * el_nme,
773 double * amss, double * rdus,
774 double * nscatt, double * xscatt)
775{
776 int id = * ind;
777 active_chem -> label[id]= g_strdup_printf("%s", lbel);
778 active_chem -> element[id]= g_strdup_printf("%s", el_nme);
779 if (* status)
780 {
781 active_chem -> nsps[id] = * nsp;
782 active_chem -> chem_prop[CHEM_Z][id] = (double) * atd;
783 active_chem -> chem_prop[CHEM_M][id] = * amss;
784 active_chem -> chem_prop[CHEM_R][id] = * rdus;
785 active_chem -> chem_prop[CHEM_N][id] = * nscatt;
786 active_chem -> chem_prop[CHEM_X][id] = * xscatt;
787 }
788}
789
799void print_info (gchar * str, gchar * stag, GtkTextBuffer * buffer)
800{
801 GtkTextIter bEnd;
802 GtkTextTag * tag;
803
804 gtk_text_buffer_get_end_iter (buffer, &bEnd);
805 if (stag != NULL)
806 {
807 tag = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table(buffer), stag);
808 gtk_text_buffer_insert_with_tags (buffer, &bEnd, str, -1, tag, NULL);
809 }
810 else
811 {
812 tag = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table(buffer), "default-size");
813 gtk_text_buffer_insert_with_tags (buffer, &bEnd, str, -1, tag, NULL);
814 }
815}
816
824gchar * textcolor (int i)
825{
826 gchar * col = NULL;
827 switch (i - i * (i / 9))
828 {
829 case 0:
830 col = g_strdup_printf ("red");
831 break;
832 case 1:
833 col = g_strdup_printf ("blue");
834 break;
835 case 2:
836 col = g_strdup_printf ("cyan");
837 break;
838 case 3:
839 col = g_strdup_printf ("green");
840 break;
841 case 4:
842 col = g_strdup_printf ("light_green");
843 break;
844 case 5:
845 col = g_strdup_printf ("yellow");
846 break;
847 case 6:
848 col = g_strdup_printf ("orange");
849 break;
850 case 7:
851 col = g_strdup_printf ("violet");
852 break;
853 case 8:
854 col = g_strdup_printf ("pink");
855 break;
856 }
857 return col;
858}
859
877void lattice_info_ (int * bid, double * volume, double * density,
878 double dvects[3][3], double rvects[3][3], double mod[3], double ang[3],
879 double f_to_c[3][3], double c_to_f[3][3])
880{
881 int i, j;
882 for ( i=0; i<3; i++)
883 {
884 for (j=0; j<3; j++)
885 {
886 active_cell -> box[* bid].vect[i][j] = dvects[j][i];
887 active_cell -> box[* bid].rvect[i][j] = rvects[j][i];
888 }
889 active_cell -> box[* bid].param[0][i] = mod[i];
890 active_cell -> box[* bid].param[1][i] = ang[i];
891 }
892 active_cell -> box[* bid].frac_to_cart = mat4(f_to_c[0][0], f_to_c[0][1], f_to_c[0][2], 0.0,
893 f_to_c[1][0], f_to_c[1][1], f_to_c[1][2], 0.0,
894 f_to_c[2][0], f_to_c[2][1], f_to_c[2][2], 0.0,
895 0.0, 0.0, 0.0, 0.0);
896 active_cell -> box[* bid].cart_to_frac = mat4(c_to_f[0][0], c_to_f[0][1], c_to_f[0][2], 0.0,
897 c_to_f[1][0], c_to_f[1][1], c_to_f[1][2], 0.0,
898 c_to_f[2][0], c_to_f[2][1], c_to_f[2][2], 0.0,
899 0.0, 0.0, 0.0, 0.0);
900#ifdef DEBUG
901 // m4_print (active_cell -> box[* bid].frac_to_cart);
902 // m4_print (active_cell -> box[* bid].cart_to_frac);
903#endif
904 active_cell -> box[* bid].vol = * volume;
905 active_cell -> box[* bid].dens = * density;
906 if ((active_cell -> npt && * bid == active_project -> steps-1) || ! active_cell -> npt)
907 {
908 active_project -> max[GR] = fdmax_ (& active_cell -> pbc);
910 int i, j;
911 active_cell -> volume = active_cell -> density = 0.0;
912 i = (active_cell -> npt) ? active_project -> steps : 1;
913 for (j=0; j<i; j++)
914 {
915 active_cell -> volume += active_cell -> box[j].vol;
916 active_cell -> density += active_cell -> box[j].dens;
917 }
918 active_cell -> volume /= i;
919 active_cell -> density /= i;
920 }
921}
922
930void send_chem_info_ (int prop[active_project -> nspec])
931{
932 int i;
933 for (i=0; i<active_project -> nspec; i++)
934 {
935 active_chem -> formula[i] = prop[i];
936 }
937}
938
950gchar * env_name (project * this_proj, int g, int s, int f, GtkTextBuffer * buffer)
951{
952 int l, m;
953 gchar * spec = exact_name(this_proj -> chemistry -> label[s]);
954 gchar * stra;
955 gchar * strb;
956
957 m = 0;
958 for (l=0; l<this_proj -> nspec; l++)
959 {
960 m += this_proj -> coord -> partial_geo[s][g][l];
961 }
962 if (m > 0)
963 {
964 stra = g_strdup_printf ("%s [", spec);
965 if (buffer != NULL)
966 {
967 print_info (spec, textcolor(s), buffer);
968 print_info ("[", "bold", buffer);
969 }
970 for (l=0; l<this_proj -> nspec; l++)
971 {
972 m = this_proj -> coord -> partial_geo[s][g][l];
973 if (m > 1)
974 {
975 if (f == 1)
976 {
977 strb = g_strdup_printf ("%s%s<sub>%d</sub>", stra, exact_name(this_proj -> chemistry -> label[l]), m);
978 }
979 else
980 {
981 strb = g_strdup_printf ("%s%s%d", stra, exact_name(this_proj -> chemistry -> label[l]), m);
982 }
983 if (buffer != NULL)
984 {
985 print_info (exact_name(this_proj -> chemistry -> label[l]), "bold", buffer);
986 g_free (strb);
987 strb = g_strdup_printf ("%d", m);
988 print_info (strb, "sub", buffer);
989 }
990 }
991 else if (m > 0)
992 {
993 strb = g_strdup_printf ("%s%s", stra, exact_name(this_proj -> chemistry -> label[l]));
994 if (buffer != NULL)
995 {
996 print_info (exact_name(this_proj -> chemistry -> label[l]), "bold", buffer);
997 }
998 }
999 else
1000 {
1001 strb = g_strdup_printf ("%s", stra);
1002 }
1003 g_free (stra);
1004 stra = g_strdup_printf ("%s", strb);
1005 g_free (strb);
1006 }
1007 strb = g_strdup_printf ("%s]", stra);
1008 if (buffer != NULL)
1009 {
1010 print_info ("]", "bold", buffer);
1011 }
1012 g_free (stra);
1013 }
1014 else
1015 {
1016 strb = g_strdup_printf ("%s - isolated", spec);
1017 if (buffer != NULL)
1018 {
1019 print_info (spec, textcolor(s), buffer);
1020 print_info (" - isolated", "bold", buffer);
1021 }
1022 }
1023 if (buffer != NULL)
1024 {
1025 strb = NULL;
1026 }
1027 g_free (spec);
1028 return strb;
1029}
1030
1038void update_after_calc (int calc)
1039{
1040 int i, j;
1041 tint cd;
1042 project * this_proj;
1043 for (i=0; i<nprojects; i++)
1044 {
1045 this_proj = get_project_by_id(i);
1046 if (this_proj -> initok[calc])
1047 {
1048 for (j= 0; j < this_proj -> numc[calc]; j++)
1049 {
1050 if (this_proj -> curves[calc][j] -> plot != NULL)
1051 {
1052 cd.a = i;
1053 cd.b = calc;
1054 cd.c = j;
1055 update_curve ((gpointer)& cd);
1056 }
1057 }
1058 }
1059 }
1060}
The text of the Affero GPL v3 license.
gchar * affero_license
Definition affero.h:31
Binding to the Fortran90 subroutines.
double fdmax_(int *)
double fkmin_(int *)
void quit_gtk()
Leave the application.
Definition callbacks.c:120
Callback declarations for main window.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
#define VERSION
Definition config.h:67
#define PACKAGE_BUGREPORT
Definition config.h:49
#define PACKAGE
Definition config.h:46
void update_curve(gpointer data)
update curve rendering
Definition curve.c:589
Variable declarations for the curve widget Functions for interactions with the curve widget.
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
gchar * text
Definition datab.c:105
float val
Definition dlp_init.c:117
char * ifbug
Definition global.c:142
gchar * PACKAGE_LAGPL
Definition global.c:106
GtkTextTag * tag
Definition global.c:213
int nprojects
Definition global.c:158
GtkWidget * MainWindow
Definition global.c:201
gchar * ATOMES_URL
Definition global.c:137
GtkWidget * atomes_logo
Definition global.c:208
gboolean cif_use_symmetry_positions
Definition global.c:189
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
GtkWidget * pop
Definition global.c:204
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:501
#define EXECUTE
Definition global.h:218
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:454
cell_info * active_cell
Definition project.c:50
void combo_set_markup(GtkWidget *combo)
use pango markup in combo widget
Definition gtk-misc.c:944
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
#define CHEM_N
Definition global.h:302
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:247
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1425
#define GR
Definition global.h:324
#define SQ
Definition global.h:325
#define CHEM_R
Definition global.h:301
@ CONTAINER_WIN
Definition global.h:252
#define NCFORMATS
Definition global.h:320
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:835
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
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
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
#define CHEM_M
Definition global.h:300
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
G_MODULE_EXPORT void run_destroy_dialog(GtkDialog *dialog, gint response_id, gpointer data)
to destroy a GtkDialog when the dialog emit the closing signal
Definition gtk-misc.c:2237
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:681
#define min(a, b)
Definition global.h:81
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:235
char * coord_files[NCFORMATS+1]
Definition callbacks.c:86
GtkWidget * message_dialogmodal(gchar *message, gchar *title, GtkMessageType mtype, GtkButtonsType buttons, GtkWidget *parent)
create a modal (cannot be ignored) message window
Definition gtk-misc.c:541
#define CHEM_X
Definition global.h:303
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
#define CHEM_Z
Definition global.h:299
#define SK
Definition global.h:326
project * active_project
Definition project.c:47
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
#define max(a, b)
Definition global.h:80
image * plot
Definition ogl_draw.c:70
G_MODULE_EXPORT void on_answer_changed(GtkWidget *widg, gpointer data)
Handling the GtkComboBox in 'int iask'.
Definition interface.c:494
gchar * field_init[3]
Definition dlp_field.c:4332
gchar * cif_configurations[3]
Definition interface.c:457
void show_web(GtkWidget *dialog, int id)
add / show web information to widget
Definition interface.c:216
G_MODULE_EXPORT void create_about_dialog(GtkWidget *widg, gpointer data)
create the about dialog
Definition interface.c:175
int iask(char *question, char *lab, int id, GtkWidget *win)
enter an integer value - prepare the dialog
Definition interface.c:556
gchar * res_char
Definition interface.c:654
gchar * cif_occ[3]
Definition interface.c:478
gchar * cask(char *question, char *lab, int id, char *old, GtkWidget *win)
enter a string - prepare the dialog
Definition interface.c:706
void show_warning_(char *warning, char *sub, char *tab)
show warning from Fortran90
Definition interface.c:275
gchar * substitute_string(gchar *init, gchar *o_motif, gchar *n_motif)
substitute all patterns in string
Definition w_library.c:372
gchar * cif_sites[2]
Definition interface.c:481
void show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:260
G_MODULE_EXPORT void run_cask(GtkDialog *cask, gint response_id, gpointer data)
enter a string - running the dialog
Definition interface.c:665
gchar * npt_type[4]
Definition interface.c:450
gboolean res_yes_no
Definition interface.c:329
void spec_data_(int *status, int *ind, int *atd, int *nsp, char *lbel, char *el_nme, double *amss, double *rdus, double *nscatt, double *xscatt)
update project data using information from Fortran90
Definition interface.c:771
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:234
gchar * textcolor(int i)
setup text color keyword
Definition interface.c:824
int res_int
Definition interface.c:502
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
G_MODULE_EXPORT gboolean leaving_question(GtkWidget *widget, GdkEvent *event, gpointer data)
Leaving atomes ?
Definition interface.c:418
GtkWidget * answer_info
Definition interface.c:484
int dummy_ask_(char *question)
Ask to use dummy atoms or not from Fortran90.
Definition interface.c:439
gchar * cif_config_leg
Definition interface.c:473
void send_chem_info_(int prop[active_project -> nspec])
Definition interface.c:930
void update_after_calc(int calc)
To update all curve plots in the workspace after a calculation.
Definition interface.c:1038
gchar * cif_occupancies[3]
Definition interface.c:460
gchar * cif_config_legends
Definition interface.c:463
void show_error_(char *error, char *sub, char *tab)
show error from Fortran90
Definition interface.c:320
GtkWidget * answer
Definition interface.c:80
gchar * npt_info[3]
Definition interface.c:454
void init_data_(int *nats, int *nspc, int *stps, int *cid)
update project data using information from Fortran90
Definition interface.c:743
void lattice_info_(int *bid, double *volume, double *density, double dvects[3][3], double rvects[3][3], double mod[3], double ang[3], double f_to_c[3][3], double c_to_f[3][3])
lattice data from Fortran90
Definition interface.c:877
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
G_MODULE_EXPORT void run_iask(GtkDialog *iask, gint response_id, gpointer data)
enter an integer value - running the dialog
Definition interface.c:513
GtkWidget * show_pop(char *pop, GtkWidget *pwin)
display pop information window
Definition interface.c:383
G_MODULE_EXPORT void run_yes_no(GtkDialog *dial, gint response_id, gpointer data)
ask yes or no for something: running dialog
Definition interface.c:340
void print_info(gchar *str, gchar *stag, GtkTextBuffer *buffer)
print information in GtkTextBuffer
Definition interface.c:799
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
GtkWidget * addweb(int id)
create a widget to present
Definition interface.c:135
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
gchar * coord_type[3]
Definition interface.c:447
void alloc_proj_data(project *this_proj, int cid)
allocate data
Definition open_p.c:210
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:351
Definition global.h:106
int b
Definition global.h:108
int c
Definition global.h:109
int a
Definition global.h:107
int status
Definition w_advance.c:178
int element
Definition w_periodic.c:61
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73