atomes 1.1.15
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 show_the_widgets (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 = string_to_double ((gpointer)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 = string_to_double ((gpointer)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 = string_to_double ((gpointer)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 {
933 }
934 else
935 {
937 }
938 }
939 else
940 {
941 if (i == 1)
942 {
944
945 }
946 else
947 {
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 = string_to_double ((gpointer)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 = string_to_double ((gpointer)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 {
1024 }
1025 else
1026 {
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 if (l == 2)
1047 {
1048 xsk = duplicate_double(active_project -> curves[l][0] -> ndata, active_project -> curves[l][0] -> data[0]);
1049 }
1050 i = 1;
1051 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1052 active_project -> curves[l][i-1] -> data[1],
1053 & active_project -> fact[l],
1054 & i,
1055 & active_project -> curves[l][i-1] -> ndata,
1056 & l);
1057 i = i+2;
1058 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1059 active_project -> curves[l][i-1] -> data[1],
1060 & active_project -> fact[l],
1061 & i,
1062 & active_project -> curves[l][i-1] -> ndata,
1063 & l);
1064 i = i+2;
1065 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1066 active_project -> curves[l][i-1] -> data[1],
1067 & active_project -> fact[l],
1068 & i,
1069 & active_project -> curves[l][i-1] -> ndata,
1070 & l);
1071 i = i+2;
1072 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1073 active_project -> curves[l][i-1] -> data[1],
1074 & active_project -> fact[l],
1075 & i,
1076 & active_project -> curves[l][i-1] -> ndata,
1077 & l);
1078 if (l == 0 || l == 3)
1079 {
1080 i = i+2;
1081 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1082 active_project -> curves[l][i-1] -> data[1],
1083 & active_project -> fact[l],
1084 & i,
1085 & active_project -> curves[l][i-1] -> ndata,
1086 & l);
1087 i = i+2;
1088 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1089 active_project -> curves[l][i-1] -> data[1],
1090 & active_project -> fact[l],
1091 & i,
1092 & active_project -> curves[l][i-1] -> ndata,
1093 & l);
1094 i = i+2;
1095 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1096 active_project -> curves[l][i-1] -> data[1],
1097 & active_project -> fact[l],
1098 & i,
1099 & active_project -> curves[l][i-1] -> ndata,
1100 & l);
1101 i = i+2;
1102 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1103 active_project -> curves[l][i-1] -> data[1],
1104 & active_project -> fact[l],
1105 & i,
1106 & active_project -> curves[l][i-1] -> ndata,
1107 & l);
1108 }
1109 for (k=0 ; k<active_project -> nspec ; k++)
1110 {
1111 for (m=0 ; m<active_project -> nspec ; m++)
1112 {
1113 i = i+2;
1114 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1115 active_project -> curves[l][i-1] -> data[1],
1116 & active_project -> fact[l],
1117 & i,
1118 & active_project -> curves[l][i-1] -> ndata,
1119 & l);
1120 if (l == 0 || l == 3)
1121 {
1122 i = i+2;
1123 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1124 active_project -> curves[l][i-1] -> data[1],
1125 & active_project -> fact[l],
1126 & i,
1127 & active_project -> curves[l][i-1] -> ndata,
1128 & l);
1129 i = i+1;
1130 }
1131 }
1132 }
1133 if (l == 1 || l == 2)
1134 {
1135 for (k=0 ; k<active_project -> nspec ; k++)
1136 {
1137 for (m=0 ; m<active_project -> nspec ; m++)
1138 {
1139 i = i+2;
1140 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1141 active_project -> curves[l][i-1] -> data[1],
1142 & active_project -> fact[l],
1143 & i,
1144 & active_project -> curves[l][i-1] -> ndata,
1145 & l);
1146 }
1147 }
1148 }
1149 if (active_project -> nspec == 2)
1150 {
1151 m = 3;
1152 if (l == 1 || l == 2) m = m+1;
1153 for (k=0 ; k<m; k++)
1154 {
1155 i = i+2;
1156 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1157 active_project -> curves[l][i-1] -> data[1],
1158 & active_project -> fact[l],
1159 & i,
1160 & active_project -> curves[l][i-1] -> ndata,
1161 & l);
1162 }
1163 }
1164 if (l == 2)
1165 {
1166 g_free (xsk);
1167 xsk = NULL;
1168 }
1169 fill_tool_model ();
1171 if (l == 0 || l == 3)
1172 {
1173 for (i=0; i<4; i=i+3) update_after_calc (i);
1174 }
1175 else
1176 {
1177 for (i=1; i<3; i++) update_after_calc (i);
1178 }
1179 }
1180 else
1181 {
1182 show_error ("No data set(s) to be smoothed\n", 0, calc_win);
1183 }
1184}
1185
1194void calc_gr_sq (GtkWidget * box, int id)
1195{
1196 gchar * val_a[4]={"Number of &#x3b4;r steps",
1197 "Number of &#x3b4;q steps",
1198 "Number of &#x3b4;q steps",
1199 "Number of &#x3b4;r steps"};
1200 gchar * val_b[3]={"Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1201 "Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1202 "Q<sub>max</sub> for the FFT [&#xC5;<sup>-1</sup>]"};
1203
1204 GtkWidget * vbox = create_vbox (5);
1205 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1206 GtkWidget * hbox = create_hbox (0);
1207 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1208 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_a[id], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1209 GtkWidget * entry= create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, GINT_TO_POINTER(id));
1210 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[id]);
1211 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1212 if (id > GR)
1213 {
1214 hbox = create_hbox (0);
1215 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1216 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[id-1], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1217 GtkWidget * entry= create_entry (G_CALLBACK(set_max), 100, 15, FALSE, GINT_TO_POINTER(id));
1218 update_entry_double (GTK_ENTRY(entry), active_project -> max[id]);
1219 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1220 }
1221
1222 if (id == GR || id == GK)
1223 {
1224 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (0, active_project -> max[GR]), FALSE, FALSE, 0);
1225 }
1226 if (id == SQ)
1227 {
1228 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SQ]), FALSE, FALSE, 0);
1229 }
1230 if (id == SK|| id == GK)
1231 {
1232 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SK]), FALSE, FALSE, 0);
1233 }
1234 if (id == GK)
1235 {
1236 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (2, active_project -> max[SK]), FALSE, FALSE, 0);
1237 }
1238 if (id == GR || id == GK)
1239 {
1240 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1241 markup_label ("D<sub>max</sub> is the maximum inter-atomic distance in the model", -1, -1, 0.0, 0.5),
1242 FALSE, FALSE, 0);
1243 }
1244 if (id > 0)
1245 {
1246 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1247 markup_label ("Q<sub>min</sub> is the minimum wave vector for the model", -1, -1, 0.0, 0.5),
1248 FALSE, FALSE, 0);
1249 }
1250 if (id == GK)
1251 {
1252 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1253 markup_label ("Q<sub>max</sub> is the maximum wave vector to compute S(q)", -1, -1, 0.0, 0.5),
1254 FALSE, FALSE, 0);
1255 }
1256
1257 vbox = create_vbox (BSEP);
1258 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1259 GtkWidget * aentry;
1260 if (id == SK)
1261 {
1262 gchar * adv_name[2]={"Probability to keep wave\nvector <i>q</i> > Q<sub>lim</sub> [0.0-1.0]",
1263 "Q<sub>lim</sub> [&#xC5;<sup>-1</sup>] in [Q<sub>min</sub>-Q<sub>max</sub>]"};
1264 GtkWidget * advanced_options = create_expander (" Advanced options", NULL);
1265 gtk_widget_set_size_request (advanced_options, -1, 20);
1266 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, advanced_options, FALSE, TRUE, 10);
1267 avbox = create_vbox (5);
1268 GtkWidget * ahbox;
1269 GtkWidget * fixed;
1270 int i;
1271 for (i=0; i<2; i++)
1272 {
1273 ahbox = create_hbox (5);
1274 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, ahbox, FALSE, FALSE, 5);
1275 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label (adv_name[i], 175, -1, 0.0, 0.5), FALSE, FALSE, 5);
1276 aentry = create_entry (G_CALLBACK(set_advanced_sq), 100, 15, FALSE, GINT_TO_POINTER(i));
1277 update_entry_double (GTK_ENTRY(aentry), active_project -> sk_advanced[i]);
1278 fixed = gtk_fixed_new ();
1279 gtk_fixed_put (GTK_FIXED(fixed), aentry, 0.0, 0.0);
1280 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, fixed, FALSE, FALSE, 10);
1281 }
1282 g_signal_connect (G_OBJECT(advanced_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(1));
1283 add_container_child (CONTAINER_EXP, advanced_options, avbox);
1284 show_the_widgets (advanced_options);
1285 widget_set_sensitive (advanced_options, 1);
1286 }
1287
1288 GtkWidget * smooth_options = create_expander (" Gaussian data smoothing", NULL);
1289 gtk_widget_set_size_request (smooth_options, -1, 20);
1290 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, smooth_options, FALSE, TRUE, 10);
1291 avbox = create_vbox (5);
1292 smbox = create_hbox (0);
1293 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, gtk_label_new("Factor [0.0-1.0]"), FALSE, FALSE, 0);
1294 aentry = create_entry (G_CALLBACK(set_sfact), 100, 15, FALSE, GINT_TO_POINTER(id));
1295 update_entry_double (GTK_ENTRY(aentry), active_project -> fact[id]);
1296 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, aentry, FALSE, TRUE, 10);
1297 GtkWidget * smooth = create_button ("Smooth", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_smoother_released), GINT_TO_POINTER(id));
1298 g_signal_connect (G_OBJECT(smooth_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(0));
1299 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, smooth, FALSE, FALSE, 0);
1300 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, smbox, FALSE, FALSE, 5);
1301 add_container_child (CONTAINER_EXP, smooth_options, avbox);
1302 show_the_widgets (smooth_options);
1303 widget_set_sensitive (smooth_options, 1);
1304}
1305
1315G_MODULE_EXPORT void run_on_calc_activate (GtkDialog * dial, gint response_id, gpointer data)
1316{
1317 int i;
1318 int id = GPOINTER_TO_INT(data);
1319 switch (response_id)
1320 {
1321 case GTK_RESPONSE_APPLY:
1322 switch (id)
1323 {
1324 case GR:
1325 if (test_gr (GR)) on_calc_gr_released (calc_win, NULL);
1326 break;
1327 case SQ:
1328 if (test_sq (SQ)) on_calc_sq_released (calc_win, NULL);
1329 break;
1330 case SK:
1331 if (test_sq (SK)) on_calc_sk_released (calc_win, NULL);
1332 break;
1333 case GK:
1334 if (test_gr (GK)) on_calc_gq_released (calc_win, NULL);
1335 break;
1336 case BD:
1338 break;
1339 case RI-1:
1340 if (test_rings ())
1341 {
1342 //show_the_widgets (spinner);
1343 //gtk_spinner_start (GTK_SPINNER(spinner));
1345 toggled_rings = FALSE;
1346 //gtk_spinner_stop (GTK_SPINNER(spinner));
1347 //hide_the_widgets (spinner);
1348 }
1349 break;
1350 case CH-1:
1351 if (test_rings ())
1352 {
1353 //show_the_widgets (spinner);
1354 //gtk_spinner_start (GTK_SPINNER(spinner));
1356 //gtk_spinner_stop (GTK_SPINNER(spinner));
1357 //hide_the_widgets (spinner);
1358 }
1359 break;
1360 case SP-1:
1361 if (test_sph ()) on_calc_sph_released (calc_win, NULL);
1362 break;
1363 case MS-1:
1364 if (test_msd ()) on_calc_msd_released (calc_win, NULL);
1365 break;
1366 default:
1367 break;
1368 }
1369 break;
1370 default:
1371 frag_update = mol_update = 0;
1372 for (i=0; i<3; i++) active_project -> runc[i] = FALSE;
1373 destroy_this_dialog (dial);
1375 avbox = NULL;
1376 }
1377}
1378
1387G_MODULE_EXPORT void on_calc_activate (GtkWidget * widg, gpointer data)
1388{
1389 int id = GPOINTER_TO_INT(data);
1390 calc_win = calc_window(id);
1391 GtkWidget * box = dialog_get_content_area (calc_win);
1392 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
1393 switch (id)
1394 {
1395 case BD:
1396 calc_bonds (box);
1397 break;
1398 case RI-1:
1399 search_type = 0;
1400 calc_rings (box);
1401 break;
1402 case CH-1:
1403 search_type = 1;
1404 calc_rings (box);
1405 break;
1406 case SP-1:
1407 calc_sph (box);
1408 break;
1409 case MS-1:
1410 calc_msd (box);
1411 break;
1412 case 9:
1413 // calc_valence (box);
1414 break;
1415 default:
1416 calc_gr_sq (box, id);
1417 break;
1418 }
1419
1420#ifndef GTK4
1421 gtk_window_set_icon (GTK_WINDOW (calc_win), gdk_pixbuf_new_from_file(calc_img[id], NULL));
1422#endif
1423 GtkWidget * vbox = create_vbox (BSEP);
1424 gtk_widget_set_size_request (vbox, -1, 30);
1425 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1426 /*GtkWidget * spinner = gtk_spinner_new ();
1427 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spinner, FALSE, FALSE, 0);
1428 gtk_widget_set_size_request (spinner, -1, 30);
1429 hide_the_widgets (spinner);*/
1431}
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:105
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:1315
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:1387
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:1194
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
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:608
double * xsk
Definition global.c:176
int frag_update
Definition global.c:170
GtkWidget * MainWindow
Definition global.c:201
GtkWidget * curvetoolbox
Definition global.c:205
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
GtkWidget * calc_dialog
Definition global.c:210
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:561
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:492
@ IMG_NONE
Definition global.h:260
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2188
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:714
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2136
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:597
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:245
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:614
#define GR
Definition global.h:322
#define SQ
Definition global.h:323
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:471
#define RI
Definition global.h:328
@ CONTAINER_EXP
Definition global.h:255
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:1863
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
Definition gtk-misc.c:2315
#define BD
Definition global.h:326
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:923
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:825
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
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:299
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
#define AN
Definition global.h:327
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2065
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
#define MS
Definition global.h:331
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
#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:226
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
#define SK
Definition global.h:324
#define GK
Definition global.h:325
GtkWidget * create_expander(gchar *name, gchar *file_img)
create GtkExpander
Definition gtk-misc.c:1984
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:2223
#define SP
Definition global.h:330
project * active_project
Definition project.c:47
#define NCALCS
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2084
#define CH
Definition global.h:329
char * calc_name[NCALCS-2]
Definition gui.c:122
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
#define max(a, b)
Definition global.h:80
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.