89 else if (view -> atom_win)
111 GtkTreeIter bond_level;
112 gchar * str_a, * str_b, * str_c;
115 gboolean pbc = this_proj -> cell.pbc;
117 int s = this_proj -> modelgl -> anim -> last ->
img ->
step;
118 at = & this_proj ->
atoms[s][
a];
119 bt = & this_proj ->
atoms[s][
b];
121 dist =
distance_3d (& this_proj -> cell, (this_proj -> cell.npt) ? s : 0, at, bt);
122 str_a = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[at -> sp],
a+1);
123 str_b = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[bt -> sp],
b+1);
124 str_c = g_strdup_printf(
"%.3lf",
dist.length);
127 gtk_tree_store_append (store, & bond_level, NULL);
128 gtk_tree_store_set (store, & bond_level, 0,
bond_id,
136 gtk_tree_store_append (store, & bond_level, NULL);
137 gtk_tree_store_set (store, & bond_level, 0,
bond_id,
160 GtkTreeIter angle_level;
161 gchar * str_a, * str_b, * str_c, * str_d;
163 atom * at, * bt, * ct;
164 gboolean pbc = this_proj -> cell.pbc;
166 int s = this_proj -> modelgl -> anim -> last ->
img ->
step;
167 at = & this_proj ->
atoms[s][
a];
168 bt = & this_proj ->
atoms[s][
b];
169 ct = & this_proj ->
atoms[s][
c];
171 theta =
angle_3d (& this_proj -> cell, (this_proj -> cell.npt) ? s : 0, at, bt, ct);
172 str_a = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[at -> sp],
a+1);
173 str_b = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[bt -> sp],
b+1);
174 str_c = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[ct -> sp],
c+1);
175 str_d = g_strdup_printf(
"%.2lf", theta.
angle);
178 gtk_tree_store_append (store, & angle_level, NULL);
179 gtk_tree_store_set (store, & angle_level, 0,
angle_id,
188 gtk_tree_store_append (store, & angle_level, NULL);
189 gtk_tree_store_set (store, & angle_level, 0,
angle_id,
215 GtkTreeIter dihedral_level;
216 gchar * str_a, * str_b, * str_c, * str_d, * str_e;
218 atom * at, * bt, * ct, * dt;
219 gboolean pbc = this_proj -> cell.pbc;
221 int s = this_proj -> modelgl -> anim -> last ->
img ->
step;
222 at = & this_proj ->
atoms[s][
a];
223 bt = & this_proj ->
atoms[s][
b];
224 ct = & this_proj ->
atoms[s][
c];
225 dt = & this_proj ->
atoms[s][
d];
227 phi =
dihedral_3d (& this_proj -> cell, (this_proj -> cell.npt) ? s : 0, at, bt, ct, dt);
228 str_a = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[at -> sp],
a+1);
229 str_b = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[bt -> sp],
b+1);
230 str_c = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[ct -> sp],
c+1);
231 str_d = g_strdup_printf(
"%s<sub>%d</sub>", this_proj ->
chemistry ->
label[dt -> sp],
d+1);
232 str_e = g_strdup_printf(
"%.2lf", phi.angle);
235 gtk_tree_store_append (store, & dihedral_level, NULL);
236 gtk_tree_store_set (store, & dihedral_level, 0,
dihedral_id,
246 gtk_tree_store_append (store, & dihedral_level, NULL);
247 gtk_tree_store_set (store, & dihedral_level, 0,
dihedral_id,
274void measure_set_visible (GtkTreeViewColumn *
col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
278 gtk_tree_model_get (mod, iter, dat ->
b, & i, -1);
279 gtk_cell_renderer_set_visible (renderer, i);
293void measure_set_color (GtkTreeViewColumn *
col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
297 gboolean docolor = FALSE;
298 gtk_tree_model_get (mod, iter, 0, & i, -1);
300 image *
img = this_proj -> modelgl -> anim -> last ->
img;
302 if (
img -> selected[
pi] -> selected)
310 if (
img -> selected[
pi] -> selected_bonds[i]) docolor = TRUE;
314 if (
img -> selected[
pi] -> selected_angles[i]) docolor = TRUE;
318 if (
img -> selected[
pi] -> selected_dihedrals[i]) docolor = TRUE;
343 gtk_tree_model_get (mod, iter, dat ->
b, & str, -1);
344 g_object_set (renderer,
"markup", str, NULL, NULL);
364 gtk_tree_model_get (mod, iter, dat ->
b, & str, -1);
365 g_object_set (renderer,
"markup", str, NULL, NULL);
382 GtkWidget * cont = gtk_widget_get_parent (view -> measure_win -> selection_tree[mid]);
383 view -> measure_win -> selection_tree[mid] =
destroy_this_widget (view -> measure_win -> selection_tree[mid]);
402 if (event_button == 1)
407 GtkTreeModel * measure_model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
409 GtkTreeViewColumn * column;
413 gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW(widget), event_x, event_y, & e_x, & e_y);
414 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), e_x, e_y, &
path, & column, & i, & j))
416 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), event_x, event_y, &
path, & column, & i, & j))
420 if (gtk_tree_model_get_iter (measure_model, &
row,
path))
422 gtk_tree_model_get (measure_model, &
row, 0, & j, -1);
427 view -> anim -> last ->
img -> selected[
pi] -> selected_bonds[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_bonds[j];
430 view -> anim -> last ->
img -> selected[
pi] -> selected_angles[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_angles[j];
433 view -> anim -> last ->
img -> selected[
pi] -> selected_dihedrals[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_dihedrals[j];
438 view -> create_shaders[
MEASU] = TRUE;
453G_MODULE_EXPORT gboolean measure_tree_selection_event (GtkWidget * widget, GdkEventButton * event, gpointer data)
455 if (event -> type == GDK_BUTTON_PRESS)
457 GdkEventButton * bevent = (GdkEventButton*)event;
476 measure_tree_button_event (gtk_event_controller_get_widget ((GtkEventController*)gesture),
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
492 GtkTreeViewColumn * sel_col[7];
493 GtkCellRenderer * sel_cell[7];
494 GtkTreeStore * sel_model;
495 gchar *
ctitle[3][7]={{
"Id",
"Atom 1",
"Atom 2",
"Distance [Ã…]",
"Using PBC",
"NULL",
"NULL"},
496 {
"Id",
"Atom 1",
"Atom 2",
"Atom 3",
"θ [°]",
"Using PBC",
"NULL"},
497 {
"Id",
"Atom 1",
"Atom 2",
"Atom 3",
"Atom 4",
"ϕ [°]",
"Using PBC"}};
498 gchar * ctype[3][7]={{
"text",
"text",
"text",
"text",
"active",
"text",
"text"},
499 {
"text",
"text",
"text",
"text",
"text",
"active",
"text"},
500 {
"text",
"text",
"text",
"text",
"text",
"text",
"active"}};
501 int tree_dim[3]={4, 5, 6};
502 GType
col_type[3][7]= {{G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING},
503 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING},
504 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN}};
507 sel_model = gtk_tree_store_newv (tree_dim[mid]+1,
col_type[mid]);
512 sel_model = gtk_tree_store_newv (tree_dim[mid],
col_type[mid]);
516 GtkWidget * selection_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(sel_model));
517 for (i=0; i<4+j+mid; i++)
519 if ((mid == 0 && i < 4) || (mid == 1 && i < 5) || (mid == 2 && i < 6))
521 sel_cell[i] = gtk_cell_renderer_text_new();
522 sel_col[i] = gtk_tree_view_column_new_with_attributes (
ctitle[mid][i], sel_cell[i], ctype[mid][i], i, NULL);
523 if (i == 0) gtk_tree_view_column_set_visible (sel_col[i], FALSE);
525 else if ((mid == 0 && i == 4) || (mid == 1 && i == 5) || (mid == 2 && i == 6))
527 sel_cell[i] = gtk_cell_renderer_toggle_new ();
528 sel_col[i] = gtk_tree_view_column_new_with_attributes (
ctitle[mid][i], sel_cell[i], ctype[mid][i], i, NULL);
530 gtk_tree_view_column_set_alignment (sel_col[i], 0.5);
531 gtk_tree_view_append_column(GTK_TREE_VIEW(selection_tree), sel_col[i]);
532 if (i > 0 && i < 4+mid)
551 if ( (mid == 0 &&
img -> selected[sid] -> selected > 1)
552 || (mid == 1 &&
img -> selected[sid] -> selected > 2)
553 || (mid == 2 &&
img -> selected[sid] -> selected > 3 &&
img -> selected[sid] -> selected <
MAX_IN_SELECTION-10))
558 bonds_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
561 NULL, NULL, NULL, NULL, NULL, NULL,
562 NULL, NULL, NULL, NULL, NULL, NULL);
564 g_signal_connect (G_OBJECT(selection_tree),
"button_press_event", G_CALLBACK(measure_tree_selection_event), & view ->
colorp[0][mid]);
570 angles_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
573 NULL, NULL, NULL, NULL, NULL, NULL,
574 NULL, NULL, NULL, NULL, NULL, NULL);
576 g_signal_connect (G_OBJECT(selection_tree),
"button_press_event", G_CALLBACK(measure_tree_selection_event), & view ->
colorp[0][mid]);
593 GtkTreeSelection * selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(selection_tree));
594 gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
595 gtk_tree_view_expand_all (GTK_TREE_VIEW(selection_tree));
596 return selection_tree;
610 GtkWidget * scrollsets =
create_scroll (NULL, 350+50*mid, 350, GTK_SHADOW_NONE);
630 str = g_strdup_printf (
"\tAtom(s) in selection<sup>*</sup> :\t<b>%d</b>",
img -> selected[sid] -> selected);
634 str = g_strdup_printf (
"\tSorry too many [%d] atoms in selection<sup>*</sup>",
img -> selected[sid] -> selected);
650 gtk_label_set_use_markup (GTK_LABEL(view -> measure_win ->
label), TRUE);
663G_MODULE_EXPORT
void close_ml (GtkButton * but, gpointer data)
680 GtkWidget * win =
create_win (str, view -> measure_win -> win, TRUE, FALSE);
692 gtk_window_set_resizable (GTK_WINDOW(win), FALSE);
723 view -> measure_win -> selection_tree[i] = NULL;
725 g_free (view -> measure_win);
726 view -> measure_win = NULL;
741 if (view -> measure_win == NULL)
743 view -> measure_win = g_malloc0 (
sizeof*view -> measure_win);
746 view -> measure_win -> win =
create_win (str, view -> win, FALSE, FALSE);
747 gtk_widget_set_size_request (view -> measure_win -> win, 450, 500);
751 GtkWidget * notebook = gtk_notebook_new ();
755 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 0), gtk_label_new (
"Distances"));
756 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 1), gtk_label_new (
"Angles"));
757 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 2), gtk_label_new (
"Dihedrals"));
758 str = g_strdup_printf (
" <sub>* You can select up to %d atoms for both inter-atomic distance(s) and angle(s),\n"
771 gtk_widget_show (view -> measure_win -> win);
integer(kind=c_int) function chemistry()
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
gchar * ctitle[MAXDATA][12]
GType col_type[MAXDATA][12]
angle dihedral_3d(cell_info *cell, int mdstep, atom *at, atom *bt, atom *ct, atom *dt)
dihedral between atom a, b, c and d in 3D
angle angle_3d(cell_info *cell, int mdstep, atom *at, atom *bt, atom *ct)
angle between atom a, b and c in 3D
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Global variable declarations Global convenience function declarations Global data structure defin...
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
gboolean is_atom_win_active(glwin *view)
is the model edition window visible ?
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
G_MODULE_EXPORT gboolean hide_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
hide a GtkWindow
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple 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.
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another 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
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
#define MAX_IN_SELECTION
Maximum number of atoms in selection to display measure information.
GtkWidget * labels_tab(glwin *view, int id)
create atomic label(s) tab for the atom(s) / clone(s) window
int num_bonds(int i)
number of distinct pair(s) of atoms in selection
void measure_set_visible(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
show / hide cell renderer in the measures tree store
GtkWidget * measurment_tab(glwin *view, int sid, int mid)
int get_selection_type(glwin *view)
get selection type
void update_label_selection(glwin *view, int sid)
update the text information for the number of atoms/measures in selection
void fill_angle_model_row(int p, int a, int b, int c, GtkTreeStore *store)
fill angle tree store row
void measure_set_color_and_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
void measure_set_color(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
set renderer color in the measures tree store
void dihedral_set_color_and_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
int num_dihedrals(int i)
number of distinct quadruplet(s) of atoms in selection
G_MODULE_EXPORT gboolean close_measure_event(GtkWidget *widg, GdkEvent *event, gpointer data)
measurements window close event callback GTK3
void dihedrals_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured dihedrals selection
void update_selection_tree(glwin *view, int sid, int mid)
update measurements tree view
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
G_MODULE_EXPORT void measure_labels(GtkButton *but, gpointer data)
measurements style edition window
void fill_dihedral_model_row(int p, int a, int b, int c, int d, GtkTreeStore *store)
fill dihedral tree store row
G_MODULE_EXPORT void measure_tree_button_pressed(GtkGesture *gesture, int n_press, double x, double y, gpointer data)
measures tree view button press callback GTK3
int num_angles(int i)
number of distinct triplet(s) of atoms in selection
void angles_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured angles selection
void bonds_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured distances selection
gchar * create_measure_label(glwin *view, int sid)
create the text information for the number of atom(s) in selection
G_MODULE_EXPORT void window_measures(GtkWidget *widg, gpointer data)
create the measurements window
GtkWidget * create_selection_tree(glwin *view, int sid, int mid)
create the measurements selection tree
G_MODULE_EXPORT void measure_tree_button_event(GtkWidget *widget, double event_x, double event_y, guint event_button, gpointer data)
measure tree button event
G_MODULE_EXPORT void close_ml(GtkButton *but, gpointer data)
measurements style edition window close button
void fill_bond_model_row(int p, int a, int b, GtkTreeStore *store)
fill bond tree store row