atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
calc_menu.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: 'calc_menu.c'
24*
25* Contains:
26*
27
28 - The creation of the calculation dialogs
29
30*
31* List of functions:
32
33 gboolean test_gr (int gr);
34 gboolean test_sq (int sq);
35 gboolean test_bonds ();
36 gboolean test_rings ();
37 gboolean test_msd ();
38 gboolean test_sph ();
39
40 void calc_sph (GtkWidget * vbox);
41 void calc_msd (GtkWidget * vbox);
42 void calc_rings (GtkWidget * vbox);
43 void calc_bonds (GtkWidget * vbox);
44 void calc_gr_sq (GtkWidget * box, int id);
45
46 G_MODULE_EXPORT void set_max (GtkEntry * entry, gpointer data);
47 G_MODULE_EXPORT void set_delta (GtkEntry * entry, gpointer data);
48 G_MODULE_EXPORT void combox_tunit_changed (GtkComboBox * box, gpointer data);
49 G_MODULE_EXPORT void set_numa (GtkEntry * entry, gpointer data);
50 G_MODULE_EXPORT void combox_rings_changed (GtkComboBox * box, gpointer data);
51 G_MODULE_EXPORT void toggle_rings (GtkCheckButton * but, gpointer data);
52 G_MODULE_EXPORT void toggle_rings (GtkToggleButton * but, gpointer data);
53 G_MODULE_EXPORT void run_toggle_bond (GtkNativeDialog * info, gint response_id, gpointer data);
54 G_MODULE_EXPORT void run_toggle_bond (GtkDialog * info, gint response_id, gpointer data);
55 G_MODULE_EXPORT void toggle_bond (GtkCheckButton * Button, gpointer data);
56 G_MODULE_EXPORT void toggle_bond (GtkToggleButton * Button, gpointer data);
57 G_MODULE_EXPORT void expand_opt (GtkWidget * exp, gpointer data);
58 G_MODULE_EXPORT void set_advanced_sq (GtkEntry * entry, gpointer data);
59 G_MODULE_EXPORT void set_sfact (GtkEntry * entry, gpointer data);
60 G_MODULE_EXPORT void on_show_curve_toolbox (GtkWidget * widg, gpointer data);
61 G_MODULE_EXPORT void on_smoother_released (GtkButton * button, gpointer data);
62 G_MODULE_EXPORT void run_on_calc_activate (GtkDialog * dial, gint response_id, gpointer data);
63 G_MODULE_EXPORT void on_calc_activate (GtkWidget * widg, gpointer data);
64
65 GtkWidget * calc_window (int i);
66 GtkWidget * combox_rings (gchar * str, int num, gchar * list_item[num], int id);
67 GtkWidget * hbox_note (int i, double val);
68
69*/
70
71#include "global.h"
72#include "callbacks.h"
73#include "interface.h"
74#include "bind.h"
75#include "project.h"
76#include "workspace.h"
77
78extern G_MODULE_EXPORT void on_calc_gr_released (GtkWidget * widg, gpointer data);
79extern G_MODULE_EXPORT void on_calc_gq_released (GtkWidget * widg, gpointer data);
80extern G_MODULE_EXPORT void on_calc_sq_released (GtkWidget * widg, gpointer data);
81extern G_MODULE_EXPORT void on_calc_sk_released (GtkWidget * widg, gpointer data);
82extern gboolean toggled_rings;
83extern G_MODULE_EXPORT void on_calc_rings_released (GtkWidget * widg, gpointer data);
84extern G_MODULE_EXPORT void on_calc_chains_released (GtkWidget * widg, gpointer data);
85extern G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data);
86extern G_MODULE_EXPORT void on_calc_sph_released (GtkWidget * widg, gpointer data);
87extern gchar * calc_img[NCALCS-2];
88
89GtkWidget * calc_win = NULL;
90GtkWidget * ba_entry[2];
92
100GtkWidget * calc_window (int i)
101{
103#ifndef GTK4
104 /* GtkWidget * apply_button =
105 button_set_image (GTK_BUTTON(apply_button), calc_name[i], IMG_FILE, (gpointer)calc_img[i]);
106 gtk_widget_show (apply_button); */
107#endif
108 return calc_dialog;
109}
110
119G_MODULE_EXPORT void set_max (GtkEntry * entry, gpointer data)
120{
121 int c = GPOINTER_TO_INT(data);
122 const gchar * m = entry_get_text (entry);
123 double v = atof(m);
124 if (v > 0)
125 {
126 if (active_project -> max[c] != v)
127 {
128 active_project -> max[c] = v;
129 // Max has changed do something !?
130 }
131 }
133}
134
135GtkWidget * rings_box[2];
136
145G_MODULE_EXPORT void set_delta (GtkEntry * entry, gpointer data)
146{
147 int c = GPOINTER_TO_INT(data);
148 const gchar * m = entry_get_text (entry);
149 double v = atof(m);
150 int i, j, k;
151 i = (int)v;
152 if (c == RI)
153 {
154 j = gtk_combo_box_get_active(GTK_COMBO_BOX(rings_box[0]));
155 k = active_project -> rsparam[j][1];
156 }
157 else if (c == CH)
158 {
159 k = active_project -> csparam[5];
160 }
161 else if (c > -1)
162 {
163 k = active_project -> num_delta[c];
164 }
165 if (c < 0)
166 {
167 if (v > 0.0)
168 {
169 if (active_project -> delta[-c] != v)
170 {
171 active_project -> delta[-c] = v;
172 }
173 }
174 }
175 else if (i > 0)
176 {
177 if (c == RI)
178 {
179 if (active_project -> rsparam[j][1] != i)
180 {
181 active_project -> rsparam[j][1] = i;
182 }
183 k = active_project -> rsparam[j][1] = i;
184 }
185 else if (c == CH)
186 {
187 if (active_project -> csparam[5] != i)
188 {
189 active_project -> csparam[5] = i;
190 }
191 k = active_project -> csparam[5] = i;
192 }
193 else
194 {
195 if (active_project -> num_delta[c] != i)
196 {
197 active_project -> num_delta[c] = i;
198 }
199 k = active_project -> num_delta[c];
200 }
201 }
202 if (c < 0)
203 {
204 update_entry_double (entry, active_project -> delta[-c]);
205 }
206 else
207 {
208 update_entry_int (entry, k);
209 }
210}
211
220G_MODULE_EXPORT void combox_tunit_changed (GtkComboBox * box, gpointer data)
221{
222 active_project -> tunit = gtk_combo_box_get_active(box);
223}
224
232void calc_sph (GtkWidget * vbox)
233{
234 GtkWidget * hbox;
235 GtkWidget * entry;
236 hbox = create_hbox (0);
237 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
238 gchar * str = "Maximum <b><i>l</i></b>, <i>l<sub>max</sub></i> in [2-40]";
239 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
240 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(SP));
241 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[SP]);
242 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
243}
244
252void calc_msd (GtkWidget * vbox)
253{
254 int i, j;
255 gchar * val_b[3]={"Number of configurations:",
256 "\tTime step &#x3b4;t used during the dynamics:",
257 "\tNumber of step(s) between each configuration:"};
258 GtkWidget * hbox;
259 GtkWidget * entry;
260 hbox = create_hbox (15);
261 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
262 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new (val_b[0]), FALSE, FALSE, 0);
263 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (g_strdup_printf ("<b>%d</b>",active_project -> steps), -1, 50, 0.5, 0.5), FALSE, FALSE, 0);
264
265 for (i=1; i<3; i++)
266 {
267 hbox = create_hbox (15);
268 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
269 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[i], 350, -1, 0.0, 0.5), FALSE, FALSE, 0);
270 if (i == 1)
271 {
272 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(-MS));
273 update_entry_double (GTK_ENTRY(entry), active_project -> delta[MS]);
274 }
275 else
276 {
277 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(MS));
278 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[MS]);
279 }
280 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
281 if (i == 1)
282 {
283 GtkWidget * tcombo = create_combo ();
284 for (j=0; j<6 ; j++) combo_text_append (tcombo, untime[j]);
285 gtk_combo_box_set_active (GTK_COMBO_BOX(tcombo), active_project -> tunit);
286 g_signal_connect(G_OBJECT(tcombo), "changed", G_CALLBACK(combox_tunit_changed), NULL);
287 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, tcombo, FALSE, FALSE, 0);
288 }
289 }
290}
291
300G_MODULE_EXPORT void set_numa (GtkEntry * entry, gpointer data)
301{
302 const gchar * m = entry_get_text (entry);
303 double v = atof(m);
304 int i, j;
305 i = (int)v;
306 if (i > 0)
307 {
308 if (! search_type)
309 {
310 if (active_project -> rsearch[1] != i) active_project -> rsearch[1] = i;
311 j = active_project -> rsearch[1];
312 }
313 else
314 {
315 if (active_project -> csearch != i) active_project -> csearch = i;
316 j = active_project -> csearch;
317 }
318 }
319 else
320 {
321 j = (search_type) ? active_project -> csearch : active_project -> rsearch[1];
322 }
323 update_entry_int (entry, j);
324}
325
336GtkWidget * combox_rings (gchar * str, int num, gchar * list_item[num], int id)
337{
338 int i;
339 GtkWidget * hbox = create_hbox (0);
340 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, 40, 0.0, 0.5), FALSE, FALSE, 0);
341 GtkWidget * fixed = gtk_fixed_new ();
342 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, fixed, FALSE, FALSE, 0);
343 rings_box[id] = create_combo ();
344 for (i=0; i<num; i++) combo_text_append (rings_box[id], list_item[i]);
345 gtk_fixed_put (GTK_FIXED(fixed), rings_box[id], -1, -1);
346 return hbox;
347}
348
349 GtkWidget * rings_entry[2];
350 GtkWidget * rings_check[4];
351
360G_MODULE_EXPORT void combox_rings_changed (GtkComboBox * box, gpointer data)
361{
362 int i, j;
363 int id = GPOINTER_TO_INT(data);
364 if (id == 0)
365 {
366 active_project -> rsearch[0] = gtk_combo_box_get_active(box);
367 widget_set_sensitive (rings_box[1], (active_project -> rsearch[0]<0) ? 0 : 1);
368 gtk_combo_box_set_active(GTK_COMBO_BOX(rings_box[1]), active_project -> rsparam[active_project -> rsearch[0]][0]);
369 for (i=0; i<2; i++) widget_set_sensitive (rings_entry[i], (active_project -> rsearch[0]<0) ? 0 : 1);
370 for (i=0; i<3; i++) widget_set_sensitive (rings_check[i], (active_project -> rsearch[0]<0) ? 0 : 1);
371 update_entry_int (GTK_ENTRY(rings_entry[0]), active_project -> rsparam[active_project -> rsearch[0]][1]);
372 i = gtk_combo_box_get_active(GTK_COMBO_BOX(rings_box[0]));
373 for (j=0; j<3; j++)
374 {
375#ifdef GTK4
376 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[j]), active_project -> rsparam[i][j+2]);
377#else
378 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[j]), active_project -> rsparam[i][j+2]);
379#endif
380 }
381 }
382 else
383 {
384 if (search_type)
385 {
386 active_project -> csparam[0] = gtk_combo_box_get_active(box);
387 }
388 else
389 {
390 i = gtk_combo_box_get_active(GTK_COMBO_BOX(rings_box[0]));
391 active_project -> rsparam[i][0] = gtk_combo_box_get_active(box);
392 }
393 }
394}
395
396#ifdef GTK4
405G_MODULE_EXPORT void toggle_rings (GtkCheckButton * but, gpointer data)
406#else
415G_MODULE_EXPORT void toggle_rings (GtkToggleButton * but, gpointer data)
416#endif
417{
418 int oid = GPOINTER_TO_INT(data);
419 int i;
420 gboolean status;
421#ifdef GTK4
422 status = gtk_check_button_get_active (but);
423#else
424 status = gtk_toggle_button_get_active (but);
425#endif
426 toggled_rings = TRUE;
427 switch (search_type)
428 {
429 case 0:
430 i = gtk_combo_box_get_active(GTK_COMBO_BOX(rings_box[0]));
431 active_project -> rsparam[i][oid+2] = status;
432 break;
433 case 1:
434 active_project -> csparam[oid+1] = status;
435 if (oid == 0 && status)
436 {
437#ifdef GTK4
438 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[1]), ! status);
439 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[2]), ! status);
440 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[3]), ! status);
441#else
442 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[1]), ! status);
443 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[2]), ! status);
444 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[3]), ! status);
445#endif
446 }
447 else if (oid == 1 && status)
448 {
449#ifdef GTK4
450 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[0]), ! status);
451#else
452 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[0]), ! status);
453#endif
454 }
455 else if (oid == 2 && status)
456 {
457#ifdef GTK4
458 gtk_check_button_set_active (GTK_CHECK_BUTTON(rings_check[1]), ! status);
459#else
460 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(rings_check[1]), ! status);
461#endif
462 }
463 break;
464 }
465}
466
474void calc_rings (GtkWidget * vbox)
475{
476 gchar * defs[6]={"All rings (No rules)",
477 "King's [1, 3]",
478 "Guttman's [2]",
479 "Primitives [4, 5, 6]",
480 "Strongs [4, 5]"};
481 gchar * val_a[2]={"Definition of ring to be used: ", "Atom(s) to initiate the search from: "};
482 gchar * val_b[2][2]={{"<i><b>n</b><sub>max</sub></i> = maximum size for a ring <sup>*</sup>",
483 "Maximum number of rings of size <i><b>n</b></i> per MD step <sup>**</sup>"},
484 {"<i><b>n</b><sub>max</sub></i> = maximum size for a chain <sup>*</sup>",
485 "Maximum number of chains of size <i><b>n</b></i> per MD step <sup>**</sup>"}};
486 gchar * val_c[2][4]={{"Only search for ABAB rings", "No homopolar bonds in the rings (A-A, B-B ...) <sup>***</sup>", "No homopolar bonds in the connectivity matrix", " "},
487 {"Only search for AAAA chains", "Only search for ABAB chains",
488 "No homopolar bonds in the chains (A-A, B-B ...) <sup>***</sup>", "Only search for 1-(2)<sub>n</sub>-1 coordinated atom chains, ie. isolated chains."}};
489 gchar * val_d={"\n*\t<i><b>n</b><sub>max</sub></i> in total number of nodes (or atoms)\n"
490 "**\tvalue used for memory allocation = f(<i><b>n</b><sub>max</sub></i>, system studied)\n"
491 "***\tBut homopolar bonds can shorten the rings"};
492 gchar * val_e={"\n<sub>[1] S. V. King. <i>Nature</i>, <b>213</b>:1112 (1967).\n"
493 "[2] L. Guttman. <i>J. Non-Cryst. Solids.</i>, <b>116</b>:145-147 (1990).\n"
494 "[3] D. S. Franzblau. <i>Phys. Rev. B</i>, <b>44</b>(10):4925-4930 (1991).\n"
495 "[4] K. Goetzke and H. J. Klein. <i>J. Non-Cryst. Solids.</i>, <b>127</b>:215-220 (1991).\n"
496 "[5] X. Yuan and A. N. Cormack. <i>Comp. Mat. Sci.</i>, <b>24</b>:343-360 (2002).\n"
497 "[6] F. Wooten. <i>Acta Cryst. A</i>, <b>58</b>(4):346-351 (2002).</sub>"};
498 gchar * list_node[active_project -> nspec+1];
499 int i, j, k;
500 toggled_rings = FALSE;
501 if (! search_type) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, combox_rings (val_a[0], 5, defs, 0), FALSE, FALSE, 0);
502
503 list_node[0] = g_strdup_printf ("All");
504 for (i=0; i<active_project -> nspec; i++) list_node[i+1] = g_strdup_printf ("%s", active_chem -> label[i]);
505 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, combox_rings (val_a[1], active_project -> nspec+1, list_node, 1), FALSE, FALSE, 0);
506
507 j = active_project -> rsearch[0];
508 k = RI + search_type;
509 GtkWidget * hbox;
510 for (i=0; i<2; i++)
511 {
512 hbox = create_hbox (0);
513 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
514 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[search_type][i], 400, -1, 0.0, 0.5), FALSE, FALSE, 0);
515 if (i == 0)
516 {
517 rings_entry[i] = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, GINT_TO_POINTER(k));
518 update_entry_int (GTK_ENTRY(rings_entry[i]), (search_type) ? active_project -> csparam[5] : active_project -> rsparam[j][1]);
519 }
520 else
521 {
522 rings_entry[i] = create_entry (G_CALLBACK(set_numa), 100, 15, FALSE, NULL);
523 update_entry_int (GTK_ENTRY(rings_entry[i]), (search_type) ? active_project -> csearch : active_project -> rsearch[1]);
524 }
525 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, rings_entry[i], FALSE, FALSE, 0);
526 if (! search_type && j < 0) widget_set_sensitive (rings_entry[i], 0);
527 }
528 gboolean status;
529 for (i=0; i<3+search_type; i++)
530 {
531 status = (j < 0) ? 0 : (search_type) ? active_project -> csparam[i+1] : active_project -> rsparam[j][i+2];
532 rings_check[i] = check_button (val_c[search_type][i], -1, 40, status, G_CALLBACK(toggle_rings), GINT_TO_POINTER(i));
533 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, rings_check[i], FALSE, FALSE, 0);
534 if (active_project -> nspec == 1) widget_set_sensitive (rings_check[i], 0);
535 if (! search_type && j < 0) widget_set_sensitive (rings_check[i], 0);
536 }
537 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label (val_d, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
538 if (! search_type)
539 {
540 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label (val_e, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
541 i = 0;
542 g_signal_connect(G_OBJECT(rings_box[0]), "changed", G_CALLBACK(combox_rings_changed), GINT_TO_POINTER(0));
543 gtk_combo_box_set_active(GTK_COMBO_BOX(rings_box[0]), active_project -> rsearch[0]);
544 widget_set_sensitive (rings_box[1], (active_project -> rsearch[0]<0) ? 0 : 1);
545 }
546 i = 1;
547 g_signal_connect(G_OBJECT(rings_box[1]), "changed", G_CALLBACK(combox_rings_changed), GINT_TO_POINTER(i));
548 gtk_combo_box_set_active(GTK_COMBO_BOX(rings_box[1]), (search_type) ? active_project -> csparam[0] : active_project -> rsparam[j][0]);
549}
550
551#ifdef GTK4
561G_MODULE_EXPORT void run_toggle_bond (GtkNativeDialog * info, gint response_id, gpointer data)
562{
563 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
564#else
574G_MODULE_EXPORT void run_toggle_bond (GtkDialog * info, gint response_id, gpointer data)
575{
576 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
577#endif
578 if (response_id == GTK_RESPONSE_ACCEPT)
579 {
580 active_project -> bondfile = file_chooser_get_file_name (chooser);
581 }
582 else
583 {
584#ifdef GTK4
585 gtk_check_button_set_active ((GtkCheckButton *)data, FALSE);
586#else
587 gtk_toggle_button_set_active ((GtkToggleButton *)data, FALSE);
588#endif
589 }
590#ifdef GTK4
592#else
593 destroy_this_dialog (info);
594#endif
595}
596
597#ifdef GTK4
606G_MODULE_EXPORT void toggle_bond (GtkCheckButton * Button, gpointer data)
607#else
616G_MODULE_EXPORT void toggle_bond (GtkToggleButton * Button, gpointer data)
617#endif
618{
619 int i = GPOINTER_TO_INT (data);
620 gboolean status;
621#ifdef GTK4
622 status = gtk_check_button_get_active (Button);
623#else
624 status = gtk_toggle_button_get_active (Button);
625#endif
626 if (i < 3)
627 {
628 active_project -> runc[i] = status;
629 if (i < 2) widget_set_sensitive (ba_entry[i], status);
630 if (i == 2) frag_update = mol_update = status;
631 }
632 else
633 {
634 if (status)
635 {
636 // To add = do not annoy me with that again !
637 show_info ("Activate this option and the result of the nearest neighbors\n"
638 "analysis will be saved during the search in a file that you may\n"
639 "use afterwards.\n", 0, MainWindow);
640#ifdef GTK4
641 GtkFileChooserNative * info;
642#else
643 GtkWidget * info;
644#endif
645 info = create_file_chooser ("Save neighbors analysis in file",
646 GTK_WINDOW(MainWindow),
647 GTK_FILE_CHOOSER_ACTION_SAVE,
648 "Save");
649 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
650#ifdef GTK3
651 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
652#endif
654 gtk_file_chooser_set_current_name (chooser, "neighbors.dat");
655#ifdef GTK4
656 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_toggle_bond), Button);
657#else
658 run_this_gtk_dialog (info, G_CALLBACK(run_toggle_bond), Button);
659#endif
660 }
661 else
662 {
663 active_project -> bondfile = NULL;
664 }
665 }
666}
667
675gboolean test_gr (int gr)
676{
677 if (active_project -> num_delta[gr] < 2)
678 {
679 show_warning ("You must specify a number of δr >= 2\n"
680 "to discretize the real space between 0.0 and D<sub>max</sub>\n", calc_win);
681 return FALSE;
682 }
683 else if (gr == GK && (active_project -> max[gr] > active_project -> max[SK] || active_project -> max[gr] <= active_project -> min[SK]))
684 {
685 show_warning ("You must specify a maximum wave vector Q<sub>max</sub>[FFT]\n"
686 "for the FFT, with Q<sub>min</sub> < Q<sub>max</sub>[FFT] <= Q<sub>max</sub>", calc_win);
687 return FALSE;
688 }
689 else
690 {
691 return TRUE;
692 }
693}
694
702gboolean test_sq (int sq)
703{
704 if (active_project -> max[sq] <= active_project -> min[sq])
705 {
706 show_warning ("You must specify a maximum wave vector Q<sub>max</sub>\n"
707 "note that Q<sub>max</sub> must be > Q<sub>min</sub>", calc_win);
708 return FALSE;
709 }
710 else if (active_project -> num_delta[sq] < 2)
711 {
712 show_warning ("You must specify a number of δq >= 2\n"
713 "to discretize the reciprocal space between 0.0 and Q<sub>max</sub>\n", calc_win);
714 return FALSE;
715 }
716 else
717 {
718 return TRUE;
719 }
720}
721
727gboolean test_bonds ()
728{
729 if (active_project -> runc[0] && active_project -> num_delta[BD] < 2)
730 {
731 show_warning ("You must specify a number of δr >= 2\n"
732 "to discretize the real space between\n"
733 "the shortest and the highest inter-atomic distances", calc_win);
734 return FALSE;
735 }
736 else if (active_project -> runc[1] && active_project -> num_delta[AN] < 2)
737 {
738 show_warning ("You must specify a number of δ° >= 2\n"
739 "to discretize the angular space between 0 and 180°", calc_win);
740 return FALSE;
741 }
742 else
743 {
744 return TRUE;
745 }
746}
747
753gboolean test_rings ()
754{
755 int i, j;
756 i = (search_type) ? active_project -> csparam[5] : active_project -> rsparam[active_project -> rsearch[0]][1];
757 j = (search_type) ? active_project -> csearch : active_project -> rsearch[1];
758 gchar * sobj[2]={"ring", "chain"};
759 gchar * str;
760 if (i == 0)
761 {
762 str = g_strdup_printf ("You must specify a maximum %s size > 1 for the search", sobj[search_type]);
763 show_warning (str, calc_win);
764 g_free (str);
765 return FALSE;
766 }
767 if (j == 0)
768 {
769 str = g_strdup_printf ("You must specify a number of %ss per size 'n' and per node\n"
770 "this value is used when allocating the memory to store the results\n"
771 "and depends on both the maximum %s size used in the search\n"
772 "and the system studied.\n"
773 "We recommend a value at least equal to 100.\n"
774 "If it appears that the value given is not big enough\n"
775 "(ex: more than 100 different %ss of size 'n' for a single node)\n"
776 "then the search will failed but the program will propose\n"
777 "you to initiate a new search using a higher value",
778 sobj[search_type], sobj[search_type], sobj[search_type]);
779 show_warning (str, calc_win);
780 g_free (str);
781 return FALSE;
782 }
783 return TRUE;
784}
785
791gboolean test_msd ()
792{
793 if(active_project -> steps > 1)
794 {
795 if (active_project -> delta[MS] == 0.0)
796 {
797 show_warning ("You must specify the time step δt\n"
798 "used to integrate the Newton's equations\n"
799 "of motion during the molecular dynamics\n", calc_win);
800 return FALSE;
801 }
802 if (active_project -> tunit < 0)
803 {
804 show_warning ("You must specify the time unit\n"
805 "used to integrate the Newton's equations\n"
806 "of motion during the molecular dynamics\n", calc_win);
807 return FALSE;
808 }
809 else
810 {
811 return TRUE;
812 }
813 }
814 else
815 {
816 if (active_project -> num_delta[MS] < 1)
817 {
818 show_warning ("You must specify the number of steps\n"
819 "between each of the %d configurations\n"
820 "found for the molecular dynamics\n", calc_win);
821 return FALSE;
822 }
823 else
824 {
825 return TRUE;
826 }
827 }
828}
829
835gboolean test_sph ()
836{
837 if (active_project -> num_delta[SP] < 2 || active_project -> num_delta[SP] > 40)
838 {
839 show_warning ("You must specify a number <i>l<sub>max</sub></i> in [2-40]", calc_win);
840 return FALSE;
841 }
842 else
843 {
844 return TRUE;
845 }
846}
847
855void calc_bonds (GtkWidget * vbox)
856{
857 gchar * val_a[2]={"Number of &#x3b4;r [D<sub>ij</sub>min-D<sub>ij</sub>max]",
858 "Number of &#x3b4;&#x3b8; [0-180°]"};
859 gchar * val_b[4]={"First coordination sphere properties",
860 "Bond and dihedral angles distribution",
861 "Search for molecules and isolated fragments",
862 "Output detailed results in text file"};
863
864 GtkWidget * hbox;
865 int i;
866 for (i=0; i<3; i++)
867 {
868 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
869 check_button (val_b[i], -1, 40, active_project -> runc[i], G_CALLBACK(toggle_bond), (gpointer)GINT_TO_POINTER(i)),
870 FALSE, FALSE, 0);
871 if (i < 2)
872 {
873 hbox = create_hbox (0);
874 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
875 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_a[i], 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
876 ba_entry[i] = create_entry (G_CALLBACK(set_delta), 150, 15, FALSE, (gpointer)GINT_TO_POINTER(BD+i));
877 update_entry_int (GTK_ENTRY(ba_entry[i]), active_project -> num_delta[BD+i]);
879 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ba_entry[i], FALSE, FALSE, 0);
880 }
881 }
882 GtkWidget * checkbd = check_button (val_b[i], -1, 40, FALSE, G_CALLBACK(toggle_bond), (gpointer)GINT_TO_POINTER(i));
883 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, checkbd, FALSE, FALSE, 0);
884 widget_set_sensitive (checkbd, 1);
885}
886
895GtkWidget * hbox_note (int i, double val)
896{
897 gchar * note[3] = {"D<sub>max</sub> = ", "Q<sub>min</sub> = ", "Q<sub>max</sub> = "};
898 gchar * unit[3] = {" &#xC5;", " &#xC5;<sup>-1</sup>", " &#xC5;<sup>-1</sup>"};
899 gchar * str;
900 GtkWidget * hbox = create_hbox (0);
901 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (note[i], 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
902 str = g_strdup_printf ("%f", val);
903 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 100, -1, 1.0, 0.5), FALSE, FALSE, 0);
904 g_free (str);
905 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (unit[i], 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
906 return hbox;
907}
908
909GtkWidget * avbox;
910GtkWidget * smbox;
912
921G_MODULE_EXPORT void expand_opt (GtkWidget * exp, gpointer data)
922{
923 int i;
924 i = GPOINTER_TO_INT(data);
925 GtkExpander * expander = GTK_EXPANDER (exp);
926 GtkWidget * wind = get_top_level (exp);
927 gtk_window_set_resizable (GTK_WINDOW (wind), TRUE);
928 if (gtk_expander_get_expanded (expander))
929 {
930 if (i == 1)
931 {
932 gtk_widget_hide (avbox);
933 }
934 else
935 {
936 gtk_widget_hide (smbox);
937 }
938 }
939 else
940 {
941 if (i == 1)
942 {
943 gtk_widget_show (avbox);
944
945 }
946 else
947 {
948 gtk_widget_show (smbox);
949 }
950 }
951 gtk_widget_set_size_request (exp, -1, -1);
952 gtk_window_set_resizable (GTK_WINDOW (wind), FALSE);
953}
954
963G_MODULE_EXPORT void set_advanced_sq (GtkEntry * entry, gpointer data)
964{
965 int c = GPOINTER_TO_INT(data);
966 const gchar * m = entry_get_text (entry);
967 double v = atof(m);
968 if (v != active_project -> sk_advanced[c])
969 {
970 if (c == 0 && (v < 0.0 || v > 1.0))
971 {
972 show_warning ("You must specify a probability between 0.0 and 1.0", calc_win);
973 }
974 else if (c == 1 && (v < active_project -> min[SK] || v > active_project -> max[SK]))
975 {
976 show_warning ("Q<sub>lim</sub> must be &#8805; Q<sub>min</sub> and &#8804; Q<sub>max</sub>", calc_win);
977 }
978 else
979 {
980 active_project -> sk_advanced[c] = v;
981 }
982 }
983 update_entry_double (entry, active_project -> sk_advanced[c]);
984}
985
994G_MODULE_EXPORT void set_sfact (GtkEntry * entry, gpointer data)
995{
996 const gchar * m;
997 int i = GPOINTER_TO_INT(data);
998 m = entry_get_text (entry);
999 double v = atof(m);
1000 if (v <= 0.0 || v >= 1.0)
1001 {
1002 show_warning ("The smoothing factor must be between 0.0 and 1.0", calc_win);
1003 }
1004 else
1005 {
1006 active_project -> fact[i] = v;
1007 }
1008 update_entry_double (entry, active_project -> fact[i]);
1009}
1010
1019G_MODULE_EXPORT void on_show_curve_toolbox (GtkWidget * widg, gpointer data)
1020{
1022 {
1023 gtk_widget_show (curvetoolbox);
1024 }
1025 else
1026 {
1027 gtk_widget_hide (curvetoolbox);
1028 }
1029}
1030
1039G_MODULE_EXPORT void on_smoother_released (GtkButton * button, gpointer data)
1040{
1041 int i, k, l, m;
1042
1043 l = GPOINTER_TO_INT(data);
1044 if (active_project -> visok[l])
1045 {
1046 i = 1;
1047 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1048 active_project -> curves[l][i-1] -> data[1],
1049 & active_project -> fact[l],
1050 & i,
1051 & active_project -> curves[l][i-1] -> ndata,
1052 & l);
1053 i = i+2;
1054 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1055 active_project -> curves[l][i-1] -> data[1],
1056 & active_project -> fact[l],
1057 & i,
1058 & active_project -> curves[l][i-1] -> ndata,
1059 & l);
1060 i = i+2;
1061 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1062 active_project -> curves[l][i-1] -> data[1],
1063 & active_project -> fact[l],
1064 & i,
1065 & active_project -> curves[l][i-1] -> ndata,
1066 & l);
1067 i = i+2;
1068 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1069 active_project -> curves[l][i-1] -> data[1],
1070 & active_project -> fact[l],
1071 & i,
1072 & active_project -> curves[l][i-1] -> ndata,
1073 & l);
1074 if (l == 0 || l == 3)
1075 {
1076 i = i+2;
1077 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1078 active_project -> curves[l][i-1] -> data[1],
1079 & active_project -> fact[l],
1080 & i,
1081 & active_project -> curves[l][i-1] -> ndata,
1082 & l);
1083 i = i+2;
1084 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1085 active_project -> curves[l][i-1] -> data[1],
1086 & active_project -> fact[l],
1087 & i,
1088 & active_project -> curves[l][i-1] -> ndata,
1089 & l);
1090 i = i+2;
1091 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1092 active_project -> curves[l][i-1] -> data[1],
1093 & active_project -> fact[l],
1094 & i,
1095 & active_project -> curves[l][i-1] -> ndata,
1096 & l);
1097 i = i+2;
1098 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1099 active_project -> curves[l][i-1] -> data[1],
1100 & active_project -> fact[l],
1101 & i,
1102 & active_project -> curves[l][i-1] -> ndata,
1103 & l);
1104 }
1105 for (k=0 ; k<active_project -> nspec ; k++)
1106 {
1107 for (m=0 ; m<active_project -> nspec ; m++)
1108 {
1109 i = i+2;
1110 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1111 active_project -> curves[l][i-1] -> data[1],
1112 & active_project -> fact[l],
1113 & i,
1114 & active_project -> curves[l][i-1] -> ndata,
1115 & l);
1116 if (l == 0 || l == 3)
1117 {
1118 i = i+2;
1119 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1120 active_project -> curves[l][i-1] -> data[1],
1121 & active_project -> fact[l],
1122 & i,
1123 & active_project -> curves[l][i-1] -> ndata,
1124 & l);
1125 i = i+1;
1126 }
1127 }
1128 }
1129 if (l == 1 || l == 2)
1130 {
1131 for (k=0 ; k<active_project -> nspec ; k++)
1132 {
1133 for (m=0 ; m<active_project -> nspec ; m++)
1134 {
1135 i = i+2;
1136 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1137 active_project -> curves[l][i-1] -> data[1],
1138 & active_project -> fact[l],
1139 & i,
1140 & active_project -> curves[l][i-1] -> ndata,
1141 & l);
1142 }
1143 }
1144 }
1145 if (active_project -> nspec == 2)
1146 {
1147 m = 3;
1148 if (l == 1 || l == 2) m = m+1;
1149 for (k=0 ; k<m; k++)
1150 {
1151 i = i+2;
1152 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1153 active_project -> curves[l][i-1] -> data[1],
1154 & active_project -> fact[l],
1155 & i,
1156 & active_project -> curves[l][i-1] -> ndata,
1157 & l);
1158 }
1159 }
1160 fill_tool_model ();
1161 gtk_widget_show (curvetoolbox);
1162 if (l == 0 || l == 3)
1163 {
1164 for (i=0; i<4; i=i+3) update_after_calc (i);
1165 }
1166 else
1167 {
1168 for (i=1; i<3; i++) update_after_calc (i);
1169 }
1170 }
1171 else
1172 {
1173 show_error ("No data set(s) to be smoothed\n", 0, calc_win);
1174 }
1175}
1176
1185void calc_gr_sq (GtkWidget * box, int id)
1186{
1187 gchar * val_a[4]={"Number of &#x3b4;r steps",
1188 "Number of &#x3b4;q steps",
1189 "Number of &#x3b4;q steps",
1190 "Number of &#x3b4;r steps"};
1191 gchar * val_b[3]={"Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1192 "Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1193 "Q<sub>max</sub> for the FFT [&#xC5;<sup>-1</sup>]"};
1194
1195 GtkWidget * vbox = create_vbox (5);
1196 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1197 GtkWidget * hbox = create_hbox (0);
1198 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1199 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_a[id], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1200 GtkWidget * entry= create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, GINT_TO_POINTER(id));
1201 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[id]);
1202 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1203 if (id > GR)
1204 {
1205 hbox = create_hbox (0);
1206 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1207 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[id-1], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1208 GtkWidget * entry= create_entry (G_CALLBACK(set_max), 100, 15, FALSE, GINT_TO_POINTER(id));
1209 update_entry_double (GTK_ENTRY(entry), active_project -> max[id]);
1210 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1211 }
1212
1213 if (id == GR || id == GK)
1214 {
1215 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (0, active_project -> max[GR]), FALSE, FALSE, 0);
1216 }
1217 if (id == SQ)
1218 {
1219 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SQ]), FALSE, FALSE, 0);
1220 }
1221 if (id == SK|| id == GK)
1222 {
1223 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SK]), FALSE, FALSE, 0);
1224 }
1225 if (id == GK)
1226 {
1227 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (2, active_project -> max[SK]), FALSE, FALSE, 0);
1228 }
1229 if (id == GR || id == GK)
1230 {
1231 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1232 markup_label ("D<sub>max</sub> is the maximum inter-atomic distance in the model", -1, -1, 0.0, 0.5),
1233 FALSE, FALSE, 0);
1234 }
1235 if (id > 0)
1236 {
1237 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1238 markup_label ("Q<sub>min</sub> is the minimum wave vector for the model", -1, -1, 0.0, 0.5),
1239 FALSE, FALSE, 0);
1240 }
1241 if (id == GK)
1242 {
1243 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1244 markup_label ("Q<sub>max</sub> is the maximum wave vector to compute S(q)", -1, -1, 0.0, 0.5),
1245 FALSE, FALSE, 0);
1246 }
1247
1248 vbox = create_vbox (BSEP);
1249 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1250 GtkWidget * aentry;
1251 if (id == SK)
1252 {
1253 gchar * adv_name[2]={"Probability to keep wave\nvector <i>q</i> > Q<sub>lim</sub> [0.0-1.0]",
1254 "Q<sub>lim</sub> [&#xC5;<sup>-1</sup>] in [Q<sub>min</sub>-Q<sub>max</sub>]"};
1255 GtkWidget * advanced_options = create_expander (" Advanced options", NULL);
1256 gtk_widget_set_size_request (advanced_options, -1, 20);
1257 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, advanced_options, FALSE, TRUE, 10);
1258 avbox = create_vbox (5);
1259 GtkWidget * ahbox;
1260 GtkWidget * fixed;
1261 int i;
1262 for (i=0; i<2; i++)
1263 {
1264 ahbox = create_hbox (5);
1265 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, ahbox, FALSE, FALSE, 5);
1266 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label (adv_name[i], 175, -1, 0.0, 0.5), FALSE, FALSE, 5);
1267 aentry = create_entry (G_CALLBACK(set_advanced_sq), 100, 15, FALSE, GINT_TO_POINTER(i));
1268 update_entry_double (GTK_ENTRY(aentry), active_project -> sk_advanced[i]);
1269 fixed = gtk_fixed_new ();
1270 gtk_fixed_put (GTK_FIXED(fixed), aentry, 0.0, 0.0);
1271 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, fixed, FALSE, FALSE, 10);
1272 }
1273 g_signal_connect (G_OBJECT(advanced_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(1));
1274 add_container_child (CONTAINER_EXP, advanced_options, avbox);
1275 show_the_widgets (advanced_options);
1276 widget_set_sensitive (advanced_options, 1);
1277 }
1278
1279 GtkWidget * smooth_options = create_expander (" Gaussian data smoothing", NULL);
1280 gtk_widget_set_size_request (smooth_options, -1, 20);
1281 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, smooth_options, FALSE, TRUE, 10);
1282 avbox = create_vbox (5);
1283 smbox = create_hbox (0);
1284 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, gtk_label_new("Factor [0.0-1.0]"), FALSE, FALSE, 0);
1285 aentry = create_entry (G_CALLBACK(set_sfact), 100, 15, FALSE, GINT_TO_POINTER(id));
1286 update_entry_double (GTK_ENTRY(aentry), active_project -> fact[id]);
1287 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, aentry, FALSE, TRUE, 10);
1288 GtkWidget * smooth = create_button ("Smooth", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_smoother_released), GINT_TO_POINTER(id));
1289 g_signal_connect (G_OBJECT(smooth_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(0));
1290 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, smooth, FALSE, FALSE, 0);
1291 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, smbox, FALSE, FALSE, 5);
1292 add_container_child (CONTAINER_EXP, smooth_options, avbox);
1293 show_the_widgets (smooth_options);
1294 widget_set_sensitive (smooth_options, 1);
1295}
1296
1306G_MODULE_EXPORT void run_on_calc_activate (GtkDialog * dial, gint response_id, gpointer data)
1307{
1308 int i;
1309 int id = GPOINTER_TO_INT(data);
1310 switch (response_id)
1311 {
1312 case GTK_RESPONSE_APPLY:
1313 switch (id)
1314 {
1315 case GR:
1316 if (test_gr (GR)) on_calc_gr_released (calc_win, NULL);
1317 break;
1318 case SQ:
1319 if (test_sq (SQ)) on_calc_sq_released (calc_win, NULL);
1320 break;
1321 case SK:
1322 if (test_sq (SK)) on_calc_sk_released (calc_win, NULL);
1323 break;
1324 case GK:
1325 if (test_gr (GK)) on_calc_gq_released (calc_win, NULL);
1326 break;
1327 case BD:
1329 break;
1330 case RI-1:
1331 if (test_rings ())
1332 {
1333 //gtk_widget_show (spinner);
1334 //gtk_spinner_start (GTK_SPINNER(spinner));
1336 toggled_rings = FALSE;
1337 //gtk_spinner_stop (GTK_SPINNER(spinner));
1338 //gtk_widget_hide (spinner);
1339 }
1340 break;
1341 case CH-1:
1342 if (test_rings ())
1343 {
1344 //gtk_widget_show (spinner);
1345 //gtk_spinner_start (GTK_SPINNER(spinner));
1347 //gtk_spinner_stop (GTK_SPINNER(spinner));
1348 //gtk_widget_hide (spinner);
1349 }
1350 break;
1351 case SP-1:
1352 if (test_sph ()) on_calc_sph_released (calc_win, NULL);
1353 break;
1354 case MS-1:
1355 if (test_msd ()) on_calc_msd_released (calc_win, NULL);
1356 break;
1357 default:
1358 break;
1359 }
1360 break;
1361 default:
1362 frag_update = mol_update = 0;
1363 for (i=0; i<3; i++) active_project -> runc[i] = FALSE;
1364 destroy_this_dialog (dial);
1366 avbox = NULL;
1367 }
1368}
1369
1378G_MODULE_EXPORT void on_calc_activate (GtkWidget * widg, gpointer data)
1379{
1380 int id = GPOINTER_TO_INT(data);
1381 calc_win = calc_window(id);
1382 GtkWidget * box = dialog_get_content_area (calc_win);
1383 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
1384 switch (id)
1385 {
1386 case BD:
1387 calc_bonds (box);
1388 break;
1389 case RI-1:
1390 search_type = 0;
1391 calc_rings (box);
1392 break;
1393 case CH-1:
1394 search_type = 1;
1395 calc_rings (box);
1396 break;
1397 case SP-1:
1398 calc_sph (box);
1399 break;
1400 case MS-1:
1401 calc_msd (box);
1402 break;
1403 case 9:
1404 // calc_valence (box);
1405 break;
1406 default:
1407 calc_gr_sq (box, id);
1408 break;
1409 }
1410
1411#ifndef GTK4
1412 gtk_window_set_icon (GTK_WINDOW (calc_win), gdk_pixbuf_new_from_file(calc_img[id], NULL));
1413#endif
1414 GtkWidget * vbox = create_vbox (BSEP);
1415 gtk_widget_set_size_request (vbox, -1, 30);
1416 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1417 /*GtkWidget * spinner = gtk_spinner_new ();
1418 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spinner, FALSE, FALSE, 0);
1419 gtk_widget_set_size_request (spinner, -1, 30);
1420 gtk_widget_hide (spinner);*/
1422}
Binding to the Fortran90 subroutines.
int smooth_and_save_(double *, double *, double *, int *, int *, int *)
gboolean test_sph()
is it safe to compute spherical harmonics ?
Definition calc_menu.c:835
void calc_bonds(GtkWidget *vbox)
creation of the bond calculation widgets
Definition calc_menu.c:855
G_MODULE_EXPORT void combox_tunit_changed(GtkComboBox *box, gpointer data)
change time units
Definition calc_menu.c:220
G_MODULE_EXPORT void on_calc_msd_released(GtkWidget *widg, gpointer data)
compute MSD
Definition msdcall.c:153
void calc_msd(GtkWidget *vbox)
creation of the MSD calculation widgets
Definition calc_menu.c:252
GtkWidget * combox_rings(gchar *str, int num, gchar *list_item[num], int id)
create a combo box for the rings statistics calculation
Definition calc_menu.c:336
GtkWidget * rings_box[2]
Definition calc_menu.c:135
GtkWidget * smbox
Definition calc_menu.c:910
G_MODULE_EXPORT void on_show_curve_toolbox(GtkWidget *widg, gpointer data)
show the curve toolboxes
Definition calc_menu.c:1019
G_MODULE_EXPORT void on_calc_rings_released(GtkWidget *widg, gpointer data)
compute ring statistics
Definition ringscall.c:439
gboolean toggled_rings
Definition ringscall.c:74
int avsize
Definition calc_menu.c:911
G_MODULE_EXPORT void toggle_bond(GtkToggleButton *Button, gpointer data)
activate bond properties detailed saving and prepare the dialog
Definition calc_menu.c:616
GtkWidget * hbox_note(int i, double val)
foot note message box with some parameters
Definition calc_menu.c:895
G_MODULE_EXPORT void combox_rings_changed(GtkComboBox *box, gpointer data)
change rings statistics calculation parameter
Definition calc_menu.c:360
void calc_sph(GtkWidget *vbox)
creation of the spherical harmonics calculation widgets
Definition calc_menu.c:232
GtkWidget * rings_entry[2]
Definition calc_menu.c:349
G_MODULE_EXPORT void on_calc_chains_released(GtkWidget *widg, gpointer data)
compute chains statistics
Definition chainscall.c:299
gboolean test_rings()
is it safe to compute ring statistics ?
Definition calc_menu.c:753
gchar * calc_img[NCALCS-2]
Definition gui.c:104
gboolean test_gr(int gr)
is it safe to compute g(r) ?
Definition calc_menu.c:675
gboolean test_sq(int sq)
is it safe to compute s(q) ?
Definition calc_menu.c:702
G_MODULE_EXPORT void run_on_calc_activate(GtkDialog *dial, gint response_id, gpointer data)
create a calculation dialog: run the dialog
Definition calc_menu.c:1306
G_MODULE_EXPORT void on_calc_gq_released(GtkWidget *widg, gpointer data)
compute g(k)
Definition grcall.c:324
gboolean test_bonds()
is it safe to compute bond properties ?
Definition calc_menu.c:727
G_MODULE_EXPORT void run_toggle_bond(GtkDialog *info, gint response_id, gpointer data)
bond properties detailed saving: run the dialog
Definition calc_menu.c:574
G_MODULE_EXPORT void on_calc_gr_released(GtkWidget *widg, gpointer data)
compute g(r)
Definition grcall.c:199
GtkWidget * ba_entry[2]
Definition calc_menu.c:90
GtkWidget * avbox
Definition calc_menu.c:909
G_MODULE_EXPORT void on_calc_sph_released(GtkWidget *widg, gpointer data)
compute spherical harmonics
Definition spcall.c:188
G_MODULE_EXPORT void set_numa(GtkEntry *entry, gpointer data)
set the rings/chains statistics parameter NUMA
Definition calc_menu.c:300
G_MODULE_EXPORT void on_calc_activate(GtkWidget *widg, gpointer data)
create a calculation dialog - prepare the dialog
Definition calc_menu.c:1378
G_MODULE_EXPORT void expand_opt(GtkWidget *exp, gpointer data)
open expander actions
Definition calc_menu.c:921
G_MODULE_EXPORT void set_advanced_sq(GtkEntry *entry, gpointer data)
set a s(k) calculation parameter
Definition calc_menu.c:963
G_MODULE_EXPORT void toggle_rings(GtkToggleButton *but, gpointer data)
toggle a rings statistics calculation parameter
Definition calc_menu.c:415
G_MODULE_EXPORT void on_smoother_released(GtkButton *button, gpointer data)
smooth g(r), s(q), s(k) or g(k)
Definition calc_menu.c:1039
GtkWidget * rings_check[4]
Definition calc_menu.c:350
G_MODULE_EXPORT void set_sfact(GtkEntry *entry, gpointer data)
set the Gaussian smoothing factor
Definition calc_menu.c:994
G_MODULE_EXPORT void on_calc_sk_released(GtkWidget *widg, gpointer data)
compute s(q) / s(k)
Definition sqcall.c:244
G_MODULE_EXPORT void on_calc_sq_released(GtkWidget *widg, gpointer data)
compute s(q) / s(k)
Definition sqcall.c:192
void calc_rings(GtkWidget *vbox)
creation of the rings statistics calculation widgets
Definition calc_menu.c:474
G_MODULE_EXPORT void set_delta(GtkEntry *entry, gpointer data)
set the number of delta between data points
Definition calc_menu.c:145
G_MODULE_EXPORT void set_max(GtkEntry *entry, gpointer data)
set a maximum value
Definition calc_menu.c:119
int search_type
Definition calc_menu.c:91
gboolean test_msd()
is it safe to compute MSD ?
Definition calc_menu.c:791
void calc_gr_sq(GtkWidget *box, int id)
creation of the g(r) / s(q) / s(k) / g(k) calculation widgets
Definition calc_menu.c:1185
GtkWidget * calc_window(int i)
create a calculation window
Definition calc_menu.c:100
GtkWidget * calc_win
Definition calc_menu.c:89
Callback declarations for main window.
void fill_tool_model()
fill the tool window tree model
Definition tools.c:87
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
float val
Definition dlp_init.c:117
char * untime[6]
Definition global.c:149
int mol_update
Definition global.c:171
int frag_update
Definition global.c:170
GtkWidget * MainWindow
Definition global.c:214
GtkWidget * curvetoolbox
Definition global.c:218
GtkWidget * calc_dialog
Definition global.c:222
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * dialog_cancel_apply(gchar *title, GtkWidget *parent, gboolean resiz)
create a dialog modal offering a choice to apply something or not
Definition gtk-misc.c:541
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:472
@ IMG_NONE
Definition global.h:232
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2164
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1294
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:613
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:694
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2112
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
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:594
#define GR
Definition global.h:294
#define SQ
Definition global.h:295
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1779
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:471
#define RI
Definition global.h:300
@ CONTAINER_EXP
Definition global.h:227
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1843
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
Definition gtk-misc.c:2291
#define BD
Definition global.h:298
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 widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:186
#define AN
Definition global.h:299
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2041
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:793
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:880
#define MS
Definition global.h:303
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2010
#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
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:781
#define SK
Definition global.h:296
#define GK
Definition global.h:297
GtkWidget * create_expander(gchar *name, gchar *file_img)
create GtkExpander
Definition gtk-misc.c:1964
GtkWidget * create_file_chooser(const gchar *title, GtkWindow *parent, GtkFileChooserAction act, const gchar *act_name)
create a GtkFileChooser, utility to select file(s)
Definition gtk-misc.c:2199
#define SP
Definition global.h:302
project * active_project
Definition project.c:47
#define NCALCS
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2060
#define CH
Definition global.h:301
char * calc_name[NCALCS-2]
Definition gui.c:107
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:169
#define max(a, b)
Definition global.h:74
void show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:260
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:234
void show_error(char *error, int val, GtkWidget *win)
show error message
Definition interface.c:293
void update_after_calc(int calc)
To update all curve plots in the workspace after a calculation.
Definition interface.c:977
Messaging function declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int c
Definition tab-1.c:95
logical function smooth(tabtoliss, gtoliss, dimtoliss, sigmaliss)
Definition utils.F90:612
int status
Definition w_advance.c:160
atom_search * csearch
Definition w_search.c:2718
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
Function declarations for workspace managment.