atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
cell_density.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: 'cell_density.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'density adjustment' tab in the cell edition window
29
30*
31* List of functions:
32
33 void display_density (cell_edition * cell, double vol, double dens, double adens);
34
35 G_MODULE_EXPORT void set_rescaling (GtkCheckButton * but, gpointer data);
36 G_MODULE_EXPORT void set_rescaling (GtkToggleButton * but, gpointer data);
37
38 GtkWidget * adjust_density_tab (project * this_proj);
39
40*/
41
42#include "cell_edit.h"
43
54void display_density (cell_edition * cell, double vol, double dens, double adens)
55{
56 cell -> density = destroy_this_widget (cell -> density);
57 cell -> density = create_vbox (BSEP);
58 GtkWidget * hbox;
59 gchar * pname[3]= {"Volume:", "Mass density:", "Number density:"};
60 gchar * punit[3]= {"&#xC5;<sup>3</sup>", "g/cm<sup>3</sup>", "atom/&#xC5;<sup>3</sup>"};
61 double val[3];
62 val[0] = vol;
63 val[1] = dens;
64 val[2] = adens;
65 int i;
66 gchar * str;
67 for (i=0; i<3; i++)
68 {
69 hbox = create_hbox (0);
70 add_box_child_start (GTK_ORIENTATION_VERTICAL, cell -> density, hbox, FALSE, FALSE, 0);
71 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(pname[i], 120, -1, 0.0, 0.5), FALSE, FALSE, 100);
72 str = g_strdup_printf ("<b>%f</b>", val[i]);
73 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(str, 120, -1, 0.0, 0.5), FALSE, FALSE, 0);
74 g_free (str);
75 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label(punit[i], 20, -1, 0.5, 0.5), FALSE, FALSE, 10);
76 }
77 add_box_child_start (GTK_ORIENTATION_VERTICAL, cell -> density_box, cell -> density, FALSE, FALSE, 10);
78 show_the_widgets (cell -> density);
79}
80
81#ifdef GTK4
90G_MODULE_EXPORT void set_rescaling (GtkCheckButton * but, gpointer data)
91#else
100G_MODULE_EXPORT void set_rescaling (GtkToggleButton * but, gpointer data)
101#endif
102{
103 glwin * view = (glwin *)data;
104#ifdef GTK4
105 view -> cell_win -> homo_density = gtk_check_button_get_active (but);
106#else
107 view -> cell_win -> homo_density = gtk_toggle_button_get_active (but);
108#endif
109 widget_set_sensitive (view -> cell_win -> shift_box[1], view -> cell_win -> homo_density);
110}
111
119GtkWidget * adjust_density_tab (project * this_proj)
120{
121 GtkWidget * layout = create_layout (350, 400);
122 GtkWidget * vbox = create_vbox (BSEP);
123 layout_add_widget (layout, vbox, 100, 10);
124 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label("Modify the density of the simulation box <sup>*</sup>: ", -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
125 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, check_button ("Homogeneous rescaling <sup>**</sup>", -1, -1, this_proj -> modelgl -> cell_win -> homo_density,
126 G_CALLBACK(set_rescaling), this_proj -> modelgl), FALSE, FALSE, 5);
127 int i;
128 for (i=3; i<6; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, create_cell_entries (this_proj, i), FALSE, FALSE, 0);
129 this_proj -> modelgl -> cell_win -> density_box = create_vbox (5);
130 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, this_proj -> modelgl -> cell_win -> density_box, FALSE, FALSE, 5);
131 display_density (this_proj -> modelgl -> cell_win, this_proj -> cell.volume,
132 this_proj -> cell.density, this_proj -> natomes/this_proj -> cell.volume);
133 gchar * info[2] = {" * Visual information will be preserved, real bonding is likely to be modified.\n"
134 " Bond properties should be re-calculated, if required bond cutoff should be updated.",
135 "** Keep the ratios between the lattice vectors A, B and C like in the initial cell."};
136 for (i=0; i<2; i++) add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(info[i], -1, -1, 0.0, 0.5), FALSE, FALSE, 5);
138 return layout;
139}
void display_density(cell_edition *cell, double vol, double dens, double adens)
create density information widgets
G_MODULE_EXPORT void set_rescaling(GtkToggleButton *but, gpointer data)
homogeneous rescaling toggle callback GTK3
GtkWidget * adjust_density_tab(project *this_proj)
create the density tab
Function declarations for the cell edition window.
GtkWidget * create_cell_entries(project *this_proj, int i)
create the cell entry widgets
Definition cell_shift.c:402
PangoLayout * layout
Definition curve.c:79
float val
Definition dlp_init.c:117
#define BSEP
Definition global.h:245
void layout_add_widget(GtkWidget *layout, GtkWidget *child, int x_pos, int y_pos)
Add a GtkWidget in a GtkLayout.
Definition gtk-misc.c:846
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1799
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
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
Definition gtk-misc.c:880
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
Definition glwin.h:875
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72