atomes 1.1.15
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 res = 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 // res = 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 // res = TRUE;
671 }
672 // return res;
673}
674
680gboolean test_cutoffs ()
681{
682 int i, j, k;
683 k = 0;
684 for (i=0; i<active_project -> nspec; i++, k++)
685 {
686 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
687 }
688 for (i=0; i<active_project -> nspec-1; i++)
689 {
690 for (j=i+1; j<active_project -> nspec; j++, k++)
691 {
692 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
693 }
694 }
695 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> max[GR])) return FALSE;
696 return TRUE;
697}
698
706void edit_bonds (GtkWidget * vbox)
707{
708 gchar * mess = "To define the existence of a bond between two atoms i (&#x3B1;) and j (&#x3B2;)."
709 "\n\tA bond exits if the two following conditions are verified:\n"
710 "\n\t\t1) D<sub>ij</sub> &#x3c; first minimum of the total g(r) - r<sub>cut</sub> (Tot.)"
711 "\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"
712 "\n\t0.0 &#x3c; r<sub>cut</sub> &#x2264; D<sub>max</sub>";
713 gchar * fin = "\n\tD<sub>max</sub> is the maximum inter-atomic distance in the model\n";
714 gchar * str;
715 if (active_project -> max[0] != 0.0)
716 {
717 str = g_strdup_printf ("%s\twith\tD<sub>max</sub> = %f &#xC5;%s",
718 mess, active_project -> max[0], fin);
719 }
720 else
721 {
722 str = g_strdup_printf ("%s%s", mess, fin);
723 }
724 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
725 g_free (str);
726 GtkWidget * hbox = create_hbox (0);
727 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
728 GtkWidget * boxv = create_vbox (BSEP);
729 cut_box (active_project, boxv);
730 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, boxv, FALSE, FALSE, 50);
731}
732
742G_MODULE_EXPORT void run_on_edit_activate (GtkDialog * win, gint response_id, gpointer data)
743{
744 int id = GPOINTER_TO_INT(data);
745 int i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
746
747 gboolean done = FALSE;
748 char * errpbc ="To apply PBC or use fractional coordinates\n"
749 "describe properly the simulation box parameters";
750 switch (response_id)
751 {
752 case GTK_RESPONSE_APPLY:
753 if (i== 0)
754 {
755 test_chem ();
756 done = TRUE;
757 }
758 else if (i == 1)
759 {
761 if (done)
762 {
763 prep_box (i);
764 if (id == 1)
765 {
766 if (! active_project -> run)
767 {
768 run_project ();
769 if (active_glwin) active_glwin -> create_shaders[MDBOX] = TRUE;
770 bonds_update = 1;
771 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
772 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
773 active_project -> runc[0] = FALSE;
774 on_calc_bonds_released (NULL, NULL);
775 }
776 }
777 }
778 else
779 {
780 show_warning (errpbc, GTK_WIDGET(win));
781 }
782 }
783 else
784 {
785 gboolean upc;
786 if (active_project -> modelgl)
787 {
788 if (active_project -> modelgl -> rings || active_project -> modelgl -> chains)
789 {
790 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));
791 }
792 else
793 {
794 upc = TRUE;
795 }
796 }
797 else
798 {
799 upc = TRUE;
800 }
802 done = TRUE;
803 }
804 break;
805 default:
806 if (i == 0)
807 {
808 test_chem ();
809 done = TRUE;
810 }
811 else if (i == 1)
812 {
813 done = test_pbc (active_cell -> pbc,
814 active_cell -> frac,
815 active_box -> param,
816 active_box -> vect);
817 }
818 else
819 {
820 done = TRUE;
821 }
822 break;
823 }
824 if (done) destroy_this_dialog (win);
825}
826
835G_MODULE_EXPORT void on_edit_activate (GtkWidget * widg, gpointer data)
836{
837 int i;
838 gboolean skip = FALSE;
839 int id = GPOINTER_TO_INT(data);
840 i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
841 GtkWidget * win = dialog_cancel_apply (edit_prop[i], MainWindow, FALSE);
842 GtkWidget * box = dialog_get_content_area (win);
843 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
844 if (i == 0)
845 {
846 edit_chem(box);
847 }
848 else if (i == 1)
849 {
850 edit_box (box);
851 if (id == 3)
852 {
854 if (skip)
855 {
856 active_cell -> ltype = tmp_lat;
857 init_box_calc ();
858 }
859 active_project -> run = 0;
860 }
861 }
862 else
863 {
865 edit_bonds (box);
866 if (id == 5) skip = test_cutoffs ();
867 }
868 if (! skip && ! silent_input)
869 {
870 run_this_gtk_dialog (win, G_CALLBACK(run_on_edit_activate), data);
871 }
872#ifdef GTK3
873 // GTK3 Menu Action To Check
874 int j, k;
875 if (active_glwin != NULL)
876 {
877 if (active_glwin -> init)
878 {
879 for (i=0; i<2; i++)
880 {
881 if (active_glwin -> ogl_box[i] != NULL)
882 {
883 widget_set_sensitive (active_glwin -> ogl_box[i], active_cell -> ltype);
884 if (i)
885 {
886 j = (active_cell -> ltype && active_project -> steps == 1) ? 1 : 0;
887 for (k=5; k<8; k++) widget_set_sensitive (active_glwin -> ogl_box[k], j);
888 }
889 }
890 }
891 }
892 }
893#endif
894 if (tmpcut)
895 {
896 g_free (tmpcut);
897 tmpcut = NULL;
898 }
899}
900
Binding to the Fortran90 subroutines.
double set_radius_(int *, int *)
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:835
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:706
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:680
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:742
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
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
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
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:900
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.