atomes 1.2.1
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-2025 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 "preferences.h"
75#include "bind.h"
76#include "project.h"
77#include "workspace.h"
78
79extern G_MODULE_EXPORT void on_calc_gr_released (GtkWidget * widg, gpointer data);
80extern G_MODULE_EXPORT void on_calc_gq_released (GtkWidget * widg, gpointer data);
81extern G_MODULE_EXPORT void on_calc_sq_released (GtkWidget * widg, gpointer data);
82extern G_MODULE_EXPORT void on_calc_sk_released (GtkWidget * widg, gpointer data);
83extern gboolean toggled_rings;
84extern G_MODULE_EXPORT void on_calc_rings_released (GtkWidget * widg, gpointer data);
85extern G_MODULE_EXPORT void on_calc_chains_released (GtkWidget * widg, gpointer data);
86extern G_MODULE_EXPORT void on_calc_msd_released (GtkWidget * widg, gpointer data);
87extern G_MODULE_EXPORT void on_calc_sph_released (GtkWidget * widg, gpointer data);
88extern gchar * calc_img[NCALCS-2];
89
90GtkWidget * calc_win = NULL;
91GtkWidget * ba_entry[2];
93
101GtkWidget * calc_window (int i)
102{
104#ifndef GTK4
105 /* GtkWidget * apply_button =
106 button_set_image (GTK_BUTTON(apply_button), calc_name[i], IMG_FILE, (gpointer)calc_img[i]);
107 show_the_widgets (apply_button); */
108#endif
109 return calc_dialog;
110}
111
120G_MODULE_EXPORT void set_max (GtkEntry * entry, gpointer data)
121{
122 int c = GPOINTER_TO_INT(data);
123 const gchar * m = entry_get_text (entry);
124 double v = string_to_double ((gpointer)m);
125 if (v > 0)
126 {
127 if (active_project -> max[c] != v)
128 {
129 active_project -> max[c] = v;
130 // Max has changed do something !?
131 }
132 }
134}
135
136GtkWidget * rings_box[2];
137
146G_MODULE_EXPORT void set_delta (GtkEntry * entry, gpointer data)
147{
148 int c = GPOINTER_TO_INT(data);
149 const gchar * m = entry_get_text (entry);
150 double v = string_to_double ((gpointer)m);
151 int i, j, k;
152 i = (int)v;
153 if (c == RI)
154 {
155 if (preferences)
156 {
157 k = tmp_rsparam[2];
158 }
159 else
160 {
162 k = active_project -> rsparam[j][1];
163 }
164 }
165 else if (c == CH)
166 {
167 k = (preferences) ? tmp_csparam[1] : active_project -> csparam[5];
168 }
169 else if (c > -1 && ! preferences)
170 {
171 k = active_project -> num_delta[c];
172 }
173 if (c < 0 && ! preferences)
174 {
175 if (v > 0.0)
176 {
177 if (active_project -> delta[-c] != v)
178 {
179 active_project -> delta[-c] = v;
180 }
181 }
182 }
183 else if (i > 0 && ! preferences)
184 {
185 if (c == RI)
186 {
187 if (active_project -> rsparam[j][1] != i)
188 {
189 active_project -> rsparam[j][1] = i;
190 }
191 k = active_project -> rsparam[j][1] = i;
192 }
193 else if (c == CH)
194 {
195 if (active_project -> csparam[5] != i)
196 {
197 active_project -> csparam[5] = i;
198 }
199 k = active_project -> csparam[5] = i;
200 }
201 else
202 {
203 if (active_project -> num_delta[c] != i)
204 {
205 active_project -> num_delta[c] = i;
206 }
207 k = active_project -> num_delta[c];
208 }
209 }
210 if (c < 0)
211 {
212 update_entry_double (entry, active_project -> delta[-c]);
213 }
214 else
215 {
216 update_entry_int (entry, k);
217 }
218}
219
228G_MODULE_EXPORT void combox_tunit_changed (GtkComboBox * box, gpointer data)
229{
230 active_project -> tunit = combo_get_active ((GtkWidget *)box);
231}
232
240void calc_sph (GtkWidget * vbox)
241{
242 GtkWidget * hbox;
243 GtkWidget * entry;
244 hbox = create_hbox (0);
245 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
246 gchar * str = "Maximum <b><i>l</i></b>, <i>l<sub>max</sub></i> in [2-40]";
247 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
248 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(SP));
249 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[SP]);
250 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
251}
252
260void calc_msd (GtkWidget * vbox)
261{
262 int i, j;
263 gchar * val_b[3]={"Number of configurations:",
264 "\tTime step &#x3b4;t used during the dynamics:",
265 "\tNumber of step(s) between each configuration:"};
266 GtkWidget * hbox;
267 GtkWidget * entry;
268 hbox = create_hbox (15);
269 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
270 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, gtk_label_new (val_b[0]), FALSE, FALSE, 0);
271 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);
272 for (i=1; i<3; i++)
273 {
274 hbox = create_hbox (15);
275 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
276 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[i], 350, -1, 0.0, 0.5), FALSE, FALSE, 0);
277 if (i == 1)
278 {
279 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(-MS));
280 update_entry_double (GTK_ENTRY(entry), active_project -> delta[MS]);
281 }
282 else
283 {
284 entry = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, (gpointer)GINT_TO_POINTER(MS));
285 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[MS]);
286 }
287 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
288 if (i == 1)
289 {
290 GtkWidget * tcombo = create_combo ();
291 for (j=0; j<5 ; j++) combo_text_append (tcombo, untime[j]);
292 combo_set_active (tcombo, active_project -> tunit);
293 g_signal_connect(G_OBJECT(tcombo), "changed", G_CALLBACK(combox_tunit_changed), NULL);
294 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, tcombo, FALSE, FALSE, 0);
295 }
296 }
297}
298
307G_MODULE_EXPORT void set_numa (GtkEntry * entry, gpointer data)
308{
309 const gchar * m = entry_get_text (entry);
310 double v = string_to_double ((gpointer)m);
311 int i, j;
312 i = (int)v;
313 if (i > 0)
314 {
315 if (! search_type)
316 {
317 if (preferences)
318 {
319 tmp_rsparam[3] = i;
320 }
321 else
322 {
323 if (active_project -> rsearch[1] != i) active_project -> rsearch[1] = i;
324 j = active_project -> rsearch[1];
325 }
326 }
327 else
328 {
329 if (preferences)
330 {
331 tmp_csparam[2] = i;
332 }
333 else
334 {
335 if (active_project -> csearch != i) active_project -> csearch = i;
336 j = active_project -> csearch;
337 }
338 }
339 }
340 else
341 {
342 if (preferences)
343 {
344 j = (search_type) ? tmp_csparam[2] : tmp_rsparam[3];
345 }
346 else
347 {
348 j = (search_type) ? active_project -> csearch : active_project -> rsearch[1];
349 }
350 }
351 update_entry_int (entry, j);
352}
353
364GtkWidget * combox_rings (gchar * str, int num, gchar * list_item[num], int id)
365{
366 int i;
367 GtkWidget * hbox = create_hbox (0);
368 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 250, -1, 0.0, 0.5), FALSE, FALSE, 0);
369 // GtkWidget * fixed = gtk_fixed_new ();
370 rings_box[id] = create_combo ();
371 gtk_widget_set_size_request (rings_box[id], 180, -1);
372 for (i=0; i<num; i++) combo_text_append (rings_box[id], list_item[i]);
373 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, rings_box[id], FALSE, FALSE, 10);
374
375 //gtk_fixed_put (GTK_FIXED(fixed), rings_box[id], -1, 5);
376
377 return hbox;
378}
379
380 GtkWidget * rings_entry[2];
381 GtkWidget * rings_check[4];
382
391G_MODULE_EXPORT void combox_rings_changed (GtkComboBox * box, gpointer data)
392{
393 int i, j;
394 int id = GPOINTER_TO_INT(data);
395 if (id == 0)
396 {
397 if (preferences)
398 {
399 tmp_rsparam[0] = combo_get_active ((GtkWidget *)box);
400 }
401 else
402 {
403 active_project -> rsearch[0] = combo_get_active ((GtkWidget *)box);
404 widget_set_sensitive (rings_box[1], (active_project -> rsearch[0]<0) ? 0 : 1);
405 combo_set_active (rings_box[1], active_project -> rsparam[active_project -> rsearch[0]][0]);
406 for (i=0; i<2; i++) widget_set_sensitive (rings_entry[i], (active_project -> rsearch[0]<0) ? 0 : 1);
407 for (i=0; i<3; i++) widget_set_sensitive (rings_check[i], (active_project -> rsearch[0]<0) ? 0 : 1);
408 update_entry_int (GTK_ENTRY(rings_entry[0]), active_project -> rsparam[active_project -> rsearch[0]][1]);
410 for (j=0; j<3; j++)
411 {
412 button_set_status (rings_check[j], active_project -> rsparam[i][j+2]);
413 }
414 }
415 }
416 else
417 {
418 if (search_type)
419 {
420 if (preferences)
421 {
422 tmp_csparam[0] = combo_get_active ((GtkWidget *)box);
423 }
424 else
425 {
426 active_project -> csparam[0] = combo_get_active ((GtkWidget *)box);
427 }
428 }
429 else
430 {
431 if (preferences)
432 {
433 tmp_rsparam[1] = combo_get_active ((GtkWidget *)box);
434 }
435 else
436 {
438 active_project -> rsparam[i][0] = combo_get_active ((GtkWidget *)box);
439 }
440 }
441 }
442}
443
444#ifdef GTK4
453G_MODULE_EXPORT void toggle_rings (GtkCheckButton * but, gpointer data)
454#else
463G_MODULE_EXPORT void toggle_rings (GtkToggleButton * but, gpointer data)
464#endif
465{
466 int oid = GPOINTER_TO_INT(data);
467 int i;
468 gboolean status;
469 status = button_get_status ((GtkWidget *)but);
470 toggled_rings = TRUE;
471 switch (search_type)
472 {
473 case 0:
475 if (preferences)
476 {
477 tmp_rsparam[oid+4] = status;
478 }
479 else
480 {
481 active_project -> rsparam[i][oid+2] = status;
482 }
483 break;
484 case 1:
485 if (preferences)
486 {
487 tmp_csparam[oid+3] = status;
488 }
489 else
490 {
491 active_project -> csparam[oid+1] = status;
492 }
493 if (oid == 0 && status)
494 {
495 for (i=1; i<4; i++) button_set_status(rings_check[i], ! status);
496 }
497 else if (oid == 1 && status)
498 {
500 }
501 else if (oid == 2 && status)
502 {
504 }
505 break;
506 }
507}
508
516void calc_rings (GtkWidget * vbox)
517{
518 gchar * defs[6]={"All rings (No rules)",
519 "King's [1, 3]",
520 "Guttman's [2]",
521 "Primitives [4, 5, 6]",
522 "Strongs [4, 5]"};
523 gchar * val_a[2]={"Definition of ring to be used: ", "Atom(s) to initiate the search from: "};
524 gchar * val_b[2][2]={{"<i><b>n</b><sub>max</sub></i> = maximum size for a ring <sup>*</sup>",
525 "Maximum number of rings of size <i><b>n</b></i> per MD step <sup>**</sup>"},
526 {"<i><b>n</b><sub>max</sub></i> = maximum size for a chain <sup>*</sup>",
527 "Maximum number of chains of size <i><b>n</b></i> per MD step <sup>**</sup>"}};
528 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", " "},
529 {"Only search for AAAA chains", "Only search for ABAB chains",
530 "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."}};
531 gchar * start[3]={"<sup>*</sup>", "<sup>**</sup>", "<sup>***</sup>"};
532 gchar * val_d[3]={"<i><b>n</b><sub>max</sub></i> in total number of nodes (or atoms)",
533 "value used for memory allocation = f(<i><b>n</b><sub>max</sub></i>, system studied)",
534 "but homopolar bonds can shorten the rings"};
535 gchar * val_e={"\n<sub>[1] S. V. King. <i>Nature</i>, <b>213</b>:1112 (1967).</sub>\n"
536 "<sub>[2] L. Guttman. <i>J. Non-Cryst. Solids.</i>, <b>116</b>:145-147 (1990).</sub>\n"
537 "<sub>[3] D. S. Franzblau. <i>Phys. Rev. B</i>, <b>44</b>(10):4925-4930 (1991).</sub>\n"
538 "<sub>[4] K. Goetzke and H. J. Klein. <i>J. Non-Cryst. Solids.</i>, <b>127</b>:215-220 (1991).</sub>\n"
539 "<sub>[5] X. Yuan and A. N. Cormack. <i>Comp. Mat. Sci.</i>, <b>24</b>:343-360 (2002).</sub>\n"
540 "<sub>[6] F. Wooten. <i>Acta Cryst. A</i>, <b>58</b>(4):346-351 (2002).</sub>"};
541 gchar * list_node[(preferences) ? 2 : active_project -> nspec+1];
542 int i, j, k;
543 toggled_rings = FALSE;
544 if (! search_type) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, combox_rings (val_a[0], 5, defs, 0), FALSE, FALSE, 5);
545
546 list_node[0] = g_strdup_printf ("All");
547 if (preferences)
548 {
549 list_node[1] = g_strdup_printf ("Chemical species");
550 }
551 else
552 {
553 for (i=0; i<active_project -> nspec; i++) list_node[i+1] = g_strdup_printf ("%s", active_chem -> label[i]);
554 }
555
556 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, combox_rings (val_a[1], (preferences) ? 2 : active_project -> nspec+1, list_node, 1), FALSE, FALSE, 5);
557
558 j = (preferences) ? tmp_rsparam[0] : active_project -> rsearch[0];
559 k = RI + search_type;
560 GtkWidget * hbox;
561 for (i=0; i<2; i++)
562 {
563 hbox = create_hbox (0);
564 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
565 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[search_type][i], 400, -1, 0.0, 0.5), FALSE, FALSE, 0);
566 if (i == 0)
567 {
568 rings_entry[i] = create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, GINT_TO_POINTER(k));
569 if (preferences)
570 {
572 }
573 else
574 {
575 update_entry_int (GTK_ENTRY(rings_entry[i]), (search_type) ? active_project -> csparam[5] : active_project -> rsparam[j][1]);
576 }
577 }
578 else
579 {
580 rings_entry[i] = create_entry (G_CALLBACK(set_numa), 100, 15, FALSE, NULL);
581 if (preferences)
582 {
584 }
585 else
586 {
587 update_entry_int (GTK_ENTRY(rings_entry[i]), (search_type) ? active_project -> csearch : active_project -> rsearch[1]);
588 }
589 }
590 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, rings_entry[i], FALSE, FALSE, 0);
591 if (! search_type && j < 0 && ! preferences) widget_set_sensitive (rings_entry[i], 0);
592 }
593 gboolean status;
594 for (i=0; i<3+search_type; i++)
595 {
596 if (preferences)
597 {
598 status = (search_type) ? tmp_csparam[i+3] : tmp_rsparam[i+4];
599 }
600 else
601 {
602 status = (j < 0) ? 0 : (search_type) ? active_project -> csparam[i+1] : active_project -> rsparam[j][i+2];
603 }
604 rings_check[i] = check_button (val_c[search_type][i], -1, 40, status, G_CALLBACK(toggle_rings), GINT_TO_POINTER(i));
605 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, rings_check[i], FALSE, FALSE, 0);
606 if (! preferences)
607 {
608 if (active_project -> nspec == 1) widget_set_sensitive (rings_check[i], 0);
609 if (! search_type && j < 0) widget_set_sensitive (rings_check[i], 0);
610 }
611 }
612 for (i=0; i<3; i++)
613 {
614 append_comments (vbox, start[i], val_d[i]);
615 }
616 if (! search_type)
617 {
618 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label (val_e, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
619 i = 0;
620 g_signal_connect(G_OBJECT(rings_box[0]), "changed", G_CALLBACK(combox_rings_changed), GINT_TO_POINTER(0));
622 widget_set_sensitive (rings_box[1], (preferences) ? 1 : (active_project -> rsearch[0]<0) ? 0 : 1);
623 }
624 i = 1;
625 g_signal_connect(G_OBJECT(rings_box[1]), "changed", G_CALLBACK(combox_rings_changed), GINT_TO_POINTER(i));
626 if (preferences)
627 {
629 }
630 else
631 {
632 combo_set_active (rings_box[1], (search_type) ? active_project -> csparam[0] : active_project -> rsparam[j][0]);
633 }
634}
635
636#ifdef GTK4
646G_MODULE_EXPORT void run_toggle_bond (GtkNativeDialog * info, gint response_id, gpointer data)
647{
648 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkFileChooserNative *)info);
649#else
659G_MODULE_EXPORT void run_toggle_bond (GtkDialog * info, gint response_id, gpointer data)
660{
661 GtkFileChooser * chooser = GTK_FILE_CHOOSER((GtkWidget *)info);
662#endif
663 if (response_id == GTK_RESPONSE_ACCEPT)
664 {
665 active_project -> bondfile = file_chooser_get_file_name (chooser);
666 }
667 else
668 {
669 button_set_status (data, FALSE);
670 }
671#ifdef GTK4
673#else
674 destroy_this_dialog (info);
675#endif
676}
677
678#ifdef GTK4
687G_MODULE_EXPORT void toggle_bond (GtkCheckButton * Button, gpointer data)
688#else
697G_MODULE_EXPORT void toggle_bond (GtkToggleButton * Button, gpointer data)
698#endif
699{
700 int i = GPOINTER_TO_INT (data);
701 gboolean status = button_get_status ((GtkWidget *)Button);
702 if (i < 3)
703 {
704 active_project -> runc[i] = status;
705 if (i < 2) widget_set_sensitive (ba_entry[i], status);
706 if (i == 2) frag_update = mol_update = status;
707 }
708 else
709 {
710 if (status)
711 {
712 // To add = do not annoy me with that again !
713 show_info ("Activate this option and the result of the nearest neighbors\n"
714 "analysis will be saved during the search in a file that you may\n"
715 "use afterwards.\n", 0, MainWindow);
716#ifdef GTK4
717 GtkFileChooserNative * info;
718#else
719 GtkWidget * info;
720#endif
721 info = create_file_chooser ("Save neighbors analysis in file",
722 GTK_WINDOW(MainWindow),
723 GTK_FILE_CHOOSER_ACTION_SAVE,
724 "Save");
725 GtkFileChooser * chooser = GTK_FILE_CHOOSER(info);
726#ifdef GTK3
727 gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
728#endif
730 gtk_file_chooser_set_current_name (chooser, "neighbors.dat");
731#ifdef GTK4
732 run_this_gtk_native_dialog ((GtkNativeDialog *)info, G_CALLBACK(run_toggle_bond), Button);
733#else
734 run_this_gtk_dialog (info, G_CALLBACK(run_toggle_bond), Button);
735#endif
736 }
737 else
738 {
739 active_project -> bondfile = NULL;
740 }
741 }
742}
743
751gboolean test_gr (int gr)
752{
753 if (active_project -> num_delta[gr] < 2)
754 {
755 show_warning ("You must specify a number of &#x3b4;r >= 2\n"
756 "to discretize the real space between 0.0 and D<sub>max</sub>\n", calc_win);
757 return FALSE;
758 }
759 else if (gr == GK && (active_project -> max[gr] > active_project -> max[SK] || active_project -> max[gr] <= active_project -> min[SK]))
760 {
761 show_warning ("You must specify a maximum wave vector Q<sub>max</sub>[FFT]\n"
762 "for the FFT, with Q<sub>min</sub> < Q<sub>max</sub>[FFT] <= Q<sub>max</sub>", calc_win);
763 return FALSE;
764 }
765 else
766 {
767 return TRUE;
768 }
769}
770
778gboolean test_sq (int sq)
779{
780 if (active_project -> max[sq] <= active_project -> min[sq])
781 {
782 show_warning ("You must specify a maximum wave vector Q<sub>max</sub>\n"
783 "note that Q<sub>max</sub> must be > Q<sub>min</sub>", calc_win);
784 return FALSE;
785 }
786 else if (active_project -> num_delta[sq] < 2)
787 {
788 show_warning ("You must specify a number of &#x3b4;q >= 2\n"
789 "to discretize the reciprocal space between 0.0 and Q<sub>max</sub>\n", calc_win);
790 return FALSE;
791 }
792 else
793 {
794 return TRUE;
795 }
796}
797
803gboolean test_bonds ()
804{
805 if (active_project -> runc[0] && active_project -> num_delta[BD] < 2)
806 {
807 show_warning ("You must specify a number of &#x3b4;r >= 2\n"
808 "to discretize the real space between\n"
809 "the shortest and the highest inter-atomic distances", calc_win);
810 return FALSE;
811 }
812 else if (active_project -> runc[1] && active_project -> num_delta[AN] < 2)
813 {
814 show_warning ("You must specify a number of &#x3b4;&#x3b8; >= 2\n"
815 "to discretize the angular space between 0 and 180°", calc_win);
816 return FALSE;
817 }
818 else
819 {
820 return TRUE;
821 }
822}
823
829gboolean test_rings ()
830{
831 int i, j;
832 i = (search_type) ? active_project -> csparam[5] : active_project -> rsparam[active_project -> rsearch[0]][1];
833 j = (search_type) ? active_project -> csearch : active_project -> rsearch[1];
834 gchar * sobj[2]={"ring", "chain"};
835 gchar * str;
836 if (i == 0)
837 {
838 str = g_strdup_printf ("You must specify a maximum %s size > 1 for the search", sobj[search_type]);
839 show_warning (str, calc_win);
840 g_free (str);
841 return FALSE;
842 }
843 if (j == 0)
844 {
845 str = g_strdup_printf ("You must specify a number of %ss per size 'n' and per node\n"
846 "this value is used when allocating the memory to store the results\n"
847 "and depends on both the maximum %s size used in the search\n"
848 "and the system studied.\n"
849 "We recommend a value at least equal to 100.\n"
850 "If it appears that the value given is not big enough\n"
851 "(ex: more than 100 different %ss of size 'n' for a single node)\n"
852 "then the search will failed but the program will propose\n"
853 "you to initiate a new search using a higher value",
854 sobj[search_type], sobj[search_type], sobj[search_type]);
855 show_warning (str, calc_win);
856 g_free (str);
857 return FALSE;
858 }
859 return TRUE;
860}
861
867gboolean test_msd ()
868{
869 if(active_project -> steps > 1)
870 {
871 if (active_project -> delta[MS] == 0.0)
872 {
873 show_warning ("You must specify the time step &#x3b4;t\n"
874 "used to integrate the Newton's equations\n"
875 "of motion during the molecular dynamics\n", calc_win);
876 return FALSE;
877 }
878 if (active_project -> tunit < 0)
879 {
880 show_warning ("You must specify the time unit\n"
881 "used to integrate the Newton's equations\n"
882 "of motion during the molecular dynamics\n", calc_win);
883 return FALSE;
884 }
885 else
886 {
887 return TRUE;
888 }
889 }
890 else
891 {
892 if (active_project -> num_delta[MS] < 1)
893 {
894 show_warning ("You must specify the number of steps\n"
895 "between each of the %d configurations\n"
896 "found for the molecular dynamics\n", calc_win);
897 return FALSE;
898 }
899 else
900 {
901 return TRUE;
902 }
903 }
904}
905
911gboolean test_sph ()
912{
913 if (active_project -> num_delta[SP] < 2 || active_project -> num_delta[SP] > 40)
914 {
915 show_warning ("You must specify a number <i>l<sub>max</sub></i> in [2-40]", calc_win);
916 return FALSE;
917 }
918 else
919 {
920 return TRUE;
921 }
922}
923
931void calc_bonds (GtkWidget * vbox)
932{
933 gchar * val_a[2]={"Number of &#x3b4;r [D<sub>ij</sub>min-D<sub>ij</sub>max]",
934 "Number of &#x3b4;&#x3b8; [0-180°]"};
935 gchar * val_b[4]={"First coordination sphere properties",
936 "Bond and dihedral angles distribution",
937 "Search for molecules and isolated fragments",
938 "Output detailed results in text file"};
939
940 GtkWidget * hbox;
941 int i;
942 for (i=0; i<3; i++)
943 {
944 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
945 check_button (val_b[i], -1, 40, active_project -> runc[i], G_CALLBACK(toggle_bond), (gpointer)GINT_TO_POINTER(i)),
946 FALSE, FALSE, 0);
947 if (i < 2)
948 {
949 hbox = create_hbox (0);
950 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
951 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_a[i], 200, -1, 0.0, 0.5), FALSE, FALSE, 0);
952 ba_entry[i] = create_entry (G_CALLBACK(set_delta), 150, 15, FALSE, (gpointer)GINT_TO_POINTER(BD+i));
953 update_entry_int (GTK_ENTRY(ba_entry[i]), active_project -> num_delta[BD+i]);
955 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, ba_entry[i], FALSE, FALSE, 0);
956 }
957 }
958 GtkWidget * checkbd = check_button (val_b[i], -1, 40, FALSE, G_CALLBACK(toggle_bond), (gpointer)GINT_TO_POINTER(i));
959 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, checkbd, FALSE, FALSE, 0);
960 widget_set_sensitive (checkbd, 1);
961}
962
971GtkWidget * hbox_note (int i, double val)
972{
973 gchar * note[3] = {"D<sub>max</sub> = ", "Q<sub>min</sub> = ", "Q<sub>max</sub> = "};
974 gchar * unit[3] = {" &#xC5;", " &#xC5;<sup>-1</sup>", " &#xC5;<sup>-1</sup>"};
975 gchar * str;
976 GtkWidget * hbox = create_hbox (0);
977 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (note[i], 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
978 str = g_strdup_printf ("%f", val);
979 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, 100, -1, 1.0, 0.5), FALSE, FALSE, 0);
980 g_free (str);
981 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (unit[i], 50, -1, 0.0, 0.5), FALSE, FALSE, 0);
982 return hbox;
983}
984
985GtkWidget * avbox;
986GtkWidget * smbox;
988
997G_MODULE_EXPORT void expand_opt (GtkWidget * exp, gpointer data)
998{
999 int i;
1000 i = GPOINTER_TO_INT(data);
1001 GtkExpander * expander = GTK_EXPANDER (exp);
1002 GtkWidget * wind = get_top_level (exp);
1003 gtk_window_set_resizable (GTK_WINDOW (wind), TRUE);
1004 if (gtk_expander_get_expanded (expander))
1005 {
1006 if (i == 1)
1007 {
1009 }
1010 else
1011 {
1013 }
1014 }
1015 else
1016 {
1017 if (i == 1)
1018 {
1020
1021 }
1022 else
1023 {
1025 }
1026 }
1027 gtk_widget_set_size_request (exp, -1, -1);
1028 gtk_window_set_resizable (GTK_WINDOW (wind), FALSE);
1029}
1030
1039G_MODULE_EXPORT void set_advanced_sq (GtkEntry * entry, gpointer data)
1040{
1041 int c = GPOINTER_TO_INT(data);
1042 const gchar * m = entry_get_text (entry);
1043 double v = string_to_double ((gpointer)m);
1044 if (v != active_project -> sk_advanced[c])
1045 {
1046 if (c == 0 && (v < 0.0 || v > 1.0))
1047 {
1048 show_warning ("You must specify a probability between 0.0 and 1.0", calc_win);
1049 }
1050 else if (c == 1 && (v < active_project -> min[SK] || v > active_project -> max[SK]))
1051 {
1052 show_warning ("Q<sub>lim</sub> must be &#8805; Q<sub>min</sub> and &#8804; Q<sub>max</sub>", calc_win);
1053 }
1054 else
1055 {
1056 active_project -> sk_advanced[c] = v;
1057 }
1058 }
1059 update_entry_double (entry, active_project -> sk_advanced[c]);
1060}
1061
1070G_MODULE_EXPORT void set_sfact (GtkEntry * entry, gpointer data)
1071{
1072 const gchar * m;
1073 int i = GPOINTER_TO_INT(data);
1074 m = entry_get_text (entry);
1075 double v = string_to_double ((gpointer)m);
1076 if (v <= 0.0 || v >= 1.0)
1077 {
1078 show_warning ("The smoothing factor must be between 0.0 and 1.0", calc_win);
1079 }
1080 else
1081 {
1082 active_project -> fact[i] = v;
1083 }
1084 update_entry_double (entry, active_project -> fact[i]);
1085}
1086
1095G_MODULE_EXPORT void on_show_curve_toolbox (GtkWidget * widg, gpointer data)
1096{
1098 {
1100 }
1101 else
1102 {
1104 }
1105}
1106
1115G_MODULE_EXPORT void on_smoother_released (GtkButton * button, gpointer data)
1116{
1117 int i, k, l, m;
1118
1119 l = GPOINTER_TO_INT(data);
1120 if (active_project -> visok[l])
1121 {
1122 if (l == 2)
1123 {
1124 xsk = duplicate_double(active_project -> curves[l][0] -> ndata, active_project -> curves[l][0] -> data[0]);
1125 }
1126 i = 1;
1127 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1128 active_project -> curves[l][i-1] -> data[1],
1129 & active_project -> fact[l],
1130 & i,
1131 & active_project -> curves[l][i-1] -> ndata,
1132 & l);
1133 i = i+2;
1134 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1135 active_project -> curves[l][i-1] -> data[1],
1136 & active_project -> fact[l],
1137 & i,
1138 & active_project -> curves[l][i-1] -> ndata,
1139 & l);
1140 i = i+2;
1141 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1142 active_project -> curves[l][i-1] -> data[1],
1143 & active_project -> fact[l],
1144 & i,
1145 & active_project -> curves[l][i-1] -> ndata,
1146 & l);
1147 i = i+2;
1148 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1149 active_project -> curves[l][i-1] -> data[1],
1150 & active_project -> fact[l],
1151 & i,
1152 & active_project -> curves[l][i-1] -> ndata,
1153 & l);
1154 if (l == 0 || l == 3)
1155 {
1156 i = i+2;
1157 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1158 active_project -> curves[l][i-1] -> data[1],
1159 & active_project -> fact[l],
1160 & i,
1161 & active_project -> curves[l][i-1] -> ndata,
1162 & l);
1163 i = i+2;
1164 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1165 active_project -> curves[l][i-1] -> data[1],
1166 & active_project -> fact[l],
1167 & i,
1168 & active_project -> curves[l][i-1] -> ndata,
1169 & l);
1170 i = i+2;
1171 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1172 active_project -> curves[l][i-1] -> data[1],
1173 & active_project -> fact[l],
1174 & i,
1175 & active_project -> curves[l][i-1] -> ndata,
1176 & l);
1177 i = i+2;
1178 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1179 active_project -> curves[l][i-1] -> data[1],
1180 & active_project -> fact[l],
1181 & i,
1182 & active_project -> curves[l][i-1] -> ndata,
1183 & l);
1184 }
1185 for (k=0 ; k<active_project -> nspec ; k++)
1186 {
1187 for (m=0 ; m<active_project -> nspec ; m++)
1188 {
1189 i = i+2;
1190 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1191 active_project -> curves[l][i-1] -> data[1],
1192 & active_project -> fact[l],
1193 & i,
1194 & active_project -> curves[l][i-1] -> ndata,
1195 & l);
1196 if (l == 0 || l == 3)
1197 {
1198 i = i+2;
1199 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1200 active_project -> curves[l][i-1] -> data[1],
1201 & active_project -> fact[l],
1202 & i,
1203 & active_project -> curves[l][i-1] -> ndata,
1204 & l);
1205 i = i+1;
1206 }
1207 }
1208 }
1209 if (l == 1 || l == 2)
1210 {
1211 for (k=0 ; k<active_project -> nspec ; k++)
1212 {
1213 for (m=0 ; m<active_project -> nspec ; m++)
1214 {
1215 i = i+2;
1216 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1217 active_project -> curves[l][i-1] -> data[1],
1218 & active_project -> fact[l],
1219 & i,
1220 & active_project -> curves[l][i-1] -> ndata,
1221 & l);
1222 }
1223 }
1224 }
1225 if (active_project -> nspec == 2)
1226 {
1227 m = 3;
1228 if (l == 1 || l == 2) m = m+1;
1229 for (k=0 ; k<m; k++)
1230 {
1231 i = i+2;
1232 smooth_and_save_ (active_project -> curves[l][i-1] -> data[0],
1233 active_project -> curves[l][i-1] -> data[1],
1234 & active_project -> fact[l],
1235 & i,
1236 & active_project -> curves[l][i-1] -> ndata,
1237 & l);
1238 }
1239 }
1240 if (l == 2)
1241 {
1242 g_free (xsk);
1243 xsk = NULL;
1244 }
1245 fill_tool_model ();
1247 if (l == 0 || l == 3)
1248 {
1249 for (i=0; i<4; i=i+3) update_after_calc (i);
1250 }
1251 else
1252 {
1253 for (i=1; i<3; i++) update_after_calc (i);
1254 }
1255 }
1256 else
1257 {
1258 show_error ("No data set(s) to be smoothed\n", 0, calc_win);
1259 }
1260}
1261
1270void calc_gr_sq (GtkWidget * box, int id)
1271{
1272 gchar * val_a[4]={"Number of &#x3b4;r steps",
1273 "Number of &#x3b4;q steps",
1274 "Number of &#x3b4;q steps",
1275 "Number of &#x3b4;r steps"};
1276 gchar * val_b[3]={"Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1277 "Q<sub>max</sub> [&#xC5;<sup>-1</sup>]",
1278 "Q<sub>max</sub> for the FFT [&#xC5;<sup>-1</sup>]"};
1279
1280 GtkWidget * vbox = create_vbox (5);
1281 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1282 GtkWidget * hbox = create_hbox (0);
1283 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1284 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_a[id], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1285 GtkWidget * entry= create_entry (G_CALLBACK(set_delta), 100, 15, FALSE, GINT_TO_POINTER(id));
1286 update_entry_int (GTK_ENTRY(entry), active_project -> num_delta[id]);
1287 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1288 if (id > GR)
1289 {
1290 hbox = create_hbox (0);
1291 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
1292 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (val_b[id-1], 150, -1, 0.0, 0.5), FALSE, FALSE, 10);
1293 GtkWidget * entry= create_entry (G_CALLBACK(set_max), 100, 15, FALSE, GINT_TO_POINTER(id));
1294 update_entry_double (GTK_ENTRY(entry), active_project -> max[id]);
1295 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 10);
1296 }
1297
1298 if (id == GR || id == GK)
1299 {
1300 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (0, active_project -> max[GR]), FALSE, FALSE, 0);
1301 }
1302 if (id == SQ)
1303 {
1304 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SQ]), FALSE, FALSE, 0);
1305 }
1306 if (id == SK|| id == GK)
1307 {
1308 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (1, active_project -> min[SK]), FALSE, FALSE, 0);
1309 }
1310 if (id == GK)
1311 {
1312 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox_note (2, active_project -> max[SK]), FALSE, FALSE, 0);
1313 }
1314 if (id == GR || id == GK)
1315 {
1316 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1317 markup_label ("D<sub>max</sub> is the maximum inter-atomic distance in the model", -1, -1, 0.0, 0.5),
1318 FALSE, FALSE, 0);
1319 }
1320 if (id > 0)
1321 {
1322 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1323 markup_label ("Q<sub>min</sub> is the minimum wave vector for the model", -1, -1, 0.0, 0.5),
1324 FALSE, FALSE, 0);
1325 }
1326 if (id == GK)
1327 {
1328 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
1329 markup_label ("Q<sub>max</sub> is the maximum wave vector to compute S(q)", -1, -1, 0.0, 0.5),
1330 FALSE, FALSE, 0);
1331 }
1332
1333 vbox = create_vbox (BSEP);
1334 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1335 GtkWidget * aentry;
1336 if (id == SK)
1337 {
1338 gchar * adv_name[2]={"Probability to keep wave\nvector <i>q</i> > Q<sub>lim</sub> [0.0-1.0]",
1339 "Q<sub>lim</sub> [&#xC5;<sup>-1</sup>] in [Q<sub>min</sub>-Q<sub>max</sub>]"};
1340 GtkWidget * advanced_options = create_expander (" Advanced options", NULL);
1341 gtk_widget_set_size_request (advanced_options, -1, 20);
1342 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, advanced_options, FALSE, TRUE, 10);
1343 avbox = create_vbox (5);
1344 GtkWidget * ahbox;
1345 GtkWidget * fixed;
1346 int i;
1347 for (i=0; i<2; i++)
1348 {
1349 ahbox = create_hbox (5);
1350 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, ahbox, FALSE, FALSE, 5);
1351 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, markup_label (adv_name[i], 175, -1, 0.0, 0.5), FALSE, FALSE, 5);
1352 aentry = create_entry (G_CALLBACK(set_advanced_sq), 100, 15, FALSE, GINT_TO_POINTER(i));
1353 update_entry_double (GTK_ENTRY(aentry), active_project -> sk_advanced[i]);
1354 fixed = gtk_fixed_new ();
1355 gtk_fixed_put (GTK_FIXED(fixed), aentry, 0.0, 0.0);
1356 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, ahbox, fixed, FALSE, FALSE, 10);
1357 }
1358 g_signal_connect (G_OBJECT(advanced_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(1));
1359 add_container_child (CONTAINER_EXP, advanced_options, avbox);
1360 show_the_widgets (advanced_options);
1361 widget_set_sensitive (advanced_options, 1);
1362 }
1363
1364 GtkWidget * smooth_options = create_expander (" Gaussian data smoothing", NULL);
1365 gtk_widget_set_size_request (smooth_options, -1, 20);
1366 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, smooth_options, FALSE, TRUE, 10);
1367 avbox = create_vbox (5);
1368 smbox = create_hbox (0);
1369 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, gtk_label_new("Factor [0.0-1.0]"), FALSE, FALSE, 0);
1370 aentry = create_entry (G_CALLBACK(set_sfact), 100, 15, FALSE, GINT_TO_POINTER(id));
1371 update_entry_double (GTK_ENTRY(aentry), active_project -> fact[id]);
1372 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, aentry, FALSE, TRUE, 10);
1373 GtkWidget * smooth = create_button ("Smooth", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_smoother_released), GINT_TO_POINTER(id));
1374 g_signal_connect (G_OBJECT(smooth_options), "activate", G_CALLBACK(expand_opt), GINT_TO_POINTER(0));
1375 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, smbox, smooth, FALSE, FALSE, 0);
1376 add_box_child_start (GTK_ORIENTATION_VERTICAL, avbox, smbox, FALSE, FALSE, 5);
1377 add_container_child (CONTAINER_EXP, smooth_options, avbox);
1378 show_the_widgets (smooth_options);
1379 widget_set_sensitive (smooth_options, 1);
1380}
1381
1391G_MODULE_EXPORT void run_on_calc_activate (GtkDialog * dial, gint response_id, gpointer data)
1392{
1393 int i;
1394 int id = GPOINTER_TO_INT(data);
1395 switch (response_id)
1396 {
1397 case GTK_RESPONSE_APPLY:
1398 switch (id)
1399 {
1400 case GR:
1401 if (test_gr (GR)) on_calc_gr_released (calc_win, NULL);
1402 break;
1403 case SQ:
1404 if (test_sq (SQ)) on_calc_sq_released (calc_win, NULL);
1405 break;
1406 case SK:
1407 if (test_sq (SK)) on_calc_sk_released (calc_win, NULL);
1408 break;
1409 case GK:
1410 if (test_gr (GK)) on_calc_gq_released (calc_win, NULL);
1411 break;
1412 case BD:
1414 break;
1415 case RI-1:
1416 if (test_rings ())
1417 {
1418 //show_the_widgets (spinner);
1419 //gtk_spinner_start (GTK_SPINNER(spinner));
1421 toggled_rings = FALSE;
1422 //gtk_spinner_stop (GTK_SPINNER(spinner));
1423 //hide_the_widgets (spinner);
1424 }
1425 break;
1426 case CH-1:
1427 if (test_rings ())
1428 {
1429 //show_the_widgets (spinner);
1430 //gtk_spinner_start (GTK_SPINNER(spinner));
1432 //gtk_spinner_stop (GTK_SPINNER(spinner));
1433 //hide_the_widgets (spinner);
1434 }
1435 break;
1436 case SP-1:
1437 if (test_sph ()) on_calc_sph_released (calc_win, NULL);
1438 break;
1439 case MS-1:
1440 if (test_msd ()) on_calc_msd_released (calc_win, NULL);
1441 break;
1442 default:
1443 break;
1444 }
1445 break;
1446 default:
1447 frag_update = mol_update = 0;
1448 for (i=0; i<3; i++) active_project -> runc[i] = FALSE;
1449 destroy_this_dialog (dial);
1451 avbox = NULL;
1452 }
1453}
1454
1463G_MODULE_EXPORT void on_calc_activate (GtkWidget * widg, gpointer data)
1464{
1465 int id = GPOINTER_TO_INT(data);
1466 calc_win = calc_window(id);
1467 GtkWidget * box = dialog_get_content_area (calc_win);
1468 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
1469 switch (id)
1470 {
1471 case BD:
1472 calc_bonds (box);
1473 break;
1474 case RI-1:
1475 search_type = 0;
1476 calc_rings (box);
1477 break;
1478 case CH-1:
1479 search_type = 1;
1480 calc_rings (box);
1481 break;
1482 case SP-1:
1483 calc_sph (box);
1484 break;
1485 case MS-1:
1486 calc_msd (box);
1487 break;
1488 case 9:
1489 // calc_valence (box);
1490 break;
1491 default:
1492 calc_gr_sq (box, id);
1493 break;
1494 }
1495
1496#ifndef GTK4
1497 gtk_window_set_icon (GTK_WINDOW (calc_win), gdk_pixbuf_new_from_file(calc_img[id], NULL));
1498#endif
1499 GtkWidget * vbox = create_vbox (BSEP);
1500 gtk_widget_set_size_request (vbox, -1, 30);
1501 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, vbox, FALSE, FALSE, 0);
1502 /*GtkWidget * spinner = gtk_spinner_new ();
1503 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, spinner, FALSE, FALSE, 0);
1504 gtk_widget_set_size_request (spinner, -1, 30);
1505 hide_the_widgets (spinner);*/
1507}
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:911
void calc_bonds(GtkWidget *vbox)
creation of the bond calculation widgets
Definition calc_menu.c:931
G_MODULE_EXPORT void combox_tunit_changed(GtkComboBox *box, gpointer data)
change time units
Definition calc_menu.c:228
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:260
GtkWidget * combox_rings(gchar *str, int num, gchar *list_item[num], int id)
create a combo box for the ring statistics calculation
Definition calc_menu.c:364
GtkWidget * rings_box[2]
Definition calc_menu.c:136
GtkWidget * smbox
Definition calc_menu.c:986
G_MODULE_EXPORT void on_show_curve_toolbox(GtkWidget *widg, gpointer data)
show the curve toolboxes
Definition calc_menu.c:1095
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:987
G_MODULE_EXPORT void toggle_bond(GtkToggleButton *Button, gpointer data)
activate bond properties detailed saving and prepare the dialog
Definition calc_menu.c:697
GtkWidget * hbox_note(int i, double val)
foot note message box with some parameters
Definition calc_menu.c:971
G_MODULE_EXPORT void combox_rings_changed(GtkComboBox *box, gpointer data)
change ring statistics calculation parameter
Definition calc_menu.c:391
void calc_sph(GtkWidget *vbox)
creation of the spherical harmonics calculation widgets
Definition calc_menu.c:240
GtkWidget * rings_entry[2]
Definition calc_menu.c:380
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:829
gchar * calc_img[NCALCS-2]
Definition gui.c:106
gboolean test_gr(int gr)
is it safe to compute g(r) ?
Definition calc_menu.c:751
gboolean test_sq(int sq)
is it safe to compute s(q) ?
Definition calc_menu.c:778
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:1391
G_MODULE_EXPORT void on_calc_gq_released(GtkWidget *widg, gpointer data)
compute g(k)
Definition grcall.c:319
gboolean test_bonds()
is it safe to compute bond properties ?
Definition calc_menu.c:803
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:659
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:91
GtkWidget * avbox
Definition calc_menu.c:985
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:307
G_MODULE_EXPORT void on_calc_activate(GtkWidget *widg, gpointer data)
create a calculation dialog - prepare the dialog
Definition calc_menu.c:1463
G_MODULE_EXPORT void expand_opt(GtkWidget *exp, gpointer data)
open expander actions
Definition calc_menu.c:997
G_MODULE_EXPORT void set_advanced_sq(GtkEntry *entry, gpointer data)
set a s(k) calculation parameter
Definition calc_menu.c:1039
G_MODULE_EXPORT void toggle_rings(GtkToggleButton *but, gpointer data)
toggle a rings statistics calculation parameter
Definition calc_menu.c:463
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:1115
GtkWidget * rings_check[4]
Definition calc_menu.c:381
G_MODULE_EXPORT void set_sfact(GtkEntry *entry, gpointer data)
set the Gaussian smoothing factor
Definition calc_menu.c:1070
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:516
G_MODULE_EXPORT void set_delta(GtkEntry *entry, gpointer data)
set the number of delta between data points
Definition calc_menu.c:146
G_MODULE_EXPORT void set_max(GtkEntry *entry, gpointer data)
set a maximum value
Definition calc_menu.c:120
int search_type
Definition calc_menu.c:92
gboolean test_msd()
is it safe to compute MSD ?
Definition calc_menu.c:867
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:1270
GtkWidget * calc_window(int i)
create a calculation window
Definition calc_menu.c:101
GtkWidget * calc_win
Definition calc_menu.c:90
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
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
char * untime[5]
Definition global.c:150
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:571
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:501
@ IMG_NONE
Definition global.h:262
void file_chooser_set_current_folder(GtkFileChooser *chooser)
set current folder in a GtkFilechooser
Definition gtk-misc.c:2323
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1375
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:643
void append_comments(GtkWidget *vbox, gchar *symbol, gchar *legend)
append comments to a vertical box
Definition gtk-misc.c:2004
gboolean is_the_widget_visible(GtkWidget *widg)
test if a GtkWidget exist, then return if it is visible or not
Definition gtk-misc.c:724
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
gchar * file_chooser_get_file_name(GtkFileChooser *chooser)
get a file name from a GtkFileChooser (single file selected)
Definition gtk-misc.c:2271
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:247
void update_entry_int(GtkEntry *entry, int intval)
update the content of a GtkEntry as int
Definition gtk-misc.c:624
void button_set_status(GtkWidget *button, int status)
set status of check / toggle button
Definition gtk-misc.c:1872
#define GR
Definition global.h:324
#define SQ
Definition global.h:325
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:514
#define RI
Definition global.h:330
@ CONTAINER_EXP
Definition global.h:257
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1955
GtkWidget * get_top_level(GtkWidget *widg)
get the top level container, window, of a widget
Definition gtk-misc.c:2450
#define BD
Definition global.h:328
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:835
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:308
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
#define AN
Definition global.h:329
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2200
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
#define MS
Definition global.h:333
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
#define min(a, b)
Definition global.h:81
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:235
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:198
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
#define SK
Definition global.h:326
#define GK
Definition global.h:327
GtkWidget * create_expander(gchar *name, gchar *file_img)
create GtkExpander
Definition gtk-misc.c:2119
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:2358
#define SP
Definition global.h:332
project * active_project
Definition project.c:47
#define NCALCS
void destroy_this_native_dialog(GtkNativeDialog *dialog)
destroy a GtkNativeDialog
Definition gtk-misc.c:2219
#define CH
Definition global.h:331
char * calc_name[NCALCS-2]
Definition gui.c:123
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
#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:1038
Messaging function declarations.
int * tmp_csparam
int * tmp_rsparam
gboolean preferences
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:351
int c
Definition tab-1.c:95
logical function smooth(tabtoliss, gtoliss, dimtoliss, sigmaliss)
Definition utils.F90:612
int status
Definition w_advance.c:178
atom_search * csearch
Definition w_search.c:2729
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
Function declarations for workspace managment.