atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
m_tools.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: 'm_tools.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'Tools' submenu
29
30*
31* List of functions:
32
33 void set_motion_sensitive (glwin * view, int status);
34 void invert_visible (project * this_proj);
35
36 G_MODULE_EXPORT void set_selection_mode (GtkWidget * widg, gpointer data);
37 G_MODULE_EXPORT void set_mode (GtkWidget * widg, gpointer data);
38 G_MODULE_EXPORT void invert_this (GtkWidget * widg, gpointer data);
39 G_MODULE_EXPORT void to_window_measures (GSimpleAction * action, GVariant * parameter, gpointer data);
40 G_MODULE_EXPORT void to_window_volumes (GSimpleAction * action, GVariant * parameter, gpointer data);
41 G_MODULE_EXPORT void change_mouse_mode_radio (GSimpleAction * action, GVariant * parameter, gpointer data);
42 G_MODULE_EXPORT void change_sel_mode_radio (GSimpleAction * action, GVariant * parameter, gpointer data);
43 G_MODULE_EXPORT void to_create_field (GSimpleAction * action, GVariant * parameter, gpointer data);
44 G_MODULE_EXPORT void to_invert_this (GSimpleAction * action, GVariant * parameter, gpointer data);
45
46 GtkWidget * menu_tools (glwin * view, int id);
47
48 GMenu * measure_section (glwin * view, int popm);
49 GMenu * volume_section (glwin * view, int popm);
50 GMenu * edit_section (glwin * view, int popm);
51 GMenu * mouse_mode_menu (glwin * view, int popm);
52 GMenu * selection_mode_menu (glwin * view, int popm);
53 GMenu * modes_section (glwin * view, int popm);
54 GMenu * md_menu (glwin * view, int popm);
55 GMenu * inv_menu (glwin * view, int popm);
56 GMenu * add_section_item_with_menu (glwin * view, gchar * item_name, GMenu * men);
57 GMenu * menu_tools (glwin * view, int popm);
58
59*/
60
61#include "cell_edit.h"
62#include "atom_edit.h"
63#include "submenus.h"
64
65extern G_MODULE_EXPORT void window_measures (GtkWidget * widg, gpointer data);
66extern G_MODULE_EXPORT void window_volumes (GtkWidget * widg, gpointer data);
67extern G_MODULE_EXPORT void create_field (GtkWidget * widg, gpointer data);
68extern gboolean spin (gpointer data);
69extern void check_hidden_visible (project * this_proj);
70
71char * input_types[NINPUTS] = {"Classical: DL-POLY",
72 "Classical: LAMMPS",
73 "First-Principles: CPMD",
74 "First-Principles: CP2K",
75 "QM-MM: CPMD - [Soon]",
76 "QM-MM: CP2K - [Soon]"};
77
78gchar * modes[3]={"Analysis", "Edition", "Input(s)"};
79gchar * smodes[NSELECTION]={"Atom/Bond", "Coordination Sphere", "Fragment", "Molecule", "Single Fragment", "Single Molecule", "Measures (Edition Mode Only)"};
80gchar * invl[2]={"Selection", "Visible/Hidden"};
81
91{
92 int i;
93#ifdef GTK3
94 // GTK3 Menu Action To Check
95 for (i=0; i<2; i++) widget_set_sensitive (view -> ogl_anim[i], status);
96#endif
97 if (view -> player != NULL) widget_set_sensitive (view -> player -> win, status);
98 if (view -> spiner != NULL) widget_set_sensitive (view -> spiner -> win, status);
99 if (view -> rec != NULL) widget_set_sensitive (view -> rec -> win, status);
100 if (! status)
101 {
102 if (view -> spin[0] || view -> spin[1])
103 {
104 for (i=0; i<2; i++)
105 {
106 view -> spin[i+2] = view -> spin[i];
107 view -> spin_speed[i+2] = view -> spin_speed[i];
108 view -> spin[i] = FALSE;
109 }
110 }
111 }
112 else if (view -> spin[2] || view -> spin[3])
113 {
114 for (i=0; i<2; i++)
115 {
116 view -> spin[i] = view -> spin[i+2];
117 view -> spin_speed[i] = view -> spin_speed[i+2];
118 g_timeout_add (REFRESH, (GSourceFunc) spin, & view -> colorp[0][i]);
119 view -> spin[i+2] = FALSE;
120 view -> spin_speed[i+2] = 0;
121 }
122 }
123}
124
133G_MODULE_EXPORT void set_selection_mode (GtkWidget * widg, gpointer data)
134{
135 tint * the_data = (tint *)data;
136 project * this_proj = get_project_by_id(the_data -> a);
137 int i = this_proj -> modelgl -> selection_mode;
138 int j = the_data -> b;
139#ifdef GTK4
140 if (i != j)
141 {
142#else
143 // GTK3 Menu Action To Check
144 if (i != j && gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
145 {
146 this_proj -> modelgl -> selection_mode = NONE;
147 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_smode[i], FALSE);
148 if (widg != this_proj -> modelgl -> ogl_smode[j])
149 {
150 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_smode[j], TRUE);
151 }
152#endif
153 this_proj -> modelgl -> selection_mode = j;
154 }
155#ifdef GTK3
156 // GTK3 Menu Action To Check
157 else if (i == j && ! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
158 {
159 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_smode[j], TRUE);
160 }
161#endif
162}
163
172G_MODULE_EXPORT void set_mode (GtkWidget * widg, gpointer data)
173{
174 tint * the_data = (tint *)data;
175 project * this_proj = get_project_by_id(the_data -> a);
176 int i = this_proj -> modelgl -> mode;
177 int j = the_data -> b;
178
179 if (! (j == EDITION && is_atom_win_active(this_proj -> modelgl)))
180 {
181#ifdef GTK4
182 if (i != j)
183#else
184 if (i != j && gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
185#endif
186 {
187 this_proj -> modelgl -> mode = NONE;
188#ifdef GTK3
189 // GTK3 Menu Action To Check
190 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_mode[i], FALSE);
191 if (widg != this_proj -> modelgl -> ogl_mode[j])
192 {
193 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_mode[j], TRUE);
194 }
195#endif
196 this_proj -> modelgl -> mode = j;
197 if (this_proj -> modelgl -> mode == EDITION)
198 {
199 for (i=1; i<3; i++) init_coordinates (this_proj, i, FALSE, TRUE);
200 set_motion_sensitive (this_proj -> modelgl, 0);
201 }
202 else
203 {
204 for (i=1; i<3; i++)
205 {
206 if (this_proj -> modelgl -> saved_coord[i] != NULL)
207 {
208 g_free (this_proj -> modelgl -> saved_coord[i]);
209 this_proj -> modelgl -> saved_coord[i] = NULL;
210 }
211 }
212 set_motion_sensitive (this_proj -> modelgl, 1);
213 if (this_proj -> modelgl -> selection_mode == NSELECTION-1)
214 {
215#ifdef GTK4
216 set_selection_mode (NULL, & this_proj -> modelgl -> colorp[0][0]);
217#else
218 // GTK3 Menu Action To Check
219 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_smode[0], TRUE);
220 set_selection_mode (this_proj -> modelgl -> ogl_smode[0], & this_proj -> modelgl -> colorp[0][0]);
221#endif
222 }
223 }
224 i = activep;
225 active_project_changed (this_proj -> id);
227#ifdef GTK3
228 // GTK3 Menu Action To Check
229 widget_set_sensitive (this_proj -> modelgl -> ogl_smode[NSELECTION-1], (this_proj -> modelgl -> mode == EDITION) ? 1 : 0);
230#endif
231 i = (this_proj -> modelgl -> mode == EDITION) ? EDITION : ANALYZE;
232 gchar * str = g_strdup_printf ("%s - 3D view - [%s mode]", prepare_for_title(this_proj -> name), mode_name[i]);
233 gtk_window_set_title (GTK_WINDOW (this_proj -> modelgl -> win), str);
234 g_free (str);
235 this_proj -> modelgl -> create_shaders[MEASU] = TRUE;
236 update (this_proj -> modelgl);
237
238 }
239#ifdef GTK3
240 // GTK3 Menu Action To Check
241 else if (i == j && ! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
242 {
243 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_mode[j], TRUE);
244 }
245#endif
246 }
247}
248
256void invert_visible (project * this_proj)
257{
258 int i, j, k;
259 for (i=0; i<this_proj -> steps; i++)
260 {
261 for (j=0; j<this_proj -> natomes; j++)
262 {
263 for (k=0; k<2; k++) this_proj -> atoms[i][j].show[k] = ! this_proj -> atoms[i][j].show[k];
264 }
265 }
266 check_hidden_visible (this_proj);
267 init_default_shaders (this_proj -> modelgl);
268}
269
278G_MODULE_EXPORT void invert_this (GtkWidget * widg, gpointer data)
279{
280 tint * the_data = (tint *)data;
281 project * this_proj = get_project_by_id(the_data -> a);
282 switch (the_data -> b)
283 {
284 case 0:
285 invert_selection (this_proj);
286 init_default_shaders (this_proj -> modelgl);
287 break;
288 case 1:
289 invert_visible (this_proj);
290 break;
291 }
292}
293
294#ifdef GTK3
295extern G_MODULE_EXPORT void window_volumes (GtkWidget * widg, gpointer data);
304GtkWidget * menu_tools (glwin * view, int id)
305{
306 int i;
307 GtkWidget * menut = gtk_menu_new ();
308 gtk3_menu_item (menut, "Measures", IMG_NONE, NULL, G_CALLBACK(window_measures), (gpointer)view, TRUE, GDK_KEY_m, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
309 GtkWidget * widg = gtk3_menu_item (menut, "Volumes", IMG_NONE, NULL, G_CALLBACK(window_volumes), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
310 widget_set_sensitive (widg, (get_project_by_id(view -> proj) -> steps > 1) ? 0 : 1);
311 add_menu_separator (menut);
312 gtk_menu_shell_append ((GtkMenuShell *)menut, menu_item_new_with_submenu("Edit", TRUE, menu_edit(view, id)));
313 add_menu_separator (menut);
314 widg = create_menu_item (FALSE, "Mouse Mode");
315 gtk_menu_shell_append ((GtkMenuShell *)menut, widg);
316 GtkWidget * menum = gtk_menu_new ();
317 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menum);
318 guint accel[3]={GDK_KEY_a, GDK_KEY_e, GDK_KEY_i};
319 guint acces[4]={GDK_KEY_A, GDK_KEY_C, GDK_KEY_F, GDK_KEY_M};
320 if (id == 0)
321 {
322 for (i=0; i<2; i++)
323 {
324 view -> ogl_mode[i] = gtk3_menu_item (menum, modes[i], IMG_NONE, NULL, G_CALLBACK(set_mode), & view -> colorp[i][0],
325 TRUE, accel[i], GDK_MOD1_MASK, TRUE, TRUE, (i == view -> mode) ? TRUE : FALSE);
326 widget_set_sensitive (view -> ogl_mode[i], (get_project_by_id(view -> proj) -> steps > 1) ? 0 : 1);
327 }
328 }
329 else
330 {
331 for (i=0; i<2; i++)
332 {
333 widg = gtk3_menu_item (menum, modes[i], IMG_NONE, NULL, G_CALLBACK(set_mode), & view -> colorp[i][0],
334 TRUE, accel[i], GDK_MOD1_MASK, TRUE, TRUE, (i == view -> mode) ? TRUE : FALSE);
335 widget_set_sensitive (widg, (get_project_by_id(view -> proj) -> steps > 1) ? 0 : 1);
336 }
337 }
338 /*widg = create_menu_item (TRUE, modes[2]);
339 gtk_menu_shell_append ((GtkMenuShell *)menum, widg);
340 GtkWidget * menui = gtk_menu_new ();
341 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menui);
342 widget_set_sensitive (widg, (get_project_by_id(view -> proj) -> steps > 1) ? 0 : 1);
343 if (id == 0)
344 {
345 for (i=0; i<NINPUTS; i++)
346 {
347 view -> ogl_mode[i+2] = gtk3_menu_item (menum, modes[i], IMG_NONE, NULL, G_CALLBACK(set_mode), & view -> colorp[2+i][0],
348 FALSE, 0, 0, TRUE, TRUE, (i+2 == view -> mode) ? TRUE : FALSE);
349 widget_set_sensitive (view -> ogl_mode[i+2], 0);
350 }
351 }
352 else
353 {
354 for (i=0; i<NINPUTS; i++)
355 {
356 widg = gtk3_menu_item (menum, modes[i], IMG_NONE, NULL, G_CALLBACK(set_mode), & view -> colorp[2+i][0],
357 FALSE, 0, 0, TRUE, TRUE, (i+2 == view -> mode) ? TRUE : FALSE);
358 widget_set_sensitive (widg, 0);
359 }
360 }*/
361 widg = create_menu_item (FALSE, "Selection Mode");
362 gtk_menu_shell_append ((GtkMenuShell *)menut, widg);
363 GtkWidget * menusm = gtk_menu_new ();
364 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menusm);
365
366 if (id == 0)
367 {
368 for (i=0; i<NSELECTION; i++)
369 {
370 if (i < 4)
371 {
372 view -> ogl_smode[i] = gtk3_menu_item (menusm, smodes[i], IMG_NONE, NULL, G_CALLBACK(set_selection_mode), & view -> colorp[i][0],
373 TRUE, acces[i], GDK_SHIFT_MASK, TRUE, TRUE, (i == view -> selection_mode) ? TRUE : FALSE);
374 }
375 else
376 {
377 view -> ogl_smode[i] = gtk3_menu_item (menusm, smodes[i], IMG_NONE, NULL, G_CALLBACK(set_selection_mode), & view -> colorp[i][0],
378 FALSE, 0, 0, TRUE, TRUE, (i == view -> selection_mode) ? TRUE : FALSE);
379 }
380 if (i == NSELECTION-1) widget_set_sensitive (view -> ogl_smode[i], (view -> mode == EDITION) ? 1 : 0);
381 }
382 }
383 else
384 {
385 for (i=0; i<NSELECTION; i++)
386 {
387 if (i < 4)
388 {
389 widg = gtk3_menu_item (menusm, smodes[i], IMG_NONE, NULL, G_CALLBACK(set_selection_mode), & view -> colorp[i][0],
390 TRUE, acces[i], GDK_SHIFT_MASK, TRUE, TRUE, (i == view -> selection_mode) ? TRUE : FALSE);
391 }
392 else
393 {
394 widg = gtk3_menu_item (menusm, smodes[i], IMG_NONE, NULL, G_CALLBACK(set_selection_mode), & view -> colorp[i][0],
395 FALSE, 0, 0, TRUE, TRUE, (i == view -> selection_mode) ? TRUE : FALSE);
396 }
397 if (i == NSELECTION-1) widget_set_sensitive (widg, (view -> mode == EDITION) ? 1 : 0);
398 }
399 }
400
401 add_menu_separator (menut);
402
403 GtkWidget * menuf = NULL;
404 widg = create_menu_item (FALSE, "Molecular Dynamics");
405 widget_set_sensitive (widg, get_project_by_id(view -> proj) -> nspec);
406 gtk_menu_shell_append ((GtkMenuShell *)menut, widg);
407 menuf = gtk_menu_new ();
408 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menuf);
409 if (id == 0)
410 {
411 for (i=0; i<NINPUTS; i++)
412 {
413 view -> ogl_mode[i+2+NINPUTS] = create_menu_item (TRUE, input_types[i]);
414 gtk_menu_shell_append ((GtkMenuShell *)menuf, view -> ogl_mode[i+2+NINPUTS]);
415 g_signal_connect (G_OBJECT (view -> ogl_mode[i+2+NINPUTS]), "activate", G_CALLBACK(create_field), & view -> colorp[i][0]);
416 if (i > 3) widget_set_sensitive (view -> ogl_mode[i+2+NINPUTS], 0);
417 }
419 }
420 else
421 {
422 for (i=0; i<NINPUTS; i++)
423 {
424 widg = create_menu_item (TRUE, input_types[i]);
425 gtk_menu_shell_append ((GtkMenuShell *)menuf, widg);
426 g_signal_connect (G_OBJECT (widg), "activate", G_CALLBACK(create_field), & view -> colorp[i][0]);
427 // if (i < 2 || i > 3) widget_set_sensitive (widg, view -> adv_bonding[1]);
428 if (i < 2) widget_set_sensitive (widg, view -> adv_bonding[1]);
429 if (i > 3) widget_set_sensitive (widg, 0);
430 }
431 }
432
433 add_menu_separator (menut);
434 GtkWidget * menuin = NULL;
435 widg = create_menu_item (FALSE, "Invert");
436 gtk_menu_shell_append ((GtkMenuShell *)menut, widg);
437 menuin = gtk_menu_new ();
438 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menuin);
439 for (i=0; i<2; i++)
440 {
441 widg = create_menu_item (FALSE, invl[i]);
442 gtk_menu_shell_append ((GtkMenuShell *)menuin, widg);
443 g_signal_connect (G_OBJECT (widg), "activate", G_CALLBACK(invert_this), & view -> colorp[i][0]);
444 }
445 return menut;
446}
447#else
457G_MODULE_EXPORT void to_window_measures (GSimpleAction * action, GVariant * parameter, gpointer data)
458{
459 window_measures (NULL, data);
460}
461
470GMenu * measure_section (glwin * view, int popm)
471{
472 GMenu * menu = g_menu_new ();
473 append_opengl_item (view, menu, "Measures", "measures", popm, popm, "<CTRL>M", IMG_NONE, NULL, FALSE, G_CALLBACK(to_window_measures), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
474 return menu;
475}
476
486G_MODULE_EXPORT void to_window_volumes (GSimpleAction * action, GVariant * parameter, gpointer data)
487{
488 window_volumes (NULL, data);
489}
490
499GMenu * volume_section (glwin * view, int popm)
500{
501 GMenu * menu = g_menu_new ();
502 append_opengl_item (view, menu, "Volumes", "volumes", popm, popm, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(to_window_volumes), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
503 return menu;
504}
505
514GMenu * edit_section (glwin * view, int popm)
515{
516 GMenu * menu = g_menu_new ();
517 append_submenu (menu, "Edit", menu_edit(view, popm));
518 return menu;
519}
520
530G_MODULE_EXPORT void change_mouse_mode_radio (GSimpleAction * action, GVariant * parameter, gpointer data)
531{
532 glwin * view = (glwin *)data;
533 const gchar * mode = g_variant_get_string (parameter, NULL);
534 int lgt = strlen (mode);
535 gchar * name = g_strdup_printf ("%c%c", mode[lgt-2], mode[lgt-1]);
536 if (g_strcmp0(name, ".1") == 0)
537 {
538 g_free (name);
539 name = g_strdup_printf ("%.*s.0", lgt-2, mode);
540 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-mouse-mode", g_variant_new_string((const gchar *)name));
541 g_free (name);
542 }
543 else
544 {
545 gchar * mode_name = NULL;
546 int i;
547 for (i=0; i<2; i++)
548 {
549 mode_name = g_strdup_printf ("set-mouse-mode.%d.0", i);
550 if (g_strcmp0(mode, (const gchar *)mode_name) == 0)
551 {
552 set_mode (NULL, & view -> colorp[i][0]);
553 g_free (mode_name);
554 mode_name = NULL;
555 break;
556 }
557 g_free (mode_name);
558 mode_name = NULL;
559 }
560 // Update the menu bar is required to activate / deactivate the selection mode option
561 update_menu_bar (view);
562 }
563}
564
573GMenu * mouse_mode_menu (glwin * view, int popm)
574{
575 GMenu * menu = g_menu_new ();
576 gchar * accel[3] = {"<ALT>A", "<ALT>E", "<ALT>I"};
577 int i, j;
578 j = (get_project_by_id(view -> proj) -> steps > 1) ? 0 : 1;
579 for (i=0; i<2; i++)
580 {
581 append_opengl_item (view, menu, modes[i], "mouse-mode", popm, i, accel[i], IMG_NONE, NULL, FALSE,
582 G_CALLBACK(change_mouse_mode_radio), (gpointer)view, FALSE, (i == view -> mode) ? TRUE : FALSE, TRUE, j);
583 }
584 return menu;
585}
586
596G_MODULE_EXPORT void change_sel_mode_radio (GSimpleAction * action, GVariant * parameter, gpointer data)
597{
598 glwin * view = (glwin *)data;
599 const gchar * mode = g_variant_get_string (parameter, NULL);
600 int lgt = strlen (mode);
601 gchar * name = g_strdup_printf ("%c%c", mode[lgt-2], mode[lgt-1]);
602 if (g_strcmp0(name, ".1") == 0)
603 {
604 g_free (name);
605 name = g_strdup_printf ("%.*s.0", lgt-2, mode);
606 g_action_group_activate_action ((GActionGroup *)view -> action_group, "set-sel-mode", g_variant_new_string((const gchar *)name));
607 g_free (name);
608 }
609 else
610 {
611 gchar * mode_name = NULL;
612 int i;
613 for (i=0; i<NSELECTION; i++)
614 {
615 mode_name = g_strdup_printf ("set-sel-mode.%d.0", i);
616 if (g_strcmp0(mode, (const gchar *)mode_name) == 0)
617 {
618 set_selection_mode (NULL, & view -> colorp[i][0]);
619 g_free (mode_name);
620 mode_name = NULL;
621 break;
622 }
623 g_free (mode_name);
624 mode_name = NULL;
625 }
626 g_action_change_state (G_ACTION (action), parameter);
627 }
628}
629
638GMenu * selection_mode_menu (glwin * view, int popm)
639{
640 GMenu * menu = g_menu_new ();
641 gchar * acces[4]={"A", "C", "F", "M"};
642 gchar * str;
643 int i, j;
644 for (i=0; i<NSELECTION; i++)
645 {
646 j = (i == NSELECTION-1) ? (view -> mode == EDITION) ? 1 : 0 : TRUE;
647 if (i < 4)
648 {
649 str = g_strdup_printf ("<SHIFT>%s", acces[i]);
650 append_opengl_item (view, menu, smodes[i], "sel-mode", popm, i, str, IMG_NONE, NULL, FALSE, G_CALLBACK(change_sel_mode_radio), (gpointer)view,
651 FALSE, (i == view -> selection_mode) ? TRUE : FALSE, TRUE, j);
652 g_free (str);
653 }
654 else
655 {
656 append_opengl_item (view, menu, smodes[i], "sel-mode", popm, i, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(change_sel_mode_radio), (gpointer)view,
657 FALSE, (i == view -> selection_mode) ? TRUE : FALSE, TRUE, j);
658 }
659 }
660 return menu;
661}
662
671GMenu * modes_section (glwin * view, int popm)
672{
673 GMenu * menu = g_menu_new ();
674 append_submenu (menu, "Mouse Mode", mouse_mode_menu(view, popm));
675 append_submenu (menu, "Selection Mode", selection_mode_menu(view, popm));
676 return menu;
677}
678
688G_MODULE_EXPORT void to_create_field (GSimpleAction * action, GVariant * parameter, gpointer data)
689{
690 create_field (NULL, data);
691}
692
701GMenu * md_menu (glwin * view, int popm)
702{
703 GMenu * menu = g_menu_new ();
704 int i;
705 for (i=0; i<NINPUTS; i++)
706 {
707 append_opengl_item (view, menu, input_types[i], "md", popm, i, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(to_create_field), & view -> colorp[i][0],
708 FALSE, FALSE, FALSE, (i < 2) ? view -> adv_bonding[1] : (i > 3) ? FALSE : TRUE);
709 }
710 return menu;
711}
712
722G_MODULE_EXPORT void to_invert_this (GSimpleAction * action, GVariant * parameter, gpointer data)
723{
724 invert_this (NULL, data);
725}
726
735GMenu * inv_menu (glwin * view, int popm)
736{
737 GMenu * menu = g_menu_new ();
738 int i;
739 for (i=0; i<2; i++)
740 {
741 append_opengl_item (view, menu, invl[i], "inv", popm, i, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(to_invert_this), & view -> colorp[i][0], FALSE, FALSE, FALSE, TRUE);
742 }
743 return menu;
744}
745
755GMenu * add_section_item_with_menu (glwin * view, gchar * item_name, GMenu * men)
756{
757 GMenu * menu = g_menu_new ();
758 append_submenu (menu, item_name, men);
759 return menu;
760}
761
770GMenu * menu_tools (glwin * view, int popm)
771{
772 GMenu * menu = g_menu_new ();
773 g_menu_append_section (menu, NULL, (GMenuModel*)measure_section(view, popm));
774 g_menu_append_section (menu, NULL, (GMenuModel*)volume_section(view, popm));
775 g_menu_append_section (menu, NULL, (GMenuModel*)edit_section(view, popm));
776 g_menu_append_section (menu, NULL, (GMenuModel*)modes_section(view, popm));
777 g_menu_append_section (menu, NULL, (GMenuModel*)add_section_item_with_menu(view, "Molecular Dynamics", md_menu(view, popm)));
778 g_menu_append_section (menu, NULL, (GMenuModel*)add_section_item_with_menu(view, "Invert", inv_menu(view, popm)));
779 return menu;
780}
781#endif
Function declarations for the mode edition window.
void init_coordinates(project *this_proj, int status, gboolean win, gboolean init)
preserve atomic coordinates
Definition atom_move.c:197
void invert_selection(project *this_proj)
invert atom(s) selection
Definition cell_cut.c:404
Function declarations for the cell edition window.
color colorp[64]
int atoms[NUM_STYLES][2]
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
int activep
Definition global.c:159
gchar * mode_name[2]
Definition global.c:137
@ IMG_NONE
Definition global.h:260
GtkWidget * gtk3_menu_item(GtkWidget *menu, gchar *name, int icon_format, gpointer item_icon, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod, gboolean check, gboolean radio, gboolean status)
gboolean is_atom_win_active(glwin *view)
is the model edition window visible ?
Definition atom_edit.c:71
project * proj
void append_submenu(GMenu *menu, const gchar *label, GMenu *submenu)
append a GMenuItem with a subenu to a GMenu, and use markup for the GMenuItem
Definition gui.c:728
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_menu_item(gboolean add_mnemo, gchar *action)
gchar * prepare_for_title(gchar *init)
prepare a string for a window title, getting rid of all markup
Definition tools.c:71
void add_menu_separator(GtkWidget *menu)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
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
action
Definition glview.h:189
#define REFRESH
Refresh time for spinning the OpenGL window in milliseconds.
Definition glview.h:130
modes
Definition glview.h:156
@ ANALYZE
Definition glview.h:157
@ EDITION
Definition glview.h:158
@ NONE
Definition glview.h:172
@ MEASU
Definition glwin.h:99
#define NINPUTS
Definition glwin.h:66
#define NSELECTION
Definition glwin.h:67
void append_opengl_item(glwin *view, GMenu *menu, const gchar *name, gchar *key, int mpop, int item_id, gchar *accel, int image_format, gpointer icon, gboolean custom, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, gboolean sensitive)
void set_advanced_bonding_menus(glwin *view)
GMenu * menu_edit(glwin *view, int popm)
create the 'Edit' submenu GTK4
Definition m_edit.c:354
G_MODULE_EXPORT void to_create_field(GSimpleAction *action, GVariant *parameter, gpointer data)
run MD input assistant callback GTK4
Definition m_tools.c:688
G_MODULE_EXPORT void change_sel_mode_radio(GSimpleAction *action, GVariant *parameter, gpointer data)
change selection mode callback GTK4
Definition m_tools.c:596
GMenu * inv_menu(glwin *view, int popm)
create the 'Tools -> Invert' submenu GTK4
Definition m_tools.c:735
G_MODULE_EXPORT void to_window_measures(GSimpleAction *action, GVariant *parameter, gpointer data)
open the measurement window callback GTK4
Definition m_tools.c:457
GMenu * modes_section(glwin *view, int popm)
create the 'Tools -> * Modes' submenus GTK4
Definition m_tools.c:671
gchar * invl[2]
Definition m_tools.c:80
G_MODULE_EXPORT void set_selection_mode(GtkWidget *widg, gpointer data)
set selection mode callback
Definition m_tools.c:133
GMenu * volume_section(glwin *view, int popm)
create the 'Tools -> Volumes' menu item GTK4
Definition m_tools.c:499
G_MODULE_EXPORT void invert_this(GtkWidget *widg, gpointer data)
invert selection or visible callback
Definition m_tools.c:278
G_MODULE_EXPORT void create_field(GtkWidget *widg, gpointer data)
start an input creation assistant
Definition calc.c:308
void check_hidden_visible(project *this_proj)
check how many atom(s) are visible
Definition popup.c:869
GMenu * selection_mode_menu(glwin *view, int popm)
create the 'Tools -> Selection Mode' submenu GTK4
Definition m_tools.c:638
G_MODULE_EXPORT void window_volumes(GtkWidget *widg, gpointer data)
create the 'Volumes' window callback
Definition w_volumes.c:1131
GMenu * mouse_mode_menu(glwin *view, int popm)
create the 'Tools -> Mouse Mode' submenu GTK4
Definition m_tools.c:573
gchar * smodes[NSELECTION]
Definition m_tools.c:79
char * input_types[NINPUTS]
Definition m_tools.c:71
gboolean spin(gpointer data)
spin
Definition w_spiner.c:56
GMenu * menu_tools(glwin *view, int popm)
create the 'Tools' submenu - GTK4
Definition m_tools.c:770
GMenu * md_menu(glwin *view, int popm)
create the 'Molecular Dynamics' submenu GTK4
Definition m_tools.c:701
G_MODULE_EXPORT void window_measures(GtkWidget *widg, gpointer data)
create the measurements window
Definition w_measures.c:739
G_MODULE_EXPORT void set_mode(GtkWidget *widg, gpointer data)
set mouse mode callback
Definition m_tools.c:172
GMenu * edit_section(glwin *view, int popm)
create the 'Tools -> Edit' submenu GTK4
Definition m_tools.c:514
G_MODULE_EXPORT void to_invert_this(GSimpleAction *action, GVariant *parameter, gpointer data)
invert this callback GTK4
Definition m_tools.c:722
void invert_visible(project *this_proj)
invert visible atom(s)
Definition m_tools.c:256
void set_motion_sensitive(glwin *view, int status)
change motion parameters following a change in the mouse mode
Definition m_tools.c:90
GMenu * add_section_item_with_menu(glwin *view, gchar *item_name, GMenu *men)
append a new menu item with a new submenu
Definition m_tools.c:755
G_MODULE_EXPORT void change_mouse_mode_radio(GSimpleAction *action, GVariant *parameter, gpointer data)
change mouse radio menu item callback GTK4
Definition m_tools.c:530
G_MODULE_EXPORT void to_window_volumes(GSimpleAction *action, GVariant *parameter, gpointer data)
open the volumes window callback GTK4
Definition m_tools.c:486
GMenu * measure_section(glwin *view, int popm)
create the 'Tools -> Measures' menu item GTK4
Definition m_tools.c:470
void active_project_changed(int id)
change the active project
Definition update_p.c:175
Definition glwin.h:875
Definition global.h:104
Function declarations for the creation of the OpenGL window menus.
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160