atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
w_measures.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: 'w_measures.c'
24*
25* Contains:
26*
27
28 - The functions to create the measurement(s) window
29
30*
31* List of functions:
32
33 int get_selection_type (glwin * view);
34
35 G_MODULE_EXPORT gboolean measure_tree_selection_event (GtkWidget * widget, GdkEventButton * event, gpointer data);
36 G_MODULE_EXPORT gboolean close_measure_event (GtkWindow * widg, gpointer data);
37 G_MODULE_EXPORT gboolean close_measure_event (GtkWidget * widg, GdkEvent * event, gpointer data);
38
39 gchar * create_measure_label (glwin * view, int sid);
40
41 void measure_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
42 void measure_set_color (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
43 void dihedral_set_color_and_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
44 void measure_set_color_and_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
45 void fill_bond_model_row (int p, int a, int b, GtkTreeStore * store);
46 void fill_angle_model_row (int p, int a, int b, int c, GtkTreeStore * store);
47 void fill_dihedral_model_row (int p, int a, int b, int c, int d, GtkTreeStore * store);
48 void update_selection_tree (glwin * view, int sid, int mid);
49 void update_label_selection (glwin * view, int sid);
50
51 G_MODULE_EXPORT void measure_tree_button_event (GtkWidget * widget, double event_x, double event_y, guint event_button, gpointer data);
52 G_MODULE_EXPORT void measure_tree_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
53 G_MODULE_EXPORT void close_ml (GtkButton * but, gpointer data);
54 G_MODULE_EXPORT void measure_labels (GtkButton * but, gpointer data);
55 G_MODULE_EXPORT void window_measures (GtkWidget * widg, gpointer data);
56
57 GtkWidget * create_selection_tree (glwin * view, int sid, int mid);
58 GtkWidget * measurment_tab (glwin * view, int sid, int mid);
59
60*/
61
62#include "global.h"
63#include "glview.h"
64
65extern void bonds_loop (glwin * view, int id, int pi, GtkTreeStore * store);
66extern void angles_loop (glwin * view, int id, int pi, GtkTreeStore * store);
67extern void dihedrals_loop (glwin * view, int id, int pi, GtkTreeStore * store);
68extern int num_bonds (int i);
69extern int num_angles (int i);
70extern int num_dihedrals (int i);
71
75
84{
85 if (view -> mode == EDITION && view -> selection_mode == NSELECTION-1)
86 {
87 return 1;
88 }
89 else if (view -> atom_win)
90 {
91 return 1;
92 }
93 else
94 {
95 return 0;
96 }
97}
98
109void fill_bond_model_row (int p, int a, int b, GtkTreeStore * store)
110{
111 GtkTreeIter bond_level;
112 gchar * str_a, * str_b, * str_c;
113 project * this_proj = get_project_by_id(p);
114 atom * at, * bt;
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];
120 bond_id ++;
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);
125 if (pbc)
126 {
127 gtk_tree_store_append (store, & bond_level, NULL);
128 gtk_tree_store_set (store, & bond_level, 0, bond_id,
129 1, str_a,
130 2, str_b,
131 3, str_c,
132 4, dist.pbc, -1);
133 }
134 else
135 {
136 gtk_tree_store_append (store, & bond_level, NULL);
137 gtk_tree_store_set (store, & bond_level, 0, bond_id,
138 1, str_a,
139 2, str_b,
140 3, str_c, -1);
141 }
142 g_free (str_a);
143 g_free (str_b);
144 g_free (str_c);
145}
146
158void fill_angle_model_row (int p, int a, int b, int c, GtkTreeStore * store)
159{
160 GtkTreeIter angle_level;
161 gchar * str_a, * str_b, * str_c, * str_d;
162 project * this_proj = get_project_by_id(p);
163 atom * at, * bt, * ct;
164 gboolean pbc = this_proj -> cell.pbc;
165 angle theta;
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];
170 angle_id ++;
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);
176 if (pbc)
177 {
178 gtk_tree_store_append (store, & angle_level, NULL);
179 gtk_tree_store_set (store, & angle_level, 0, angle_id,
180 1, str_a,
181 2, str_b,
182 3, str_c,
183 4, str_d,
184 5, theta.pbc, -1);
185 }
186 else
187 {
188 gtk_tree_store_append (store, & angle_level, NULL);
189 gtk_tree_store_set (store, & angle_level, 0, angle_id,
190 1, str_a,
191 2, str_b,
192 3, str_c,
193 4, str_d, -1);
194 }
195 g_free (str_a);
196 g_free (str_b);
197 g_free (str_c);
198 g_free (str_d);
199}
200
213void fill_dihedral_model_row (int p, int a, int b, int c, int d, GtkTreeStore * store)
214{
215 GtkTreeIter dihedral_level;
216 gchar * str_a, * str_b, * str_c, * str_d, * str_e;
217 project * this_proj = get_project_by_id(p);
218 atom * at, * bt, * ct, * dt;
219 gboolean pbc = this_proj -> cell.pbc;
220 angle phi;
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];
226 dihedral_id ++;
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);
233 if (pbc)
234 {
235 gtk_tree_store_append (store, & dihedral_level, NULL);
236 gtk_tree_store_set (store, & dihedral_level, 0, dihedral_id,
237 1, str_a,
238 2, str_b,
239 3, str_c,
240 4, str_d,
241 5, str_e,
242 6, phi.pbc, -1);
243 }
244 else
245 {
246 gtk_tree_store_append (store, & dihedral_level, NULL);
247 gtk_tree_store_set (store, & dihedral_level, 0, dihedral_id,
248 1, str_a,
249 2, str_b,
250 3, str_c,
251 4, str_d,
252 5, str_e, -1);
253 }
254 g_free (str_a);
255 g_free (str_b);
256 g_free (str_c);
257 g_free (str_d);
258 g_free (str_e);
259}
260
261extern ColRGBA init_color (int id, int numid);
262
274void measure_set_visible (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
275{
276 int i;
277 tint * dat = (tint *)data;
278 gtk_tree_model_get (mod, iter, dat -> b, & i, -1);
279 gtk_cell_renderer_set_visible (renderer, i);
280}
281
293void measure_set_color (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
294{
295 int i, j;
296 j = 0;
297 tint * dat = (tint *) data;
298 gboolean docolor = FALSE;
299 gtk_tree_model_get (mod, iter, 0, & i, -1);
300 project * this_proj = get_project_by_id(dat -> a);
301 image * img = this_proj -> modelgl -> anim -> last -> img;
302 int pi = get_selection_type (this_proj -> modelgl);
303 if (img -> selected[pi] -> selected)
304 {
305 if ((dat -> c == 2 && img -> selected[pi] -> selected < MAX_IN_SELECTION-10) || (dat -> c < 2 && img -> selected[pi] -> selected < MAX_IN_SELECTION))
306 {
307 switch (dat -> c)
308 {
309 case 0:
310 j = num_bonds (img -> selected[pi] -> selected);
311 if (img -> selected[pi] -> selected_bonds[i]) docolor = TRUE;
312 break;
313 case 1:
314 j = num_angles (img -> selected[pi] -> selected);
315 if (img -> selected[pi] -> selected_angles[i]) docolor = TRUE;
316 break;
317 case 2:
318 j = num_dihedrals (img -> selected[pi] -> selected);
319 if (img -> selected[pi] -> selected_dihedrals[i]) docolor = TRUE;
320 break;
321 }
322 }
323 }
324 set_renderer_color (docolor, renderer, init_color (i, j));
325}
326
338void dihedral_set_color_and_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
339{
340 tint * dat = (tint *)data;
341 dat -> c = 2;
342 measure_set_color (col, renderer, mod, iter, data);
343 gchar * str = NULL;
344 gtk_tree_model_get (mod, iter, dat -> b, & str, -1);
345 g_object_set (renderer, "markup", str, NULL, NULL);
346 g_free (str);
347}
348
360void measure_set_color_and_markup (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
361{
362 tint * dat = (tint *)data;
363 measure_set_color (col, renderer, mod, iter, dat);
364 gchar * str = NULL;
365 gtk_tree_model_get (mod, iter, dat -> b, & str, -1);
366 g_object_set (renderer, "markup", str, NULL, NULL);
367 g_free (str);
368}
369
370GtkWidget * create_selection_tree (glwin * view, int sid, int mid);
371
381void update_selection_tree (glwin * view, int sid, int mid)
382{
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]);
385 view -> measure_win -> selection_tree[mid] = create_selection_tree (view, sid, mid);
386 add_container_child (CONTAINER_SCR, cont, view -> measure_win -> selection_tree[mid]);
387 show_the_widgets (cont);
388}
389
401G_MODULE_EXPORT void measure_tree_button_event (GtkWidget * widget, double event_x, double event_y, guint event_button, gpointer data)
402{
403 if (event_button == 1)
404 {
405 tint * dat = (tint *)data;
406 glwin * view = get_project_by_id(dat -> a) -> modelgl;
407 int pi = get_selection_type (view);
408 GtkTreeModel * measure_model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
409 GtkTreePath * path;
410 GtkTreeViewColumn * column;
411 int i, j;
412#ifdef GTK4
413 int e_x, e_y;
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))
416#else
417 if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW(widget), event_x, event_y, & path, & column, & i, & j))
418#endif
419 {
420 GtkTreeIter row;
421 if (gtk_tree_model_get_iter (measure_model, & row, path))
422 {
423 gtk_tree_model_get (measure_model, & row, 0, & j, -1);
424 // select bonds, angles or dihedraks:
425 switch (dat -> c)
426 {
427 case 0:
428 view -> anim -> last -> img -> selected[pi] -> selected_bonds[j] = ! view -> anim -> last -> img -> selected[pi] -> selected_bonds[j];
429 break;
430 case 1:
431 view -> anim -> last -> img -> selected[pi] -> selected_angles[j] = ! view -> anim -> last -> img -> selected[pi] -> selected_angles[j];
432 break;
433 case 2:
434 view -> anim -> last -> img -> selected[pi] -> selected_dihedrals[j] = ! view -> anim -> last -> img -> selected[pi] -> selected_dihedrals[j];
435 break;
436 }
437 }
438 }
439 view -> create_shaders[MEASU] = TRUE;
440 update (view);
441 }
442}
443
444#ifdef GTK3
454G_MODULE_EXPORT gboolean measure_tree_selection_event (GtkWidget * widget, GdkEventButton * event, gpointer data)
455{
456 if (event -> type == GDK_BUTTON_PRESS)
457 {
458 GdkEventButton * bevent = (GdkEventButton*)event;
459 measure_tree_button_event (widget, bevent -> x, bevent -> y, bevent -> button, data);
460 }
461 return FALSE;
462}
463#else
475G_MODULE_EXPORT void measure_tree_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data)
476{
477 measure_tree_button_event (gtk_event_controller_get_widget ((GtkEventController*)gesture), x, y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
478}
479#endif
480
490GtkWidget * create_selection_tree (glwin * view, int sid, int mid)
491{
492 int i, j;
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}};
506 if (get_project_by_id(view -> proj) -> cell.pbc)
507 {
508 sel_model = gtk_tree_store_newv (tree_dim[mid]+1, col_type[mid]);
509 j = 1;
510 }
511 else
512 {
513 sel_model = gtk_tree_store_newv (tree_dim[mid], col_type[mid]);
514 j = 0;
515 }
516
517 GtkWidget * selection_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(sel_model));
518 for (i=0; i<4+j+mid; i++)
519 {
520 if ((mid == 0 && i < 4) || (mid == 1 && i < 5) || (mid == 2 && i < 6))
521 {
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);
525 }
526 else if ((mid == 0 && i == 4) || (mid == 1 && i == 5) || (mid == 2 && i == 6))
527 {
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);
530 }
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)
534 {
535 if (mid < 2)
536 {
537 gtk_tree_view_column_set_cell_data_func (sel_col[i], sel_cell[i], measure_set_color_and_markup, & view -> colorp[i][mid], NULL);
538 }
539 else
540 {
541 gtk_tree_view_column_set_cell_data_func (sel_col[i], sel_cell[i], dihedral_set_color_and_markup, & view -> colorp[i][0], NULL);
542 }
543 }
544 else if (i > 0)
545 {
546 gtk_tree_view_column_set_cell_data_func (sel_col[i], sel_cell[i], measure_set_visible, & view -> colorp[i][0], NULL);
547 }
548 }
549 image * img = view -> anim -> last -> img;
550 if (img -> selected[sid] -> selected < MAX_IN_SELECTION)
551 {
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))
555 {
556 if (mid == 0)
557 {
558 bond_id = -1;
559 bonds_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
560#ifdef GTK4
561 add_widget_gesture_and_key_action (selection_tree, "bond-tree-pressed", G_CALLBACK(measure_tree_button_pressed), & view -> colorp[0][mid],
562 NULL, NULL, NULL, NULL, NULL, NULL,
563 NULL, NULL, NULL, NULL, NULL, NULL);
564#else
565 g_signal_connect (G_OBJECT(selection_tree), "button_press_event", G_CALLBACK(measure_tree_selection_event), & view -> colorp[0][mid]);
566#endif
567 }
568 else if (mid == 1)
569 {
570 angle_id = -1;
571 angles_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
572#ifdef GTK4
573 add_widget_gesture_and_key_action (selection_tree, "angle-tree-pressed", G_CALLBACK(measure_tree_button_pressed), & view -> colorp[0][mid],
574 NULL, NULL, NULL, NULL, NULL, NULL,
575 NULL, NULL, NULL, NULL, NULL, NULL);
576#else
577 g_signal_connect (G_OBJECT(selection_tree), "button_press_event", G_CALLBACK(measure_tree_selection_event), & view -> colorp[0][mid]);
578#endif
579 }
580 else if (mid == 2)
581 {
582 dihedral_id = -1;
583 dihedrals_loop (view, 2, sid, GTK_TREE_STORE(sel_model));
584/*#ifdef GTK4
585 add_widget_gesture_and_key_action (selection_tree, "dihedral-tree-pressed", G_CALLBACK(measure_tree_button_pressed), & view -> colorp[0][mid],
586 NULL, NULL, NULL, NULL, NULL, NULL,
587 NULL, NULL, NULL, NULL, NULL, NULL);
588#else
589 g_signal_connect (G_OBJECT(selection_tree), "button_press_event", G_CALLBACK(measure_tree_selection_event), & view -> colorp[0][mid]);
590#endif*/
591 }
592 }
593 }
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;
598}
599
609GtkWidget * measurment_tab (glwin * view, int sid, int mid)
610{
611 GtkWidget * scrollsets = create_scroll (NULL, 350+50*mid, 350, GTK_SHADOW_NONE);
612 view -> measure_win -> selection_tree[mid] = create_selection_tree (view, sid, mid);
613 add_container_child (CONTAINER_SCR, scrollsets, view -> measure_win -> selection_tree[mid]);
614 return scrollsets;
615}
616
625gchar * create_measure_label (glwin * view, int sid)
626{
627 gchar * str;
628 image * img = view -> anim -> last -> img;
629 if (img -> selected[sid] -> selected < MAX_IN_SELECTION)
630 {
631 str = g_strdup_printf ("\tAtom(s) in selection<sup>*</sup> :\t<b>%d</b>", img -> selected[sid] -> selected);
632 }
633 else
634 {
635 str = g_strdup_printf ("\tSorry too many [%d] atoms in selection<sup>*</sup>", img -> selected[sid] -> selected);
636 }
637 return str;
638}
639
648void update_label_selection (glwin * view, int sid)
649{
650 gtk_label_set_text (GTK_LABEL(view -> measure_win -> label), create_measure_label(view, sid));
651 gtk_label_set_use_markup (GTK_LABEL(view -> measure_win -> label), TRUE);
652}
653
654extern GtkWidget * labels_tab (glwin * view, int id);
655
664G_MODULE_EXPORT void close_ml (GtkButton * but, gpointer data)
665{
666 destroy_this_widget (GTK_WIDGET(data));
667}
668
677G_MODULE_EXPORT void measure_labels (GtkButton * but, gpointer data)
678{
679 glwin * view = (glwin *) data;
680 gchar * str = g_strdup_printf ("%s - measures - style", get_project_by_id(view -> proj) -> name);
681 GtkWidget * win = create_win (str, view -> measure_win -> win, TRUE, FALSE);
682 //gtk_widget_set_size_request (win, -1, -1480);
683 g_free (str);
684 GtkWidget * vbox = create_vbox (BSEP);
686 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, labels_tab (view, (is_atom_win_active(view) || (view -> mode == EDITION && view -> selection_mode == NSELECTION-1)) ? 4 : 3), FALSE, FALSE, 0);
687 GtkWidget * hbox = create_hbox (0);
688 GtkWidget * close_but = create_button ("Close", IMG_NONE, NULL, 100, -1, GTK_RELIEF_NORMAL, G_CALLBACK(close_ml), win);
689 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, close_but, FALSE, TRUE, 150);
690 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 20);
691 add_gtk_close_event (win, G_CALLBACK(hide_this_window), NULL);
692 show_the_widgets (win);
693 gtk_window_set_resizable (GTK_WINDOW(win), FALSE);
694}
695
696#ifdef GTK4
705G_MODULE_EXPORT gboolean close_measure_event (GtkWindow * widg, gpointer data)
706#else
716G_MODULE_EXPORT gboolean close_measure_event (GtkWidget * widg, GdkEvent * event, gpointer data)
717#endif
718{
719 glwin * view = (glwin *) data;
720 view -> measure_win -> win = destroy_this_widget (view -> measure_win -> win);
721 int i;
722 for (i=0; i<3; i++)
723 {
724 view -> measure_win -> selection_tree[i] = NULL;
725 }
726 g_free (view -> measure_win);
727 view -> measure_win = NULL;
728 return FALSE;
729}
730
739G_MODULE_EXPORT void window_measures (GtkWidget * widg, gpointer data)
740{
741 glwin * view = (glwin *) data;
742 if (view -> measure_win == NULL)
743 {
744 view -> measure_win = g_malloc0 (sizeof*view -> measure_win);
745 gchar * str = g_strdup_printf ("%s - measures", get_project_by_id(view -> proj) -> name);
746 int pi = get_selection_type (view);
747 view -> measure_win -> win = create_win (str, view -> win, FALSE, FALSE);
748 gtk_widget_set_size_request (view -> measure_win -> win, 450, 500);
749 g_free (str);
750 GtkWidget * vbox = create_vbox (BSEP);
751 add_container_child (CONTAINER_WIN, view -> measure_win -> win, vbox);
752 GtkWidget * notebook = gtk_notebook_new ();
753 view -> measure_win -> label = markup_label(create_measure_label(view, pi), -1, 50, 0.0, 0.5);
754 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, view -> measure_win -> label, FALSE, FALSE, 0);
755 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, notebook, FALSE, FALSE, 0);
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"
760 " and up to %d atoms for dihedral angle(s) measurement(s)</sub>", MAX_IN_SELECTION-1, MAX_IN_SELECTION-11);
761 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
762 g_free (str);
763 GtkWidget * hbox = create_hbox (0);
764 GtkWidget * but = create_button ("Font and style", IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(measure_labels), view);
765 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, TRUE, 150);
766 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
767 add_gtk_close_event (view -> measure_win -> win, G_CALLBACK(close_measure_event), view);
768 show_the_widgets (view -> measure_win -> win);
769 }
770 else
771 {
772 show_the_widgets (view -> measure_win -> win);
773 }
774}
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
color colorp[64]
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
double dist
Definition d_measures.c:73
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
GtkTreeIter row
Definition datab.c:104
gchar * ctitle[MAXDATA][12]
Definition dlp_field.c:834
GType col_type[MAXDATA][12]
Definition dlp_field.c:856
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
Definition ogl_utils.c:204
angle angle_3d(cell_info *cell, int mdstep, atom *at, atom *bt, atom *ct)
angle between atom a, b and c in 3D
Definition ogl_utils.c:179
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
double pi
Definition global.c:195
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
Definition gtk-misc.c:1653
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:1960
gboolean is_atom_win_active(glwin *view)
is the model edition window visible ?
Definition atom_edit.c:71
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:445
project * proj
#define BSEP
Definition global.h:245
G_MODULE_EXPORT gboolean hide_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
hide a GtkWindow
Definition gtk-misc.c:2371
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2387
@ CONTAINER_WIN
Definition global.h:250
@ CONTAINER_SCR
Definition global.h:251
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:1863
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
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
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
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
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.
Definition glview.h:135
@ EDITION
Definition glview.h:158
int step
Definition ogl_draw.c:70
@ MEASU
Definition glwin.h:99
#define NSELECTION
Definition glwin.h:67
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
Definition glwin.h:114
double angle
Definition glwin.h:115
gboolean pbc
Definition glwin.h:116
Definition global.h:886
Definition glwin.h:875
Definition glwin.h:277
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int d
Definition tab-1.c:95
int a
Definition tab-1.c:95
int angle_id
Definition w_measures.c:73
GtkWidget * labels_tab(glwin *view, int id)
create atomic label(s) tab for the atom(s) / clone(s) window
Definition w_labels.c:537
int num_bonds(int i)
number of distinct pair(s) of atoms in selection
Definition selection.c:183
void measure_set_visible(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
show / hide cell renderer in the measures tree store
Definition w_measures.c:274
GtkWidget * measurment_tab(glwin *view, int sid, int mid)
Definition w_measures.c:609
int get_selection_type(glwin *view)
get selection type
Definition w_measures.c:83
void update_label_selection(glwin *view, int sid)
update the text information for the number of atoms/measures in selection
Definition w_measures.c:648
void fill_angle_model_row(int p, int a, int b, int c, GtkTreeStore *store)
fill angle tree store row
Definition w_measures.c:158
void measure_set_color_and_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
Definition w_measures.c:360
void measure_set_color(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
set renderer color in the measures tree store
Definition w_measures.c:293
void dihedral_set_color_and_markup(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
Definition w_measures.c:338
int num_dihedrals(int i)
number of distinct quadruplet(s) of atoms in selection
Definition selection.c:207
int dihedral_id
Definition w_measures.c:74
G_MODULE_EXPORT gboolean close_measure_event(GtkWidget *widg, GdkEvent *event, gpointer data)
measurements window close event callback GTK3
Definition w_measures.c:716
void dihedrals_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured dihedrals selection
Definition d_measures.c:319
void update_selection_tree(glwin *view, int sid, int mid)
update measurements tree view
Definition w_measures.c:381
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
G_MODULE_EXPORT void measure_labels(GtkButton *but, gpointer data)
measurements style edition window
Definition w_measures.c:677
void fill_dihedral_model_row(int p, int a, int b, int c, int d, GtkTreeStore *store)
fill dihedral tree store row
Definition w_measures.c:213
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
Definition w_measures.c:475
int num_angles(int i)
number of distinct triplet(s) of atoms in selection
Definition selection.c:195
void angles_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured angles selection
Definition d_measures.c:204
void bonds_loop(glwin *view, int id, int pi, GtkTreeStore *store)
do things for the measured distances selection
Definition d_measures.c:530
gchar * create_measure_label(glwin *view, int sid)
create the text information for the number of atom(s) in selection
Definition w_measures.c:625
G_MODULE_EXPORT void window_measures(GtkWidget *widg, gpointer data)
create the measurements window
Definition w_measures.c:739
GtkWidget * create_selection_tree(glwin *view, int sid, int mid)
create the measurements selection tree
Definition w_measures.c:490
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
Definition w_measures.c:401
G_MODULE_EXPORT void close_ml(GtkButton *but, gpointer data)
measurements style edition window close button
Definition w_measures.c:664
void fill_bond_model_row(int p, int a, int b, GtkTreeStore *store)
fill bond tree store row
Definition w_measures.c:109
int bond_id
Definition w_measures.c:72
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * img
Definition workspace.c:70
GtkWidget * vbox
Definition workspace.c:72