atomes 1.2.1
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-2025 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#include "preferences.h"
72
73char * box_p[2]={"<b>Edges [&#xC5;]</b>", "<b>Angles [&#xB0;]</b>"};
74char * box_prop[2][3]={{"<b><i>a</i></b>", "<b><i>b</i></b>", "<b><i>c</i></b>"},
75 {"alpha - &#x3B1;", "beta - &#x3B2;", "gamma - &#x263;"}};
76char * chem_lab[CHEM_PARAMS+2]={"Atom:", "Element:",
77 "Atomic number", "Atomic mass:", "Radius",
78 "Neutrons scattering length:", "X-rays scattering length:"};
79char * chem_rad[4]={"Covalent", "Ionic", "van Der Waals", "In crystal"};
80char * chem_unit[4]={" g/mol", " &#xC5;", " fm", " e.u"};
81char * edit_prop[4]={"Chemistry and physics", "Box and periodicity", "Bond cutoffs", "Lattice vectors"};
82char * vect_name[3]={"<i>a</i>", "<i>b</i>", "<i>c</i>"};
83char * vect_comp[3]={"x", "y", "z"};
84GtkWidget * frac_box;
85GtkWidget * spec_box;
86GtkWidget * rad_box;
87GtkWidget * chem_spec[2];
88GtkWidget * chem_entry[CHEM_PARAMS-1];
89GtkWidget * vect_entry[9];
91double tmp_lattice[2][3];
92double tmp_vect[3][3];
96extern double * tmpcut;
97extern void update_cutoffs (project * this_proj);
98extern void cut_box (project * this_proj, GtkWidget * vbox);
99
108G_MODULE_EXPORT void update_box (GtkEntry * entry, gpointer data)
109{
110 dint * id = (dint *)data;
111 const gchar * m = entry_get_text (entry);
112 double v = string_to_double ((gpointer)m);
113 if (v >= 0.0)
114 {
115 tmp_lattice[id -> a][id -> b] = v;
116 }
117 update_entry_double (entry, v);
118}
119
120#ifdef GTK4
129G_MODULE_EXPORT void toggle_pbc (GtkCheckButton * Button, gpointer data)
130#else
139G_MODULE_EXPORT void toggle_pbc (GtkToggleButton * Button, gpointer data)
140#endif
141{
142 tmp_pbc = button_get_status ((GtkWidget *)Button);
143}
144
145#ifdef GTK4
154G_MODULE_EXPORT void toggle_frac (GtkCheckButton * Button, gpointer data)
155#else
164G_MODULE_EXPORT void toggle_frac (GtkToggleButton * Button, gpointer data)
165#endif
166{
167 tmp_frac = button_get_status ((GtkWidget *)Button);
168 /*if (gtk_toggle_button_get_active (Button))
169 {
170 widget_set_sensitive (frac_box, 1);
171 combo_set_active (frac_box, 0);
172 }
173 else
174 {
175 combo_set_active (frac_box, -1);
176 widget_set_sensitive (frac_box, 0);
177 }*/
178}
179
188G_MODULE_EXPORT void update_vect (GtkEntry * entry, gpointer data)
189{
190 const gchar * m = entry_get_text (entry);
191 double v = string_to_double ((gpointer)m);
192 update_entry_double (entry, v);
193}
194
204G_MODULE_EXPORT void run_vectors (GtkDialog * win, gint response_id, gpointer data)
205{
206 if (response_id == GTK_RESPONSE_APPLY)
207 {
208 int i, j, k;
209 const gchar * m;
210 double v;
211 i = 0;
212 for (j=0; j<3; j++)
213 {
214 for (k=0; k<3; k++)
215 {
216 m = entry_get_text (GTK_ENTRY(vect_entry[i]));
217 v = string_to_double ((gpointer)m);
218 tmp_vect[j][k] = v;
219 i ++;
220 }
221 }
222 }
224}
225
234G_MODULE_EXPORT void on_vectors_clicked (GtkButton * but, gpointer data)
235{
236 int i, j, k;
237 GtkWidget * win = dialog_cancel_apply (edit_prop[3], MainWindow, FALSE);
238 GtkWidget * table = gtk_grid_new ();
239 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area (win), table, FALSE, FALSE, 5);
240 k = 0;
241 for (i=0; i<4; i++)
242 {
243 if (i > 0)
244 {
245 gtk_grid_attach (GTK_GRID (table), markup_label(vect_name[i-1], 30, -1, 0.5, 0.5), 0, i, 1, 1);
246 }
247 for (j=0; j<4; j++)
248 {
249 if (j > 0)
250 {
251 if (i == 0)
252 {
253 gtk_grid_attach (GTK_GRID (table), markup_label(vect_comp[j-1], -1, 30, 0.5, 0.5), j, 0, 1, 1);
254 }
255 else
256 {
257 vect_entry[k] = create_entry (G_CALLBACK(update_vect), 100, 15, FALSE, NULL);
258 update_entry_double (GTK_ENTRY(vect_entry[k]), tmp_vect[i-1][j-1]);
259 gtk_grid_attach (GTK_GRID (table), vect_entry[k], j, i, 1, 1);
260 k ++;
261 }
262 }
263 }
264 }
265 run_this_gtk_dialog (win, G_CALLBACK(run_vectors), NULL);
266}
267
275void edit_box (GtkWidget * vbox)
276{
277 int i, j, k;
278 GtkWidget * entry;
279 GtkWidget * hbox;
280 tmp_pbc = active_cell -> pbc;
281 tmp_frac = active_cell -> frac;
282
283 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
284 check_button ("Apply Periodic Boundary Conditions",
285 -1, 40, tmp_pbc, G_CALLBACK(toggle_pbc), NULL), FALSE, FALSE, 0);
286 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
287 check_button ("Fractional coordinates",
288 -1, 40, tmp_frac, G_CALLBACK(toggle_frac), NULL), FALSE, FALSE, 0);
289 GtkWidget * table = gtk_grid_new ();
290 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 0);
291 k = 0;
292 for (i=0; i<3; i++)
293 {
294 for (j=0; j<3; j++, k++)
295 {
296 if (i < 2) tmp_lattice[i][j] = active_box -> param[i][j];
297 tmp_vect[i][j] = active_box -> vect[i][j];
298 t_box[k].a = i;
299 t_box[k].b = j;
300 }
301 }
302 tmp_lat = active_cell -> ltype;
303 k = 0;
304 for (i=0; i<2; i++)
305 {
306 gtk_grid_attach (GTK_GRID (table), markup_label(box_p[i], -1, 50, 0.5, 0.5), 1, i+2*i, 1, 1);
307 for (j=0; j<3; j++, k++)
308 {
309 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);
310 entry = create_entry (G_CALLBACK(update_box), 100, 15, FALSE, (gpointer)& t_box[k]);
311 update_entry_double (GTK_ENTRY(entry), tmp_lattice[i][j]);
312 gtk_grid_attach (GTK_GRID (table), entry, j, i+2*i+2, 1, 1);
313 }
314 }
315 GtkWidget * but = create_button ("Lattice Vectors", IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_vectors_clicked), NULL);
316 hbox = create_hbox (0);
317 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 145);
318 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 15);
319}
320
329G_MODULE_EXPORT void update_chemistry (GtkEntry * entry, gpointer data)
330{
331 int i = combo_get_active (spec_box);
332 int j = GPOINTER_TO_INT(data);
333 const gchar * m = entry_get_text (entry);
334 double v = string_to_double ((gpointer)m);
335 tmp_chem[j][i] = v;
336 update_entry_double (entry, v);
337}
338
347G_MODULE_EXPORT void on_spec_changed (GtkComboBox * combo, gpointer data)
348{
349 int i, j;
350 i = combo_get_active ((GtkWidget *)combo);
351 gtk_label_set_text (GTK_LABEL(chem_spec[0]), active_chem -> element[i]);
352 gtk_label_set_text (GTK_LABEL(chem_spec[1]), g_strdup_printf("%d", (int)active_chem -> chem_prop[CHEM_Z][i]));
353 for (j=0; j<CHEM_PARAMS-1; j++)
354 {
355 update_entry_double (GTK_ENTRY(chem_entry[j]), tmp_chem[j][i]);
356 }
358}
359
368G_MODULE_EXPORT void on_rad_changed (GtkComboBox * combo, gpointer data)
369{
370 int i, j, k;
371 i = combo_get_active ((GtkWidget *)combo);
372 if (i != -1)
373 {
375 k = (int)active_chem -> chem_prop[CHEM_Z][j];
376 tmp_chem[1][j] = set_radius_ (& k, & i);
377 update_entry_double (GTK_ENTRY(chem_entry[1]), tmp_chem[1][j]);
378 }
379}
380
381#ifdef GTK4
390G_MODULE_EXPORT void toggle_xcor (GtkCheckButton * but, gpointer data)
391#else
400G_MODULE_EXPORT void toggle_xcor (GtkToggleButton * but, gpointer data)
401#endif
402{
403 tmp_xcor = button_get_status ((GtkWidget *)but);
405}
406
414void edit_chem (GtkWidget * vbox)
415{
416 int i, j;
419 g_signal_connect(G_OBJECT(spec_box), "changed", G_CALLBACK(on_spec_changed), NULL);
420 GtkWidget * table = gtk_grid_new ();
421 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 5);
422 GtkWidget * chem_fixed = gtk_fixed_new ();
423 gtk_grid_attach (GTK_GRID (table), chem_fixed, 1, 0, 1, 1);
424 for (i=0; i<CHEM_PARAMS+2; i++)
425 {
426 j = (i == 0) ? i : i + 2;
427 gtk_grid_attach (GTK_GRID (table), markup_label(chem_lab[i], 180, 30, 0.0, 0.5), 0, j, 1, 1);
428 if (i == 0)
429 {
430 for (j=0; j<active_project -> nspec; j++)
431 {
433 }
434 }
435 else
436 {
437 if (i > 0 && i < 3)
438 {
439 chem_spec[i-1] = markup_label ("", -1, -1, 0.5, 0.5);
440 gtk_grid_attach (GTK_GRID (table), chem_spec[i-1], 1, i+2, 1, 1);
441 }
442 else
443 {
444 if (i==5)
445 {
447 gtk_widget_set_size_request (rad_box, -1, 30);
448 for (j=0; j<4; j++)
449 {
451 }
453 g_signal_connect(G_OBJECT(rad_box), "changed", G_CALLBACK(on_rad_changed), NULL);
454 gtk_grid_attach (GTK_GRID (table), rad_box, 1, i+1, 1, 1);
455 }
456 tmp_chem[i-3] = g_malloc (active_project -> nspec*sizeof*tmp_chem[i-3]);
457 for (j=0; j<active_project -> nspec; j++)
458 {
459 tmp_chem[i-3][j] = active_chem -> chem_prop[i-2][j];
460 }
461 chem_entry[i-3] = create_entry (G_CALLBACK(update_chemistry), 120, 15, FALSE, GINT_TO_POINTER(i-3));
462 update_entry_double (GTK_ENTRY(chem_entry[i-3]), tmp_chem[i-3][0]);
463 gtk_grid_attach (GTK_GRID (table), chem_entry[i-3], 2, i+2, 1, 1);
464 if (i==CHEM_PARAMS+1)
465 {
466 tmp_xcor = active_project -> xcor;
467 GtkWidget * chem_xcor = check_button ("= f(Q)", -1, 30, tmp_xcor, G_CALLBACK(toggle_xcor), NULL);
469 gtk_grid_attach (GTK_GRID (table), chem_xcor, 1, i+2, 1, 1);
470 }
471 gtk_grid_attach (GTK_GRID (table), markup_label(chem_unit[i-3], -1, -1, 0.0, 0.5), 3, i+2, 1, 1);
472 }
473 }
474 }
476 gtk_fixed_put (GTK_FIXED (chem_fixed), spec_box, -1, -1);
477}
478
487gboolean test_vol (double box[2][3], double vect[3][3])
488{
489 int i, j;
490 gboolean val = TRUE;
491 tmp_lat = 0;
492 for (i=0; i<2; i++)
493 {
494 for (j=0; j<3; j++)
495 {
496 if (box[i][j] == 0.0) val = FALSE;
497 }
498 }
499 if (val) tmp_lat = 1;
500 val = TRUE;
501 for (i=0; i<3; i++)
502 {
503 if (vect[i][0] == 0.0 && vect[i][1] == 0.0 && vect[i][2] == 0.0)
504 {
505 val = FALSE;
506 }
507 }
508 if (val) tmp_lat = 2;
509 return (tmp_lat) ? TRUE : FALSE;
510}
511
522gboolean test_pbc (int pbc, int frac, double box[2][3], double vect[3][3])
523{
524 if (! pbc && ! frac)
525 {
526 if (! test_vol (box, vect)) tmp_lat = active_cell -> ltype;
527 return TRUE;
528 }
529 else
530 {
531 return test_vol (box, vect);
532 }
533}
534
541{
542 int i;
543 active_cell -> has_a_box = test_vol (active_box -> param, active_box -> vect);
544 if (! active_cell -> has_a_box)
545 {
546 for (i=0; i<4; i++) active_project -> runok[i] = FALSE;
547 }
548 else
549 {
550 for (i=0; i<3; i=i+2)
551 {
552 active_project -> runok[i] = TRUE;
553 active_project -> runok[i+1] = active_project -> visok[i];
554 }
555 }
557}
558
560{
561 int i, j;
562 gboolean changed = FALSE;
563 for (i=0; i<2; i++)
564 {
565 for (j=0; j<3; j++)
566 {
567 if (tmp_lattice[i][j] != active_box -> param[i][j])
568 {
569 active_box -> param[i][j] = tmp_lattice[i][j];
570 changed = TRUE;
571 }
572 }
573 }
574 return changed;
575}
576
578{
579 int i, j;
580 gboolean changed = FALSE;
581 for (i=0; i<3; i++)
582 {
583 for (j=0; j<3; j++)
584 {
585 if (tmp_vect[i][j] != active_box -> vect[i][j])
586 {
587 active_box -> vect[i][j] = tmp_vect[i][j];
588 changed = TRUE;
589 }
590 }
591 }
592 return changed;
593}
594
602void prep_box (int id)
603{
604 int i;
605 // active_project -> run = 1;
606 if (tmp_pbc != active_cell -> pbc) active_project -> run = 0;
607 active_cell -> pbc = tmp_pbc;
609 if (tmp_lat > 0)
610 {
611 if (tmp_lat == 1 && has_box_changed())
612 {
613 active_project -> run = 0;
614 }
615 else if (tmp_lat == 2 && have_vectors_changed())
616 {
617 active_project -> run = 0;
618 }
619 }
620 active_cell -> ltype = tmp_lat;
621 init_box_calc ();
622 if (tmp_frac != active_cell -> frac) active_project -> run = 0;
623 active_cell -> frac = tmp_frac;
624 if (id > 1) active_project -> run = 0;
625 if (! active_project -> run)
626 {
627 if (active_project -> modelgl)
628 {
629 for (i=0; i<3; i++) active_project -> modelgl -> cshift[i] = 0.0;
630 }
631 }
632}
633
640{
641 int i, j;
642 gboolean upchem = FALSE;
643 for (i=1; i<CHEM_PARAMS; i++)
644 {
645 for (j=0; j<active_project -> nspec; j++)
646 {
647 if (tmp_chem[i-1][j] != active_chem -> chem_prop[i][j])
648 {
649 active_chem -> chem_prop[i][j] = tmp_chem[i-1][j];
650 upchem = TRUE;
651 }
652 }
653 g_free (tmp_chem[i-1]);
654 tmp_chem[i-1] = NULL;
655 }
656 if (tmp_xcor != active_project -> xcor)
657 {
658 active_project -> xcor = tmp_xcor;
659 upchem = TRUE;
660 }
661 if (upchem)
662 {
663 read_chem_ (active_chem -> chem_prop[CHEM_M], active_chem -> chem_prop[CHEM_R],
664 active_chem -> chem_prop[CHEM_N], active_chem -> chem_prop[CHEM_X]);
665 }
666}
667
673gboolean test_cutoffs ()
674{
675 int i, j, k;
676 k = 0;
677 for (i=0; i<active_project -> nspec; i++, k++)
678 {
679 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
680 }
681 for (i=0; i<active_project -> nspec-1; i++)
682 {
683 for (j=i+1; j<active_project -> nspec; j++, k++)
684 {
685 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
686 }
687 }
688 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
689 return TRUE;
690}
691
699void edit_bonds (GtkWidget * vbox)
700{
701 gchar * mess[2] = {"To define the existence of a bond between two atoms i (&#x3B1;) and j (&#x3B2;), ",
702 "a bond exits if the two following conditions are verified:"};
703 gchar * cond[2] = {"1) D<sub>ij</sub> &#x3c; first minimum of the total g(r) - r<sub>cut</sub> (Tot.)",
704 "2) D<sub>ij</sub> &#x3c; first minimum of the partial gr<sub>&#x3B1;,&#x3B2;</sub>(r) - r<sub>cut</sub> (&#x3B1;,&#x3B2;)"};
705 gchar * m_end= "0.0 &#x3c; r<sub>cut</sub> &#x2264; D<sub>max</sub>";
706 gchar * fin = "D<sub>max</sub> is the maximum inter-atomic distance in the model\n";
707 gchar * str;
708 if (! preferences)
709 {
710 if (active_project -> max[0] != 0.0)
711 {
712 str = g_strdup_printf ("%s\twith\tD<sub>max</sub> = %f &#xC5;",
713 m_end, active_project -> max[0]);
714 }
715 else
716 {
717 str = g_strdup_printf ("With %s", m_end);
718 }
719 }
720 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(mess[0], -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
721 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(mess[1], -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
722 GtkWidget * vvbox = create_vbox (0);
723 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vvbox, FALSE, FALSE, 20);
724 GtkWidget * hbox = create_hbox (0);
725 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 0);
726 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cond[0], -1, -1, 0.0, 0.5), FALSE, FALSE, 50);
727 hbox = create_hbox (0);
728 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 0);
729 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(cond[1], -1, -1, 0.0, 0.5), FALSE, FALSE, 50);
730 if (! preferences)
731 {
732 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, vbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
733 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, vbox, markup_label(fin, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
734 g_free (str);
735 hbox = create_hbox (0);
736 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
737 GtkWidget * boxv = create_vbox (BSEP);
738 cut_box (active_project, boxv);
739 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, boxv, FALSE, FALSE, 50);
740 }
741}
742
752G_MODULE_EXPORT void run_on_edit_activate (GtkDialog * win, gint response_id, gpointer data)
753{
754 int id = GPOINTER_TO_INT(data);
755 int i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
756
757 gboolean done = FALSE;
758 char * errpbc ="To apply PBC or use fractional coordinates\n"
759 "describe properly the simulation box parameters";
760 switch (response_id)
761 {
762 case GTK_RESPONSE_APPLY:
763 if (i== 0)
764 {
765 test_chem ();
766 done = TRUE;
767 }
768 else if (i == 1)
769 {
771 if (done)
772 {
773 prep_box (i);
774 if (id == 1)
775 {
776 if (! active_project -> run)
777 {
778 run_project ();
779 if (active_glwin) active_glwin -> create_shaders[MDBOX] = TRUE;
780 bonds_update = 1;
781 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
782 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
783 active_project -> runc[0] = FALSE;
784 on_calc_bonds_released (NULL, NULL);
785 }
786 }
787 }
788 else
789 {
790 show_warning (errpbc, GTK_WIDGET(win));
791 }
792 }
793 else
794 {
795 gboolean upc;
796 if (active_project -> modelgl)
797 {
798 if (active_project -> modelgl -> rings || active_project -> modelgl -> chains)
799 {
800 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));
801 }
802 else
803 {
804 upc = TRUE;
805 }
806 }
807 else
808 {
809 upc = TRUE;
810 }
812 done = TRUE;
813 }
814 break;
815 default:
816 if (i == 0)
817 {
818 test_chem ();
819 done = TRUE;
820 }
821 else if (i == 1)
822 {
823 done = test_pbc (active_cell -> pbc,
824 active_cell -> frac,
825 active_box -> param,
826 active_box -> vect);
827 }
828 else
829 {
830 done = TRUE;
831 }
832 break;
833 }
834 if (done) destroy_this_dialog (win);
835}
836
845G_MODULE_EXPORT void on_edit_activate (GtkWidget * widg, gpointer data)
846{
847 int i;
848 gboolean skip = FALSE;
849 int id = GPOINTER_TO_INT(data);
850 i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
851 GtkWidget * win = dialog_cancel_apply (edit_prop[i], MainWindow, FALSE);
852 GtkWidget * box = dialog_get_content_area (win);
853 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
854 if (i == 0)
855 {
856 edit_chem(box);
857 }
858 else if (i == 1)
859 {
860 edit_box (box);
861 if (id == 3)
862 {
864 if (skip)
865 {
866 active_cell -> ltype = tmp_lat;
867 init_box_calc ();
868 }
869 active_project -> run = 0;
870 }
871 }
872 else
873 {
875 edit_bonds (box);
876 if (id == 5) skip = test_cutoffs ();
877 }
878 if (! skip && ! silent_input)
879 {
880 run_this_gtk_dialog (win, G_CALLBACK(run_on_edit_activate), data);
881 }
882#ifdef GTK3
883 // GTK3 Menu Action To Check
884 int j, k;
885 if (active_glwin != NULL)
886 {
887 if (active_glwin -> init)
888 {
889 for (i=0; i<2; i++)
890 {
891 if (active_glwin -> ogl_box[i] != NULL)
892 {
893 widget_set_sensitive (active_glwin -> ogl_box[i], active_cell -> ltype);
894 if (i)
895 {
896 j = (active_cell -> ltype && active_project -> steps == 1) ? 1 : 0;
897 for (k=5; k<8; k++) widget_set_sensitive (active_glwin -> ogl_box[k], j);
898 }
899 }
900 }
901 }
902 }
903#endif
904 if (tmpcut)
905 {
906 g_free (tmpcut);
907 tmpcut = NULL;
908 }
909}
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:631
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:84
char * chem_lab[CHEM_PARAMS+2]
Definition edit_menu.c:76
G_MODULE_EXPORT void on_edit_activate(GtkWidget *widg, gpointer data)
create an edition dialog - prepare the dialog
Definition edit_menu.c:845
char * box_prop[2][3]
Definition edit_menu.c:74
void prep_box(int id)
prepare the project depending on the changes to the MD box
Definition edit_menu.c:602
void update_cutoffs(project *this_proj)
update bond cutoffs
Definition w_cutoffs.c:59
char * vect_comp[3]
Definition edit_menu.c:83
G_MODULE_EXPORT void update_box(GtkEntry *entry, gpointer data)
update lattice parameters
Definition edit_menu.c:108
GtkWidget * vect_entry[9]
Definition edit_menu.c:89
G_MODULE_EXPORT void toggle_pbc(GtkToggleButton *Button, gpointer data)
use PBC ?
Definition edit_menu.c:139
double tmp_vect[3][3]
Definition edit_menu.c:92
gboolean test_vol(double box[2][3], double vect[3][3])
is the cell properly described to use PBC ?
Definition edit_menu.c:487
void edit_bonds(GtkWidget *vbox)
creation of the edit bond cutoff widgets
Definition edit_menu.c:699
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:673
char * vect_name[3]
Definition edit_menu.c:82
G_MODULE_EXPORT void update_chemistry(GtkEntry *entry, gpointer data)
update chemical property
Definition edit_menu.c:329
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:752
G_MODULE_EXPORT void run_vectors(GtkDialog *win, gint response_id, gpointer data)
lattice vectors: run the dialog
Definition edit_menu.c:204
gboolean have_vectors_changed()
Definition edit_menu.c:577
gboolean test_pbc(int pbc, int frac, double box[2][3], double vect[3][3])
is the cell properly described ?
Definition edit_menu.c:522
char * chem_unit[4]
Definition edit_menu.c:80
double * tmpcut
Definition w_cutoffs.c:50
void edit_chem(GtkWidget *vbox)
creation of the edit chemical properties widgets
Definition edit_menu.c:414
char * edit_prop[4]
Definition edit_menu.c:81
void init_box_calc()
initialize calculation possibilities based the periodicity
Definition edit_menu.c:540
int tmp_lat
Definition edit_menu.c:94
G_MODULE_EXPORT void toggle_frac(GtkToggleButton *Button, gpointer data)
use fractional coordinates
Definition edit_menu.c:164
GtkWidget * rad_box
Definition edit_menu.c:86
G_MODULE_EXPORT void on_rad_changed(GtkComboBox *combo, gpointer data)
change the type of atomic radius
Definition edit_menu.c:368
char * box_p[2]
Definition edit_menu.c:73
double tmp_lattice[2][3]
Definition edit_menu.c:91
int tmp_xcor
Definition edit_menu.c:94
dint t_box[9]
Definition edit_menu.c:95
G_MODULE_EXPORT void on_spec_changed(GtkComboBox *combo, gpointer data)
change the chemical species
Definition edit_menu.c:347
G_MODULE_EXPORT void on_vectors_clicked(GtkButton *but, gpointer data)
lattice vectors - prepare the dialog
Definition edit_menu.c:234
G_MODULE_EXPORT void update_vect(GtkEntry *entry, gpointer data)
update lattice vector component
Definition edit_menu.c:188
gboolean has_box_changed()
Definition edit_menu.c:559
double * tmp_chem[CHEM_PARAMS]
Definition edit_menu.c:90
int tmp_frac
Definition edit_menu.c:93
void edit_box(GtkWidget *vbox)
creation of the edit cell widgets
Definition edit_menu.c:275
char * chem_rad[4]
Definition edit_menu.c:79
GtkWidget * spec_box
Definition edit_menu.c:85
int tmp_pbc
Definition edit_menu.c:93
GtkWidget * chem_spec[2]
Definition edit_menu.c:87
G_MODULE_EXPORT void toggle_xcor(GtkToggleButton *but, gpointer data)
use X ray diffraction q coorection
Definition edit_menu.c:400
GtkWidget * chem_entry[CHEM_PARAMS-1]
Definition edit_menu.c:88
void test_chem()
were chemical properties modified ?
Definition edit_menu.c:639
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: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
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
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:643
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
cell_info * active_cell
Definition project.c:50
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
#define CHEM_N
Definition global.h:302
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 opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
#define GR
Definition global.h:324
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
#define STEP_LIMIT
Definition global.h:279
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:514
#define CHEM_PARAMS
Definition global.h:298
#define CHEM_R
Definition global.h:301
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:1955
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
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
#define CHEM_M
Definition global.h:300
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
#define CHEM_X
Definition global.h:303
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 CHEM_Z
Definition global.h:299
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
gboolean preferences
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:351
Definition global.h:99
int b
Definition global.h:101
int a
Definition global.h:100
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.