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)
298 gboolean docolor = FALSE;
299 gtk_tree_model_get (mod, iter, 0, & i, -1);
301 image *
img = this_proj -> modelgl -> anim -> last ->
img;
303 if (
img -> selected[
pi] -> selected)
311 if (
img -> selected[
pi] -> selected_bonds[i]) docolor = TRUE;
315 if (
img -> selected[
pi] -> selected_angles[i]) docolor = TRUE;
319 if (
img -> selected[
pi] -> selected_dihedrals[i]) docolor = TRUE;
344 gtk_tree_model_get (mod, iter, dat ->
b, & str, -1);
345 g_object_set (renderer,
"markup", str, NULL, NULL);
365 gtk_tree_model_get (mod, iter, dat ->
b, & str, -1);
366 g_object_set (renderer,
"markup", str, NULL, NULL);
383 GtkWidget * cont = gtk_widget_get_parent (view -> measure_win -> selection_tree[mid]);
384 view -> measure_win -> selection_tree[mid] =
destroy_this_widget (view -> measure_win -> selection_tree[mid]);
403 if (event_button == 1)
408 GtkTreeModel * measure_model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
410 GtkTreeViewColumn * column;
414 gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW(widget), event_x, event_y, & e_x, & e_y);
415 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), e_x, e_y, &
path, & column, & i, & j))
417 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), event_x, event_y, &
path, & column, & i, & j))
421 if (gtk_tree_model_get_iter (measure_model, &
row,
path))
423 gtk_tree_model_get (measure_model, &
row, 0, & j, -1);
428 view -> anim -> last ->
img -> selected[
pi] -> selected_bonds[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_bonds[j];
431 view -> anim -> last ->
img -> selected[
pi] -> selected_angles[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_angles[j];
434 view -> anim -> last ->
img -> selected[
pi] -> selected_dihedrals[j] = ! view -> anim -> last ->
img -> selected[
pi] -> selected_dihedrals[j];
439 view -> create_shaders[
MEASU] = TRUE;
454G_MODULE_EXPORT gboolean measure_tree_selection_event (GtkWidget * widget, GdkEventButton * event, gpointer data)
456 if (event -> type == GDK_BUTTON_PRESS)
458 GdkEventButton * bevent = (GdkEventButton*)event;
477 measure_tree_button_event (gtk_event_controller_get_widget ((GtkEventController*)gesture),
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
493 GtkTreeViewColumn * sel_col[7];
494 GtkCellRenderer * sel_cell[7];
495 GtkTreeStore * sel_model;
496 gchar *
ctitle[3][7]={{
"Id",
"Atom 1",
"Atom 2",
"Distance [Ã…]",
"Using PBC",
"NULL",
"NULL"},
497 {
"Id",
"Atom 1",
"Atom 2",
"Atom 3",
"θ [°]",
"Using PBC",
"NULL"},
498 {
"Id",
"Atom 1",
"Atom 2",
"Atom 3",
"Atom 4",
"ϕ [°]",
"Using PBC"}};
499 gchar * ctype[3][7]={{
"text",
"text",
"text",
"text",
"active",
"text",
"text"},
500 {
"text",
"text",
"text",
"text",
"text",
"active",
"text"},
501 {
"text",
"text",
"text",
"text",
"text",
"text",
"active"}};
502 int tree_dim[3]={4, 5, 6};
503 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},
504 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING},
505 {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN}};
508 sel_model = gtk_tree_store_newv (tree_dim[mid]+1,
col_type[mid]);
513 sel_model = gtk_tree_store_newv (tree_dim[mid],
col_type[mid]);
517 GtkWidget * selection_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(sel_model));
518 for (i=0; i<4+j+mid; i++)
520 if ((mid == 0 && i < 4) || (mid == 1 && i < 5) || (mid == 2 && i < 6))
522 sel_cell[i] = gtk_cell_renderer_text_new();
523 sel_col[i] = gtk_tree_view_column_new_with_attributes (
ctitle[mid][i], sel_cell[i], ctype[mid][i], i, NULL);
524 if (i == 0) gtk_tree_view_column_set_visible (sel_col[i], FALSE);
526 else if ((mid == 0 && i == 4) || (mid == 1 && i == 5) || (mid == 2 && i == 6))
528 sel_cell[i] = gtk_cell_renderer_toggle_new ();
529 sel_col[i] = gtk_tree_view_column_new_with_attributes (
ctitle[mid][i], sel_cell[i], ctype[mid][i], i, NULL);
531 gtk_tree_view_column_set_alignment (sel_col[i], 0.5);
532 gtk_tree_view_append_column(GTK_TREE_VIEW(selection_tree), sel_col[i]);
533 if (i > 0 && i < 4+mid)
552 if ( (mid == 0 &&
img -> selected[sid] -> selected > 1)
553 || (mid == 1 &&
img -> selected[sid] -> selected > 2)
554 || (mid == 2 &&
img -> selected[sid] -> selected > 3 &&
img -> selected[sid] -> selected <
MAX_IN_SELECTION-10))
559 bonds_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
562 NULL, NULL, NULL, NULL, NULL, NULL,
563 NULL, NULL, NULL, NULL, NULL, NULL);
565 g_signal_connect (G_OBJECT(selection_tree),
"button_press_event", G_CALLBACK(measure_tree_selection_event), & view ->
colorp[0][mid]);
571 angles_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
574 NULL, NULL, NULL, NULL, NULL, NULL,
575 NULL, NULL, NULL, NULL, NULL, NULL);
577 g_signal_connect (G_OBJECT(selection_tree),
"button_press_event", G_CALLBACK(measure_tree_selection_event), & view ->
colorp[0][mid]);
594 GtkTreeSelection * selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(selection_tree));
595 gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
596 gtk_tree_view_expand_all (GTK_TREE_VIEW(selection_tree));
597 return selection_tree;
611 GtkWidget * scrollsets =
create_scroll (NULL, 350+50*mid, 350, GTK_SHADOW_NONE);
631 str = g_strdup_printf (
"\tAtom(s) in selection<sup>*</sup> :\t<b>%d</b>",
img -> selected[sid] -> selected);
635 str = g_strdup_printf (
"\tSorry too many [%d] atoms in selection<sup>*</sup>",
img -> selected[sid] -> selected);
651 gtk_label_set_use_markup (GTK_LABEL(view -> measure_win ->
label), TRUE);
664G_MODULE_EXPORT
void close_ml (GtkButton * but, gpointer data)
681 GtkWidget * win =
create_win (str, view -> measure_win -> win, TRUE, FALSE);
693 gtk_window_set_resizable (GTK_WINDOW(win), FALSE);
724 view -> measure_win -> selection_tree[i] = NULL;
726 g_free (view -> measure_win);
727 view -> measure_win = NULL;
742 if (view -> measure_win == NULL)
744 view -> measure_win = g_malloc0 (
sizeof*view -> measure_win);
747 view -> measure_win -> win =
create_win (str, view -> win, FALSE, FALSE);
748 gtk_widget_set_size_request (view -> measure_win -> win, 450, 500);
752 GtkWidget * notebook = gtk_notebook_new ();
756 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 0), gtk_label_new (
"Distances"));
757 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 1), gtk_label_new (
"Angles"));
758 gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
measurment_tab (view,
pi, 2), gtk_label_new (
"Dihedrals"));
759 str = g_strdup_printf (
" <sub>* You can select up to %d atoms for both inter-atomic distance(s) and angle(s),\n"
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