atomes 1.3.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-2026 by CNRS and University of Strasbourg */
15
21
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]={i18n("<b>Edges [&#xC5;]</b>"), i18n("<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 * edit_prop[4]={i18n("Chemistry and physics"), i18n("Box and periodicity"), i18n("Bond cutoffs"), i18n("Lattice vectors")};
77char * vect_name[3]={"<i>a</i>", "<i>b</i>", "<i>c</i>"};
78char * vect_comp[3]={"x", "y", "z"};
79GtkWidget * frac_box;
80GtkWidget * spec_box;
81GtkWidget * rad_box;
82GtkWidget * chem_spec[2];
83GtkWidget * chem_entry[CHEM_PARAMS-1];
84GtkWidget * vect_entry[9];
86double tmp_lattice[2][3];
87double tmp_vect[3][3];
91extern double * tmpcut;
92extern void update_cutoffs (project * this_proj);
93extern void cut_box (project * this_proj, GtkWidget * vbox);
94
103G_MODULE_EXPORT void update_box (GtkEntry * entry, gpointer data)
104{
105 dint * id = (dint *)data;
106 const gchar * m = entry_get_text (entry);
107 double v = string_to_double ((gpointer)m);
108 if (v >= 0.0)
109 {
110 tmp_lattice[id -> a][id -> b] = v;
111 }
112 update_entry_double (entry, v);
113}
114
115#ifdef GTK4
124G_MODULE_EXPORT void toggle_pbc (GtkCheckButton * Button, gpointer data)
125#else
134G_MODULE_EXPORT void toggle_pbc (GtkToggleButton * Button, gpointer data)
135#endif
136{
137 tmp_pbc = button_get_status ((GtkWidget *)Button);
138}
139
140#ifdef GTK4
149G_MODULE_EXPORT void toggle_frac (GtkCheckButton * Button, gpointer data)
150#else
159G_MODULE_EXPORT void toggle_frac (GtkToggleButton * Button, gpointer data)
160#endif
161{
162 tmp_frac = button_get_status ((GtkWidget *)Button);
163 /*if (gtk_toggle_button_get_active (Button))
164 {
165 widget_set_sensitive (frac_box, 1);
166 combo_set_active (frac_box, 0);
167 }
168 else
169 {
170 combo_set_active (frac_box, -1);
171 widget_set_sensitive (frac_box, 0);
172 }*/
173}
174
183G_MODULE_EXPORT void update_vect (GtkEntry * entry, gpointer data)
184{
185 const gchar * m = entry_get_text (entry);
186 double v = string_to_double ((gpointer)m);
187 update_entry_double (entry, v);
188}
189
199G_MODULE_EXPORT void run_vectors (GtkDialog * win, gint response_id, gpointer data)
200{
201 if (response_id == GTK_RESPONSE_APPLY)
202 {
203 int i, j, k;
204 const gchar * m;
205 double v;
206 i = 0;
207 for (j=0; j<3; j++)
208 {
209 for (k=0; k<3; k++)
210 {
211 m = entry_get_text (GTK_ENTRY(vect_entry[i]));
212 v = string_to_double ((gpointer)m);
213 tmp_vect[j][k] = v;
214 i ++;
215 }
216 }
217 }
219}
220
229G_MODULE_EXPORT void on_vectors_clicked (GtkButton * but, gpointer data)
230{
231 int i, j, k;
232 GtkWidget * win = dialog_cancel_apply (_(edit_prop[3]), MainWindow, FALSE);
233 GtkWidget * table = gtk_grid_new ();
234 add_box_child_start (GTK_ORIENTATION_VERTICAL, dialog_get_content_area (win), table, FALSE, FALSE, 5);
235 k = 0;
236 for (i=0; i<4; i++)
237 {
238 if (i > 0)
239 {
240 gtk_grid_attach (GTK_GRID (table), markup_label(vect_name[i-1], 30, -1, 0.5, 0.5), 0, i, 1, 1);
241 }
242 for (j=0; j<4; j++)
243 {
244 if (j > 0)
245 {
246 if (i == 0)
247 {
248 gtk_grid_attach (GTK_GRID (table), markup_label(vect_comp[j-1], -1, 30, 0.5, 0.5), j, 0, 1, 1);
249 }
250 else
251 {
252 vect_entry[k] = create_entry (G_CALLBACK(update_vect), 100, 15, FALSE, NULL);
253 update_entry_double (GTK_ENTRY(vect_entry[k]), tmp_vect[i-1][j-1]);
254 gtk_grid_attach (GTK_GRID (table), vect_entry[k], j, i, 1, 1);
255 k ++;
256 }
257 }
258 }
259 }
260 run_this_gtk_dialog (win, G_CALLBACK(run_vectors), NULL);
261}
262
270void edit_box (GtkWidget * vbox)
271{
272 int i, j, k;
273 GtkWidget * entry;
274 GtkWidget * hbox;
275 tmp_pbc = active_cell -> pbc;
276 tmp_frac = active_cell -> frac;
277
278 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
279 check_button (_("Apply <b>P</b>eriodic <b>B</b>oundary <b>C</b>onditions"),
280 -1, 40, tmp_pbc, G_CALLBACK(toggle_pbc), NULL), FALSE, FALSE, 0);
281 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox,
282 check_button (_("Fractional coordinates"),
283 -1, 40, tmp_frac, G_CALLBACK(toggle_frac), NULL), FALSE, FALSE, 0);
284 GtkWidget * table = gtk_grid_new ();
285 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 0);
286 k = 0;
287 for (i=0; i<3; i++)
288 {
289 for (j=0; j<3; j++, k++)
290 {
291 if (i < 2) tmp_lattice[i][j] = active_box -> param[i][j];
292 tmp_vect[i][j] = active_box -> vect[i][j];
293 t_box[k].a = i;
294 t_box[k].b = j;
295 }
296 }
297 tmp_lat = active_cell -> ltype;
298 k = 0;
299 for (i=0; i<2; i++)
300 {
301 gtk_grid_attach (GTK_GRID (table), markup_label(_(box_p[i]), -1, 50, 0.5, 0.5), 1, i+2*i, 1, 1);
302 for (j=0; j<3; j++, k++)
303 {
304 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);
305 entry = create_entry (G_CALLBACK(update_box), 100, 15, FALSE, (gpointer)& t_box[k]);
306 update_entry_double (GTK_ENTRY(entry), tmp_lattice[i][j]);
307 gtk_grid_attach (GTK_GRID (table), entry, j, i+2*i+2, 1, 1);
308 }
309 }
310 GtkWidget * but = create_button (_("Lattice vectors"), IMG_NONE, NULL, -1, -1, GTK_RELIEF_NORMAL, G_CALLBACK(on_vectors_clicked), NULL);
311 hbox = create_hbox (0);
312 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 145);
313 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 15);
314}
315
324G_MODULE_EXPORT void update_chemistry (GtkEntry * entry, gpointer data)
325{
326 int i = combo_get_active (spec_box);
327 int j = GPOINTER_TO_INT(data);
328 const gchar * m = entry_get_text (entry);
329 double v = string_to_double ((gpointer)m);
330 tmp_chem[j][i] = v;
331 update_entry_double (entry, v);
332}
333
342G_MODULE_EXPORT void on_spec_changed (GtkComboBox * combo, gpointer data)
343{
344 int i, j;
345 i = combo_get_active ((GtkWidget *)combo);
346 gtk_label_set_text (GTK_LABEL(chem_spec[0]), active_chem -> element[i]);
347 gtk_label_set_text (GTK_LABEL(chem_spec[1]), g_strdup_printf("%d", (int)active_chem -> chem_prop[CHEM_Z][i]));
348 for (j=0; j<CHEM_PARAMS-1; j++)
349 {
350 update_entry_double (GTK_ENTRY(chem_entry[j]), tmp_chem[j][i]);
351 }
353}
354
363G_MODULE_EXPORT void on_rad_changed (GtkComboBox * combo, gpointer data)
364{
365 int i, j, k;
366 i = combo_get_active ((GtkWidget *)combo);
367 if (i != -1)
368 {
370 k = (int)active_chem -> chem_prop[CHEM_Z][j];
371 tmp_chem[1][j] = set_radius_ (& k, & i);
372 update_entry_double (GTK_ENTRY(chem_entry[1]), tmp_chem[1][j]);
373 }
374}
375
376#ifdef GTK4
385G_MODULE_EXPORT void toggle_xcor (GtkCheckButton * but, gpointer data)
386#else
395G_MODULE_EXPORT void toggle_xcor (GtkToggleButton * but, gpointer data)
396#endif
397{
398 tmp_xcor = button_get_status ((GtkWidget *)but);
400}
401
409void edit_chem (GtkWidget * vbox)
410{
411 char * chem_lab[CHEM_PARAMS+2]={i18n("Atom:"), i18n("Element:"),
412 i18n("Atomic number:"), i18n("Atomic mass:"), i18n("Radius:"),
413 i18n("Neutrons scattering length:"), i18n("X-rays scattering length:")};
414 char * chem_rad[4]={i18n("Covalent"), i18n("Ionic"), "van der Waals", i18n("In Crystal")};
415 char * chem_unit[4]={" g/mol", " &#xC5;", " fm", " e.u"};
416 int i, j;
417
420 g_signal_connect(G_OBJECT(spec_box), "changed", G_CALLBACK(on_spec_changed), NULL);
421 GtkWidget * table = gtk_grid_new ();
422 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, table, FALSE, FALSE, 5);
423 GtkWidget * chem_fixed = gtk_fixed_new ();
424 gtk_grid_attach (GTK_GRID (table), chem_fixed, 1, 0, 1, 1);
425 for (i=0; i<CHEM_PARAMS+2; i++)
426 {
427 j = (i == 0) ? i : i + 2;
428 gtk_grid_attach (GTK_GRID (table), markup_label(_(chem_lab[i]), 180, 30, 0.0, 0.5), 0, j, 1, 1);
429 if (i == 0)
430 {
431 for (j=0; j<active_project -> nspec; j++)
432 {
434 }
435 }
436 else
437 {
438 if (i > 0 && i < 3)
439 {
440 chem_spec[i-1] = markup_label ("", -1, -1, 0.5, 0.5);
441 gtk_grid_attach (GTK_GRID (table), chem_spec[i-1], 1, i+2, 1, 1);
442 }
443 else
444 {
445 if (i==5)
446 {
448 gtk_widget_set_size_request (rad_box, -1, 30);
449 for (j=0; j<4; j++)
450 {
451 combo_text_append (rad_box, _(chem_rad[j]));
452 }
454 g_signal_connect(G_OBJECT(rad_box), "changed", G_CALLBACK(on_rad_changed), NULL);
455 gtk_grid_attach (GTK_GRID (table), rad_box, 1, i+1, 1, 1);
456 }
457 tmp_chem[i-3] = g_malloc0(active_project -> nspec*sizeof*tmp_chem[i-3]);
458 for (j=0; j<active_project -> nspec; j++)
459 {
460 tmp_chem[i-3][j] = active_chem -> chem_prop[i-2][j];
461 }
462 chem_entry[i-3] = create_entry (G_CALLBACK(update_chemistry), 120, 15, FALSE, GINT_TO_POINTER(i-3));
463 update_entry_double (GTK_ENTRY(chem_entry[i-3]), tmp_chem[i-3][0]);
464 gtk_grid_attach (GTK_GRID (table), chem_entry[i-3], 2, i+2, 1, 1);
465 if (i==CHEM_PARAMS+1)
466 {
467 tmp_xcor = active_project -> xcor;
468 GtkWidget * chem_xcor = check_button ("= f(Q)", -1, 30, tmp_xcor, G_CALLBACK(toggle_xcor), NULL);
470 gtk_grid_attach (GTK_GRID (table), chem_xcor, 1, i+2, 1, 1);
471 }
472 gtk_grid_attach (GTK_GRID (table), markup_label(chem_unit[i-3], -1, -1, 0.0, 0.5), 3, i+2, 1, 1);
473 }
474 }
475 }
477 gtk_fixed_put (GTK_FIXED (chem_fixed), spec_box, -1, -1);
478}
479
488gboolean test_vol (double box[2][3], double vect[3][3])
489{
490 int i, j;
491 gboolean val = TRUE;
492 tmp_lat = 0;
493 for (i=0; i<2; i++)
494 {
495 for (j=0; j<3; j++)
496 {
497 if (box[i][j] == 0.0) val = FALSE;
498 }
499 }
500 if (val) tmp_lat = 1;
501 val = TRUE;
502 for (i=0; i<3; i++)
503 {
504 if (vect[i][0] == 0.0 && vect[i][1] == 0.0 && vect[i][2] == 0.0)
505 {
506 val = FALSE;
507 }
508 }
509 if (val) tmp_lat = 2;
510 return (tmp_lat) ? TRUE : FALSE;
511}
512
523gboolean test_pbc (int pbc, int frac, double box[2][3], double vect[3][3])
524{
525 if (! pbc && ! frac)
526 {
527 if (! test_vol (box, vect)) tmp_lat = active_cell -> ltype;
528 return TRUE;
529 }
530 else
531 {
532 return test_vol (box, vect);
533 }
534}
535
542{
543 active_cell -> has_a_box = test_vol (active_box -> param, active_box -> vect);
544 if (! active_cell -> has_a_box)
545 {
546
547 if (active_project -> analysis)
548 {
549 active_project -> analysis[GDR] -> avail_ok = FALSE;
550 active_project -> analysis[SQD] -> avail_ok = FALSE;
551 active_project -> analysis[SKD] -> avail_ok = FALSE;
552 active_project -> analysis[GDK] -> avail_ok = FALSE;
553 }
554 }
555 else
556 {
557 if (active_project -> analysis)
558 {
559 active_project -> analysis[GDR] -> avail_ok = TRUE;
560 active_project -> analysis[SQD] -> avail_ok = active_project -> analysis[GDR] -> calc_ok;
561 active_project -> analysis[SKD] -> avail_ok = TRUE;
562 active_project -> analysis[GDK] -> avail_ok = active_project -> analysis[SKD] -> calc_ok;
563 }
564 }
566}
567
569{
570 int i, j;
571 gboolean changed = FALSE;
572 for (i=0; i<2; i++)
573 {
574 for (j=0; j<3; j++)
575 {
576 g_debug ("i= %d, j= %d, tmp_lattice[%d][%d]= %f, active_box -> param[%d][%d]= %f", i, j, i, j, tmp_lattice[i][j], i, j, active_box -> param[i][j]);
577 if (tmp_lattice[i][j] != active_box -> param[i][j])
578 {
579 active_box -> param[i][j] = tmp_lattice[i][j];
580
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;
620 if (tmp_lat > 0)
621 {
622 if (has_box_changed())
623 {
624 tmp_lat = 1;
625 active_project -> run = 0;
626 }
627 else if (have_vectors_changed())
628 {
629 tmp_lat = 2;
630 active_project -> run = 0;
631 }
632 }
633 active_cell -> ltype = tmp_lat;
634 init_box_calc ();
635 if (tmp_frac != active_cell -> frac) active_project -> run = 0;
636 active_cell -> frac = tmp_frac;
637 if (id > 1) active_project -> run = 0;
638 if (! active_project -> run)
639 {
640 if (active_project -> modelgl)
641 {
642 for (i=0; i<3; i++) active_project -> modelgl -> cshift[i] = 0.0;
643 }
644 }
645}
646
653{
654 int i, j;
655 gboolean upchem = FALSE;
656 for (i=1; i<CHEM_PARAMS; i++)
657 {
658 for (j=0; j<active_project -> nspec; j++)
659 {
660 if (tmp_chem[i-1][j] != active_chem -> chem_prop[i][j])
661 {
662 active_chem -> chem_prop[i][j] = tmp_chem[i-1][j];
663 upchem = TRUE;
664 }
665 }
666 g_free (tmp_chem[i-1]);
667 tmp_chem[i-1] = NULL;
668 }
669 if (tmp_xcor != active_project -> xcor)
670 {
671 active_project -> xcor = tmp_xcor;
672 upchem = TRUE;
673 }
674 if (upchem)
675 {
676 read_chem_ (active_chem -> chem_prop[CHEM_M], active_chem -> chem_prop[CHEM_R],
677 active_chem -> chem_prop[CHEM_N], active_chem -> chem_prop[CHEM_X]);
678 }
679}
680
686gboolean test_cutoffs ()
687{
688 int i, j, k;
689 k = 0;
690 for (i=0; i<active_project -> nspec; i++, k++)
691 {
692 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> analysis[GDR] -> max)) return FALSE;
693 }
694 for (i=0; i<active_project -> nspec-1; i++)
695 {
696 for (j=i+1; j<active_project -> nspec; j++, k++)
697 {
698 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> analysis[GDR] -> max)) return FALSE;
699 }
700 }
701 if (tmpcut[k] == 0.0 || (active_project -> run && tmpcut[k] > active_project -> analysis[GDR] -> max)) return FALSE;
702 return TRUE;
703}
704
712void edit_bonds (GtkWidget * vbox)
713{
714 gchar * mess[2] = {i18n("To define the existence of a bond between 2 atoms i (&#x3B1;) and j (&#x3B2;), "),
715 i18n("a bond exits if the 2 following conditions are verified:")};
716 gchar * cond[2] = {i18n("1) D<sub>ij</sub> &#x3c; first minimum of the total g(r) - r<sub>cut</sub> (Tot.)"),
717 i18n("2) D<sub>ij</sub> &#x3c; first minimum of the partial g<sub>&#x3B1;,&#x3B2;</sub>(r) - r<sub>cut</sub> (&#x3B1;,&#x3B2;)")};
718 gchar * m_end= i18n("0.0 &#x3c; r<sub>cut</sub> &#x2264; D<sub>max</sub>");
719 gchar * fin = i18n("D<sub>max</sub> is the maximum inter-atomic distance in the model\n");
720 gchar * str;
721 if (! preferences)
722 {
723 if (active_project -> analysis)
724 {
725 if (active_project -> analysis[GDR] -> max != 0.0)
726 {
727 str = g_strdup_printf (_("%s\twith\tD<sub>max</sub> = %f &#xC5;"),
728 _(m_end), active_project -> analysis[GDR] -> max);
729 }
730 else
731 {
732 str = g_strdup_printf (_("With %s"), _(m_end));
733 }
734 }
735 else
736 {
737 str = g_strdup_printf (_("With %s"), _(m_end));
738 }
739 }
740 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_(mess[0]), -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
741 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(_(mess[1]), -1, -1, 0.5, 0.5), FALSE, FALSE, 5);
742 GtkWidget * vvbox = create_vbox (0);
743 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, vvbox, FALSE, FALSE, 20);
744 GtkWidget * hbox = create_hbox (0);
745 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 0);
746 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_(cond[0]), -1, -1, 0.0, 0.5), FALSE, FALSE, 50);
747 hbox = create_hbox (0);
748 add_box_child_start (GTK_ORIENTATION_VERTICAL, vvbox, hbox, FALSE, FALSE, 0);
749 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(_(cond[1]), -1, -1, 0.0, 0.5), FALSE, FALSE, 50);
750 if (! preferences)
751 {
752 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, vbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
753 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, vbox, markup_label(_(fin), -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
754 g_free (str);
755 hbox = create_hbox (0);
756 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
757 GtkWidget * boxv = create_vbox (BSEP);
758 cut_box (active_project, boxv);
759 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, boxv, FALSE, FALSE, 50);
760 }
761}
762
772G_MODULE_EXPORT void run_on_edit_activate (GtkDialog * win, gint response_id, gpointer data)
773{
774 int id = GPOINTER_TO_INT(data);
775 int i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
776
777 gboolean done = FALSE;
778 char * errpbc = i18n("To apply PBC or use fractional coordinates\n"
779 "describe properly the simulation box parameters");
780 switch (response_id)
781 {
782 case GTK_RESPONSE_APPLY:
783 if (i== 0)
784 {
785 test_chem ();
786 done = TRUE;
787 }
788 else if (i == 1)
789 {
791 if (done)
792 {
793 prep_box (i);
794 if (id == 1)
795 {
796 if (! active_project -> run)
797 {
798 run_project ();
799 if (active_glwin) active_glwin -> create_shaders[MDBOX] = TRUE;
800 bonds_update = 1;
801 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
802 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
803 active_project -> runc[0] = FALSE;
804 on_calc_bonds_released (NULL, NULL);
805 }
806 }
807 }
808 else
809 {
810 show_warning (_(errpbc), GTK_WIDGET(win));
811 }
812 }
813 else
814 {
815 gboolean upc;
816 if (active_project -> modelgl)
817 {
818 if (active_project -> modelgl -> rings || active_project -> modelgl -> chains)
819 {
820 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));
821 }
822 else
823 {
824 upc = TRUE;
825 }
826 }
827 else
828 {
829 upc = TRUE;
830 }
832 done = TRUE;
833 }
834 break;
835 default:
836 if (i == 0)
837 {
838 test_chem ();
839 done = TRUE;
840 }
841 else if (i == 1)
842 {
843 done = test_pbc (active_cell -> pbc,
844 active_cell -> frac,
845 active_box -> param,
846 active_box -> vect);
847 }
848 else
849 {
850 done = TRUE;
851 }
852 break;
853 }
854 if (done) destroy_this_dialog (win);
855}
856
865G_MODULE_EXPORT void on_edit_activate (GtkWidget * widg, gpointer data)
866{
867 int i;
868 gboolean skip = FALSE;
869 int id = GPOINTER_TO_INT(data);
870 i = (id < 2) ? id : (id > 2 && id < 5) ? 1 : 2;
871 GtkWidget * win = dialog_cancel_apply (_(edit_prop[i]), MainWindow, FALSE);
872 GtkWidget * box = dialog_get_content_area (win);
873 gtk_box_set_homogeneous (GTK_BOX(box), FALSE);
874 if (i == 0)
875 {
876 edit_chem(box);
877 }
878 else if (i == 1)
879 {
880 edit_box (box);
881 if (id == 3)
882 {
884 if (skip)
885 {
886 active_cell -> ltype = tmp_lat;
887 init_box_calc ();
888 }
889 active_project -> run = 0;
890 }
891 }
892 else
893 {
895 edit_bonds (box);
896 if (id == 5) skip = test_cutoffs ();
897 }
898 if (! skip && ! silent_input)
899 {
900 run_this_gtk_dialog (win, G_CALLBACK(run_on_edit_activate), data);
901 }
902#ifdef GTK3
903 // GTK3 Menu Action To Check
904 int j, k;
905 if (active_glwin != NULL)
906 {
907 if (active_glwin -> init)
908 {
909 for (i=0; i<2; i++)
910 {
911 if (active_glwin -> ogl_box[i] != NULL)
912 {
913 widget_set_sensitive (active_glwin -> ogl_box[i], active_cell -> ltype);
914 if (i)
915 {
916 j = (active_cell -> ltype && active_project -> steps == 1) ? 1 : 0;
917 for (k=5; k<8; k++) widget_set_sensitive (active_glwin -> ogl_box[k], j);
918 }
919 }
920 }
921 }
922 }
923#endif
924 if (tmpcut)
925 {
926 g_free (tmpcut);
927 tmpcut = NULL;
928 }
929}
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:759
Callback declarations for main window.
integer function chains()
Definition chains.F90:54
gchar * param[2]
float val
Definition dlp_init.c:117
GtkWidget * frac_box
Definition edit_menu.c:79
G_MODULE_EXPORT void on_edit_activate(GtkWidget *widg, gpointer data)
create an edition dialog - prepare the dialog
Definition edit_menu.c:865
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:613
void update_cutoffs(project *this_proj)
update bond cutoffs
Definition w_cutoffs.c:59
G_MODULE_EXPORT void update_box(GtkEntry *entry, gpointer data)
update lattice parameters
Definition edit_menu.c:103
GtkWidget * vect_entry[9]
Definition edit_menu.c:84
G_MODULE_EXPORT void toggle_pbc(GtkToggleButton *Button, gpointer data)
use PBC ?
Definition edit_menu.c:134
double tmp_vect[3][3]
Definition edit_menu.c:87
gboolean test_vol(double box[2][3], double vect[3][3])
is the cell properly described to use PBC ?
Definition edit_menu.c:488
void edit_bonds(GtkWidget *vbox)
creation of the edit bond cutoff widgets
Definition edit_menu.c:712
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:686
char * vect_name[3]
Definition edit_menu.c:77
G_MODULE_EXPORT void update_chemistry(GtkEntry *entry, gpointer data)
update chemical property
Definition edit_menu.c:324
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:772
G_MODULE_EXPORT void run_vectors(GtkDialog *win, gint response_id, gpointer data)
lattice vectors: run the dialog
Definition edit_menu.c:199
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:523
double * tmpcut
Definition w_cutoffs.c:50
void edit_chem(GtkWidget *vbox)
creation of the edit chemical properties widgets
Definition edit_menu.c:409
char * edit_prop[4]
Definition edit_menu.c:76
void init_box_calc()
initialize calculation possibilities based the periodicity
Definition edit_menu.c:541
int tmp_lat
Definition edit_menu.c:89
G_MODULE_EXPORT void toggle_frac(GtkToggleButton *Button, gpointer data)
use fractional coordinates
Definition edit_menu.c:159
GtkWidget * rad_box
Definition edit_menu.c:81
G_MODULE_EXPORT void on_rad_changed(GtkComboBox *combo, gpointer data)
change the type of atomic radius
Definition edit_menu.c:363
char * box_p[2]
Definition edit_menu.c:73
double tmp_lattice[2][3]
Definition edit_menu.c:86
int tmp_xcor
Definition edit_menu.c:89
dint t_box[9]
Definition edit_menu.c:90
G_MODULE_EXPORT void on_spec_changed(GtkComboBox *combo, gpointer data)
change the chemical species
Definition edit_menu.c:342
G_MODULE_EXPORT void on_vectors_clicked(GtkButton *but, gpointer data)
lattice vectors - prepare the dialog
Definition edit_menu.c:229
G_MODULE_EXPORT void update_vect(GtkEntry *entry, gpointer data)
update lattice vector component
Definition edit_menu.c:183
gboolean has_box_changed()
Definition edit_menu.c:568
double * tmp_chem[CHEM_PARAMS]
Definition edit_menu.c:85
int tmp_frac
Definition edit_menu.c:88
void edit_box(GtkWidget *vbox)
creation of the edit cell widgets
Definition edit_menu.c:270
GtkWidget * spec_box
Definition edit_menu.c:80
int tmp_pbc
Definition edit_menu.c:88
GtkWidget * chem_spec[2]
Definition edit_menu.c:82
G_MODULE_EXPORT void toggle_xcor(GtkToggleButton *but, gpointer data)
use X ray diffraction q coorection
Definition edit_menu.c:395
GtkWidget * chem_entry[CHEM_PARAMS-1]
Definition edit_menu.c:83
void test_chem()
were chemical properties modified ?
Definition edit_menu.c:652
int mol_update
Definition global.c:175
int activep
Definition global.c:162
gboolean silent_input
Definition global.c:192
int frag_update
Definition global.c:174
GtkWidget * MainWindow
Definition global.c:207
int bonds_update
Definition global.c:173
#define i18n(String)
Definition global.c:80
double string_to_double(gpointer string)
convert string to double
Definition global.c:611
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:616
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:533
@ IMG_NONE
Definition global.h:276
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:935
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1401
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:688
#define SQD
Definition global.h:338
#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:958
#define CHEM_N
Definition global.h:319
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:652
chemical_data * active_chem
Definition project.c:48
#define BSEP
Definition global.h:261
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:296
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1937
#define STEP_LIMIT
Definition global.h:293
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:559
#define CHEM_PARAMS
Definition global.h:315
#define CHEM_R
Definition global.h:318
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:1999
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:1010
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:861
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1672
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:340
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:247
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2235
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:849
#define CHEM_M
Definition global.h:317
#define SKD
Definition global.h:339
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:987
#define CHEM_X
Definition global.h:320
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:837
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1899
#define CHEM_Z
Definition global.h:316
#define GDK
Definition global.h:340
project * active_project
Definition project.c:47
#define GDR
Definition global.h:337
#define max(a, b)
Definition global.h:92
@ 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:266
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:420
Messaging function declarations.
void prep_calc_actions()
prepare analysis widgets
Definition update_p.c:59
char * vect_comp[3]
Definition edit_menu.c:78
gboolean preferences
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Definition glwin.h:350
Definition global.h:111
int element
Definition w_periodic.c:61
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
Function declarations for workspace managment.