74 box = & this_proj -> cell.box[0];
75 lat = mat4 (box -> vect[0][0], box -> vect[1][0], box -> vect[2][0], 0.0,
76 box -> vect[0][1], box -> vect[1][1], box -> vect[2][1], 0.0,
77 box -> vect[0][2], box -> vect[1][2], box -> vect[2][2], 0.0,
79 rec = mat4 (box -> rvect[0][0], box -> rvect[0][1], box -> rvect[0][2], 0.0,
80 box -> rvect[1][0], box -> rvect[1][1], box -> rvect[1][2], 0.0,
81 box -> rvect[2][0], box -> rvect[2][1], box -> rvect[2][2], 0.0,
84 for (i=0; i<this_proj -> steps; i++)
86 for (j=0; j<this_proj -> natomes; j++)
88 pos = vec3(this_proj ->
atoms[i][j].
x, this_proj ->
atoms[i][j].
y, this_proj ->
atoms[i][j].
z);
91 res = m4_mul_pos(*drec, pos);
92 pos = m4_mul_pos(*dlat,
res);
96 if (this_proj -> cell.npt && i)
98 box = & this_proj -> cell.box[i];
99 lat = mat4 (box -> vect[0][0], box -> vect[1][0], box -> vect[2][0], 0.0,
100 box -> vect[0][1], box -> vect[1][1], box -> vect[2][1], 0.0,
101 box -> vect[0][2], box -> vect[1][2], box -> vect[2][2], 0.0,
103 rec = mat4 (box -> rvect[0][0], box -> rvect[0][1], box -> rvect[0][2], 0.0,
104 box -> rvect[1][0], box -> rvect[1][1], box -> rvect[1][2], 0.0,
105 box -> rvect[2][0], box -> rvect[2][1], box -> rvect[2][2], 0.0,
108 res = m4_mul_pos(rec, pos);
110 res.x -= (int)(
res.x/0.5);
112 res.y -= (int)(
res.y/0.5);
114 res.z -= (int)(
res.z/0.5);
115 pos = m4_mul_pos(lat,
res);
117 this_proj ->
atoms[i][j].x = pos.
x;
118 this_proj ->
atoms[i][j].y = pos.
y;
119 this_proj ->
atoms[i][j].z = pos.
z;
123 for (j=0; j<this_proj -> modelgl ->
bonds[i][1]; j++)
125 pos = vec3(this_proj -> modelgl -> clones[i][j].
x, this_proj -> modelgl -> clones[i][j].
y, this_proj -> modelgl -> clones[i][j].
z);
126 res = m4_mul_pos(*drec, pos);
127 pos = m4_mul_pos(*dlat,
res);
128 this_proj -> modelgl -> clones[i][j].x = pos.
x;
129 this_proj -> modelgl -> clones[i][j].y = pos.
y;
130 this_proj -> modelgl -> clones[i][j].z = pos.
z;
190 if (density) this_proj -> modelgl -> create_shaders[
MDBOX] = TRUE;
191 if (this_proj -> modelgl -> n_shaders[
SLABS][0]) this_proj -> modelgl -> create_shaders[
SLABS] = TRUE;
192 update (this_proj -> modelgl);
226 box_info * box = & this_proj -> cell.box[0];
227 mat4_t rec = mat4 (box -> rvect[0][0], box -> rvect[0][1], box -> rvect[0][2], 0.0,
228 box -> rvect[1][0], box -> rvect[1][1], box -> rvect[1][2], 0.0,
229 box -> rvect[2][0], box -> rvect[2][1], box -> rvect[2][2], 0.0,
231 for (i=0; i<3; i++) box ->
param[0][i] = this_proj -> modelgl -> cell_win -> cparam[i+3];
232 i = this_proj -> cell.ltype;
233 this_proj -> cell.ltype = 1;
236 this_proj -> cell.ltype = i;
238 mat4_t lat = mat4 (box -> vect[0][0], box -> vect[1][0], box -> vect[2][0], 0.0,
239 box -> vect[0][1], box -> vect[1][1], box -> vect[2][1], 0.0,
240 box -> vect[0][2], box -> vect[1][2], box -> vect[2][2], 0.0,
244 for (i=0; i<this_proj -> nspec; i++) m += this_proj ->
chemistry -> nsps[i] * this_proj ->
chemistry -> chem_prop[
CHEM_M][i];
245 this_proj -> cell.density = 10.0*m/(this_proj -> cell.volume*6.02214179);
247 this_proj -> cell.volume,
248 this_proj -> cell.density, this_proj -> natomes/this_proj -> cell.volume);
264 cell_edition * cedit = this_proj -> modelgl -> cell_win;
265 l = (this_proj -> cell.npt) ? this_proj -> modelgl -> anim -> last ->
img ->
step : 0;
268 if (
val >= - this_proj -> cell.box[l].param[0][dat ->
b]/2.0 && val <= this_proj -> cell.box[l].param[0][dat ->
b]/2.0)
270 if (
val != cedit -> cparam[dat ->
b])
273 for (i=0; i<3; i++) cparam[i] = - cedit -> cparam[i];
274 shift_it (vec3(cparam[0], cparam[1], cparam[2]), 0, dat ->
a);
275 cedit -> cparam[dat ->
b] =
val;
276 for (i=0; i<3; i++) cparam[i] = cedit -> cparam[i];
277 shift_it (vec3(cparam[0], cparam[1], cparam[2]), 1, dat ->
a);
281 else if (dat ->
b < 6)
283 if (
val > 0.0 && val <= cedit -> initbox[dat ->
b-3]*100.0)
285 if (
val != cedit -> cparam[dat ->
b])
288 if (cedit -> homo_density)
290 double v =
val / cedit -> initbox[dat ->
b - 3];
291 for (i=0; i<3; i++) cedit -> cparam[i+3] = v * cedit -> initbox[i];
295 cedit -> cparam[dat ->
b] =
val;
301 else if (dat ->
b > 5 && dat ->
b < 15)
303 i = (dat ->
b < 9) ? 6 : (dat ->
b < 12) ? 9 : dat ->
b;
304 j = (dat ->
b < 9) ? 1 : (dat ->
b < 12) ? 2 : 10;
305 k = (dat ->
b < 9) ? 1 : 0;
306 if (
val > -k * cedit -> initbox[dat ->
b - i] && val <= j * cedit -> initbox[dat ->
b - i])
308 if (
val != cedit -> cparam[dat ->
b])
310 cedit -> cparam[dat ->
b] =
val;
311 if (this_proj -> modelgl -> n_shaders[
SLABS][0])
313 this_proj -> modelgl -> create_shaders[
SLABS] = TRUE;
314 update (this_proj -> modelgl);
319 else if (dat ->
b > 14)
321 i = (dat ->
b < 18) ? 0 : 1;
322 if (
val >= -i * 180.0 &&
val <= 180.0)
324 if (
val != cedit -> cparam[dat ->
b])
326 cedit -> cparam[dat ->
b] =
val;
327 if (this_proj -> modelgl -> n_shaders[
SLABS][0])
329 this_proj -> modelgl -> create_shaders[
SLABS] = TRUE;
330 update (this_proj -> modelgl);
335 if ((dat ->
b > 2 && dat ->
b < 6) && cedit -> homo_density)
340 gtk_range_set_value (GTK_RANGE(cedit -> edit_scale[i]), cedit -> cparam[i]);
346 gtk_range_set_value (GTK_RANGE(cedit -> edit_scale[dat ->
b]), cedit -> cparam[dat ->
b]);
375G_MODULE_EXPORT gboolean
scroll_shift_coord (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
408 gchar *
axis[3]={
"x",
"y",
"z"};
409 gchar * angl[3]={
"α",
"β",
"ɣ"};
410 gchar * unit[2]={
"<b>Å</b>",
"<b>°</b>"};
412 cell_edition * cedit = this_proj -> modelgl -> cell_win;
414 if (i < 3 || (i > 5 && i < 12))
416 j = (i < 3) ? i : (i < 9) ? i - 6 : i - 9;
420 cedit -> edit_scale[i] =
create_hscale (-l*this_proj -> cell.box[0].param[0][j]/k, m*this_proj -> cell.box[0].param[0][j]/k, 0.01, cedit -> cparam[i],
422 str = g_strdup_printf (
"on <b>%s</b> axis [+/- Å]",
axis[j]);
426 cedit -> initbox[i-3] = cedit -> cparam[i] = this_proj -> cell.box[0].param[0][i-3];
427 cedit -> edit_scale[i] =
create_hscale (0.0, this_proj -> cell.box[0].param[0][i-3]*10.0, 0.01, cedit -> cparam[i],
429 str = g_strdup_printf (
"Lattice <b>%s</b> [+/- Å]",
box_prop[0][i-3]);
433 cedit -> edit_scale[i] =
create_hscale (0.0, this_proj -> cell.box[0].param[0][0]*10.0, 0.01, cedit -> cparam[i],
435 str = g_strdup_printf (
"Length [+/- Å]");
437 else if (i > 14 && i < 18)
439 cedit -> edit_scale[i] =
create_hscale (0.0, 180.0, 0.01, cedit -> cparam[i],
441 str = g_strdup_printf (
"Angle <b>%s</b> [+/- °]", angl[i-15]);
445 cedit -> edit_scale[i] =
create_hscale (-180, 180.0, 0.01, cedit -> cparam[i],
447 str = g_strdup_printf (
"on <b>%s</b> axis [+/- °]",
axis[i-18]);
451 cedit -> edit_scale[i] =
create_hscale (0.0, this_proj -> cell.box[0].param[0][0]*10.0, 0.01, cedit -> cparam[i],
453 str = g_strdup_printf (
"Radius [+/- Å]");
457 lab =
markup_label(unit[(i > 14 && i < 18) ? 1 : 0], 20, -1, 0.0, 0.5);
462 GtkWidget * fixed = gtk_fixed_new ();
463 gtk_fixed_put (GTK_FIXED(fixed), cedit -> edit_entry[i], 0, 15);
465 fixed = gtk_fixed_new ();
467 gtk_fixed_put (GTK_FIXED(fixed),
lab, (i>2 && i<6) ? -50 : 0, 25);
500 gchar *
text =
"You are about to put all the atoms back inside the model box\n"
501 "This action is irreversible, proceed anyway ?";
502 if (
ask_yes_no (
"Wrap atomic coordinates in unit cell ?",
text, GTK_MESSAGE_WARNING, view -> win))
505 view -> wrapped = TRUE;
507 if (view -> cell_win)
509 if (view -> cell_win -> shift_box[0])
511 if (GTK_IS_WIDGET(view -> cell_win -> shift_box[0]))
519 if (GTK_IS_WIDGET(view -> ogl_box[2]))
535G_MODULE_EXPORT
void wrap_coord (GtkCheckButton * but, gpointer data)
545G_MODULE_EXPORT
void wrap_coord (GtkToggleButton * but, gpointer data)
563 glwin * view = this_proj -> modelgl;
565 view -> cell_win -> put_in_box =
check_button (
"Wrap atomic coordinates in unit cell", -1, -1, FALSE, G_CALLBACK(
wrap_coord), view);
void translate(project *this_proj, int status, int axis, vec3_t trans)
translate
gboolean run_distance_matrix(GtkWidget *widg, int calc, int up_ngb)
compute distance matrix
void display_density(cell_edition *cell, double vol, double dens, double adens)
create density information widgets
Function declarations for the cell edition window.
void modify_coordinates_in_lattice(project *this_proj, mat4_t *dlat, mat4_t *drec, int refresh, int density)
modify atomic coordinates in lattice
void wrapping(glwin *view)
wrapping atomic coordinates
G_MODULE_EXPORT void set_shift(GtkEntry *res, gpointer data)
set atomic coordinates shift
G_MODULE_EXPORT void shift_coord(GtkRange *range, gpointer data)
shift coordinates callback - range
G_MODULE_EXPORT gboolean scroll_shift_coord(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
shift coordinates callback - scroll
GtkWidget * create_shift_box(project *this_proj)
create shift box widgets
GtkWidget * shift_center_tab(project *this_proj)
create the shift cell center tab
void adjust_it(int refresh, int proj)
adjust atomic coordinates
G_MODULE_EXPORT void wrap_coord(GtkToggleButton *but, gpointer data)
wrap atomic coordinates callback GTK3
void shift_has_changed(gpointer data, double val)
shift atomic coordinates
void shift_it(vec3_t shift, int refresh, int proj)
shift atomic coordinates
GtkWidget * create_cell_entries(project *this_proj, int i)
create the cell entry widgets
integer(kind=c_int) function chemistry()
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
double string_to_double(gpointer string)
convert string to double
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
void layout_add_widget(GtkWidget *layout, GtkWidget *child, int x_pos, int y_pos)
Add a GtkWidget in a GtkLayout.
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
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.
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * create_layout(int x, int y)
create a GtkLayout / GtkFixed widget
GtkWidget * create_hscale(float min, float max, float delta, float val, int pos, int round, int size, GCallback handler, GCallback scroll_handler, gpointer data)
create an horizontal scale GtkWidget
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
void update(glwin *view)
update the rendering of the OpenGL window
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
void active_project_changed(int id)
change the active project