atomes 1.1.14
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-2024 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 © 2024 \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);
222 show_the_widgets (box);
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 {
427 gtk_widget_show (MainWindow);
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"};
457GtkWidget * answer_info;
458
467G_MODULE_EXPORT void on_answer_changed (GtkWidget * widg, gpointer data)
468{
469 int i, j;
470 i = gtk_combo_box_get_active (GTK_COMBO_BOX(widg));
471 j = (! i || i == 2) ? 0 : (i == 1) ? 1 : 2;
472 gtk_label_set_text (GTK_LABEL(answer_info), npt_info[j]);
473}
474
476
486G_MODULE_EXPORT void run_iask (GtkDialog * iask, gint response_id, gpointer data)
487{
488 int i = GPOINTER_TO_INT(data);
489 gboolean done = FALSE;
490 const gchar * riask;
491 if (response_id == GTK_RESPONSE_OK)
492 {
493 if (i == 0 || i > 3)
494 {
495 riask = entry_get_text (GTK_ENTRY(answer));
496 res_int = atof(riask);
497 if (i > 4)
498 {
499 if (res_int > 0 && res_int < i+1)
500 {
501 done = TRUE;
502 res_int --;
503 }
504 }
505 else if (res_int > 0)
506 {
507 done = TRUE;
508 }
509 }
510 else
511 {
512 done = TRUE;
513 res_int = gtk_combo_box_get_active (GTK_COMBO_BOX(answer));
514 }
515 }
516 if (done) destroy_this_dialog (iask);
517}
518
529int iask (char * question, char * lab, int id, GtkWidget * win)
530{
531 GtkWidget * iask;
532 GtkWidget * vbox;
533 GtkWidget * hboxa;
534 GtkWidget * quest;
535 int i;
536 iask = message_dialogmodal (question, "Parameter Required", GTK_MESSAGE_INFO, GTK_BUTTONS_OK, win);
538 gtk_box_set_spacing (GTK_BOX(vbox), 15);
539 hboxa = create_hbox (0);
540 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hboxa, TRUE, TRUE, 0);
541 quest = gtk_label_new (lab);
542 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, quest, TRUE, TRUE, 0);
543
544 if (id == 0 || id > 3)
545 {
546 answer = gtk_entry_new ();
547 gtk_widget_set_size_request (answer, 100, -1);
548 gtk_entry_set_alignment (GTK_ENTRY(answer), 1.0);
549 }
550 else
551 {
552 if (id < 3)
553 {
554 answer = create_combo ();
555 gtk_widget_set_size_request (answer, -1, 40);
556 if (id < 0) for (i=0; i<3; i++) combo_text_append (answer, field_init[i]);
557 if (id == 1) for (i=0; i<3; i++) combo_text_append (answer, coord_type[i]);
558 if (id == 2) for (i=0; i<NCFORMATS; i++) combo_text_append (answer, coord_files[i]);
559 }
560 else
561 {
562 GtkTreeIter iter;
563 GtkTreeStore * store = store = gtk_tree_store_new (1, G_TYPE_STRING);
564 for (i=0; i<4; i++)
565 {
566 gtk_tree_store_append (store, & iter, NULL);
567 gtk_tree_store_set (store, & iter, 0, npt_type[i], -1);
568 }
569 answer = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
570 GtkCellRenderer * renderer = gtk_cell_renderer_combo_new ();
571 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (answer), renderer, TRUE);
572 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (answer), renderer, "text", 0, NULL);
573 GList * cell_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(answer));
574 if(cell_list && cell_list -> data)
575 {
576 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(answer), cell_list -> data, "markup", 0, NULL);
577 }
578 }
579 gtk_combo_box_set_active (GTK_COMBO_BOX(answer), 0);
580 }
581 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, answer, FALSE, FALSE, 10);
582 if (id == 3)
583 {
584 answer_info = markup_label(npt_info[0], -1, -1, 0.5, 0.5);
585 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, answer_info, FALSE, FALSE, 5);
586 g_signal_connect(G_OBJECT(answer), "changed", G_CALLBACK(on_answer_changed), NULL);
587 }
588
589 run_this_gtk_dialog (iask, G_CALLBACK(run_iask), GINT_TO_POINTER(id));
590 return res_int;
591}
592
593gchar * res_char;
594
604G_MODULE_EXPORT void run_cask (GtkDialog * cask, gint response_id, gpointer data)
605{
606 int i = GPOINTER_TO_INT(data);
607 gboolean done = FALSE;
608 if (i < 0)
609 {
610 while (! done)
611 {
612 if (response_id == GTK_RESPONSE_OK)
613 {
614 res_char = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(answer)));
615 done = TRUE;
616 }
617 }
618 }
619 else
620 {
621 if (response_id == GTK_RESPONSE_OK)
622 {
623 res_char = g_strdup_printf ("%s", entry_get_text (GTK_ENTRY(answer)));
624 }
625 else
626 {
627 res_char = NULL;
628 }
629 done = TRUE;
630 }
631 if (done) destroy_this_dialog (cask);
632}
633
645gchar * cask (char * question, char * lab, int id, char * old, GtkWidget * win)
646{
647 GtkWidget * cask;
648 GtkWidget * dialog_ask;
649 GtkWidget * hboxa;
650 GtkWidget * quest;
651 res_char = NULL;
652 cask = message_dialogmodal (question, "Parameter required", GTK_MESSAGE_INFO, GTK_BUTTONS_OK, win);
653 dialog_ask = dialog_get_content_area (cask);
654 gtk_box_set_spacing (GTK_BOX(dialog_ask), 15);
655
656 hboxa = create_hbox (0);
657 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_ask, hboxa, TRUE, TRUE, 0);
658 gtk_widget_show(hboxa);
659 quest = gtk_label_new (lab);
660 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, quest, TRUE, TRUE, 0);
661 gtk_widget_show(quest);
662 answer = gtk_entry_new ();
663 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hboxa, answer, TRUE, TRUE, 0);
664 gtk_widget_set_size_request (answer, 50, -1);
665 gtk_entry_set_alignment (GTK_ENTRY(answer), 1.0);
666 update_entry_text (GTK_ENTRY(answer), old);
667 run_this_gtk_dialog (cask, G_CALLBACK(run_cask), GINT_TO_POINTER(id));
668
669 return (res_char);
670}
671
682void init_data_ (int * nats, int * nspc, int * stps, int * cid)
683{
684 active_project -> natomes = * nats;
685 active_project -> nspec = * nspc;
686 active_project -> steps = * stps;
688 if (* cid) active_chem = active_project -> chemistry;
689}
690
710void spec_data_ (int * status, int * ind, int * atd, int * nsp,
711 char * lbel, char * el_nme,
712 double * amss, double * rdus,
713 double * nscatt, double * xscatt)
714{
715 int id = * ind;
716 active_chem -> label[id]= g_strdup_printf("%s", lbel);
717 active_chem -> element[id]= g_strdup_printf("%s", el_nme);
718 if (* status)
719 {
720 active_chem -> nsps[id] = * nsp;
721 active_chem -> chem_prop[CHEM_Z][id] = (double) * atd;
722 active_chem -> chem_prop[CHEM_M][id] = * amss;
723 active_chem -> chem_prop[CHEM_R][id] = * rdus;
724 active_chem -> chem_prop[CHEM_N][id] = * nscatt;
725 active_chem -> chem_prop[CHEM_X][id] = * xscatt;
726 }
727}
728
738void print_info (gchar * str, gchar * stag, GtkTextBuffer * buffer)
739{
740 GtkTextIter bEnd;
741 GtkTextTag * tag;
742
743 gtk_text_buffer_get_end_iter (buffer, &bEnd);
744 if (stag != NULL)
745 {
746 tag = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table(buffer), stag);
747 gtk_text_buffer_insert_with_tags (buffer, &bEnd, str, -1, tag, NULL);
748 }
749 else
750 {
751 tag = gtk_text_tag_table_lookup (gtk_text_buffer_get_tag_table(buffer), "default-size");
752 gtk_text_buffer_insert_with_tags (buffer, &bEnd, str, -1, tag, NULL);
753 }
754}
755
763gchar * textcolor (int i)
764{
765 gchar * col = NULL;
766 switch (i - i * (i / 9))
767 {
768 case 0:
769 col = g_strdup_printf ("red");
770 break;
771 case 1:
772 col = g_strdup_printf ("blue");
773 break;
774 case 2:
775 col = g_strdup_printf ("cyan");
776 break;
777 case 3:
778 col = g_strdup_printf ("green");
779 break;
780 case 4:
781 col = g_strdup_printf ("light_green");
782 break;
783 case 5:
784 col = g_strdup_printf ("yellow");
785 break;
786 case 6:
787 col = g_strdup_printf ("orange");
788 break;
789 case 7:
790 col = g_strdup_printf ("violet");
791 break;
792 case 8:
793 col = g_strdup_printf ("pink");
794 break;
795 }
796 return col;
797}
798
816void lattice_info_ (int * bid, double * volume, double * density,
817 double dvects[3][3], double rvects[3][3], double mod[3], double ang[3],
818 double f_to_c[3][3], double c_to_f[3][3])
819{
820 int i, j;
821 for ( i=0; i<3; i++)
822 {
823 for (j=0; j<3; j++)
824 {
825 active_cell -> box[* bid].vect[i][j] = dvects[j][i];
826 active_cell -> box[* bid].rvect[i][j] = rvects[j][i];
827 }
828 active_cell -> box[* bid].param[0][i] = mod[i];
829 active_cell -> box[* bid].param[1][i] = ang[i];
830 }
831 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,
832 f_to_c[1][0], f_to_c[1][1], f_to_c[1][2], 0.0,
833 f_to_c[2][0], f_to_c[2][1], f_to_c[2][2], 0.0,
834 0.0, 0.0, 0.0, 0.0);
835 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,
836 c_to_f[1][0], c_to_f[1][1], c_to_f[1][2], 0.0,
837 c_to_f[2][0], c_to_f[2][1], c_to_f[2][2], 0.0,
838 0.0, 0.0, 0.0, 0.0);
839#ifdef DEBUG
840 // m4_print (active_cell -> box[* bid].frac_to_cart);
841 // m4_print (active_cell -> box[* bid].cart_to_frac);
842#endif
843 active_cell -> box[* bid].vol = * volume;
844 active_cell -> box[* bid].dens = * density;
845 if ((active_cell -> npt && * bid == active_project -> steps-1) || ! active_cell -> npt)
846 {
847 active_project -> max[GR] = fdmax_ (& active_cell -> ltype);
848 active_project -> min[SQ] = active_project -> min[SK] = fkmin_ (& active_cell -> ltype);
849 int i, j;
850 active_cell -> volume = active_cell -> density = 0.0;
851 i = (active_cell -> npt) ? active_project -> steps : 1;
852 for (j=0; j<i; j++)
853 {
854 active_cell -> volume += active_cell -> box[j].vol;
855 active_cell -> density += active_cell -> box[j].dens;
856 }
857 active_cell -> volume /= i;
858 active_cell -> density /= i;
859 }
860}
861
869void send_chem_info_ (int prop[active_project -> nspec])
870{
871 int i;
872 for (i=0; i<active_project -> nspec; i++)
873 {
874 active_chem -> formula[i] = prop[i];
875 }
876}
877
889gchar * env_name (project * this_proj, int g, int s, int f, GtkTextBuffer * buffer)
890{
891 int l, m;
892 gchar * spec = exact_name(this_proj -> chemistry -> label[s]);
893 gchar * stra;
894 gchar * strb;
895
896 m = 0;
897 for (l=0; l<this_proj -> nspec; l++)
898 {
899 m += this_proj -> coord -> partial_geo[s][g][l];
900 }
901 if (m > 0)
902 {
903 stra = g_strdup_printf ("%s [", spec);
904 if (buffer != NULL)
905 {
906 print_info (spec, textcolor(s), buffer);
907 print_info ("[", "bold", buffer);
908 }
909 for (l=0; l<this_proj -> nspec; l++)
910 {
911 m = this_proj -> coord -> partial_geo[s][g][l];
912 if (m > 1)
913 {
914 if (f == 1)
915 {
916 strb = g_strdup_printf ("%s%s<sub>%d</sub>", stra, exact_name(this_proj -> chemistry -> label[l]), m);
917 }
918 else
919 {
920 strb = g_strdup_printf ("%s%s%d", stra, exact_name(this_proj -> chemistry -> label[l]), m);
921 }
922 if (buffer != NULL)
923 {
924 print_info (exact_name(this_proj -> chemistry -> label[l]), "bold", buffer);
925 g_free (strb);
926 strb = g_strdup_printf ("%d", m);
927 print_info (strb, "sub", buffer);
928 }
929 }
930 else if (m > 0)
931 {
932 strb = g_strdup_printf ("%s%s", stra, exact_name(this_proj -> chemistry -> label[l]));
933 if (buffer != NULL)
934 {
935 print_info (exact_name(this_proj -> chemistry -> label[l]), "bold", buffer);
936 }
937 }
938 else
939 {
940 strb = g_strdup_printf ("%s", stra);
941 }
942 g_free (stra);
943 stra = g_strdup_printf ("%s", strb);
944 g_free (strb);
945 }
946 strb = g_strdup_printf ("%s]", stra);
947 if (buffer != NULL)
948 {
949 print_info ("]", "bold", buffer);
950 }
951 g_free (stra);
952 }
953 else
954 {
955 strb = g_strdup_printf ("%s - isolated", spec);
956 if (buffer != NULL)
957 {
958 print_info (spec, textcolor(s), buffer);
959 print_info (" - isolated", "bold", buffer);
960 }
961 }
962 if (buffer != NULL)
963 {
964 strb = NULL;
965 }
966 g_free (spec);
967 return strb;
968}
969
977void update_after_calc (int calc)
978{
979 int i, j;
980 tint cd;
981 project * this_proj;
982 for (i=0; i<nprojects; i++)
983 {
984 this_proj = get_project_by_id(i);
985 if (this_proj -> initok[calc])
986 {
987 for (j= 0; j < this_proj -> numc[calc]; j++)
988 {
989 if (this_proj -> curves[calc][j] -> plot != NULL)
990 {
991 cd.a = i;
992 cd.b = calc;
993 cd.c = j;
994 update_curve ((gpointer)& cd);
995 }
996 }
997 }
998 }
999}
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:119
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:141
GtkTextTag * tag
Definition global.c:225
int nprojects
Definition global.c:158
GtkWidget * MainWindow
Definition global.c:214
gchar * ATOMES_URL
Definition global.c:136
GtkWidget * atomes_logo
Definition global.c:221
GtkWidget * pop
Definition global.c:217
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:472
#define EXECUTE
Definition global.h:188
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:425
cell_info * active_cell
Definition project.c:50
#define CHEM_N
Definition global.h:272
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:577
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:217
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1344
#define GR
Definition global.h:294
#define SQ
Definition global.h:295
#define CHEM_R
Definition global.h:271
@ CONTAINER_WIN
Definition global.h:222
#define NCFORMATS
Definition global.h:290
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:903
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:805
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1565
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:279
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2041
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
#define CHEM_M
Definition global.h:270
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:880
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:2078
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:651
#define min(a, b)
Definition global.h:75
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:206
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:511
#define CHEM_X
Definition global.h:273
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:781
#define CHEM_Z
Definition global.h:269
#define SK
Definition global.h:296
project * active_project
Definition project.c:47
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
#define max(a, b)
Definition global.h:74
image * plot
Definition ogl_draw.c:66
G_MODULE_EXPORT void on_answer_changed(GtkWidget *widg, gpointer data)
Handling the GtkComboBox in 'int iask'.
Definition interface.c:467
gchar * field_init[3]
Definition dlp_field.c:4351
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:529
gchar * res_char
Definition interface.c:593
gchar * cask(char *question, char *lab, int id, char *old, GtkWidget *win)
enter a string - prepare the dialog
Definition interface.c:645
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
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:604
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:710
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:763
int res_int
Definition interface.c:475
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:457
int dummy_ask_(char *question)
Ask to use dummy atoms or not from Fortran90.
Definition interface.c:439
void send_chem_info_(int prop[active_project -> nspec])
Definition interface.c:869
void update_after_calc(int calc)
To update all curve plots in the workspace after a calculation.
Definition interface.c:977
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:682
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:816
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
G_MODULE_EXPORT void run_iask(GtkDialog *iask, gint response_id, gpointer data)
enter an integer value - running the dialog
Definition interface.c:486
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:738
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:206
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:98
int b
Definition global.h:100
int c
Definition global.h:101
int a
Definition global.h:99
int status
Definition w_advance.c:160
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