atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
edit_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: 'edit_menu.c'
24*
25* Contains:
26*
27
28 - The creation of the edition dialogs
29
30*
31* List of functions:
32
33 gboolean test_vol (double box[2][3], double vect[3][3]);
34 gboolean test_pbc (int pbc, int frac, double box[2][3], double vect[3][3]);
35 gboolean has_box_changed ();
36 gboolean have_vectors_changed ();
37 gboolean test_cutoffs ();
38
39 void edit_box (GtkWidget * vbox);
40 void edit_chem (GtkWidget * vbox);
41 void init_box_calc ();
42 void prep_box (int id);
43 void test_chem ();
44 void edit_bonds (GtkWidget * vbox);
45
46 G_MODULE_EXPORT void update_box (GtkEntry * entry, gpointer data);
47 G_MODULE_EXPORT void toggle_pbc (GtkCheckButton * Button, gpointer data);
48 G_MODULE_EXPORT void toggle_pbc (GtkToggleButton * Button, gpointer data);
49 G_MODULE_EXPORT void toggle_frac (GtkCheckButton * Button, gpointer data);
50 G_MODULE_EXPORT void toggle_frac (GtkToggleButton * Button, gpointer data);
51 G_MODULE_EXPORT void update_vect (GtkEntry * entry, gpointer data);
52 G_MODULE_EXPORT void run_vectors (GtkDialog * win, gint response_id, gpointer data);
53 G_MODULE_EXPORT void on_vectors_clicked (GtkButton * but, gpointer data);
54 G_MODULE_EXPORT void update_chemistry (GtkEntry * entry, gpointer data);
55 G_MODULE_EXPORT void on_spec_changed (GtkComboBox * combo, gpointer data);
56 G_MODULE_EXPORT void on_rad_changed (GtkComboBox * combo, gpointer data);
57 G_MODULE_EXPORT void toggle_xcor (GtkCheckButton * but, gpointer data);
58 G_MODULE_EXPORT void toggle_xcor (GtkToggleButton * but, gpointer data);
59 G_MODULE_EXPORT void run_on_edit_activate (GtkDialog * win, gint response_id, gpointer data);
60 G_MODULE_EXPORT void on_edit_activate (GtkWidget * widg, gpointer data);
61
62*/
63
64#include "global.h"
65#include "bind.h"
66#include "callbacks.h"
67#include "interface.h"
68#include "project.h"
69#include "workspace.h"
70#include "glwindow.h"
71
72char * box_p[2]={"<b>Edges [&#xC5;]</b>", "<b>Angles [&#xB0;]</b>"};
73char * box_prop[2][3]={{"<b><i>a</i></b>", "<b><i>b</i></b>", "<b><i>c</i></b>"},
74 {"alpha - &#x3B1;", "beta - &#x3B2;", "gamma - &#x263;"}};
75char * chem_lab[CHEM_PARAMS+2]={"Atom:", "Element:",
76 "Atomic number", "Atomic mass:", "Radius",
77 "Neutrons scattering length:", "X-rays scattering length:"};
78char * chem_rad[4]={"Covalent", "Ionic", "van Der Waals", "In crystal"};
79char * chem_unit[4]={" g/mol", " &#xC5;", " fm", " e.u"};
80char * edit_prop[4]={"Chemistry and physics", "Box and periodicity", "Bond cutoffs", "Lattice vectors"};
81char * vect_name[3]={"<i>a</i>", "<i>b</i>", "<i>c</i>"};
82char * vect_comp[3]={"x", "y", "z"};
83GtkWidget * frac_box;
84GtkWidget * spec_box;
85GtkWidget * rad_box;
86GtkWidget * chem_spec[2];
87GtkWidget * chem_entry[CHEM_PARAMS-1];
88GtkWidget * vect_entry[9];
90double tmp_box[2][3];
91double tmp_vect[3][3];
95extern double * tmpcut;
96extern void update_cutoffs (project * this_proj);
97extern void cut_box (project * this_proj, GtkWidget * vbox);
98
107G_MODULE_EXPORT void update_box (GtkEntry * entry, gpointer data)
108{
109 dint * id = (dint *)data;
110 const gchar * m = entry_get_text (entry);
111 double v = string_to_double ((gpointer)m);
112 if (v >= 0.0)
113 {
114 tmp_box[id -> a][id -> b] = v;
115 }
116 update_entry_double (entry, v);
117}
118
119#ifdef GTK4
128G_MODULE_EXPORT void toggle_pbc (GtkCheckButton * Button, gpointer data)
129#else
138G_MODULE_EXPORT void toggle_pbc (GtkToggleButton * Button, gpointer data)
139#endif
140{
141#ifdef GTK4
142 tmp_pbc = gtk_check_button_get_active (Button);
143#else
144 tmp_pbc = gtk_toggle_button_get_active (Button);
145#endif
146}
147
148#ifdef GTK4
157G_MODULE_EXPORT void toggle_frac (GtkCheckButton * Button, gpointer data)
158#else
167G_MODULE_EXPORT void toggle_frac (GtkToggleButton * Button, gpointer data)
168#endif
169{
170#ifdef GTK4
171 tmp_frac = gtk_check_button_get_active (Button);
172#else
173 tmp_frac = gtk_toggle_button_get_active (Button);
174#endif
175 /*if (gtk_toggle_button_get_active (Button))
176 {
177 widget_set_sensitive (frac_box, 1);
178 gtk_combo_box_set_active (GTK_COMBO_BOX(frac_box), 0);
179 }
180 else
181 {
182 gtk_combo_box_set_active (GTK_COMBO_BOX(frac_box), -1);
183 widget_set_sensitive (frac_box, 0);
184 }*/
185}
186
195G_MODULE_EXPORT void update_vect (GtkEntry * entry, gpointer data)
196{
197 const gchar * m = entry_get_text (entry);
198 double v = string_to_double ((gpointer)m);
199 update_entry_double (entry, v);
200}
201
211G_MODULE_EXPORT void run_vectors (GtkDialog * win, gint response_id, gpointer data)
212{
213 if (response_id == GTK_RESPONSE_APPLY)
214 {
215 int i, j, k;
216 const gchar * m;
217 double v;
218 i = 0;
219 for (j=0; j<3; j++)
220 {
221 for (k=0; k<3; k++)
222 {
223 m = entry_get_text (GTK_ENTRY(vect_entry[i]));
224 v = string_to_double ((gpointer)m);
225 tmp_vect[j][k] = v;
226 i ++;
227 }
228 }
229 }
231}
232
241G_MODULE_EXPORT void on_vectors_clicked (GtkButton * but, gpointer data)
242{
243 int i, j, k;
244 GtkWidget * win = dialog_cancel_apply (edit_prop[3], MainWindow, FALSE);
245 GtkWidget * table = gtk_grid_new ();
246 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area (win), table, FALSE, FALSE, 5);
247 k = 0;
248 for (i=0; i<4; i++)
249 {
250 if (i > 0)
251 {
252 gtk_grid_attach (GTK_GRID (table), markup_label(vect_name[i-1], 30, -1, 0.5, 0.5), 0, i, 1, 1);
253 }
254 for (j=0; j<4; j++)
255 {
256 if (j > 0)
257 {
258 if (i == 0)
259 {
260 gtk_grid_attach (GTK_GRID (table), markup_label(vect_comp[j-1], -1, 30, 0.5, 0.5), j, 0, 1, 1);
261 }
262 else
263 {
264 vect_entry[k] = create_entry (G_CALLBACK(update_vect), 100, 15, FALSE, NULL);
265 update_entry_double (GTK_ENTRY(vect_entry[k]), tmp_vect[i-1][j-1]);
266 gtk_grid_attach (GTK_GRID (table), vect_entry[k], j, i, 1, 1);
267 k ++;
268 }
269 }
270 }
271 }
272 run_this_gtk_dialog (win, G_CALLBACK(run_vectors), NULL);
273}
274
282void edit_box (GtkWidget * vbox)
283{
284 int i, j, k;
285 GtkWidget * entry;
286 GtkWidget * hbox;
287 tmp_pbc = active_cell -> pbc;
288 tmp_frac = active_cell -> frac;
289
290 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
291 check_button ("Apply Periodic Boundary Conditions",
292 -1, 40, tmp_pbc, G_CALLBACK(toggle_pbc), NULL), FALSE, FALSE, 0);
293 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
294 check_button ("Fractional coordinates",
295 -1, 40, tmp_frac, G_CALLBACK(toggle_frac), NULL), FALSE, FALSE, 0);
296 GtkWidget * table = gtk_grid_new ();
297 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 0);
298 k = 0;
299 for (i=0; i<3; i++)
300 {
301 for (j=0; j<3; j++, k++)
302 {
303 if (i < 2) tmp_box[i][j] = active_box -> param[i][j];
304 tmp_vect[i][j] = active_box -> vect[i][j];
305 t_box[k].a = i;
306 t_box[k].b = j;
307 }
308 }
309 tmp_lat = active_cell -> ltype;
310 k = 0;
311 for (i=0; i<2; i++)
312 {
313 gtk_grid_attach (GTK_GRID (table), markup_label(box_p[i], -1, 50, 0.5, 0.5), 1, i+2*i, 1, 1);
314 for (j=0; j<3; j++, k++)
315 {
316 gtk_grid_attach (GTK_GRID (table), markup_label(box_prop[i][j], -1, -1, 0.5, 0.5), j, i+2*i+1, 1, 1);
317 entry = create_entry (G_CALLBACK(update_box), 100, 15, FALSE, (gpointer)& t_box[k]);
318 update_entry_double (GTK_ENTRY(entry), tmp_box[i][j]);
319 gtk_grid_attach (GTK_GRID (table), entry, j, i+2*i+2, 1, 1);
320 }
321 }
322 GtkWidget * but = create_button ("Lattice Vectors", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_vectors_clicked), NULL);
323 hbox = create_hbox (0);
324 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 145);
325 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 15);
326}
327
336G_MODULE_EXPORT void update_chemistry (GtkEntry * entry, gpointer data)
337{
338 int i = gtk_combo_box_get_active (GTK_COMBO_BOX(spec_box));
339 int j = GPOINTER_TO_INT(data);
340 const gchar * m = entry_get_text (entry);
341 double v = string_to_double ((gpointer)m);
342 tmp_chem[j][i] = v;
343 update_entry_double (entry, v);
344}
345
354G_MODULE_EXPORT void on_spec_changed (GtkComboBox * combo, gpointer data)
355{
356 int i, j;
357 i = gtk_combo_box_get_active (combo);
358 gtk_label_set_text (GTK_LABEL(chem_spec[0]), active_chem -> element[i]);
359 gtk_label_set_text (GTK_LABEL(chem_spec[1]), g_strdup_printf("%d", (int)active_chem -> chem_prop[CHEM_Z][i]));
360 for (j=0; j<CHEM_PARAMS-1; j++)
361 {
362 update_entry_double (GTK_ENTRY(chem_entry[j]), tmp_chem[j][i]);
363 }
364 gtk_combo_box_set_active (GTK_COMBO_BOX(rad_box), -1);
365}
366
375G_MODULE_EXPORT void on_rad_changed (GtkComboBox * combo, gpointer data)
376{
377 int i, j, k;
378 i = gtk_combo_box_get_active (combo);
379 if (i != -1)
380 {
381 j = gtk_combo_box_get_active (GTK_COMBO_BOX(spec_box));
382 k = (int)active_chem -> chem_prop[CHEM_Z][j];
383 tmp_chem[1][j] = set_radius_ (& k, & i);
384 update_entry_double (GTK_ENTRY(chem_entry[1]), tmp_chem[1][j]);
385 }
386}
387
388#ifdef GTK4
397G_MODULE_EXPORT void toggle_xcor (GtkCheckButton * but, gpointer data)
398#else
407G_MODULE_EXPORT void toggle_xcor (GtkToggleButton * but, gpointer data)
408#endif
409{
410#ifdef GTK4
411 tmp_xcor = gtk_check_button_get_active (but);
412#else
413 tmp_xcor = gtk_toggle_button_get_active (but);
414#endif
416}
417
425void edit_chem (GtkWidget * vbox)
426{
427 int i, j;
430 g_signal_connect(G_OBJECT(spec_box), "changed", G_CALLBACK(on_spec_changed), NULL);
431 GtkWidget * table = gtk_grid_new ();
432 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 5);
433 GtkWidget * chem_fixed = gtk_fixed_new ();
434 gtk_grid_attach (GTK_GRID (table), chem_fixed, 1, 0, 1, 1);
435 for (i=0; i<CHEM_PARAMS+2; i++)
436 {
437 j = (i == 0) ? i : i + 2;
438 gtk_grid_attach (GTK_GRID (table), markup_label(chem_lab[i], 180, 30, 0.0, 0.5), 0, j, 1, 1);
439 if (i == 0)
440 {
441 for (j=0; j<active_project -> nspec; j++)
442 {
444 }
445 }
446 else
447 {
448 if (i > 0 && i < 3)
449 {
450 chem_spec[i-1] = markup_label ("", -1, -1, 0.5, 0.5);
451 gtk_grid_attach (GTK_GRID (table), chem_spec[i-1], 1, i+2, 1, 1);
452 }
453 else
454 {
455 if (i==5)
456 {
458 gtk_widget_set_size_request (rad_box, -1, 30);
459 for (j=0; j<4; j++)
460 {
462 }
463 gtk_combo_box_set_active (GTK_COMBO_BOX(rad_box), -1);
464 g_signal_connect(G_OBJECT(rad_box), "changed", G_CALLBACK(on_rad_changed), NULL);
465 gtk_grid_attach (GTK_GRID (table), rad_box, 1, i+1, 1, 1);
466 }
467 tmp_chem[i-3] = g_malloc (active_project -> nspec*sizeof*tmp_chem[i-3]);
468 for (j=0; j<active_project -> nspec; j++)
469 {
470 tmp_chem[i-3][j] = active_chem -> chem_prop[i-2][j];
471 }
472 chem_entry[i-3] = create_entry (G_CALLBACK(update_chemistry), 120, 15, FALSE, GINT_TO_POINTER(i-3));
473 update_entry_double (GTK_ENTRY(chem_entry[i-3]), tmp_chem[i-3][0]);
474 gtk_grid_attach (GTK_GRID (table), chem_entry[i-3], 2, i+2, 1, 1);
475 if (i==CHEM_PARAMS+1)
476 {
477 tmp_xcor = active_project -> xcor;
478 GtkWidget * chem_xcor = check_button ("= f(Q)", -1, 30, tmp_xcor, G_CALLBACK(toggle_xcor), NULL);
480 gtk_grid_attach (GTK_GRID (table), chem_xcor, 1, i+2, 1, 1);
481 }
482 gtk_grid_attach (GTK_GRID (table), markup_label(chem_unit[i-3], -1, -1, 0.0, 0.5), 3, i+2, 1, 1);
483 }
484 }
485 }
486 gtk_combo_box_set_active (GTK_COMBO_BOX(spec_box), 0);
487 gtk_fixed_put (GTK_FIXED (chem_fixed), spec_box, -1, -1);
488}
489
498gboolean test_vol (double box[2][3], double vect[3][3])
499{
500 int i, j;
501 gboolean val = TRUE;
502 tmp_lat = 0;
503 for (i=0; i<2; i++)
504 {
505 for (j=0; j<3; j++)
506 {
507 if (box[i][j] == 0.0) val = FALSE;
508 }
509 }
510 if (val) tmp_lat = 1;
511 val = TRUE;
512 for (i=0; i<3; i++)
513 {
514 if (vect[i][0] == 0.0 && vect[i][1] == 0.0 && vect[i][2] == 0.0)
515 {
516 val = FALSE;
517 }
518 }
519 if (val) tmp_lat = 2;
520 return (tmp_lat) ? TRUE : FALSE;
521}
522
533gboolean test_pbc (int pbc, int frac, double box[2][3], double vect[3][3])
534{
535 if (! pbc && ! frac)
536 {
537 if (! test_vol (box, vect)) tmp_lat = active_cell -> ltype;
538 return TRUE;
539 }
540 else
541 {
542 return test_vol (box, vect);
543 }
544}
545
552{
553 int i;
554 active_cell -> has_a_box = test_vol (active_box -> param, active_box -> vect);
555 if (! active_cell -> has_a_box)
556 {
557 for (i=0; i<4; i++) active_project -> runok[i] = FALSE;
558 }
559 else
560 {
561 for (i=0; i<3; i=i+2)
562 {
563 active_project -> runok[i] = TRUE;
564 active_project -> runok[i+1] = active_project -> visok[i];
565 }
566 }
568}
569
571{
572 int i, j;
573 gboolean changed = FALSE;
574 for (i=0; i<2; i++)
575 {
576 for (j=0; j<3; j++)
577 {
578 if (tmp_box[i][j] != active_box -> param[i][j])
579 {
580 active_box -> param[i][j] = tmp_box[i][j];
581 changed = TRUE;
582 }
583 }
584 }
585 return changed;
586}
587
589{
590 int i, j;
591 gboolean changed = FALSE;
592 for (i=0; i<3; i++)
593 {
594 for (j=0; j<3; j++)
595 {
596 if (tmp_vect[i][j] != active_box -> vect[i][j])
597 {
598 active_box -> vect[i][j] = tmp_vect[i][j];
599 changed = TRUE;
600 }
601 }
602 }
603 return changed;
604}
605
613void prep_box (int id)
614{
615 int i;
616 // active_project -> run = 1;
617 if (tmp_pbc != active_cell -> pbc) active_project -> run = 0;
618 active_cell -> pbc = tmp_pbc;
619 if (tmp_lat < 2 && tmp_lat != active_cell -> ltype) active_project -> run = 0;
620 if (tmp_lat > 0)
621 {
622 if (tmp_lat == 1 && has_box_changed())
623 {
624 active_project -> run = 0;
625 }
626 else if (tmp_lat == 2 && have_vectors_changed())
627 {
628 active_project -> run = 0;
629 }
630 }
631 active_cell -> ltype = tmp_lat;
632 init_box_calc ();
633 if (tmp_frac != active_cell -> frac) active_project -> run = 0;
634 active_cell -> frac = tmp_frac;
635 if (id > 1) active_project -> run = 0;
636 if (! active_project -> run)
637 {
638 if (active_project -> modelgl)
639 {
640 for (i=0; i<3; i++) active_project -> modelgl -> cshift[i] = 0.0;
641 }
642 }
643}
644
651{
652 int i, j;
653 gboolean upchem = FALSE;
654 for (i=1; i<CHEM_PARAMS; i++)
655 {
656 for (j=0; j<active_project -> nspec; j++)
657 {
658 if (tmp_chem[i-1][j] != active_chem -> chem_prop[i][j])
659 {
660 active_chem -> chem_prop[i][j] = tmp_chem[i-1][j];
661 upchem = TRUE;
662 }
663 }
664 g_free (tmp_chem[i-1]);
665 tmp_chem[i-1] = NULL;
666 }
667 if (tmp_xcor != active_project -> xcor)
668 {
669 active_project -> xcor = tmp_xcor;
670 upchem = TRUE;
671 }
672 if (upchem)
673 {
674 read_chem_ (active_chem -> chem_prop[CHEM_M], active_chem -> chem_prop[CHEM_R],
675 active_chem -> chem_prop[CHEM_N], active_chem -> chem_prop[CHEM_X]);
676 }
677}
678
684gboolean test_cutoffs ()
685{
686 int i, j, k;
687 k = 0;
688 for (i=0; i<active_project -> nspec; i++, k++)
689 {
690 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
691 }
692 for (i=0; i<active_project -> nspec-1; i++)
693 {
694 for (j=i+1; j<active_project -> nspec; j++, k++)
695 {
696 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
697 }
698 }
699 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
700 return TRUE;
701}
702
710void edit_bonds (GtkWidget * vbox)
711{
712 gchar * mess = "To define the existence of a bond between two atoms i (&#x3B1;) and j (&#x3B2;)."
713 "\n\tA bond exits if the two following conditions are verified:\n"
714 "\n\t\t1) D<sub>ij</sub> &#x3c; first minimum of the total g(r) - r<sub>cut</sub> (Tot.)"
715 "\n\t\t2) D<sub>ij</sub> &#x3c; first minimum of the partial gr<sub>&#x3B1;,&#x3B2;</sub>(r) - r<sub>cut</sub> (&#x3B1;,&#x3B2;)\n"
716 "\n\t0.0 &#x3c; r<sub>cut</sub> &#x2264; D<sub>max</sub>";
717 gchar * fin = "\n\tD<sub>max</sub> is the maximum inter-atomic distance in the model\n";
718 gchar * str;
719 if (active_project -> max[0] != 0.0)
720 {
721 str = g_strdup_printf ("%s\twith\tD<sub>max</sub> = %f &#xC5;%s",
722 mess, active_project -> max[0], fin);
723 }
724 else
725 {
726 str = g_strdup_printf ("%s%s", mess, fin);
727 }
728 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
729 g_free (str);
730 GtkWidget * hbox = create_hbox (0);
731 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
732 GtkWidget * boxv = create_vbox (BSEP);
733 cut_box (active_project, boxv);
734 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, boxv, FALSE, FALSE, 50);
735}
736
746G_MODULE_EXPORT void run_on_edit_activate (GtkDialog * win, gint response_id, gpointer data)
747{
748 int id = GPOINTER_TO_INT(data);
749 int i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
750
751 gboolean done = FALSE;
752 char * errpbc ="To apply PBC or use fractional coordinates\n"
753 "describe properly the simulation box parameters";
754 switch (response_id)
755 {
756 case GTK_RESPONSE_APPLY:
757 if (i== 0)
758 {
759 test_chem ();
760 done = TRUE;
761 }
762 else if (i == 1)
763 {
765 if (done)
766 {
767 prep_box (i);
768 if (id == 1)
769 {
770 if (! active_project -> run)
771 {
772 run_project ();
773 if (active_glwin) active_glwin -> create_shaders[MDBOX] = TRUE;
774 bonds_update = 1;
775 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
776 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
777 active_project -> runc[0] = FALSE;
778 on_calc_bonds_released (NULL, NULL);
779 }
780 }
781 }
782 else
783 {
784 show_warning (errpbc, GTK_WIDGET(win));
785 }
786 }
787 else
788 {
789 gboolean upc;
790 if (active_project -> modelgl)
791 {
792 if (active_project -> modelgl -> rings || active_project -> modelgl -> chains)
793 {
794 upc = ask_yes_no ("Data can be lost !", "You will lose\n rings statistics and/or chains statistics data\nProceed anyway ?", GTK_MESSAGE_WARNING, GTK_WIDGET(win));
795 }
796 else
797 {
798 upc = TRUE;
799 }
800 }
801 else
802 {
803 upc = TRUE;
804 }
806 done = TRUE;
807 }
808 break;
809 default:
810 if (i == 0)
811 {
812 test_chem ();
813 done = TRUE;
814 }
815 else if (i == 1)
816 {
817 done = test_pbc (active_cell -> pbc,
818 active_cell -> frac,
819 active_box -> param,
820 active_box -> vect);
821 }
822 else
823 {
824 done = TRUE;
825 }
826 break;
827 }
828 if (done) destroy_this_dialog (win);
829}
830
839G_MODULE_EXPORT void on_edit_activate (GtkWidget * widg, gpointer data)
840{
841 int i;
842 gboolean skip = FALSE;
843 int id = GPOINTER_TO_INT(data);
844 i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
845 GtkWidget * win = dialog_cancel_apply (edit_prop[i], MainWindow, FALSE);
846 GtkWidget * box = dialog_get_content_area (win);
847 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
848 if (i == 0)
849 {
850 edit_chem(box);
851 }
852 else if (i == 1)
853 {
854 edit_box (box);
855 if (id == 3)
856 {
858 if (skip)
859 {
860 active_cell -> ltype = tmp_lat;
861 init_box_calc ();
862 }
863 active_project -> run = 0;
864 }
865 }
866 else
867 {
869 edit_bonds (box);
870 if (id == 5) skip = test_cutoffs ();
871 }
872 if (! skip && ! silent_input)
873 {
874 run_this_gtk_dialog (win, G_CALLBACK(run_on_edit_activate), data);
875 }
876#ifdef GTK3
877 // GTK3 Menu Action To Check
878 int j, k;
879 if (active_glwin != NULL)
880 {
881 if (active_glwin -> init)
882 {
883 for (i=0; i<2; i++)
884 {
885 if (active_glwin -> ogl_box[i] != NULL)
886 {
887 widget_set_sensitive (active_glwin -> ogl_box[i], active_cell -> ltype);
888 if (i)
889 {
890 j = (active_cell -> ltype && active_project -> steps == 1) ? 1 : 0;
891 for (k=5; k<8; k++) widget_set_sensitive (active_glwin -> ogl_box[k], j);
892 }
893 }
894 }
895 }
896 }
897#endif
898 if (tmpcut)
899 {
900 g_free (tmpcut);
901 tmpcut = NULL;
902 }
903}
904
Binding to the Fortran90 subroutines.
double set_radius_(int *, int *)
void read_chem_(double *, double *, double *, double *)
void run_project()
send project data to Fortran90
Definition callbacks.c:633
Callback declarations for main window.
integer function chains()
Definition chains.F90:54
gchar * param[2]
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
GtkWidget * frac_box
Definition edit_menu.c:83
char * chem_lab[CHEM_PARAMS+2]
Definition edit_menu.c:75
G_MODULE_EXPORT void on_edit_activate(GtkWidget *widg, gpointer data)
create an edition dialog - prepare the dialog
Definition edit_menu.c:839
char * box_prop[2][3]
Definition edit_menu.c:73
void prep_box(int id)
prepare the project depending on the changes to the MD box
Definition edit_menu.c:613
void update_cutoffs(project *this_proj)
update bond cutoffs
Definition w_cutoffs.c:59
char * vect_comp[3]
Definition edit_menu.c:82
G_MODULE_EXPORT void update_box(GtkEntry *entry, gpointer data)
update lattice parameters
Definition edit_menu.c:107
GtkWidget * vect_entry[9]
Definition edit_menu.c:88
G_MODULE_EXPORT void toggle_pbc(GtkToggleButton *Button, gpointer data)
use PBC ?
Definition edit_menu.c:138
double tmp_vect[3][3]
Definition edit_menu.c:91
gboolean test_vol(double box[2][3], double vect[3][3])
is the cell properly described to use PBC ?
Definition edit_menu.c:498
void edit_bonds(GtkWidget *vbox)
creation of the edit bond cutoff widgets
Definition edit_menu.c:710
void cut_box(project *this_proj, GtkWidget *vbox)
box cutoff entries
Definition w_cutoffs.c:155
gboolean test_cutoffs()
are all cutoffs described ?
Definition edit_menu.c:684
char * vect_name[3]
Definition edit_menu.c:81
G_MODULE_EXPORT void update_chemistry(GtkEntry *entry, gpointer data)
update chemical property
Definition edit_menu.c:336
G_MODULE_EXPORT void run_on_edit_activate(GtkDialog *win, gint response_id, gpointer data)
create an edition dialog: run the dialog
Definition edit_menu.c:746
G_MODULE_EXPORT void run_vectors(GtkDialog *win, gint response_id, gpointer data)
lattice vectors: run the dialog
Definition edit_menu.c:211
gboolean have_vectors_changed()
Definition edit_menu.c:588
gboolean test_pbc(int pbc, int frac, double box[2][3], double vect[3][3])
is the cell properly described ?
Definition edit_menu.c:533
char * chem_unit[4]
Definition edit_menu.c:79
double * tmpcut
Definition w_cutoffs.c:50
void edit_chem(GtkWidget *vbox)
creation of the edit chemical properties widgets
Definition edit_menu.c:425
char * edit_prop[4]
Definition edit_menu.c:80
double tmp_box[2][3]
Definition edit_menu.c:90
void init_box_calc()
initialize calculation possibilities based the periodicity
Definition edit_menu.c:551
int tmp_lat
Definition edit_menu.c:93
G_MODULE_EXPORT void toggle_frac(GtkToggleButton *Button, gpointer data)
use fractional coordinates
Definition edit_menu.c:167
GtkWidget * rad_box
Definition edit_menu.c:85
G_MODULE_EXPORT void on_rad_changed(GtkComboBox *combo, gpointer data)
change the type of atomic radius
Definition edit_menu.c:375
char * box_p[2]
Definition edit_menu.c:72
int tmp_xcor
Definition edit_menu.c:93
dint t_box[9]
Definition edit_menu.c:94
G_MODULE_EXPORT void on_spec_changed(GtkComboBox *combo, gpointer data)
change the chemical species
Definition edit_menu.c:354
G_MODULE_EXPORT void on_vectors_clicked(GtkButton *but, gpointer data)
lattice vectors - prepare the dialog
Definition edit_menu.c:241
G_MODULE_EXPORT void update_vect(GtkEntry *entry, gpointer data)
update lattice vector component
Definition edit_menu.c:195
gboolean has_box_changed()
Definition edit_menu.c:570
double * tmp_chem[CHEM_PARAMS]
Definition edit_menu.c:89
int tmp_frac
Definition edit_menu.c:92
void edit_box(GtkWidget *vbox)
creation of the edit cell widgets
Definition edit_menu.c:282
char * chem_rad[4]
Definition edit_menu.c:78
GtkWidget * spec_box
Definition edit_menu.c:84
int tmp_pbc
Definition edit_menu.c:92
GtkWidget * chem_spec[2]
Definition edit_menu.c:86
G_MODULE_EXPORT void toggle_xcor(GtkToggleButton *but, gpointer data)
use X ray diffraction q coorection
Definition edit_menu.c:407
GtkWidget * chem_entry[CHEM_PARAMS-1]
Definition edit_menu.c:87
void test_chem()
were chemical properties modified ?
Definition edit_menu.c:650
int mol_update
Definition global.c:171
int activep
Definition global.c:159
gboolean silent_input
Definition global.c:188
int frag_update
Definition global.c:170
GtkWidget * MainWindow
Definition global.c:201
int bonds_update
Definition global.c:169
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
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
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1314
glwin * active_glwin
Definition project.c:53
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:633
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
cell_info * active_cell
Definition project.c:50
#define CHEM_N
Definition global.h:300
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 opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
#define GR
Definition global.h:322
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
#define STEP_LIMIT
Definition global.h:277
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:471
#define CHEM_PARAMS
Definition global.h:296
#define CHEM_R
Definition global.h:299
box_info * active_box
Definition project.c:51
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 * 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
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
#define CHEM_M
Definition global.h:298
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
#define CHEM_X
Definition global.h:301
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
#define CHEM_Z
Definition global.h:297
project * active_project
Definition project.c:47
#define max(a, b)
Definition global.h:80
@ MDBOX
Definition glwin.h:93
Function declarations for the creation of the OpenGL window.
void show_warning(char *warning, GtkWidget *win)
show warning
Definition interface.c:260
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
Messaging function declarations.
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:58
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition global.h:97
int b
Definition global.h:99
int a
Definition global.h:98
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
int element
Definition w_periodic.c:61
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
Function declarations for workspace managment.