atomes 1.1.16
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
popup.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
24/*
25* This file: 'popup.c'
26*
27* Contains:
28*
29
30 - The functions to create the OpenGL window popup menus:
31 - The main popup menu
32 - The contextual, atom or bond related, popup menus
33
34*
35* List of functions:
36
37 int get_to_be_selected (glwin * view);
38 int get_style (gchar * str);
39 int check_label_numbers (project * this_proj, int types);
40
41 gchar * get_object_from_action (GSimpleAction * action);
42
43 void to_remove_this_object (int type, gpointer data);
44 void to_replace_this_object (int type, GSimpleAction * action, gpointer data);
45 void to_replace_this_object (int type, GtkWidget * widg, gpointer data);
46 void copy_bond_selection ();
47 void remove_object ();
48 void insert_object (int action, gpointer data);
49 void check_hidden_visible (project * this_proj);
50 void create_new_project_using_data (atom_selection * selection);
51 void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data);
52 void add_edition_sub_menu (GtkWidget * item, GCallback handler, gpointer data);
53 void create_selection_item (GMenu * menu, glwin * view, gchar * str, gchar * act, int aid, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data);
54 void analyze_popup_attach_color_palettes (glwin * view, GtkWidget * menu, int ato, int spc, int totc, int parc, int frag, int mol);
55 void popup_selection (glwin * view, double ptx, double pty, int spe, int mmod, int ati, int bti, int aoc);
56 void analyze_menu_attach_color_palettes (glwin * view, GtkWidget * menu);
57 void popup_main_menu (glwin * view, double ptx, double pty);
58
59 G_MODULE_EXPORT void set_full_screen (GSimpleAction * action, GVariant * parameter, gpointer data);
60 G_MODULE_EXPORT void set_full_screen (GtkWidget * widg, gpointer data);
61 G_MODULE_EXPORT void remove_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
62 G_MODULE_EXPORT void remove_this_atom (GtkWidget * widg, gpointer data);
63 G_MODULE_EXPORT void add_object (GSimpleAction * action, GVariant * parameter, gpointer data);
64 G_MODULE_EXPORT void add_object (GtkWidget * widg, gpointer data);
65 G_MODULE_EXPORT void to_add_object (GSimpleAction * action, GVariant * parameter, gpointer data);
66 G_MODULE_EXPORT void to_add_object (GtkWidget * widg, gpointer data);
67 G_MODULE_EXPORT void replace_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
68 G_MODULE_EXPORT void replace_this_atom (GtkWidget * widg, gpointer data);
69 G_MODULE_EXPORT void copy_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
70 G_MODULE_EXPORT void copy_this_atom (GtkWidget * widg, gpointer data);
71 G_MODULE_EXPORT void show_hide_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
72 G_MODULE_EXPORT void show_hide_this_atom (GtkWidget * widg, gpointer data);
73 G_MODULE_EXPORT void label_unlabel_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
74 G_MODULE_EXPORT void label_unlabel_this_atom (GtkWidget * widg, gpointer data);
75 G_MODULE_EXPORT void select_unselect_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
76 G_MODULE_EXPORT void select_unselect_this_atom (GtkWidget * widg, gpointer data);
77 G_MODULE_EXPORT void style_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
78 G_MODULE_EXPORT void style_this_atom (GtkWidget * widg, gpointer data);
79 G_MODULE_EXPORT void remove_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
80 G_MODULE_EXPORT void remove_the_atoms (GtkWidget * widg, gpointer data);
81 G_MODULE_EXPORT void replace_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
82 G_MODULE_EXPORT void replace_the_atoms (GtkWidget * widg, gpointer data);
83 G_MODULE_EXPORT void copy_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
84 G_MODULE_EXPORT void copy_the_atoms (GtkWidget * widg, gpointer data);
85 G_MODULE_EXPORT void show_hide_others (GSimpleAction * action, GVariant * parameter, gpointer data);
86 G_MODULE_EXPORT void show_hide_others (GtkWidget * widg, gpointer data);
87 G_MODULE_EXPORT void show_hide_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
88 G_MODULE_EXPORT void show_hide_the_atoms (GtkWidget * widg, gpointer data);
89 G_MODULE_EXPORT void label_unlabel_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
90 G_MODULE_EXPORT void label_unlabel_atoms (GtkWidget * widg, gpointer data);
91 G_MODULE_EXPORT void select_unselect_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
92 G_MODULE_EXPORT void select_unselect_atoms (GtkWidget * widg, gpointer data);
93 G_MODULE_EXPORT void style_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
94 G_MODULE_EXPORT void style_the_atoms (GtkWidget * widg, gpointer data);
95 G_MODULE_EXPORT void remove_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
96 G_MODULE_EXPORT void remove_the_coord (GtkWidget * widg, gpointer data);
97 G_MODULE_EXPORT void replace_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
98 G_MODULE_EXPORT void replace_the_coord (GtkWidget * widg, gpointer data);
99 G_MODULE_EXPORT void copy_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
100 G_MODULE_EXPORT void copy_the_coord (GtkWidget * widg, gpointer data);
101 G_MODULE_EXPORT void show_hide_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
102 G_MODULE_EXPORT void show_hide_the_coord (GtkWidget * widg, gpointer data);
103 G_MODULE_EXPORT void label_unlabel_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
104 G_MODULE_EXPORT void label_unlabel_coord (GtkWidget * widg, gpointer data);
105 G_MODULE_EXPORT void select_unselect_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
106 G_MODULE_EXPORT void select_unselect_coord (GtkWidget * widg, gpointer data);
107 G_MODULE_EXPORT void style_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
108 G_MODULE_EXPORT void style_the_coord (GtkWidget * widg, gpointer data);
109 G_MODULE_EXPORT void edit_in_new_project (GSimpleAction * action, GVariant * parameter, gpointer data);
110 G_MODULE_EXPORT void edit_in_new_project (GtkWidget * widg, gpointer data);
111 G_MODULE_EXPORT void edit_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
112 G_MODULE_EXPORT void edit_coord (GtkWidget * widg, gpointer data);
113 G_MODULE_EXPORT void edit_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
114 G_MODULE_EXPORT void edit_atoms (GtkWidget * widg, gpointer data);
115 G_MODULE_EXPORT void select_action_for_all (GSimpleAction * action, GVariant * parameter, gpointer data);
116 G_MODULE_EXPORT void select_action_for_all (GtkWidget * widg, gpointer data);
117 G_MODULE_EXPORT void select_action_for_this_bond (GSimpleAction * action, GVariant * parameter, gpointer data);
118 G_MODULE_EXPORT void select_action_for_this_bond (GtkWidget * widg, gpointer data);
119 G_MODULE_EXPORT void select_action_for_all_bonds (GSimpleAction * action, GVariant * parameter, gpointer data);
120 G_MODULE_EXPORT void select_action_for_all_bonds (GtkWidget * widg, gpointer data);
121 G_MODULE_EXPORT void reset_coords (GSimpleAction * action, GVariant * parameter, gpointer data);
122 G_MODULE_EXPORT void reset_coords (GtkWidget * widg, gpointer data);
123 G_MODULE_EXPORT void turn_rebuild (GSimpleAction * action, GVariant * parameter, gpointer data);
124 G_MODULE_EXPORT void turn_rebuild (GtkWidget * widg, gpointer data);
125 G_MODULE_EXPORT void to_center_this_molecule (GtkWidget * widg, gpointer data);
126
127 GtkWidget * create_selection_item (glwin * view, gchar * str, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data);
128 GtkWidget * selection_menu (glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c);
129
130 GMenu * add_edition_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data);
131 GMenu * add_style_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data);
132 GMenu * selection_menu (int aid, glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c);
133 GMenu * tools_section (glwin * view);
134 GMenu * anim_section (glwin * view);
135
136 atom_search * free_this_search_data (atom_search * this_search);
137
138*/
139
140#include "global.h"
141#include "callbacks.h"
142#include "interface.h"
143#include "workspace.h"
144#include "project.h"
145#include "glview.h"
146#include "glwindow.h"
147#include "submenus.h"
148#include "color_box.h"
149#include "bind.h"
150#include "atom_edit.h"
151
152#define CONTEXTACT 12
153
154extern atom_search * allocate_atom_search (int proj, int action, int searchid, int tsize);
155extern void check_all_trees (project * this_proj);
156extern int action_atoms_from_project (project * this_proj, atom_search * asearch, gboolean visible);
157extern G_MODULE_EXPORT void opengl_advanced (GtkWidget * widg, gpointer data);
158extern G_MODULE_EXPORT void render_gl_image (GtkWidget * widg, gpointer data);
159extern G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data);
160extern void apply_project (gboolean showtools);
161extern GtkWidget * field_atom_menu (int p, int s, int a, int f);
162extern void reset_coordinates (project * this_proj, int status);
163extern vec3_t get_bary (project * this_proj, int status);
164extern void prepare_to_instert (gchar * key, project * this_proj, atom_search * asearch, gboolean visible);
165extern insertion_menu mol[];
166extern atom_in_selection * new_atom_in_selection (int id, int sp);
167extern int inserted_from_lib;
168extern void duplicate_material_and_lightning (image * new_img, image * old_img);
169#ifdef GTK4
170extern GSimpleActionGroup * view_pop_actions;
171extern G_MODULE_EXPORT void window_color_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
172extern GtkWidget * color_palette (glwin * view, int ideo, int spec, int geo);
173#endif
174extern G_MODULE_EXPORT void view_shortcuts (GSimpleAction * action, GVariant * parameter, gpointer data);
177
186
189
198{
199 if (view -> atom_win && ! column_label)
200 {
201 return (view -> atom_win -> visible || view -> selection_mode == NSELECTION-1) ? 1 : 0;
202 }
203 else
204 {
205 return 0;
206 }
207}
208
209#ifdef GTK4
219G_MODULE_EXPORT void set_full_screen (GSimpleAction * action, GVariant * parameter, gpointer data)
220#else
229G_MODULE_EXPORT void set_full_screen (GtkWidget * widg, gpointer data)
230#endif
231{
232 glwin * view = (glwin *)data;
233 if (! view -> fullscreen)
234 {
235 gtk_window_fullscreen (GTK_WINDOW(view -> win));
236 hide_the_widgets (view -> menu_box);
237 view -> fullscreen = TRUE;
238 }
239 else
240 {
241 gtk_window_unfullscreen (GTK_WINDOW(view -> win));
242 show_the_widgets (view -> menu_box);
243 view -> fullscreen = FALSE;
244 }
245}
246
254int get_style (gchar * str)
255{
256 int i;
257 is_filled = NONE;
258#ifdef GTK4
259 i = strlen (str);
260 return (int) string_to_double ((gpointer)g_strdup_printf ("%c", str[i-1]));
261#else
262 for (i=0; i<OGL_STYLES; i++)
263 {
264 if (g_strcmp0 (text_styles[i], str) == 0) return i;
265 }
266 for (i=0; i<FILLED_STYLES; i++)
267 {
268 if (g_strcmp0 (text_filled[i], str) == 0)
269 {
270 is_filled = i;
271 return SPACEFILL;
272 }
273 }
274#endif
275 return NONE;
276}
277
286{
287 project * this_proj = get_project_by_id(this_search -> proj);
288 g_free (this_search);
290 if (this_proj -> modelgl -> atom_win)
291 {
292 if (! this_proj -> modelgl -> atom_win -> visible)
293 {
294 if (! this_proj -> modelgl -> cell_win || ! this_proj -> modelgl -> cell_win -> slab_passivate)
295 {
296 g_free (this_proj -> modelgl -> atom_win);
297 this_proj -> modelgl -> atom_win = NULL;
298 }
299 }
300 }
301 return NULL;
302}
303
312void to_remove_this_object (int type, gpointer data)
313{
314 int i, j;
315 atom_in_selection * selat;
316 tint * sel;
317 prepare_atom_edition (& opengl_project -> modelgl -> colorp[0][0], FALSE);
319 switch (type)
320 {
321 case 0:
322 i = GPOINTER_TO_INT(data);
323 remove_search -> todo[i] = 1;
324 break;
325 case 1:
326 sel = (tint * )data;
327 i = opengl_project -> modelgl -> anim -> last -> img -> step;
328 for (j=0; j<opengl_project -> natomes; j++)
329 {
330 if (sel -> a < 2)
331 {
332 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
333 {
334 remove_search -> todo[j] = 1;
335 }
336 }
337 else
338 {
339 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
340 {
341 remove_search -> todo[j] = 1;
342 }
343 }
344 }
345 break;
346 case 2:
347 sel = (tint * )data;
348 i = opengl_project -> modelgl -> anim -> last -> img -> step;
349 gboolean doit;
350 for (j=0; j<opengl_project -> natomes; j++)
351 {
352 doit = FALSE;
353 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
354 {
355 if (! sel -> a)
356 {
357 if (opengl_project -> atoms[i][j].pick[0] == is_selected || is_selected == -1) doit = TRUE;
358 }
359 else if (sel -> a == 2)
360 {
361 doit = TRUE;
362 }
363 else if (opengl_project -> atoms[i][j].label[0] == is_labelled)
364 {
365 if (opengl_project -> atoms[i][j].pick[0] == is_selected || is_selected == -1) doit = TRUE;
366 }
367 if (doit)
368 {
369 remove_search -> todo[j] = 1;
370 }
371 }
372 }
373 break;
374 case 3:
375 selat = bond_selection -> first;
376 for (i=0; i<bond_selection -> selected ; i++)
377 {
378 j = selat -> id;
379 remove_search -> todo[j] = 1;
380 selat = selat -> next;
381 }
382 break;
383 }
384}
385
393gchar * get_object_from_action (GSimpleAction * action)
394{
395 int i, j, k;
396 const gchar * act = g_action_get_name(G_ACTION(action));
397 gchar * act_end;
398 gchar * str;
399 k = strlen (act);
400 if (strstr(act, "set-mol-ins"))
401 {
402 act_end = g_strdup_printf ("%c%c", act[k-4], act[k-3]);
403 for (i=0; mol[i].type || mol[i].object; i++)
404 {
405 if (mol[i].object)
406 {
407 str = (i < 10) ? g_strdup_printf (".%d", i) : g_strdup_printf ("%d", i);
408 if (g_strcmp0(str, act_end) == 0)
409 {
410 g_free (str);
411 g_free (act_end);
412 return g_strdup_printf ("%s", mol[i].object);
413 break;
414 }
415 g_free (str);
416 }
417 }
418 g_free (act_end);
419 }
420 if (strstr(act, "set-ifp"))
421 {
422 act_end = g_strdup_printf ("%c%c%c%c", act[k-6], act[k-5], act[k-4], act[k-3]);
423 for (i=0; i<nprojects; i++)
424 {
425 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
426 {
427 for (j=0; j<3; j++)
428 {
429 str = g_strdup_printf ("-%d.%d", j, i);
430 if (g_strcmp0(str, act_end) == 0)
431 {
432 g_free (str);
433 g_free (act_end);
434 return g_strdup_printf ("%s in %s", action_atoms[j], g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1));
435 }
436 g_free (str);
437 }
438 }
439 }
440 g_free (act_end);
441 }
442 return NULL;
443}
444
445#ifdef GTK4
455void to_replace_this_object (int type, GSimpleAction * action, gpointer data)
456#else
466void to_replace_this_object (int type, GtkWidget * widg, gpointer data)
467#endif
468{
469 int h, i, j;
470 atom_in_selection * selat;
471 tint * sel;
472 gboolean replace = TRUE;
473 if (opengl_project -> modelgl -> cell_win)
474 {
475 if (opengl_project -> modelgl -> cell_win -> cut_this_slab) replace = FALSE;
476 }
477 if (replace)
478 {
479 prepare_atom_edition (& opengl_project -> modelgl -> colorp[0][0], FALSE);
481 }
482 else
483 {
484 insert_search = opengl_project -> modelgl -> search_widg[8];
485 }
486 gchar * lab;
487#ifdef GTK4
488 if (action != NULL)
489 {
491 }
492#else
493 if (widg != NULL)
494 {
495 lab = g_strdup_printf ("%s", gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
496 }
497#endif
498 else
499 {
500 lab = g_strdup_printf ("Copied Data");
501 }
503 g_free (lab);
504 if (h != 0)
505 {
506 switch (type)
507 {
508 case 0:
509 i = GPOINTER_TO_INT(data);
511 insert_search -> todo[i] = 1;
512 break;
513 case 1:
514 sel = (tint * )data;
515 i = opengl_project -> modelgl -> anim -> last -> img -> step;
516 for (j=0; j<opengl_project -> natomes; j++)
517 {
518 if (sel -> a < 2)
519 {
520 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
521 {
523 insert_search -> todo[j] = 1;
524 }
525 }
526 else if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
527 {
529 insert_search -> todo[j] = 1;
530 }
531 }
532 break;
533 case 2:
534 sel = (tint * )data;
535 gboolean doit;
536 i = opengl_project -> modelgl -> anim -> last -> img -> step;
537 for (j=0; j<opengl_project -> natomes; j++)
538 {
539 doit = FALSE;
540 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
541 {
542 if (! sel -> a)
543 {
544 if (opengl_project -> atoms[i][j].pick[0] == is_selected || is_selected == -1) doit = TRUE;
545 }
546 else if (sel -> a == 2)
547 {
548 doit = TRUE;
549 }
550 else if (opengl_project -> atoms[i][j].label[0] == is_labelled)
551 {
552 if (opengl_project -> atoms[i][j].pick[0] == is_selected || is_selected == -1) doit = TRUE;
553 }
554 if (doit)
555 {
557 insert_search -> todo[j] = 1;
558 }
559 }
560 }
561 break;
562 case 3:
563 selat = bond_selection -> first;
564 for (i=0; i<bond_selection -> selected ; i++)
565 {
566 j = selat -> id;
568 insert_search -> todo[j] = 1;
569 selat = selat -> next;
570 }
571 break;
572 }
573 }
574}
575
582{
583 if (copied_object)
584 {
585 g_free (copied_object);
586 copied_object = NULL;
587 }
588 pasted_todo = allocint (opengl_project -> natomes);
589 atom_in_selection * selat = bond_selection -> first;
590 while (selat)
591 {
592 pasted_todo[selat -> id] = 1;
593 selat = selat -> next;
594 }
596}
597
604{
605 gchar * str;
606 gboolean vis = (opengl_project -> modelgl -> atom_win) ? opengl_project -> modelgl -> atom_win -> visible : FALSE;
609 if (! opengl_project -> modelgl -> cell_win || ! opengl_project -> modelgl -> cell_win -> slab_passivate)
610 {
611 if (! i)
612 {
613 str = g_strdup_printf ("No atoms to be removed !");
614 }
615 else
616 {
617 str = g_strdup_printf ("%d atom(s) removed !", i);
618 }
619 show_info (str, 0, opengl_project -> modelgl -> win);
620 g_free (str);
621 }
622 else
623 {
624 opengl_project -> modelgl -> search_widg[8] -> int_b = i;
625 }
626}
627
628#ifdef GTK4
638G_MODULE_EXPORT void remove_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
639#else
648G_MODULE_EXPORT void remove_this_atom (GtkWidget * widg, gpointer data)
649#endif
650{
651 to_remove_this_object (0, data);
652 remove_object ();
653}
654
663void insert_object (int action, gpointer data)
664{
665 int i, j;
666 gchar * str;
667 gboolean vis = (opengl_project -> modelgl -> atom_win) ? opengl_project -> modelgl -> atom_win -> visible : FALSE;
668 if (insert_search -> in_selection)
669 {
670 if (action == 1 && remove_search != NULL)
671 {
673 }
675 if (action == 1)
676 {
677 str = g_strdup_printf ("%d atom(s) removed !\n%d atom(s) inserted !", i, j);
678 }
679 else
680 {
681 str = g_strdup_printf ("%d atom(s) inserted !", (inserted_from_lib) ? inserted_from_lib : j);
683 }
685 show_info (str, 0, opengl_project -> modelgl -> win);
686 g_free (str);
687 }
689}
690
692
693#ifdef GTK4
703G_MODULE_EXPORT void add_object (GSimpleAction * action, GVariant * parameter, gpointer data)
704#else
713G_MODULE_EXPORT void add_object (GtkWidget * widg, gpointer data)
714#endif
715{
716 prepare_atom_edition (data, FALSE);
719 {
720 gchar * lab = NULL;
721#ifdef GTK4
722 if (action != NULL)
723 {
725 }
726#else
727 if (widg != NULL)
728 {
729 lab = g_strdup_printf ("%s", gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
730 }
731#endif
732 else
733 {
734 lab = g_strdup_printf ("Copied Data");
735 }
737 insert_search -> todo[0] = 1;
739 g_free (lab);
740 }
741 else if (copied_object)
742 {
743 tint ul = ulam_coord (opengl_project -> modelgl);
744 opengl_project -> modelgl -> atom_win -> to_be_inserted[1] = duplicate_atomic_object (copied_object);
745 atomic_object * object = opengl_project -> modelgl -> atom_win -> to_be_inserted[1];
746 int i;
747 for (i=0; i<object -> atoms; i++)
748 {
749 object -> at_list[i].x += opengl_project -> modelgl -> insert_coords.x + object -> dim*ul.a;
750 object -> at_list[i].y += opengl_project -> modelgl -> insert_coords.y + object -> dim*ul.b;
751 object -> at_list[i].z += opengl_project -> modelgl -> insert_coords.z + object -> dim*ul.c;
752 }
754 insert_search -> todo[0] = 1;
755 insert_search -> in_selection ++;
756 }
757 insert_object (3, data);
758}
759
760#ifdef GTK4
770G_MODULE_EXPORT void to_add_object (GSimpleAction * action, GVariant * parameter, gpointer data)
771#else
780G_MODULE_EXPORT void to_add_object (GtkWidget * widg, gpointer data)
781#endif
782{
783 insert_this_object = TRUE;
784#ifdef GTK4
785 add_object (action, parameter, data);
786#else
787 add_object (widg, data);
788#endif
789 insert_this_object = FALSE;
790}
791
792#ifdef GTK4
802G_MODULE_EXPORT void replace_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
803{
805#else
814G_MODULE_EXPORT void replace_this_atom (GtkWidget * widg, gpointer data)
815{
816 to_replace_this_object (0, widg, data);
817#endif
818 to_remove_this_object (0, data);
819 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
820}
821
822#ifdef GTK4
832G_MODULE_EXPORT void copy_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
833#else
842G_MODULE_EXPORT void copy_this_atom (GtkWidget * widg, gpointer data)
843#endif
844{
845 int i;
846 if (pasted_todo)
847 {
848 g_free (pasted_todo);
849 pasted_todo = NULL;
850 }
851 if (copied_object)
852 {
853 g_free (copied_object);
854 copied_object = NULL;
855 }
856 pasted_todo = allocint (opengl_project -> natomes);
857 i = GPOINTER_TO_INT(data);
858 pasted_todo[i] = 1;
860}
861
870{
871 int i, j, k, l, m;
872 int ** num;
873 int * numc[4];
874 int * numv[4];
875 int * numg[2];
876
877 k = 2;
878 num = allocdint (2, this_proj -> nspec);
879 for (i=0; i<2; i++) if (this_proj -> modelgl -> adv_bonding[i]) k ++;
880 for (i=0; i<k; i++)
881 {
882 numc[i] = allocint (this_proj -> coord -> totcoord[i]);
883 numv[i] = allocint (this_proj -> coord -> totcoord[i]);
884 if (i < 2)
885 {
886 numg[i] = allocint (this_proj -> nspec);
887 for (j=1; j<this_proj -> nspec; j++)
888 {
889 numg[i][j] = this_proj -> coord -> ntg[i][j-1] + numg[i][j-1];
890 }
891 }
892 }
893 for (i=0; i<this_proj -> steps; i++)
894 {
895 for (j=0; j<this_proj -> natomes; j++)
896 {
897 for (l=0; l<2; l++) if (this_proj -> atoms[i][j].show[l]) num[l][this_proj -> atoms[i][j].sp] ++;
898 for (l=0; l<k; l++)
899 {
900 m = this_proj -> atoms[i][j].coord[l];
901 if (l < 2 && this_proj -> atoms[i][j].sp > 0) m += numg[l][this_proj -> atoms[i][j].sp];
902 numc[l][m] ++;
903 if (this_proj -> atoms[i][j].show[0]) numv[l][m] ++;
904 }
905 }
906 }
907#ifdef GTK4
908 gboolean update_bar = FALSE;
909#endif
910 for (i=0; i<2; i++)
911 {
912 for (j=0; j<this_proj -> nspec; j++)
913 {
914 if (num[i][j] > 0)
915 {
916 if (num[i][j] == this_proj -> chemistry -> nsps[j]*this_proj -> steps)
917 {
918#ifdef GTK4
919 if (! this_proj -> modelgl -> anim -> last -> img -> show_atom[i][j]) update_bar = TRUE;
920#else
921 // GTK3 Menu Action To Check
922 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j], TRUE);
923#endif
924 this_proj -> modelgl -> anim -> last -> img -> show_atom[i][j] = TRUE;
925 }
926 }
927 else if (this_proj -> modelgl -> anim -> last -> img -> show_atom[i][j])
928 {
929#ifdef GTK4
930 update_bar = TRUE;
931#else
932 // GTK3 Menu Action To Check
933 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[i][j], FALSE);
934#endif
935 this_proj -> modelgl -> anim -> last -> img -> show_atom[i][j] = FALSE;
936 }
937 }
938 }
939 l = 0;
940 for (i=0; i<k; i++)
941 {
942 if (is_coord_in_menu(i, this_proj))
943 {
944 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
945 {
946 if (numv[i][j] > 0)
947 {
948 if (numc[i][j] == numv[i][j])
949 {
950#ifdef GTK4
951 if (! this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j]) update_bar = TRUE;
952#else
953 // GTK3 Menu Action To Check
954 for (l=0; l<2; l++) gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[l][i][j], TRUE);
955#endif
956 }
957 this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j] = TRUE;
958 }
959 else if (this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j])
960 {
961#ifdef GTK4
962 update_bar = TRUE;
963#else
964 // GTK3 Menu Action To Check
965 for (l=0; l<2; l++) gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[l][i][j], FALSE);
966#endif
967 this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j] = FALSE;
968 }
969 }
970 }
971 else
972 {
973 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
974 {
975 if (numv[i][j] > 0)
976 {
977 this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j] = TRUE;
978 }
979 else if (this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j])
980 {
981 this_proj -> modelgl -> anim -> last -> img -> show_coord[i][j] = FALSE;
982 }
983 }
984 }
985 }
986 for (i=0; i<2; i++) g_free (num[i]);
987 g_free (num);
988 for (i=0; i<k; i++)
989 {
990 g_free (numc[i]);
991 g_free (numv[i]);
992 if (i < 2) g_free (numg[i]);
993 }
994#ifdef GTK4
995 if (update_bar) update_menu_bar (this_proj -> modelgl);
996#endif
997}
998
999#ifdef GTK4
1009G_MODULE_EXPORT void show_hide_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
1010#else
1019G_MODULE_EXPORT void show_hide_this_atom (GtkWidget * widg, gpointer data)
1020#endif
1021{
1022 int i;
1023 int id = GPOINTER_TO_INT (data);
1024 for (i=0; i<opengl_project -> steps; i++)
1025 {
1026 opengl_project -> atoms[i][id].show[0] = ! opengl_project -> atoms[i][id].show[0];
1027 }
1030}
1031
1040int check_label_numbers (project * this_proj, int types)
1041{
1042 int h, i, j, k, l;
1043 int start, end;
1044 int * naid = allocint (this_proj -> nspec);
1045 int * nlid = allocint (this_proj -> nspec);
1046 start = (types == 0 || types == 2) ? 0 : 1;
1047 end = (types == 1 || types == 2) ? 2 : 1;
1048 l = 0;
1049#ifdef GTK4
1050 gboolean update_bar = FALSE;
1051#endif
1052 for (h=start; h<end; h++)
1053 {
1054 for (i=0; i<this_proj -> nspec; i++) naid[i] = nlid[i] = 0;
1055 for (i=0; i<this_proj -> steps; i++)
1056 {
1057 for (j=0; j<this_proj -> natomes; j++)
1058 {
1059 k = this_proj -> atoms[i][j].sp;
1060 naid[k] ++;
1061 if (this_proj -> atoms[i][j].label[h]) nlid[k] ++;
1062 }
1063 }
1064 if (h==types || (h == 0 && types == 2)) l = 0;
1065 for (i=0; i<this_proj -> nspec; i++)
1066 {
1067 // g_debug ("h= %d, i= %d, nlid[%d]= %d, naid[%d]= %d", h, i+1, i+1, nlid[i], i+1, naid[i]);
1068 if (nlid[i] == naid[i])
1069 {
1070#ifdef GTK4
1071 if (! this_proj -> modelgl -> anim -> last -> img -> show_label[h][i]) update_bar = TRUE;
1072#else
1073 if (! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[h][i]))
1074 {
1075 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[h][i], 1);
1076 }
1077#endif
1078 this_proj -> modelgl -> anim -> last -> img -> show_label[h][i] = TRUE;
1079
1080 }
1081 else
1082 {
1083 if (nlid[i] == 0)
1084 {
1085#ifdef GTK4
1086 if (this_proj -> modelgl -> anim -> last -> img -> show_label[h][i]) update_bar = TRUE;
1087#else
1088 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[h][i]))
1089 {
1090 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[h][i], 0);
1091 }
1092#endif
1093 }
1094 this_proj -> modelgl -> anim -> last -> img -> show_label[h][i] = FALSE;
1095 }
1096 if (h==types || (h == 0 && types == 2)) l += nlid[i];
1097 }
1098 }
1099 g_free (naid);
1100 g_free (nlid);
1101 check_all_trees (this_proj);
1102#ifdef GTK4
1103 if (update_bar) update_menu_bar (this_proj -> modelgl);
1104#endif
1105 return l;
1106}
1107
1108#ifdef GTK4
1118G_MODULE_EXPORT void label_unlabel_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
1119#else
1128G_MODULE_EXPORT void label_unlabel_this_atom (GtkWidget * widg, gpointer data)
1129#endif
1130{
1131 int i, j, k, l, m;
1132 int id = GPOINTER_TO_INT (data);
1133 i = opengl_project -> modelgl -> anim -> last -> img -> step;
1134 j = opengl_project -> atoms[i][id].label[0];
1135 for (k=0; k<opengl_project -> steps; k++)
1136 {
1137 opengl_project -> atoms[k][id].label[0] = ! j;
1138 opengl_project -> atoms[k][id].label[1] = ! j;
1139 if (opengl_project -> modelgl -> selection_mode == 1)
1140 {
1141 for (l=0; l<opengl_project -> atoms[k][id].numv; l++)
1142 {
1143 m = opengl_project -> atoms[k][id].vois[l];
1144 opengl_project -> atoms[k][m].label[0] = ! j;
1145 opengl_project -> atoms[k][m].label[1] = ! j;
1146 }
1147 }
1148 }
1149 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1150 if (check_label)
1151 {
1152 opengl_project -> modelgl -> labelled = check_label_numbers (opengl_project, 2);
1153 update (opengl_project -> modelgl);
1154 }
1155}
1156
1157#ifdef GTK4
1167G_MODULE_EXPORT void select_unselect_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
1168#else
1177G_MODULE_EXPORT void select_unselect_this_atom (GtkWidget * widg, gpointer data)
1178#endif
1179{
1180 int h, i, j, k, l, m;
1181 int id = GPOINTER_TO_INT (data);
1182 h = get_to_be_selected (opengl_project -> modelgl);
1183 j = opengl_project -> modelgl -> anim -> last -> img -> step;
1184 save_all_selections (opengl_project -> modelgl, h);
1185 k = opengl_project -> atoms[j][id].pick[h];
1186 for (i=0; i<opengl_project -> steps; i++)
1187 {
1188 if (i == j)
1189 {
1190 if (! opengl_project -> modelgl -> selection_mode || opengl_project -> atoms[i][id].pick[h] != selected_status)
1191 {
1192 process_selected_atom (opengl_project, opengl_project -> modelgl, id, 0, 0, h);
1193 }
1194 if (opengl_project -> modelgl -> selection_mode == 1)
1195 {
1196 for (l=0; l<opengl_project -> atoms[j][id].numv; l++)
1197 {
1198 m = opengl_project -> atoms[i][id].vois[l];
1199 if (opengl_project -> atoms[i][m].pick[h] != opengl_project -> atoms[i][id].pick[h])
1200 {
1201 process_selected_atom (opengl_project, opengl_project -> modelgl, m, 0, 0, h);
1202 }
1203 }
1204 }
1205 }
1206 else
1207 {
1208 if (! opengl_project -> modelgl -> selection_mode || opengl_project -> atoms[i][id].pick[h] != selected_status)
1209 {
1210 opengl_project -> atoms[i][id].pick[h] = ! k;
1211 }
1212 if (opengl_project -> modelgl -> selection_mode == 1)
1213 {
1214 for (l=0; l<opengl_project -> atoms[j][id].numv; l++)
1215 {
1216 m = opengl_project -> atoms[j][id].vois[l];
1217 opengl_project -> atoms[i][m].pick[h] = opengl_project -> atoms[i][id].pick[h];
1218 }
1219 }
1220 }
1221 }
1222 update_all_selections (opengl_project -> modelgl, h);
1223 int shaders[1] = {SELEC};
1225 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1226 if (opengl_project -> modelgl -> mode == EDITION)
1227 {
1228 if (opengl_project -> modelgl -> rebuild[0][1]) opengl_project -> modelgl -> rebuild[0][0] = TRUE;
1229 if (opengl_project -> modelgl -> rebuild[1][1]) opengl_project -> modelgl -> rebuild[1][0] = TRUE;
1230 }
1231 update (opengl_project -> modelgl);
1232}
1233
1234gboolean wait_for_style = FALSE;
1235
1236#ifdef GTK4
1246G_MODULE_EXPORT void style_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data)
1247#else
1256G_MODULE_EXPORT void style_this_atom (GtkWidget * widg, gpointer data)
1257#endif
1258{
1259 int i, j;
1260 int id = GPOINTER_TO_INT (data);
1261#ifdef GTK4
1262 j = get_style ((gchar *)g_action_get_name (G_ACTION(action)));
1263#else
1264 j = get_style ((char *)gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
1265#endif
1266 for (i=0; i<opengl_project -> steps; i++)
1267 {
1268 opengl_project -> atoms[i][id].style = j;
1269 }
1270 if (! wait_for_style)
1271 {
1273 update (opengl_project -> modelgl);
1274 }
1275}
1276
1277#ifdef GTK4
1287G_MODULE_EXPORT void remove_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1288#else
1297G_MODULE_EXPORT void remove_the_atoms (GtkWidget * widg, gpointer data)
1298#endif
1299{
1300 to_remove_this_object (2, data);
1301 remove_object ();
1302}
1303
1304#ifdef GTK4
1314G_MODULE_EXPORT void replace_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1315{
1316 to_replace_this_object (2, action, data);
1317#else
1326G_MODULE_EXPORT void replace_the_atoms (GtkWidget * widg, gpointer data)
1327{
1328 to_replace_this_object (2, widg, data);
1329#endif
1330 to_remove_this_object (2, data);
1331 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
1333}
1334
1335#ifdef GTK4
1345G_MODULE_EXPORT void copy_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1346#else
1355G_MODULE_EXPORT void copy_the_atoms (GtkWidget * widg, gpointer data)
1356#endif
1357{
1358 tint * sel = (tint *)data;
1359 int h, i, j;
1360 if (copied_object)
1361 {
1362 g_free (copied_object);
1363 copied_object = NULL;
1364 }
1365 pasted_todo = allocint (opengl_project -> natomes);
1366 h = 0;
1367 i = opengl_project -> modelgl -> anim -> last -> img -> step;
1368 for (j=0; j<opengl_project -> natomes; j++)
1369 {
1370 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
1371 {
1372 if (! sel -> a || opengl_project -> atoms[i][j].label[0] == is_labelled)
1373 {
1374 if (opengl_project -> atoms[i][j].pick[0] == is_selected || is_selected == -1)
1375 {
1376 pasted_todo[j] = 1;
1377 h = 1;
1378 }
1379 }
1380 }
1381 }
1382 if (h)
1383 {
1385 }
1386 else
1387 {
1388 g_free (pasted_todo);
1389 pasted_todo = NULL;
1390 }
1391}
1392
1393#ifdef GTK4
1403G_MODULE_EXPORT void show_hide_others (GSimpleAction * action, GVariant * parameter, gpointer data)
1404#else
1413G_MODULE_EXPORT void show_hide_others (GtkWidget * widg, gpointer data)
1414#endif
1415{
1416 tint * sel = (tint * )data;
1417 int i, j, k;
1418
1419 for (i=0; i<opengl_project -> steps; i++)
1420 {
1421 for (j=0; j<opengl_project -> natomes; j++)
1422 {
1423 for (k=0; k<2; k++)
1424 {
1425 if (opengl_project -> atoms[i][j].show[k] == sel -> c)
1426 {
1427 opengl_project -> atoms[i][j].show[k] = ! sel -> c;
1428 }
1429 }
1430 }
1431 }
1434}
1435
1436#ifdef GTK4
1446G_MODULE_EXPORT void show_hide_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1447#else
1456G_MODULE_EXPORT void show_hide_the_atoms (GtkWidget * widg, gpointer data)
1457#endif
1458{
1459 tint * sel = (tint * )data;
1460 int h, i, j;
1461 h = get_to_be_selected (opengl_project -> modelgl);
1462 for (i=0; i<opengl_project -> steps; i++)
1463 {
1464 for (j=0; j<opengl_project -> natomes; j++)
1465 {
1466 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
1467 {
1468 if (sel -> a == 2 || (opengl_project -> atoms[i][j].pick[h] == is_selected || is_selected == -1))
1469 {
1470 if (sel -> a || opengl_project -> atoms[i][j].label[0] == is_labelled)
1471 {
1472 opengl_project -> atoms[i][j].show[0] = sel -> c;
1473 opengl_project -> atoms[i][j].show[1] = sel -> c;
1474 }
1475 }
1476 }
1477 }
1478 }
1481}
1482
1483#ifdef GTK4
1493G_MODULE_EXPORT void label_unlabel_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1494#else
1503G_MODULE_EXPORT void label_unlabel_atoms (GtkWidget * widg, gpointer data)
1504#endif
1505{
1506 tint * sel = (tint * )data;
1507 int h, i, j;
1508 h = get_to_be_selected (opengl_project -> modelgl);
1509 for (i=0; i<opengl_project -> steps; i++)
1510 {
1511 for (j=0; j<opengl_project -> natomes; j++)
1512 {
1513 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
1514 {
1515 if (sel -> a == 2 || (opengl_project -> atoms[i][j].pick[h] == is_selected || is_selected == -1))
1516 {
1517 opengl_project -> atoms[i][j].label[0] = sel -> c;
1518 opengl_project -> atoms[i][j].label[1] = sel -> c;
1519 }
1520 }
1521 }
1522 }
1523 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1524 if (check_label)
1525 {
1526 opengl_project -> modelgl -> labelled = check_label_numbers (opengl_project, 2);
1527 update (opengl_project -> modelgl);
1528 }
1529}
1530
1531#ifdef GTK4
1541G_MODULE_EXPORT void select_unselect_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1542#else
1551G_MODULE_EXPORT void select_unselect_atoms (GtkWidget * widg, gpointer data)
1552#endif
1553{
1554 tint * sel = (tint *)data;
1555 int h, i, j;
1556 h = get_to_be_selected (opengl_project -> modelgl);
1557 save_all_selections (opengl_project -> modelgl, h);
1558 for (i=0; i<opengl_project -> steps; i++)
1559 {
1560 for (j=0; j<opengl_project -> natomes; j++)
1561 {
1562 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
1563 {
1564 if (! sel -> b || opengl_project -> atoms[i][j].label[0] == is_labelled)
1565 {
1566 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1567 {
1568 if (opengl_project -> atoms[i][j].pick[h] != sel -> c)
1569 {
1570 process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1571 }
1572 }
1573 else
1574 {
1575 if (opengl_project -> atoms[i][j].pick[h] != sel -> c)
1576 {
1577 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1578 }
1579 }
1580 }
1581 }
1582 }
1583 }
1584 update_all_selections (opengl_project -> modelgl, h);
1585 int shaders[1] = {SELEC};
1587 opengl_project -> modelgl -> create_shaders[MEASU] = TRUE;
1588 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1589 if (opengl_project -> modelgl -> mode == EDITION)
1590 {
1591 if (opengl_project -> modelgl -> rebuild[0][1]) opengl_project -> modelgl -> rebuild[0][0] = TRUE;
1592 if (opengl_project -> modelgl -> rebuild[1][1]) opengl_project -> modelgl -> rebuild[1][0] = TRUE;
1593 }
1594 update (opengl_project -> modelgl);
1595}
1596
1597#ifdef GTK4
1607G_MODULE_EXPORT void style_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
1608#else
1617G_MODULE_EXPORT void style_the_atoms (GtkWidget * widg, gpointer data)
1618#endif
1619{
1620 int h, i, j, k;
1621 tint * sel = (tint *)data;
1622 h = get_to_be_selected (opengl_project -> modelgl);
1623#ifdef GTK4
1624 k = get_style ((gchar *)g_action_get_name(G_ACTION(action)));
1625#else
1626 k = get_style ((char *)gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
1627#endif
1628 for (i=0; i<opengl_project -> steps; i++)
1629 {
1630 for (j=0; j<opengl_project -> natomes; j++)
1631 {
1632 if (opengl_project -> atoms[i][j].sp == selected_aspec || selected_aspec == -1)
1633 {
1634 if (sel -> a == 2 || (opengl_project -> atoms[i][j].pick[h] == is_selected || is_selected == -1))
1635 {
1636 if (sel -> a || opengl_project -> atoms[i][j].label[0] == is_labelled)
1637 {
1638 opengl_project -> atoms[i][j].style = k;
1639 }
1640 }
1641 }
1642 }
1643 }
1645 update (opengl_project -> modelgl);
1646}
1647
1648#ifdef GTK4
1658G_MODULE_EXPORT void remove_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1659#else
1668G_MODULE_EXPORT void remove_the_coord (GtkWidget * widg, gpointer data)
1669#endif
1670{
1671 to_remove_this_object (1, data);
1672 remove_object ();
1673}
1674
1675#ifdef GTK4
1685G_MODULE_EXPORT void replace_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1686{
1687 to_replace_this_object (1, action, data);
1688#else
1697G_MODULE_EXPORT void replace_the_coord (GtkWidget * widg, gpointer data)
1698{
1699 to_replace_this_object (1, widg, data);
1700#endif
1701 to_remove_this_object (1, data);
1702 insert_object (1, data);
1703}
1704
1705#ifdef GTK4
1715G_MODULE_EXPORT void copy_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1716#else
1725G_MODULE_EXPORT void copy_the_coord (GtkWidget * widg, gpointer data)
1726#endif
1727{
1728 tint * sel = (tint *)data;
1729 int h, i, j;
1730 if (copied_object)
1731 {
1732 g_free (copied_object);
1733 copied_object = NULL;
1734 }
1735 pasted_todo = allocint (opengl_project -> natomes);
1736 h = 0;
1737 i = opengl_project -> modelgl -> anim -> last -> img -> step;
1738 for (j=0; j<opengl_project -> natomes; j++)
1739 {
1740 if (sel -> a < 2)
1741 {
1742 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1743 {
1744 pasted_todo[j] = 1;
1745 h = 1;
1746 }
1747 }
1748 else
1749 {
1750 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1751 {
1752 pasted_todo[j] = 1;
1753 h = 1;
1754 }
1755 }
1756 }
1757 if (h)
1758 {
1760 }
1761 else
1762 {
1763 g_free (pasted_todo);
1764 pasted_todo = NULL;
1765 }
1766}
1767
1768#ifdef GTK4
1778G_MODULE_EXPORT void show_hide_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1779#else
1788G_MODULE_EXPORT void show_hide_the_coord (GtkWidget * widg, gpointer data)
1789#endif
1790{
1791 tint * sel = (tint * )data;
1792 int i, j;
1793 for (i=0; i<opengl_project -> steps; i++)
1794 {
1795 for (j=0; j<opengl_project -> natomes; j++)
1796 {
1797 if (sel -> a < 2)
1798 {
1799 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1800 {
1801 opengl_project -> atoms[i][j].show[0] = sel -> c;
1802 opengl_project -> atoms[i][j].show[1] = sel -> c;
1803 }
1804 }
1805 else
1806 {
1807 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1808 {
1809 opengl_project -> atoms[i][j].show[0] = sel -> c;
1810 opengl_project -> atoms[i][j].show[1] = sel -> c;
1811 }
1812 }
1813 }
1814 }
1817}
1818
1819#ifdef GTK4
1829G_MODULE_EXPORT void label_unlabel_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1830#else
1839G_MODULE_EXPORT void label_unlabel_coord (GtkWidget * widg, gpointer data)
1840#endif
1841{
1842 tint * sel = (tint * )data;
1843 int i, j, k, l, m;
1844 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
1845 for (i=0; i<opengl_project -> steps; i++)
1846 {
1847 for (j=0; j<opengl_project -> natomes; j++)
1848 {
1849 if (sel -> a < 2)
1850 {
1851 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1852 {
1853 opengl_project -> atoms[i][j].label[0] = sel -> c;
1854 opengl_project -> atoms[i][j].label[1] = sel -> c;
1855 if (opengl_project -> modelgl -> selection_mode == 1)
1856 {
1857 for (l=0; l<opengl_project -> atoms[i][j].numv; l++)
1858 {
1859 m = opengl_project -> atoms[i][j].vois[l];
1860 opengl_project -> atoms[i][m].label[0] = sel -> c;
1861 opengl_project -> atoms[i][m].label[1] = sel -> c;
1862 }
1863 }
1864 }
1865 }
1866 else if (sel -> a < 4)
1867 {
1868 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1869 {
1870 opengl_project -> atoms[i][j].label[0] = sel -> c;
1871 opengl_project -> atoms[i][j].label[1] = sel -> c;
1872 }
1873 }
1874 else
1875 {
1876 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
1877 {
1878 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
1879 {
1880 opengl_project -> atoms[i][j].label[0] = sel -> c;
1881 opengl_project -> atoms[i][j].label[1] = sel -> c;
1882 }
1883 }
1884 }
1885 }
1886 }
1887 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1888 if (check_label)
1889 {
1890 opengl_project -> modelgl -> labelled = check_label_numbers (opengl_project, 2);
1891 update (opengl_project -> modelgl);
1892 }
1893}
1894
1895#ifdef GTK4
1905G_MODULE_EXPORT void select_unselect_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1906#else
1915G_MODULE_EXPORT void select_unselect_coord (GtkWidget * widg, gpointer data)
1916#endif
1917{
1918 tint * sel = (tint * )data;
1919 int h, i, j, k;
1920 h = get_to_be_selected (opengl_project -> modelgl);
1921 save_all_selections (opengl_project -> modelgl, h);
1922 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
1923 for (i=0; i<opengl_project -> steps; i++)
1924 {
1925 for (j=0; j<opengl_project -> natomes; j++)
1926 {
1927 if (sel -> a < 2)
1928 {
1929 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1930 {
1931 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1932 {
1933 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1934 }
1935 else
1936 {
1937 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1938 }
1939 }
1940 }
1941 else if (sel -> a < 4)
1942 {
1943 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1944 {
1945 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1946 {
1947 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1948 }
1949 else
1950 {
1951 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1952 }
1953 }
1954 }
1955 else
1956 {
1957 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
1958 {
1959 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
1960 {
1961 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1962 {
1963 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1964 }
1965 else
1966 {
1967 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1968 }
1969 }
1970 }
1971 }
1972 }
1973 }
1974 update_all_selections (opengl_project -> modelgl, h);
1975 int shader[1] = {SELEC};
1977 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1978 opengl_project -> modelgl -> create_shaders[MEASU] = TRUE;
1979 if (opengl_project -> modelgl -> mode == EDITION)
1980 {
1981 if (opengl_project -> modelgl -> rebuild[0][1]) opengl_project -> modelgl -> rebuild[0][0] = TRUE;
1982 if (opengl_project -> modelgl -> rebuild[1][1]) opengl_project -> modelgl -> rebuild[1][0] = TRUE;
1983 }
1984 update (opengl_project -> modelgl);
1985}
1986
1987#ifdef GTK4
1997G_MODULE_EXPORT void style_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1998#else
2007G_MODULE_EXPORT void style_the_coord (GtkWidget * widg, gpointer data)
2008#endif
2009{
2010 tint * sel = (tint * )data;
2011 int i, j, k, l;
2012 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
2013#ifdef GTK4
2014 l = get_style ((gchar *)g_action_get_name(G_ACTION(action)));
2015#else
2016 l = get_style ((char *)gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
2017#endif
2018 for (i=0; i<opengl_project -> steps; i++)
2019 {
2020 for (j=0; j<opengl_project -> natomes; j++)
2021 {
2022 if (sel -> a < 2)
2023 {
2024 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
2025 {
2026 opengl_project -> atoms[i][j].style = l;
2027 }
2028 }
2029 else if (sel -> a < 4)
2030 {
2031 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
2032 {
2033 opengl_project -> atoms[i][j].style = l;
2034 }
2035 }
2036 else
2037 {
2038 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
2039 {
2040 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
2041 {
2042 opengl_project -> atoms[i][j].style = l;
2043 }
2044 }
2045 }
2046 }
2047 }
2049 update (opengl_project -> modelgl);
2050}
2051
2060{
2061 int i, j, k, l;
2062 int nspec = 0;
2063 int * pos_sp, * specs;
2064 atom_in_selection * tmp;
2065
2066 pos_sp = allocint (opengl_project -> nspec);
2067 specs = allocint (opengl_project -> nspec);
2068 for (i=0; i<opengl_project -> nspec; i++)
2069 {
2070 specs[i] = 0;
2071 pos_sp[i] = -1;
2072 }
2073
2074 tmp = selection -> first;
2075 j = -1;
2076 for (i=0; i<selection -> selected; i++)
2077 {
2078 specs[tmp -> sp] ++;
2079 if (pos_sp[tmp -> sp] < 0)
2080 {
2081 j ++;
2082 pos_sp[tmp -> sp] = j;
2083 }
2084 if (tmp -> next != NULL) tmp = tmp -> next;
2085 }
2086
2087 for (i=0; i<opengl_project -> nspec; i++) if (specs[i] > 0) nspec ++;
2088
2089 init_project (TRUE);
2090 active_project -> nspec = nspec;
2091 active_project -> natomes = selection -> selected;
2092 active_project -> steps = 1;
2095
2096 if (active_project -> natomes == opengl_project -> natomes)
2097 {
2098 active_cell -> ltype = opengl_project -> cell.ltype;
2099 active_cell -> pbc = opengl_project -> cell.pbc;
2100 k = (active_cell -> npt) ? opengl_project -> modelgl -> anim -> last -> img -> step : 0;
2101 for (i=0; i<3; i++)
2102 {
2103 for (j=0; j<3; j++)
2104 {
2105 if (i < 2) active_box -> param[i][j] = opengl_project -> cell.box[k].param[i][j];
2106 active_box -> vect[i][j] = opengl_project -> cell.box[k].vect[i][j];
2107 }
2108 }
2109 }
2110
2111 for (i=0; i<opengl_project -> nspec; i++)
2112 {
2113 if (pos_sp[i] > -1)
2114 {
2115 k = pos_sp[i];
2116 active_chem -> label[k] = g_strdup_printf ("%s", opengl_project -> chemistry -> label[i]);
2117 active_chem -> element[k] = g_strdup_printf ("%s", opengl_project -> chemistry -> element[i]);
2118 active_chem -> nsps[k] = specs[i];
2119 for (j=0; j<CHEM_PARAMS; j++) active_chem -> chem_prop[j][k] = opengl_project -> chemistry -> chem_prop[j][i];
2120 for (j=0; j<opengl_project -> nspec; j++)
2121 {
2122 if (pos_sp[j] > -1)
2123 {
2124 l = pos_sp[j];
2125 active_chem -> cutoffs[k][l] = opengl_project -> chemistry -> cutoffs[i][j];
2126 }
2127 }
2128 }
2129 }
2130 active_chem -> grtotcutoff = opengl_project -> chemistry -> grtotcutoff;
2131
2132 tmp = selection -> first;
2133 for (i=0; i<active_project -> steps; i++)
2134 {
2135 tmp = selection -> first;
2136 for (j=0; j<active_project -> natomes; j++)
2137 {
2138 k = tmp -> id;
2139 active_project -> atoms[i][j].id = j;
2140 active_project -> atoms[i][j].sp = pos_sp[tmp -> sp];
2141 active_project -> atoms[i][j].x = opengl_project -> atoms[i][k].x;
2142 active_project -> atoms[i][j].y = opengl_project -> atoms[i][k].y;
2143 active_project -> atoms[i][j].z = opengl_project -> atoms[i][k].z;
2144 active_project -> atoms[i][j].show[0] = TRUE;
2145 active_project -> atoms[i][j].show[1] = TRUE;
2146 active_project -> atoms[i][j].label[0] = FALSE;
2147 active_project -> atoms[i][j].label[1] = FALSE;
2148 active_project -> atoms[i][j].pick[0] = FALSE;
2149 active_project -> atoms[i][j].cloned = FALSE;
2150 // Next line for style, to initialize style use: NONE
2151 active_project -> atoms[i][j].style = opengl_project -> atoms[i][k].style;
2152 if (tmp -> next != NULL) tmp = tmp -> next;
2153 }
2154 }
2155 active_project -> runok[BD] = TRUE;
2156 active_project -> runok[RI] = TRUE;
2157 active_project -> runok[CH] = TRUE;
2158 active_project -> runok[SP] = TRUE;
2161 i = opengl_project -> modelgl -> anim -> last -> img -> style;
2162 apply_project (FALSE);
2163 active_image -> style = i;
2165 g_free (pos_sp);
2166 g_free (specs);
2167 // Duplicate lightning and material
2168 duplicate_material_and_lightning (active_image, opengl_project -> modelgl -> anim -> last -> img);
2170}
2171
2172#ifdef GTK4
2182G_MODULE_EXPORT void edit_in_new_project (GSimpleAction * action, GVariant * parameter, gpointer data)
2183#else
2192G_MODULE_EXPORT void edit_in_new_project (GtkWidget * widg, gpointer data)
2193#endif
2194{
2195 tint * sel = (tint * )data;
2196 int h, i, j;
2197 atom_selection * selected;
2199 selected = g_malloc0 (sizeof*selected);
2200 h = get_to_be_selected (opengl_project -> modelgl);
2201 if (! sel -> b)
2202 {
2203 if (sel -> c)
2204 {
2205 selected = opengl_project -> modelgl -> anim -> last -> img -> selected[h];
2206 }
2207 else
2208 {
2209 selected -> selected = opengl_project -> natomes - opengl_project -> modelgl -> anim -> last -> img -> selected[h] -> selected;
2210 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2211 for (i=0; i<opengl_project -> natomes; i++)
2212 {
2213 if (! opengl_project -> atoms[j][i].pick[h])
2214 {
2215 if (selected -> first)
2216 {
2217 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2218 tmp_a = tmp_a -> next;
2219 }
2220 else
2221 {
2222 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2223 tmp_a = selected -> first;
2224 }
2225 }
2226 }
2227 }
2228 }
2229 else
2230 {
2231 selected -> selected = (is_labelled) ? opengl_project -> modelgl -> labelled : opengl_project -> natomes - opengl_project -> modelgl -> labelled;
2232 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2233 for (i=0; i<opengl_project -> natomes; i++)
2234 {
2235 if (opengl_project -> atoms[j][i].label[0] == is_labelled)
2236 {
2237 if (selected -> first)
2238 {
2239 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2240 tmp_a = tmp_a -> next;
2241 }
2242 else
2243 {
2244 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2245 tmp_a = selected -> first;
2246 }
2247 }
2248 }
2249 }
2250 if (selected -> selected > 0) create_new_project_using_data (selected);
2251 selected = NULL;
2252 g_free (selected);
2253}
2254
2255#ifdef GTK4
2265G_MODULE_EXPORT void edit_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
2266#else
2275G_MODULE_EXPORT void edit_coord (GtkWidget * widg, gpointer data)
2276#endif
2277{
2278 tint * sel = (tint * )data;
2279 int i, j;
2280 atom_selection * selected;
2282 gboolean save_it;
2283
2284 selected = g_malloc0 (sizeof*selected);
2285 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2286 for (i=0; i<opengl_project -> natomes; i++)
2287 {
2288 save_it = FALSE;
2289 if (sel -> a < 2)
2290 {
2291 if (opengl_project -> atoms[j][i].sp == selected_aspec && opengl_project -> atoms[j][i].coord[sel -> a] == sel -> b)
2292 {
2293 save_it = TRUE;
2294 }
2295 }
2296 else
2297 {
2298 if (opengl_project -> atoms[j][i].coord[sel -> a] == sel -> b)
2299 {
2300 save_it = TRUE;
2301 }
2302 }
2303 if (save_it)
2304 {
2305 if (selected -> first)
2306 {
2307 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2308 tmp_a = tmp_a -> next;
2309 }
2310 else
2311 {
2312 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2313 tmp_a = selected -> first;
2314 }
2315 selected -> selected ++;
2316 }
2317 }
2318 if (selected -> selected > 0) create_new_project_using_data (selected);
2319 g_free (selected);
2320}
2321
2322#ifdef GTK4
2332G_MODULE_EXPORT void edit_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
2333#else
2342G_MODULE_EXPORT void edit_atoms (GtkWidget * widg, gpointer data)
2343#endif
2344{
2345 int i, j;
2346 atom_selection * selected;
2348
2349 selected = g_malloc0 (sizeof*selected);
2350 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2351 for (i=0; i<opengl_project -> natomes; i++)
2352 {
2353 if (opengl_project -> atoms[j][i].sp == selected_aspec || selected_aspec == -1)
2354 {
2355 if (selected -> first)
2356 {
2357 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2358 tmp_a = tmp_a -> next;
2359 }
2360 else
2361 {
2362 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2363 tmp_a = selected -> first;
2364 }
2365 selected -> selected ++;
2366 }
2367 }
2368 if (selected -> selected > 0) create_new_project_using_data (selected);
2369 g_free (selected);
2370}
2371
2372#ifdef GTK4
2382G_MODULE_EXPORT void select_action_for_all (GSimpleAction * action, GVariant * parameter, gpointer data)
2383#else
2392G_MODULE_EXPORT void select_action_for_all (GtkWidget * widg, gpointer data)
2393#endif
2394{
2395 int i = GPOINTER_TO_INT(data);
2396 selected_aspec = -1;
2397#ifdef DEBUG
2398 g_debug ("Action for All= %d", i);
2399#endif // DEBUG
2400#ifdef GTK4
2401 switch (i)
2402 {
2403 case 0:
2404 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][1]);
2405 break;
2406 case 1:
2407 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
2408 break;
2409 case 2:
2410 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][1]);
2411 break;
2412 case 3:
2413 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
2414 break;
2415 case 4:
2416 show_hide_the_atoms (NULL, NULL, & atoid[0][0]);
2417 break;
2418 case 5:
2419 show_hide_the_atoms (NULL, NULL, & atoid[1][1]);
2420 break;
2421 case 6:
2422 style_the_atoms (action, NULL, & atoid[0][1]);
2423 break;
2424 // No case 7 = color
2425 case 8:
2426 edit_in_new_project (NULL, NULL, & opengl_project -> modelgl -> colorp[0][is_selected]);
2427 break;
2428 case 9:
2429 remove_the_atoms (action, NULL, & cut_sel);
2430 break;
2431 case 10:
2432 replace_the_atoms (action, NULL, & cut_sel);
2433 break;
2434 case 11:
2435 copy_the_atoms (action, NULL, & cut_sel);
2436 break;
2437 case CONTEXTACT:
2438 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[1][1]);
2439 break;
2440 case CONTEXTACT+1:
2441 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[1][0]);
2442 break;
2443 case CONTEXTACT+2:
2444 is_selected = -1;
2445 label_unlabel_atoms (NULL, NULL, & atoid[0][0]);
2446 break;
2447 case CONTEXTACT+3:
2448 is_selected = -1;
2449 label_unlabel_atoms (NULL, NULL, & atoid[1][0]);
2450 break;
2451 case CONTEXTACT+4:
2452 is_selected = -1;
2453 show_hide_the_atoms (NULL, NULL, & atoid[0][0]);
2454 break;
2455 case CONTEXTACT+5:
2456 is_selected = -1;
2457 show_hide_the_atoms (NULL, NULL, & atoid[1][0]);
2458 break;
2459 case CONTEXTACT+6:
2460 is_selected = -1;
2461 style_the_atoms (action, NULL, & atoid[0][0]);
2462 break;
2463 case CONTEXTACT+8:
2464 is_selected = -1;
2465 edit_in_new_project (NULL, NULL, & opengl_project -> modelgl -> colorp[1][1]);
2466 break;
2467 case CONTEXTACT+9:
2468 is_selected = -1;
2469 remove_the_atoms (action, NULL, & cut_sel);
2470 break;
2471 case CONTEXTACT+10:
2472 is_selected = -1;
2473 replace_the_atoms (action, NULL, & cut_sel);
2474 break;
2475 case CONTEXTACT+11:
2476 is_selected = -1;
2477 copy_the_atoms (action, NULL, & cut_sel);
2478 break;
2479 case 2*CONTEXTACT+4:
2480 is_selected = -1;
2481 show_hide_the_atoms (NULL, NULL, & atoid[0][1]);
2482 break;
2483 case 2*CONTEXTACT+5:
2484 is_selected = -1;
2485 show_hide_the_atoms (NULL, NULL, & atoid[1][1]);
2486 break;
2487 }
2488#else
2489 switch (i)
2490 {
2491 case 0:
2492 select_unselect_atoms (widg, & opengl_project -> modelgl -> colorp[0][1]);
2493 break;
2494 case 1:
2495 select_unselect_atoms (widg, & opengl_project -> modelgl -> colorp[0][0]);
2496 break;
2497 case 2:
2498 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][1]);
2499 break;
2500 case 3:
2501 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
2502 break;
2503 case 4:
2504 show_hide_the_atoms (NULL, & atoid[0][0]);
2505 break;
2506 case 5:
2507 show_hide_the_atoms (NULL, & atoid[1][1]);
2508 break;
2509 case 6:
2510 style_the_atoms (widg, & atoid[0][1]);
2511 break;
2512 // No case 7 = color
2513 case 8:
2514 edit_in_new_project (NULL, & opengl_project -> modelgl -> colorp[0][is_selected]);
2515 break;
2516 case 9:
2517 remove_the_atoms (widg, & cut_sel);
2518 break;
2519 case 10:
2520 replace_the_atoms (widg, & cut_sel);
2521 break;
2522 case 11:
2523 copy_the_atoms (widg, & cut_sel);
2524 break;
2525 case CONTEXTACT:
2526 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[1][1]);
2527 break;
2528 case CONTEXTACT+1:
2529 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[1][0]);
2530 break;
2531 case CONTEXTACT+2:
2532 is_selected = -1;
2533 label_unlabel_atoms (NULL, & atoid[0][0]);
2534 break;
2535 case CONTEXTACT+3:
2536 is_selected = -1;
2537 label_unlabel_atoms (NULL, & atoid[1][0]);
2538 break;
2539 case CONTEXTACT+4:
2540 is_selected = -1;
2541 show_hide_the_atoms (NULL, & atoid[0][0]);
2542 break;
2543 case CONTEXTACT+5:
2544 is_selected = -1;
2545 show_hide_the_atoms (NULL, & atoid[1][0]);
2546 break;
2547 case CONTEXTACT+6:
2548 is_selected = -1;
2549 style_the_atoms (widg, & atoid[0][0]);
2550 break;
2551 case CONTEXTACT+8:
2552 is_selected = -1;
2553 edit_in_new_project (NULL, & opengl_project -> modelgl -> colorp[1][1]);
2554 break;
2555 case CONTEXTACT+9:
2556 is_selected = -1;
2557 remove_the_atoms (widg, & cut_sel);
2558 break;
2559 case CONTEXTACT+10:
2560 is_selected = -1;
2561 replace_the_atoms (widg, & cut_sel);
2562 break;
2563 case CONTEXTACT+11:
2564 is_selected = -1;
2565 copy_the_atoms (widg, & cut_sel);
2566 break;
2567 case 2*CONTEXTACT+4:
2568 is_selected = -1;
2569 show_hide_the_atoms (NULL, & atoid[0][1]);
2570 break;
2571 case 2*CONTEXTACT+5:
2572 is_selected = -1;
2573 show_hide_the_atoms (NULL, & atoid[1][1]);
2574 break;
2575 }
2576#endif
2577}
2578
2579#ifdef GTK4
2589G_MODULE_EXPORT void select_action_for_this_bond (GSimpleAction * action, GVariant * parameter, gpointer data)
2590#else
2599G_MODULE_EXPORT void select_action_for_this_bond (GtkWidget * widg, gpointer data)
2600#endif
2601{
2602 int i, s;
2603 i = GPOINTER_TO_INT(data);
2604#ifdef GTK4
2605 switch (i)
2606 {
2607 case 0:
2608 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2609 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2610 break;
2611 case 1:
2612 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2613 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2614 break;
2615 case 2:
2616 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2617 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2618 break;
2619 case 3:
2620 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2621 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2622 break;
2623 case 4:
2624 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2625 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2626 break;
2627 case 5:
2628 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2629 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2630 break;
2631 case 6:
2632 style_this_atom (action, NULL, GINT_TO_POINTER(selected_atom));
2633 style_this_atom (action, NULL, GINT_TO_POINTER(selected_btom));
2634 break;
2635 default:
2636 // 8 = create project
2637 // 9 = remove
2638 // 10 = replace
2639 // 11 = copy
2640 bond_selection = g_malloc0(sizeof*bond_selection);
2641 s = opengl_project -> modelgl -> anim -> last -> img -> step;
2643 bond_selection -> selected ++;
2645 bond_selection -> selected ++;
2646 switch (i)
2647 {
2648 case 8:
2650 break;
2651 case 9:
2652 to_remove_this_object (3, NULL);
2653 remove_object ();
2654 break;
2655 case 10:
2656 to_replace_this_object (3, action, data);
2657 to_remove_this_object (3, data);
2658 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
2660 break;
2661 case 11:
2663 break;
2664 }
2665 break;
2666 g_free (bond_selection);
2667 bond_selection = NULL;
2668 }
2669#else
2670 switch (i)
2671 {
2672 case 0:
2673 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2674 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2675 break;
2676 case 1:
2677 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2678 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2679 break;
2680 case 2:
2681 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2682 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2683 break;
2684 case 3:
2685 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2686 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2687 break;
2688 case 4:
2689 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2690 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2691 break;
2692 case 5:
2693 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2694 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2695 break;
2696 case 6:
2697 style_this_atom (widg, GINT_TO_POINTER(selected_atom));
2698 style_this_atom (widg, GINT_TO_POINTER(selected_btom));
2699 break;
2700 default:
2701 // 8 = create project
2702 // 9 = remove
2703 // 10 = replace
2704 // 11 = copy
2705 bond_selection = g_malloc0(sizeof*bond_selection);
2706 s = opengl_project -> modelgl -> anim -> last -> img -> step;
2708 bond_selection -> selected ++;
2710 bond_selection -> selected ++;
2711 switch (i)
2712 {
2713 case 8:
2715 break;
2716 case 9:
2717 to_remove_this_object (3, NULL);
2718 remove_object ();
2719 break;
2720 case 10:
2721 to_replace_this_object (3, widg, data);
2722 to_remove_this_object (3, data);
2723 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
2725 break;
2726 case 11:
2728 break;
2729 }
2730 break;
2731 g_free (bond_selection);
2732 bond_selection = NULL;
2733 }
2734#endif
2735}
2736
2737#ifdef GTK4
2747G_MODULE_EXPORT void select_action_for_all_bonds (GSimpleAction * action, GVariant * parameter, gpointer data)
2748#else
2757G_MODULE_EXPORT void select_action_for_all_bonds (GtkWidget * widg, gpointer data)
2758#endif
2759{
2760 int g, h, i, j, k, l, m, n, o;
2761 int mid = GPOINTER_TO_INT(data);
2762 int s = opengl_project -> modelgl -> anim -> last -> img -> step;
2763 g = get_to_be_selected (opengl_project -> modelgl);
2764 gboolean doit;
2765 gboolean eqtc, eqpc;
2766 bond_selection = NULL;
2768 if (mid == 6 || mid == 6+CONTEXTACT || mid == 6+2*CONTEXTACT) wait_for_style = TRUE;
2769 for (h=0; h<2; h++)
2770 {
2771 for (i=0; i<opengl_project -> modelgl -> bonds[s][h]; i++)
2772 {
2773 doit = FALSE;
2774 k = opengl_project -> modelgl -> bondid[s][h][i][0];
2775 j = opengl_project -> modelgl -> bondid[s][h][i][1];
2776 l = opengl_project -> atoms[s][k].coord[0];
2777 m = opengl_project -> atoms[s][j].coord[0];
2778 n = opengl_project -> atoms[s][k].coord[1];
2779 o = opengl_project -> atoms[s][j].coord[1];
2780 if ((opengl_project -> atoms[s][j].sp == selected_aspec && opengl_project -> atoms[s][k].sp == selected_bspec) ||
2781 (opengl_project -> atoms[s][k].sp == selected_aspec && opengl_project -> atoms[s][j].sp == selected_bspec)) doit = TRUE;
2782 if (doit)
2783 {
2784 if (opengl_project -> atoms[s][j].sp == selected_aspec && opengl_project -> atoms[s][k].sp == selected_bspec)
2785 {
2786 eqtc = ((l == atoid[0][0].b && m == btoid.a) || (l == btoid.a && m == atoid[0][0].b)) ? TRUE : FALSE;
2787 eqpc = ((n == atoid[0][1].b && o == btoid.b) || (n == btoid.b && o == atoid[0][1].b)) ? TRUE : FALSE;
2788 }
2789 else
2790 {
2791 eqtc = ((l == atoid[0][0].b && m == btoid.a) || (l == btoid.a && m == atoid[0][0].b)) ? TRUE : FALSE;
2792 eqpc = ((n == atoid[0][1].b && o == btoid.b) || (n == btoid.b && o == atoid[0][1].b)) ? TRUE : FALSE;
2793 }
2794#ifdef GTK4
2795 if (mid == 0 || (mid == CONTEXTACT && eqtc) || (mid == 2*CONTEXTACT && eqpc))
2796 {
2797 if (! opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2798 if (! opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2799 }
2800 else if (mid == 1 || (mid == CONTEXTACT+1 && eqtc) || (mid == 2*CONTEXTACT+1 && eqpc))
2801 {
2802 if (opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2803 if (opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2804 }
2805 else if (mid == 2 || (mid == CONTEXTACT+2 && eqtc) || (mid == 2*CONTEXTACT+2 && eqpc))
2806 {
2807 if (! opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2808 if (! opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2809 }
2810 else if (mid == 3 || (mid == CONTEXTACT+3 && eqtc) || (mid == 2*CONTEXTACT+3 && eqpc))
2811 {
2812 if (opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2813 if (opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2814 }
2815 else if (mid == 4 || (mid == CONTEXTACT+4 && eqtc) || (mid == 2*CONTEXTACT+4 && eqpc))
2816 {
2817 if (! opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2818 if (! opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2819 }
2820 else if (mid == 5 || (mid == CONTEXTACT+5 && eqtc) || (mid == 2*CONTEXTACT+5 && eqpc))
2821 {
2822 if (opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2823 if (opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2824 }
2825 else if (mid == 6 || (mid == CONTEXTACT+6 && eqtc) || (mid == 2*CONTEXTACT+6 && eqpc))
2826 {
2827 style_this_atom (action, NULL, GINT_TO_POINTER(j));
2828 style_this_atom (action, NULL, GINT_TO_POINTER(k));
2829 }
2830#else
2831 if (mid == 0 || (mid == CONTEXTACT && eqtc) || (mid == 2*CONTEXTACT && eqpc))
2832 {
2833 if (! opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(j));
2834 if (! opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(k));
2835 }
2836 else if (mid == 1 || (mid == CONTEXTACT+1 && eqtc) || (mid == 2*CONTEXTACT+1 && eqpc))
2837 {
2838 if (opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(j));
2839 if (opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(k));
2840 }
2841 else if (mid == 2 || (mid == CONTEXTACT+2 && eqtc) || (mid == 2*CONTEXTACT+2 && eqpc))
2842 {
2843 if (! opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
2844 if (! opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(k));
2845 }
2846 else if (mid == 3 || (mid == CONTEXTACT+3 && eqtc) || (mid == 2*CONTEXTACT+3 && eqpc))
2847 {
2848 if (opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
2849 if (opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(k));
2850 }
2851 else if (mid == 4 || (mid == CONTEXTACT+4 && eqtc) || (mid == 2*CONTEXTACT+4 && eqpc))
2852 {
2853 if (! opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(j));
2854 if (! opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(k));
2855 }
2856 else if (mid == 5 || (mid == CONTEXTACT+5 && eqtc) || (mid == 2*CONTEXTACT+5 && eqpc))
2857 {
2858 if (opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(j));
2859 if (opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(k));
2860 }
2861 else if (mid == 6 || (mid == CONTEXTACT+6 && eqtc) || (mid == 2*CONTEXTACT+6 && eqpc))
2862 {
2863 style_this_atom (widg, GINT_TO_POINTER(j));
2864 style_this_atom (widg, GINT_TO_POINTER(k));
2865 }
2866#endif
2867 else if ((mid == 8 || (mid == CONTEXTACT+8 && eqtc) || (mid == 2*CONTEXTACT+8 && eqpc))
2868 || (mid == 9 || (mid == CONTEXTACT+9 && eqtc) || (mid == 2*CONTEXTACT+9 && eqpc))
2869 || (mid == 10 || (mid == CONTEXTACT+10 && eqtc) || (mid == 2*CONTEXTACT+10 && eqpc))
2870 || (mid == 11 || (mid == CONTEXTACT+11 && eqtc) || (mid == 2*CONTEXTACT+11 && eqpc)))
2871 {
2872 if (! bond_selection)
2873 {
2874 bond_selection = g_malloc0 (sizeof*bond_selection);
2875 bond_selection -> first = new_atom_in_selection (j, opengl_project -> atoms[s][j].sp);
2876 tmp_a = bond_selection -> first;
2877 }
2878 else
2879 {
2880 tmp_a -> next = new_atom_in_selection (j, opengl_project -> atoms[s][j].sp);
2881 tmp_a = tmp_a -> next;
2882 }
2883 bond_selection -> selected ++;
2884 tmp_a -> next = new_atom_in_selection (k, opengl_project -> atoms[s][k].sp);
2885 tmp_a = tmp_a -> next;
2886 bond_selection -> selected ++;
2887 }
2888 }
2889 }
2890 }
2891 if (mid == 6 || mid == CONTEXTACT+6 || mid == 2*CONTEXTACT+6)
2892 {
2894 update (opengl_project -> modelgl);
2895 wait_for_style = FALSE;
2896 }
2897 else if (mid == 8 || mid == CONTEXTACT+8 || mid == 2*CONTEXTACT+8)
2898 {
2900 g_free (bond_selection);
2901 bond_selection = NULL;
2902 }
2903 else if (mid == 9 || mid == CONTEXTACT+9 || mid == 2*CONTEXTACT+9)
2904 {
2905 if (bond_selection)
2906 {
2907 to_remove_this_object (3, data);
2908 remove_object ();
2909 g_free (bond_selection);
2910 bond_selection = NULL;
2911 }
2912 }
2913 else if (mid == 10 || mid == CONTEXTACT+10 || mid == 2*CONTEXTACT+10)
2914 {
2915 if (bond_selection)
2916 {
2917#ifdef GTK4
2918 to_replace_this_object (3, action, data);
2919#else
2920 to_replace_this_object (3, widg, data);
2921#endif
2922 to_remove_this_object (3, data);
2923 insert_object (1, data);
2924 g_free (bond_selection);
2925 bond_selection = NULL;
2926 }
2927 }
2928 else if (mid == 11 || mid == CONTEXTACT+11 || mid == 2*CONTEXTACT+11)
2929 {
2930 if (bond_selection)
2931 {
2933 g_free (bond_selection);
2934 bond_selection = NULL;
2935 }
2936 }
2937}
2938
2939#ifdef GTK4
2951GMenu * add_edition_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data)
2952{
2953 GMenu * menu = g_menu_new ();
2954 GMenu * menus;
2955 gchar * word, * name, * str;
2956 gchar * eact = g_strdup_printf ("mol-ins-%s-%d", act, aid);
2957 int i, j;
2958 for (i=0; mol[i].type || mol[i].object; i++)
2959 {
2960 if (mol[i].type)
2961 {
2962 menus = g_menu_new ();
2963 append_submenu (menu, mol[i].type, menus);
2964
2965 }
2966 if (mol[i].object)
2967 {
2968 append_opengl_item (view, menus, mol[i].object, eact, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
2969 }
2970 }
2971 g_free (eact);
2972
2973 gboolean doit = FALSE;
2974 for (i=0; i<nprojects; i++)
2975 {
2976 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2977 {
2978 doit = TRUE;
2979 break;
2980 }
2981 }
2982
2983 if (doit)
2984 {
2985 GMenu * menup = g_menu_new ();
2986 GMenu * menups;
2987 eact = g_strdup_printf ("ifp-%s-%d", act, aid);
2988 for (i=0; i<nprojects; i++)
2989 {
2990 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2991 {
2992 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2993 menups = g_menu_new ();
2994 for (j=0; j<3; j++)
2995 {
2996 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2997 str = g_strdup_printf ("%s-%d", eact, j);
2998 append_opengl_item (view, menups, word, str, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
2999 g_free (word);
3000 g_free (str);
3001 }
3002 append_submenu (menup, name, menups);
3003 g_object_unref (menups);
3004 g_free (name);
3005 }
3006 }
3007 g_free (eact);
3008 append_submenu (menu, "Import From Project", menup);
3009 g_object_unref (menup);
3010 }
3011 eact = g_strdup_printf ("cp-%s-%d", act, aid);
3012 append_opengl_item (view, menu, "Copied Data", eact, 1, 0, "<CTRL>V", IMG_NONE, NULL, FALSE, G_CALLBACK(add_object), data, FALSE, FALSE, FALSE, (copied_object) ? TRUE : FALSE);
3013 g_free (eact);
3014 return menu;
3015}
3016
3028GMenu * add_style_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data)
3029{
3030 GMenu * menu = g_menu_new ();
3031 gchar * actc = g_strdup_printf ("%s-%d", act, aid);
3032 int i;
3033 for (i=0; i<OGL_STYLES; i++)
3034 {
3035 append_opengl_item (view, menu, text_styles[i], actc, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
3036 }
3037 g_free (actc);
3038 return menu;
3039}
3040#else
3050void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3051{
3052 GtkWidget * menu = gtk_menu_new ();
3053 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3054 int i; //, j;
3055 for (i=0; i<OGL_STYLES; i++)
3056 {
3057 //if (i != SPACEFILL)
3058 {
3059 gtk3_menu_item (menu, text_styles[i], IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3060 }
3061 /* else
3062 {
3063 GtkWidget *widg = create_menu_item (FALSE, "Spacefilled");
3064 gtk_menu_shell_append ((GtkMenuShell *)menu, widg);
3065 GtkWidget * menuf = gtk_menu_new ();
3066 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menuf);
3067 for (j=0; j < FILLED_STYLES; j++)
3068 {
3069 gtk3_menu_item (menuf, text_filled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3070 }
3071 } */
3072 }
3073}
3074
3075/*void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3076{
3077 GtkWidget * menu = gtk_menu_new ();
3078 GtkWidget * pmenu;
3079 GtkWidget * sitem, * pitem;
3080 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3081 int i, j;
3082 for (i=0; i<OGL_STYLES; i++)
3083 {
3084 if (i != SPACEFILL)
3085 {
3086 sitem = gtk3_menu_item (menu, text_stylesled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, TRUE, FALSE);
3087 }
3088 else
3089 {
3090 sitem = create_menu_item (FALSE, "Spacefilled");
3091 gtk_menu_shell_append ((GtkMenuShell *)menu, sitem);
3092 pmenu = gtk_menu_new ();
3093 gtk_menu_item_set_submenu ((GtkMenuItem *)sitem, pmenu);
3094 for (j=0; j < FILLED_STYLES; j++)
3095 {
3096 pitem = gtk3_menu_item (menu, text_filled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, TRUE, FALSE);
3097 }
3098 }
3099 }
3100}*/
3101
3111void add_edition_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3112{
3113 GtkWidget * menu = gtk_menu_new ();
3114 GtkWidget * smenu, * pmenu;
3115 GtkWidget * titem, * sitem;
3116 gchar * word, * name;
3117 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3118 int i, j;
3119
3120 for (i=0; mol[i].type || mol[i].object; i++)
3121 {
3122 if (mol[i].type != NULL)
3123 {
3124 titem = create_menu_item (TRUE, mol[i].type);
3125 gtk_menu_shell_append ((GtkMenuShell *)menu, titem);
3126 smenu = gtk_menu_new ();
3127 gtk_menu_item_set_submenu ((GtkMenuItem *)titem, smenu);
3128 }
3129 if (mol[i].object != NULL)
3130 {
3131 gtk3_menu_item (smenu, mol[i].object, IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3132 }
3133 }
3134
3135 gboolean doit = FALSE;
3136 for (i=0; i<nprojects; i++)
3137 {
3138 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
3139 {
3140 doit = TRUE;
3141 break;
3142 }
3143 }
3144
3145 if (doit)
3146 {
3147 titem = create_menu_item (TRUE, "Import From Project");
3148 gtk_menu_shell_append ((GtkMenuShell *)menu, titem);
3149 smenu = gtk_menu_new ();
3150 gtk_menu_item_set_submenu ((GtkMenuItem *)titem, smenu);
3151 for (i=0; i<nprojects; i++)
3152 {
3153 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
3154 {
3155 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
3156 sitem = create_menu_item_from_widget (markup_label(name, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3157 //child = gtk_bin_get_child (GTK_BIN (sitem));
3158 //gtk_label_set_use_markup (GTK_LABEL(child), 1);
3159 //g_signal_connect (G_OBJECT (sitem), "activate", handler, data);
3160 gtk_menu_shell_append ((GtkMenuShell *)smenu, sitem);
3161 pmenu = gtk_menu_new ();
3162 gtk_menu_item_set_submenu ((GtkMenuItem *)sitem, pmenu);
3163 for (j=0; j<3; j++)
3164 {
3165 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
3166 gtk3_menu_item (pmenu, word, IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3167 g_free (word);
3168 }
3169 g_free (name);
3170 }
3171 }
3172 }
3173 GtkWidget * pastem = gtk3_menu_item (menu, "Copied Data", IMG_NONE, NULL, G_CALLBACK(add_object), data, TRUE, GDK_KEY_v, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
3174 if (! copied_object) widget_set_sensitive (pastem, 0);
3175}
3176#endif
3177
3178#ifdef GTK4
3196void create_selection_item (GMenu * menu, glwin * view, gchar * str, gchar * act, int aid, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data)
3197{
3198 gchar * actc = g_strdup_printf ("%s-%d", act, aid);
3199#else
3214GtkWidget * create_selection_item (glwin * view, gchar * str, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data)
3215{
3216 GtkWidget * sel_item = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3217#endif
3218 int i, j;
3219 if (mid == 6)
3220 {
3221#ifdef GTK4
3222 append_submenu (menu, str, add_style_sub_menu (view, act, aid, handler, data));
3223#else
3224 add_style_sub_menu (sel_item, handler, data);
3225#endif
3226 }
3227 else if (mid == 7)
3228 {
3229 if (cid < 0)
3230 {
3231 i = get_project_by_id (view -> proj) -> nspec;
3232#ifdef GTK4
3233 append_submenu (menu, str, color_item(view, actc, mid, G_CALLBACK(to_run_atom_color_window), & view -> colorp[0][selected_aspec+aoc*i]));
3234#else
3235 gtk_menu_item_set_submenu ((GtkMenuItem *)sel_item, color_box(view, selected_aspec+aoc*i, 0, 0));
3236#endif
3237 }
3238 else
3239 {
3240#ifdef GTK4
3241 i = cid;
3242 if (gid < 2)
3243 {
3244 for (j=0; j<selected_aspec; j++) i += opengl_project -> coord -> ntg[gid][j];
3245 }
3246 append_submenu (menu, str, color_item(view, actc, mid, G_CALLBACK(window_color_coord), & view -> gcid[gid][i][gid]));
3247#else
3248 int k;
3249 j = 2*opengl_project -> nspec;
3250 for (i=0; i < gid; i++)
3251 {
3252 j += opengl_project -> coord -> totcoord[i];
3253 }
3254 if (gid < 2)
3255 {
3256 for (i=0; i<selected_aspec; i++)
3257 {
3258 j += opengl_project -> coord -> ntg[gid][i];
3259 }
3260 k = selected_aspec;
3261 }
3262 else
3263 {
3264 k = gid;
3265 }
3266 gtk_menu_item_set_submenu ((GtkMenuItem *)sel_item, color_box(view, j+cid, k, cid));
3267#endif
3268 }
3269 }
3270 else if (mid == 10)
3271 {
3272#ifdef GTK4
3273 append_submenu (menu, str, add_edition_sub_menu (view, act, aid, handler, data));
3274#else
3275 add_edition_sub_menu (sel_item, handler, data);
3276#endif
3277 }
3278 else
3279 {
3280#ifdef GTK4
3281 append_opengl_item (view, menu, str, actc, 1, 0, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
3282#else
3283 g_signal_connect (G_OBJECT (sel_item), "activate", handler, data);
3284#endif
3285 }
3286#ifdef GTK4
3287 g_free (actc);
3288#else
3289 return sel_item;
3290#endif
3291}
3292
3293gchar * mot[2][2]={{"All Non-Selected Atom(s)/Bond(s)", "All Selected Atom(s)/Bond(s)"},
3294 {"All Non-Labelled Atom(s)/Bond(s)", "All Labelled Atom(s)/Bond(s)"}};
3295
3296#ifdef GTK4
3312GMenu * selection_menu (int aid, glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
3313#else
3328GtkWidget * selection_menu (glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
3329#endif
3330{
3331 int p = view -> proj;
3332 int s = view -> anim -> last -> img -> step;
3333 int spa, spb;
3334 int i, j, k;
3335 gchar * str;
3336
3337#ifdef GTK4
3338 gchar * strb;
3339 GMenu * menu = g_menu_new ();
3340#else
3341 GtkWidget * sel;
3342 GtkWidget * menu = gtk_menu_new ();
3343#endif
3344 project * this_proj = get_project_by_id(p);
3345 spa = this_proj -> atoms[s][ati].sp;
3346 if (bti > -1) spb = this_proj -> atoms[s][bti].sp;
3347 if (bti < 0 && (((mid == 5 || mid == 6) && this_proj -> atoms[s][ati].show[aoc])
3348 || (mid == 0 && ! is_selected) || (mid == 1 && is_selected)
3349 || (mid == 2 && ! is_labelled) || (mid == 3 && is_labelled) || (mid > 8 && mid < 11)))
3350 {
3351 str = g_strdup_printf ("This Atom: %s<sub>%d</sub>", exact_name(this_proj -> chemistry -> label[spa]), ati+1);
3352#ifdef GTK4
3353 if (mid == 6)
3354 {
3355 append_submenu (menu, str, add_style_sub_menu (view, "tas", aid, handler_a, GINT_TO_POINTER(ati)));
3356 }
3357 else if (mid == 10)
3358 {
3359 append_submenu (menu, str, add_edition_sub_menu (view, "tae", aid, handler_a, GINT_TO_POINTER(ati)));
3360 }
3361 else
3362 {
3363 strb = g_strdup_printf ("act-%d-%d", aid, mid);
3364 append_opengl_item (view, menu, str, strb, 1, 0, NULL, IMG_NONE, NULL, FALSE, handler_a, GINT_TO_POINTER(ati), FALSE, FALSE, FALSE, TRUE);
3365 g_free (strb);
3366 }
3367#else
3368 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3369 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3370 if (mid == 6)
3371 {
3372 add_style_sub_menu (sel, handler_a, GINT_TO_POINTER(ati));
3373 }
3374 else if (mid == 10)
3375 {
3376 add_edition_sub_menu (sel, handler_a, GINT_TO_POINTER(ati));
3377 }
3378 else
3379 {
3380 g_signal_connect (G_OBJECT (sel), "activate", handler_a, GINT_TO_POINTER(ati));
3381 }
3382#endif
3383 }
3384 else if (bti > -1 && mid != 4 && mid != 7)
3385 {
3386 str = g_strdup_printf ("This Bond: %s<sub>%d</sub> - %s<sub>%d</sub>",
3387 exact_name(this_proj -> chemistry -> label[spa]), ati+1,
3388 exact_name(this_proj -> chemistry -> label[spb]), bti+1);
3389#ifdef GTK4
3390 if (mid == 6)
3391 {
3392 append_submenu (menu, str, add_style_sub_menu (view, "tb-s", aid, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid)));
3393 }
3394 else if (mid == 10)
3395 {
3396 append_submenu (menu, str, add_edition_sub_menu (view, "tb-e", aid, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid)));
3397 }
3398 else
3399 {
3400 strb = g_strdup_printf ("act-%d-%d", aid, mid);
3401 append_opengl_item (view, menu, str, strb, 1, 0, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid), FALSE, FALSE, FALSE, TRUE);
3402 g_free (strb);
3403 }
3404#else
3405 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3406 if (mid == 6)
3407 {
3408 add_style_sub_menu (sel, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3409 }
3410 else if (mid == 10)
3411 {
3412 add_edition_sub_menu (sel, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3413 }
3414 else
3415 {
3416 g_signal_connect (G_OBJECT (sel), "activate", G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3417 }
3418 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3419#endif
3420 g_free (str);
3421 }
3422
3423 if (mid != 7)
3424 {
3425 k = 0;
3426 for (j=0; j<2; j++)
3427 {
3428 if (mid<2 && j==0)
3429 {
3430 i = mid;
3431 }
3432 else if ((mid > 1 && mid < 4) && j==1)
3433 {
3434 i = mid - 2;
3435 }
3436 else
3437 {
3438 i = (j) ? is_labelled : is_selected;
3439 }
3440#ifdef GTK4
3441 if (mid == 6)
3442 {
3443 append_submenu (menu, mot[j][i], add_style_sub_menu (view, "all-s", aid, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k)));
3444 }
3445 else if (mid == 10)
3446 {
3447 append_submenu (menu, mot[j][i], add_edition_sub_menu (view, "all-e", aid, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k)));
3448 }
3449 else
3450 {
3451 strb = g_strdup_printf ("act-all-%d-%d", aid, mid+k);
3452 append_opengl_item (view, menu, mot[j][i], strb, 1, 0, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k), FALSE, FALSE, FALSE, TRUE);
3453 g_free (strb);
3454 }
3455#else
3456 sel = create_menu_item_from_widget (markup_label (mot[j][i], -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3457 if (mid == 6)
3458 {
3459 add_style_sub_menu (sel, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3460 }
3461 else if (mid == 10)
3462 {
3463 add_edition_sub_menu (sel, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3464 }
3465 else
3466 {
3467 g_signal_connect (G_OBJECT (sel), "activate", G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3468 }
3469 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3470#endif
3471 k = CONTEXTACT;
3472 }
3473 }
3474
3475 for (i=0; i<2; i++)
3476 {
3477 if (this_proj -> modelgl -> adv_bonding[i])
3478 {
3479 j = this_proj -> atoms[s][ati].coord[2+i];
3480 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j+1) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j+1);
3481#ifdef GTK4
3482 create_selection_item (menu, view, str, (! i) ? "afm" : "amo", aid, mid, 2+i, j, aoc, handler_b, & atoid[mid][2+i]);
3483#else
3484 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item (view, str, mid, 2+i, j, aoc, handler_b, & atoid[mid][2+i]));
3485#endif
3486 g_free (str);
3487 }
3488 }
3489 if (bti < 0)
3490 {
3491 if (this_proj -> atoms[s][ati].coord[0] > -1)
3492 {
3493 i = this_proj -> atoms[s][ati].coord[0];
3494 str = g_strdup_printf ("All <b>%d</b> Fold %s Atoms", this_proj -> coord -> geolist[0][spa][i], exact_name(this_proj -> chemistry -> label[spa]));
3495#ifdef GTK4
3496 create_selection_item (menu, view, str, "atc", aid, mid, 0, i, aoc, handler_b, & atoid[mid][0]);
3497#else
3498 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 0, i, aoc, handler_b, & atoid[mid][0]));
3499#endif
3500 g_free (str);
3501 }
3502 if (this_proj -> atoms[s][ati].coord[1] > -1)
3503 {
3504 i = this_proj -> atoms[s][ati].coord[1];
3505 str = g_strdup_printf ("All <b>%s</b> Coordinations", env_name (this_proj, i, spa, 1, NULL));
3506#ifdef GTK4
3507 create_selection_item (menu, view, str, "apc", aid, mid, 1, i, aoc, handler_b, & atoid[mid][1]);
3508#else
3509 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 1, i, aoc, handler_b, & atoid[mid][1]));
3510#endif
3511 g_free (str);
3512 }
3513 if (! aoc)
3514 {
3515 str = g_strdup_printf ("All <b>%s</b> Atoms", exact_name(this_proj -> chemistry -> label[spa]));
3516 }
3517 else
3518 {
3519 str = g_strdup_printf ("All <b>%s*</b> Clones", exact_name(this_proj -> chemistry -> label[spa]));
3520 }
3521#ifdef GTK4
3522 create_selection_item (menu, view, str, "asp", aid, mid, 0, -1, aoc, handler_c, & atoid[mid][2]);
3523#else
3524 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 0, -1, aoc, handler_c, & atoid[mid][2]));
3525#endif
3526 g_free (str);
3527 }
3528 else
3529 {
3530 if (this_proj -> atoms[s][ati].coord[0] > -1 && this_proj -> atoms[s][bti].coord[0] > -1)
3531 {
3532 i = this_proj -> atoms[s][ati].coord[0];
3533 j = this_proj -> atoms[s][bti].coord[0];
3534 str = g_strdup_printf ("All %s <b>%d</b> - %s <b>%d</b> Bonds",
3535 exact_name(this_proj -> chemistry -> label[spa]), this_proj -> coord -> geolist[0][spa][i],
3536 exact_name(this_proj -> chemistry -> label[spb]), this_proj -> coord -> geolist[0][spb][j]);
3537#ifdef GTK4
3538 create_selection_item (menu, view, str, "atcb", aid, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid+CONTEXTACT));
3539#else
3540 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid+CONTEXTACT)));
3541#endif
3542 g_free (str);
3543 }
3544 if (this_proj -> atoms[s][ati].coord[1] > -1 && this_proj -> atoms[s][bti].coord[1] > -1)
3545 {
3546 i = this_proj -> atoms[s][ati].coord[1];
3547 j = this_proj -> atoms[s][bti].coord[1];
3548 str = g_strdup_printf ("All <b>%s</b> - <b>%s</b> Bonds", env_name (this_proj, i, spa, 1, NULL), env_name (this_proj, j, spb, 1, NULL));
3549#ifdef GTK4
3550 create_selection_item (menu, view, str, "apcb", aid, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid+2*CONTEXTACT));
3551#else
3552 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid+2*CONTEXTACT)));
3553#endif
3554 g_free (str);
3555 }
3556 str = g_strdup_printf ("All %s - %s Bonds", exact_name(this_proj -> chemistry -> label[spa]), exact_name(this_proj -> chemistry -> label[spb]));
3557#ifdef GTK4
3558 create_selection_item (menu, view, str, "acb", aid, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid));
3559#else
3560 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid)));
3561#endif
3562 g_free (str);
3563 }
3564 if (mid > 3 && mid < 6)
3565 {
3566 gchar * mat[2]={"All Hidden Atom(s)/Bond(s)", "All Visible Atom(s)/Bond(s)"};
3567#ifdef GTK4
3568 strb = g_strdup_printf ("all-hv-%d-%d", aid, mid);
3569 append_opengl_item (view, menu, mat[mid%2], strb, 1, 0, NULL, IMG_NONE, NULL, FALSE, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+2*CONTEXTACT), FALSE, FALSE, FALSE, TRUE);
3570 g_free (strb);
3571#else
3572 gtk3_menu_item (menu, mat[mid%2], IMG_NONE, NULL, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+2*CONTEXTACT), FALSE, 0, 0, FALSE, FALSE, FALSE);
3573#endif
3574 }
3575 return menu;
3576}
3577
3578#ifdef GTK4
3593void analyze_popup_attach_color_palettes (glwin * view, GtkWidget * menu, int ato, int spc, int totc, int parc, int frag, int mol)
3594{
3595 /* Here we need to attached color palettes for:
3596 - The chemical species of the atom in selection
3597 - The total coordination of the atom in selection
3598 - The partial coordination of the atom in selection
3599 - The fragment of the atom in selection
3600 - The molecule of the atom in selection
3601 This is a work in progress since the 'gtk_popover_menu_bar_add_child' to use to insert widget is bugged:
3602 https://gitlab.gnome.org/GNOME/gtk/-/issues/5955
3603 */
3604 int i, j;
3605 project * this_proj = get_project_by_id (view -> proj);
3606 // The chemical species of the atom in selection
3607 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, ato*this_proj -> nspec+spc, -1, -1), "set-asp-7.7"))
3608 {
3609 g_debug ("Color palette error: species in selection - custom= set-asp-7.7");
3610 }
3611 // The total coordination
3612 i = 0;
3613 for (j=0; j<spc; j++)
3614 {
3615 i += this_proj -> coord -> ntg[0][j];
3616 }
3617 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+i, -1, -1), "set-atc-7.7"))
3618 {
3619 g_debug ("Color palette error: total coordination in selection - custom= set-atc-7.7");
3620 }
3621 // The partial coordination
3622 i = this_proj -> coord -> totcoord[0];
3623 for (j=0; j<spc; j++)
3624 {
3625 i += this_proj -> coord -> ntg[1][j];
3626 }
3627 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+i, -1, -1), "set-apc-7.7"))
3628 {
3629 g_debug ("Color palette error: partial coordination in selection - custom= set-apc-7.7");
3630 }
3631 if (view -> adv_bonding[0])
3632 {
3633 // The fragment of the atom in selection
3634 i = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + frag;
3635 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i, 2, 0), "set-afm-7.7"))
3636 {
3637 g_debug ("Color palette error: fragment in selection - custom= set-afm-7.7");
3638 }
3639 }
3640 if (view -> adv_bonding[1])
3641 {
3642 // The molecule of the atom in selection
3643 i = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + this_proj -> coord -> totcoord[2] + mol;
3644 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i, 3, 0), "set-amo-7.7"))
3645 {
3646 g_debug ("Color palette error: fragment in selection - custom= set-amo-7.7");
3647 }
3648 }
3649}
3650#endif
3651
3666void popup_selection (glwin * view, double ptx, double pty, int spe, int mmod, int ati, int bti, int aoc)
3667{
3668 int p = view -> proj;
3669 int s = view -> anim -> last -> img -> step;
3670 int i, j;
3671 gchar * str, * strp;
3672 gchar * menu_names[CONTEXTACT] = {"Select", "Unselect", "Label", "Unlabel", "Show", "Hide", "Style", "Color", "Edit as New Project", "Remove", "Replace", "Copy"};
3673 GCallback handlers[CONTEXTACT][3] = {{G_CALLBACK(select_unselect_this_atom), G_CALLBACK(select_unselect_coord), G_CALLBACK(select_unselect_atoms)},
3674 {G_CALLBACK(select_unselect_this_atom), G_CALLBACK(select_unselect_coord), G_CALLBACK(select_unselect_atoms)},
3675 {G_CALLBACK(label_unlabel_this_atom), G_CALLBACK(label_unlabel_coord), G_CALLBACK(label_unlabel_atoms)},
3676 {G_CALLBACK(label_unlabel_this_atom), G_CALLBACK(label_unlabel_coord), G_CALLBACK(label_unlabel_atoms)},
3677 {G_CALLBACK(show_hide_this_atom), G_CALLBACK(show_hide_the_coord), G_CALLBACK(show_hide_the_atoms)},
3678 {G_CALLBACK(show_hide_this_atom), G_CALLBACK(show_hide_the_coord), G_CALLBACK(show_hide_the_atoms)},
3679 {G_CALLBACK(style_this_atom), G_CALLBACK(style_the_coord), G_CALLBACK(style_the_atoms)},
3680 {NULL, NULL, NULL},
3681 {NULL, G_CALLBACK(edit_coord), G_CALLBACK(edit_atoms)},
3682 {G_CALLBACK(remove_this_atom), G_CALLBACK(remove_the_coord), G_CALLBACK(remove_the_atoms)},
3683 {G_CALLBACK(replace_this_atom), G_CALLBACK(replace_the_coord), G_CALLBACK(replace_the_atoms)},
3684 {G_CALLBACK(copy_this_atom), G_CALLBACK(copy_the_coord), G_CALLBACK(copy_the_atoms)}};
3685#ifdef GTK4
3686 if (view_pop_actions) g_object_unref (view_pop_actions);
3687 view_pop_actions = g_simple_action_group_new ();
3688 GMenu * gmenu = g_menu_new ();
3689#else
3690 GtkWidget * menu = gtk_menu_new ();
3691 GtkWidget * sel;
3692#endif
3693#ifdef DEBUG
3694 g_debug ("POP_SEL:: spe= %d, ati= %d, bti= %d, aoc= %d", spe, ati, bti, aoc);
3695#endif // DEBUG
3696
3698 selected_atom = ati;
3699 selected_btom = bti;
3700 selected_aspec = opengl_project -> atoms[s][ati].sp;
3701 selected_bspec = -1;
3702 selected_status = ! opengl_project -> atoms[s][ati].pick[get_to_be_selected (view)];
3703 is_selected = opengl_project -> atoms[s][ati].pick[mmod];
3704 is_labelled = opengl_project -> atoms[s][ati].label[aoc];
3705#ifdef DEBUG
3706 if (is_selected != spe) g_debug ("Something is wrong in popup");
3707#endif // DEBUG
3708
3709 for (i=0; i<CONTEXTACT; i++)
3710 {
3711 for (j=0; j<4; j++)
3712 {
3713 atoid[i][j].a = j;
3714 atoid[i][j].b = opengl_project -> atoms[s][ati].coord[j];
3715 atoid[i][j].c = ((i-2*(i/2)) == 0 ? 1 : 0);
3716/*#ifdef DEBUG
3717 g_debug ("atoid[%d][%d].a= %d, atoid[%d][%d].b= %d, atoid[%d][%d].c= %d",
3718 i, j, atoid[i][j].a, i, j, atoid[i][j].b, i, j, atoid[i][j].c);
3719#endif*/
3720 }
3721 }
3722 if (bti > -1)
3723 {
3724 btoid.a = opengl_project -> atoms[s][bti].coord[0];
3725 btoid.b = opengl_project -> atoms[s][bti].coord[1];
3726 selected_bspec = opengl_project -> atoms[s][bti].sp;
3727 distance dist = distance_3d (& opengl_project -> cell, (opengl_project -> cell.npt) ? s : 0, & opengl_project -> atoms[s][ati], & opengl_project -> atoms[s][bti]);
3728 if (aoc == 0)
3729 {
3730 str = g_strdup_printf ("%s<sub>%d</sub> - %s<sub>%d</sub>",
3732 }
3733 else
3734 {
3735 str = g_strdup_printf ("%s<sub>%d</sub> - %s<sub>%d</sub>",
3737 }
3738 if (dist.pbc)
3739 {
3740 strp = g_strdup_printf ("<b>%s \t d= %.3f Ã… (PBC)</b>", str, dist.length);
3741 }
3742 else
3743 {
3744 strp = g_strdup_printf ("<b>%s \t d= %.3f Ã…</b>", str, dist.length);
3745 }
3746#ifdef GTK4
3747 append_opengl_item (view, gmenu, strp, "w-dist", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3748#else
3749 sel = create_menu_item_from_widget (markup_label (strp, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3750 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3751#endif
3752 g_free (strp);
3753 for (i=0; i<2; i++)
3754 {
3755 if (view -> adv_bonding[i])
3756 {
3757 j = opengl_project -> atoms[s][ati].coord[2+i] + 1;
3758 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j);
3759#ifdef GTK4
3760 append_opengl_item (view, gmenu, str, "w-dist-fm", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3761#else
3762 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3763 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3764#endif
3765 g_free (str);
3766 }
3767 }
3768 }
3769 else
3770 {
3771 if (aoc == 0)
3772 {
3773 str = g_strdup_printf ("<b>%s<sub>%d</sub></b>", exact_name(opengl_project -> chemistry -> label[selected_aspec]), ati+1);
3774 }
3775 else
3776 {
3777 str = g_strdup_printf ("<b>%s<sub>%d</sub><sup>*</sup></b>", exact_name(opengl_project -> chemistry -> label[selected_aspec]), ati+1);
3778 }
3779#ifdef GTK4
3780 append_opengl_item (view, gmenu, str, "w-ac", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3781#else
3782 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3783 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3784#endif
3785 g_free (str);
3786 str = g_strdup_printf ("\tx : <b>%f</b>\n\ty : <b>%f</b>\n\tz : <b>%f</b>",
3787 opengl_project -> atoms[s][ati].x, opengl_project -> atoms[s][ati].y, opengl_project -> atoms[s][ati].z);
3788#ifdef GTK4
3789 append_opengl_item (view, gmenu, str, "xyz", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3790#else
3791 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3792 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3793#endif
3794 g_free (str);
3795 if (opengl_project -> atoms[s][ati].coord[0] > -1)
3796 {
3797 i = opengl_project -> atoms[s][ati].coord[0];
3798 str = g_strdup_printf ("Total Coordination: <b>%d</b>", opengl_project -> coord -> geolist[0][selected_aspec][i]);
3799#ifdef GTK4
3800 append_opengl_item (view, gmenu, str, "w-tc", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3801#else
3802 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3803 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3804#endif
3805 g_free (str);
3806 i = opengl_project -> atoms[s][ati].coord[1];
3807 str = g_strdup_printf ("Partial Coordination: <b>%s</b>",
3808 env_name (opengl_project, i, selected_aspec, 1, NULL));
3809#ifdef GTK4
3810 append_opengl_item (view, gmenu, str, "w-pc", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3811#else
3812 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3813 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3814#endif
3815 g_free (str);
3816 }
3817 for (i=0; i<2; i++)
3818 {
3819 if (view -> adv_bonding[i])
3820 {
3821 j = opengl_project -> atoms[s][ati].coord[2+i] + 1;
3822 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j);
3823#ifdef GTK4
3824 append_opengl_item (view, gmenu, str, "w-fm", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3825#else
3826 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3827 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3828#endif
3829 g_free (str);
3830 }
3831 }
3832 }
3833
3834 //if (fc)
3835 //{
3836 // gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3837 // add_menu_separator (menu);
3838 // atoms menu
3839 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_atom_menu(p, s, ati, fc-2));
3840 // bonds menu, if ati involved in bonding, or bti > -1
3841 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_bond_menu(p, s, ati, bti));
3842 // angles menu, if ati involved in bonding with more than 2 neighbors
3843 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_angle_menu(p, s, ati, bti));
3844 //}
3845
3846#ifdef GTK4
3847 GMenu * menua = g_menu_new ();
3848 g_menu_append_section (gmenu, NULL, (GMenuModel *)menua);
3849#else
3850 add_menu_separator (menu);
3851#endif
3852 gboolean go;
3853
3854 for (i=0; i<12; i++)
3855 {
3856 go = TRUE;
3857 if (i < 9 && view -> mode == EDITION) go = FALSE;
3858 if ((i > 8 && i < 11) && view -> mode == ANALYZE) go = FALSE;
3859 if (i == 0 && view -> anim -> last -> img -> selected[mmod] -> selected == opengl_project -> natomes) go = FALSE;
3860 if (i == 1 && view -> anim -> last -> img -> selected[mmod] -> selected == 0) go = FALSE;
3861 if (i == 2 && view -> labelled == opengl_project -> natomes*opengl_project -> steps) go = FALSE;
3862 if (i == 3 && view -> labelled == 0) go = FALSE;
3863 if (bti > -1 && i == 7) go = FALSE;
3864 j = (i == 8 && view -> mode == ANALYZE) ? 11 : (i == 11 && view -> mode == ANALYZE) ? 8 : i;
3865 if (go)
3866 {
3867#ifdef GTK4
3868 append_submenu (menua, menu_names[j], selection_menu (i, view, ati, bti, aoc, j, handlers[j][0], handlers[j][1], handlers[j][2]));
3869#else
3870 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu(menu_names[j], TRUE, selection_menu (view, ati, bti, aoc, j, handlers[j][0], handlers[j][1], handlers[j][2])));
3871#endif
3872 }
3873 }
3874#ifdef GTK4
3875 GtkWidget * menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)gmenu, GTK_POPOVER_MENU_NESTED);
3876 // Color palettes here
3877 if (view -> mode == ANALYZE) analyze_popup_attach_color_palettes (view, menu, aoc, selected_aspec, atoid[0][0].b, atoid[0][1].b, atoid[0][2].b, atoid[0][3].b);
3878
3879 gtk_widget_set_parent (menu, view -> win);
3880 str = g_strdup_printf ("gl-%d", view -> action_id);
3881 gtk_widget_insert_action_group (menu, str, G_ACTION_GROUP(view_pop_actions));
3882 g_free (str);
3883 i = (view -> mode == ANALYZE) ? (is_selected) ? 385 : 355 : 230;
3884 i += (view -> adv_bonding[0] && bti < 0) ? 30 : 0;
3885 i += (view -> adv_bonding[1] && bti < 0) ? 30 : 0;
3886 if (bti > -1) i -= (view -> mode == ANALYZE) ? 70 : 50;
3887 gtk_widget_set_size_request (menu, -1, i);
3888 pop_menu_at_pointer (menu, ptx, pty);
3889#else
3890 pop_menu_at_pointer (menu, NULL);
3891#endif
3892}
3893
3894#ifdef GTK4
3904G_MODULE_EXPORT void reset_coords (GSimpleAction * action, GVariant * parameter, gpointer data)
3905#else
3914G_MODULE_EXPORT void reset_coords (GtkWidget * widg, gpointer data)
3915#endif
3916{
3917 glwin * view = (glwin *)data;
3919 int shaders[5] = {ATOMS, BONDS, POLYS, RINGS, SELEC};
3921 view -> create_shaders[MEASU] = TRUE;
3922 view -> create_shaders[PICKS] = TRUE;
3923 init_coordinates (get_project_by_id(view -> proj), 1, FALSE, TRUE);
3924 update (view);
3925}
3926
3927#ifdef GTK4
3937G_MODULE_EXPORT void turn_rebuild (GSimpleAction * action, GVariant * parameter, gpointer data)
3938#else
3947G_MODULE_EXPORT void turn_rebuild (GtkWidget * widg, gpointer data)
3948#endif
3949{
3950 tint * dat =(tint *)data;
3951 glwin * view = get_project_by_id(dat -> a) -> modelgl;
3952#ifdef GTK4
3953 view -> rebuild[dat -> b][0] = ! view -> rebuild[dat -> b][0];
3954 view -> rebuild[dat -> b][1] = view -> rebuild[dat -> b][0];
3955 update_menu_bar (view);
3956#else
3957 view -> rebuild[dat -> b][0] = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
3958 view -> rebuild[dat -> b][1] = view -> rebuild[dat -> b][0];
3959 if (widg != view -> rbuild[dat -> b])
3960 {
3961 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> rbuild[dat -> b], view -> rebuild[dat -> b][0]);
3962 }
3963#endif
3964}
3965
3974G_MODULE_EXPORT void to_center_this_molecule (GtkWidget * widg, gpointer data)
3975{
3976 glwin * view = (glwin *)data;
3977 gboolean center = ! get_project_by_id(view -> proj) -> cell.crystal ? TRUE :
3978 ask_yes_no ("Center crystal atom(s)", "Are you sure, this can affect the visual representation of the unit cell ?", GTK_MESSAGE_QUESTION, view -> win);
3979 if (center) center_this_molecule (view);
3980}
3981
3982#ifdef GTK4
3990GMenu * tools_section (glwin * view)
3991{
3992 GMenu * menu = g_menu_new ();
3993 append_submenu (menu, "Tools", menu_tools(view, 1));
3994 return menu;
3995}
3996
4004GMenu * anim_section (glwin * view)
4005{
4006 GMenu * menu = g_menu_new ();
4007 append_submenu (menu, "Animate", menu_anim(view, 1));
4008 return menu;
4009}
4010
4019void analyze_menu_attach_color_palettes (glwin * view, GtkWidget * menu)
4020{
4021 /* Here we need to attached color palettes for:
4022 - Box
4023 - Atoms
4024 - Clones
4025 - Total coordination(s)
4026 - Partial coordination(s)
4027 - Fragment(s) and molecule(s)
4028 - Ring(s)
4029 - Background
4030 This is a work in progress since the 'gtk_popover_menu_bar_add_child' to use to insert widget is bugged:
4031 https://gitlab.gnome.org/GNOME/gtk/-/issues/5955
4032 */
4033 int i, j, k, l, m;
4034 gchar * str;
4035 project * this_proj = get_project_by_id (view -> proj);
4036 // Box
4037 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -1, -1, -1), "set-box-color.0"))
4038 {
4039 g_debug ("Color palette error: box - custom= set-box-color.0");
4040 }
4041 // Atom(s) and clone(s)
4042 for (i=0; i<2; i++)
4043 {
4044 for (j=0; j<this_proj -> nspec; j++)
4045 {
4046 str = g_strdup_printf ("set-%s.%d", (! i) ? "atom-color" : "clone-color", j);
4047 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i*this_proj -> nspec+j, -1, -1), (const gchar *)str))
4048 {
4049 g_debug ("Color palette error: %s - %d - custom= %s", (! i) ? "atom-color" : "clone-color", j+1, str);
4050 }
4051 g_free (str);
4052 }
4053 }
4054 // Coordinations
4055 for (i=0; i<2; i++)
4056 {
4057 if (this_proj -> coord -> ntg[i])
4058 {
4059 for (j=0; j<this_proj -> nspec; j++)
4060 {
4061 for (k=0; k<this_proj -> coord -> ntg[i][j]; k++)
4062 {
4063 m = 0;
4064 for (l=0; l<j; l++)
4065 {
4066 m += this_proj -> coord -> ntg[i][l];
4067 }
4068 if (i)
4069 {
4070 str = g_strdup_printf ("set-%s-c.%d", exact_name (env_name (this_proj, k, j, 1, NULL)), m);
4071 }
4072 else
4073 {
4074 str = g_strdup_printf ("set-%d-c.%d", this_proj -> coord -> geolist[i][j][k], m);
4075 }
4076 m += (i) ? this_proj -> coord -> totcoord[0] : 0;
4077 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+m, -1, -1), (const gchar *)str))
4078 {
4079 g_debug ("Color palette error: %s - spec= %d - coord= %d, custom= %s", (! i) ? "total-coord" : "partial-coord", j+1, k+1, str);
4080 }
4081 g_free (str);
4082 }
4083 }
4084 }
4085 }
4086 // Fragment(s) and molecule(s)
4087 for (i=2; i<4; i++)
4088 {
4089 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
4090 {
4091 str = g_strdup_printf ("set-%s-%d", (i == 2) ? "fcol" : "mcol", j);
4092 k = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + j;
4093 if (i == 3) k += this_proj -> coord -> totcoord[2];
4094 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, k, i, 0), (const gchar *)str))
4095 {
4096 g_debug ("Color palette error: %s - %d, custom= %s", (i == 2) ? "fragment" : "molecule", j+1, str);
4097 }
4098 g_free (str);
4099 }
4100 }
4101 // Rings
4102 for (i=4; i<9; i++)
4103 {
4104 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
4105 {
4106 str = g_strdup_printf ("set-rcol-%d-%d", i, j);
4107 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -3, i-4, 0), (const gchar *)str))
4108 {
4109 g_debug ("Color palette error: rings - %d - %d, custom= %s", i, j+1, str);
4110 }
4111 g_free (str);
4112 }
4113 }
4114 // Background
4115 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -2, -1, -1), "set-back-color.0"))
4116 {
4117 g_debug ("Color palette error: background - custom= set-back-color.0");
4118 }
4119}
4120#endif
4121
4131void popup_main_menu (glwin * view, double ptx, double pty)
4132{
4133 GtkWidget * menu;
4134 opengl_project_changed (view -> proj);
4135#ifdef GTK4
4136 if (view_pop_actions) g_object_unref (view_pop_actions);
4137 view_pop_actions = g_simple_action_group_new ();
4138 GMenu * gmenu = g_menu_new ();
4139 if (view -> mode == ANALYZE)
4140 {
4141 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_opengl_menu(view, 1));
4142 if (get_project_by_id(view -> proj) -> natomes)
4143 {
4144 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_model_menu(view, 1));
4145 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_coord_menu(view, 1));
4146 }
4147 g_menu_append_section (gmenu, NULL, (GMenuModel *)tools_section(view));
4148 g_menu_append_section (gmenu, NULL, (GMenuModel *)menu_view(view, 1));
4149 g_menu_append_section (gmenu, NULL, (GMenuModel *)anim_section(view));
4150 }
4151 else
4152 {
4153 g_menu_append_section (gmenu, NULL, (GMenuModel *)tools_section(view));
4154 append_submenu (gmenu, "Insert", add_edition_sub_menu (view, "ins", 0, G_CALLBACK(to_add_object), & view -> colorp[0][0]));
4155 if (opengl_project -> steps == 1) g_menu_append_section (gmenu, NULL, (GMenuModel *)extract_section(view, 1));
4156 append_opengl_item (view, gmenu, "Reset Motion", "res-mot", 1, 0, NULL, IMG_STOCK, MEDIA_LOOP, FALSE, G_CALLBACK(reset_coords), view, FALSE, FALSE, FALSE, TRUE);
4157 }
4158 g_menu_append_section (gmenu, NULL, (GMenuModel*)menu_reset(view, 1));
4159 g_menu_append_section (gmenu, NULL, (GMenuModel*)menu_fullscreen(view, 1));
4160 g_menu_append_section (gmenu, NULL, (GMenuModel*)menu_shortcuts(view, 1));
4161
4162 menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)gmenu, GTK_POPOVER_MENU_NESTED);
4163 if (view -> mode == ANALYZE) analyze_menu_attach_color_palettes (view, menu);
4164
4165 gtk_popover_present ((GtkPopover *)menu);
4166 gchar * str = g_strdup_printf ("gl-%d", view -> action_id);
4167 gtk_widget_insert_action_group (menu, str, G_ACTION_GROUP(view_pop_actions));
4168 g_free (str);
4169 gtk_widget_set_parent (menu, view -> win);
4170 gtk_widget_set_size_request (menu, -1, (view -> mode == ANALYZE) ? 742 : 242);
4171 pop_menu_at_pointer (menu, ptx, pty);
4172#else
4173 menu = gtk_menu_new ();
4174 GtkWidget * item;
4175 if (view -> mode == ANALYZE)
4176 {
4177 menu_items_opengl (menu, view, 1);
4178 add_menu_separator (menu);
4179 if (get_project_by_id(view -> proj) -> nspec)
4180 {
4181 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Atom(s)", TRUE, menu_atoms (view, 1, 0)));
4182 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Bond(s)", TRUE, menu_bonds (view, 1, 0)));
4183 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Clone(s)", TRUE, menu_clones (view, 1)));
4184 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_box_axis (view, 1, 0));
4185 add_menu_separator (menu);
4186 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_coord (view, 1));
4187 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Polyhedra", TRUE, menu_poly (view, 1)));
4188 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Rings", view -> rings, menu_rings (view, 1)));
4189 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Chain(s)", view -> chains, add_menu_coord (view, 1, 9)));
4190 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Fragment(s)", opengl_project -> coord -> totcoord[2], add_menu_coord (view, 1, 2)));
4191 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Molecule(s)", opengl_project -> coord -> totcoord[3], add_menu_coord (view, 1, 3)));
4192 gtk3_menu_item (menu, "Advanced", IMG_NONE, NULL, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
4193 // add_advanced_item (menu, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK);
4194 add_menu_separator (menu);
4195 }
4196 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Tools", TRUE, menu_tools(view, 1)));
4197 add_menu_separator (menu);
4198 menu_items_view (menu, view, 1);
4199 add_menu_separator (menu);
4200 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_anim (view, 1));
4201 }
4202 else
4203 {
4204 item = create_menu_item (TRUE, "Tools");
4205 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu_tools(view, 1));
4206 gtk_menu_shell_append ((GtkMenuShell *)menu, item);
4207 add_menu_separator (menu);
4208
4209 item = create_menu_item (TRUE, "Insert");
4210 add_edition_sub_menu (item, G_CALLBACK(to_add_object), & view -> colorp[0][0]);
4211 gtk_menu_shell_append ((GtkMenuShell *)menu, item);
4212 add_menu_separator (menu);
4213
4214 if (opengl_project -> steps == 1)
4215 {
4216 gtk3_menu_item (menu, "Extract/Rebuild on Motion", IMG_STOCK, (gpointer)ECUT, G_CALLBACK(turn_rebuild), & view -> colorp[0][0], FALSE, 0, 0, TRUE, FALSE, view -> rebuild[0][0]);
4217 gtk3_menu_item (menu, "Extract/Rebuild on Copy", IMG_STOCK, (gpointer)ECUT, G_CALLBACK(turn_rebuild), & view -> colorp[1][0], FALSE, 0, 0, TRUE, FALSE, view -> rebuild[1][0]);
4218 }
4219 gtk3_menu_item (menu, "Reset Motion", IMG_STOCK, (gpointer)MEDIA_LOOP, G_CALLBACK(reset_coords), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4220 }
4221 add_menu_separator (menu);
4222 gtk3_menu_item (menu, "Reset View", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_reset_view), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4223 gtk3_menu_item (menu, "Center Molecule", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_center_this_molecule), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4224 add_menu_separator (menu);
4225 if (! view -> fullscreen)
4226 {
4227 gtk3_menu_item (menu, "Fullscreen", IMG_STOCK, (gpointer)FULLSCREEN, G_CALLBACK(set_full_screen), (gpointer)view, TRUE, GDK_KEY_f, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
4228 }
4229 else
4230 {
4231 gtk3_menu_item (menu, "Exit Fullscreen", IMG_STOCK, (gpointer)FULLSCREEN, G_CALLBACK(set_full_screen), (gpointer)view, TRUE, GDK_KEY_Escape, 0, FALSE, FALSE, FALSE);
4232 }
4233 add_menu_separator (menu);
4234 gtk3_menu_item (menu, "Shortcuts", IMG_NONE, NULL, G_CALLBACK(view_shortcuts), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4235 pop_menu_at_pointer (menu, NULL);
4236#endif
4237}
void prepare_atom_edition(gpointer data, gboolean visible)
prepare atom edition
Definition atom_edit.c:459
void clean_other_window_after_edit(project *this_proj)
update other windows after model edition if required
Definition atom_edit.c:110
gchar * action_atoms[3]
Definition atom_edit.c:61
Function declarations for the mode edition window.
atomic_object * create_object_from_selection(project *this_proj)
create object from atom selection
void init_coordinates(project *this_proj, int status, gboolean win, gboolean init)
preserve atomic coordinates
Definition atom_move.c:197
int get_selected_object_id(gboolean visible, int p, gchar *str, atom_search *asearch)
get the id of the object selected (in contextual menu, or in combo box)
Definition w_search.c:2385
tint ulam_coord(glwin *view)
shift insertion position for object not to have overlapping objects for multiple/repeated insertions
atomic_object * duplicate_atomic_object(atomic_object *old_obj)
duplicate an insert object
void to_insert_in_project(int stat, int orig, project *this_proj, atom_search *asearch, gboolean visible)
to insert object in project
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3717
Binding to the Fortran90 subroutines.
Callback declarations for main window.
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:493
integer function chains()
Definition chains.F90:54
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
GtkWidget * color_box(glwin *view, int ideo, int spec, int geo)
create the color palette pointers and menus GTK3 version
Definition color_box.c:254
Structure definitions for color management Function declarations for color management.
color colorp[64]
G_MODULE_EXPORT void window_color_coord(GtkWidget *widg, gpointer data)
create a window to select a color callback GTK3
Definition w_colors.c:285
G_MODULE_EXPORT void to_run_atom_color_window(GtkWidget *widg, gpointer data)
to run atom color selection window callback GTK3
Definition w_colors.c:223
gchar * param[2]
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
double dist
Definition d_measures.c:73
atom_in_selection * tmp_a
Definition d_measures.c:69
int atoms[NUM_STYLES][2]
int bonds[NUM_STYLES][2]
GtkTreeSelection * sel
Definition datab.c:102
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
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
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
int activep
Definition global.c:159
int * pasted_todo
Definition global.c:174
int nprojects
Definition global.c:158
gboolean selected_status
Definition global.c:187
gboolean column_label
Definition global.c:184
gboolean check_label
Definition global.c:185
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
@ IMG_STOCK
Definition global.h:264
glwin * active_glwin
Definition project.c:53
GtkWidget * create_menu_item_from_widget(GtkWidget *widg, gboolean check, gboolean radio, gboolean status)
#define FITBEST
Definition global.h:199
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)
cell_info * active_cell
Definition project.c:50
#define MEDIA_LOOP
Definition global.h:189
project * proj
chemical_data * active_chem
Definition project.c:48
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
void pop_menu_at_pointer(GtkWidget *widg, GdkEvent *event)
popup a menu at pointer location
Definition gtk-misc.c:2301
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
#define CHEM_PARAMS
Definition global.h:296
#define RI
Definition global.h:328
box_info * active_box
Definition project.c:51
#define BD
Definition global.h:326
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1585
project * opengl_project
Definition project.c:54
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
#define FULLSCREEN
Definition global.h:198
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
tint cut_sel
Definition gui.c:144
#define ECUT
Definition global.h:205
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
void add_menu_separator(GtkWidget *menu)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
#define SP
Definition global.h:330
project * active_project
Definition project.c:47
atomic_object * copied_object
Definition glwindow.c:123
#define CH
Definition global.h:329
image * active_image
Definition project.c:52
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
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
Definition glview.c:1522
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
action
Definition glview.h:189
gboolean is_coord_in_menu(int id, project *this_proj)
is this coordination in a menu ?
Definition m_coord.c:74
gboolean pick
void update_all_menus(glwin *view, int nats)
update all menus of the OpenGL window
Definition glwindow.c:337
@ ANALYZE
Definition glview.h:157
@ EDITION
Definition glview.h:158
int step
Definition ogl_draw.c:70
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
@ REPLACE
Definition glview.h:225
@ REMOVE
Definition glview.h:226
@ INSERT
Definition glview.h:227
@ SPACEFILL
Definition glview.h:175
@ NONE
Definition glview.h:172
#define FILLED_STYLES
Definition glwin.h:105
char * text_filled[FILLED_STYLES]
Definition m_style.c:61
#define OGL_STYLES
Definition glwin.h:106
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ PICKS
Definition glwin.h:97
@ LABEL
Definition glwin.h:98
@ POLYS
Definition glwin.h:92
@ SELEC
Definition glwin.h:91
@ MEASU
Definition glwin.h:99
@ ATOMS
Definition glwin.h:89
@ RINGS
Definition glwin.h:96
#define NSELECTION
Definition glwin.h:67
char * text_styles[OGL_STYLES]
Definition m_style.c:54
G_MODULE_EXPORT void to_reset_view(GtkWidget *widg, gpointer data)
reset view callback - GTK3
Definition m_rep.c:200
Function declarations for the creation of the OpenGL window.
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 init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:72
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:234
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
GMenu * menu_anim(glwin *view, int popm)
create the 'Animate' submenu elements
Definition m_anim.c:139
GMenu * menu_atoms(glwin *view, int popm, int at)
create the 'Atom(s)' submenu elements
Definition m_atoms.c:797
GMenu * menu_bonds(glwin *view, int popm, int at)
create the 'Bond(s)' submenu GTK4
Definition m_bonds.c:367
GMenuItem * menu_box_axis(glwin *view, int popm, int ab)
create the 'Model -> Box' and 'View -> Axis' submenus GTK4
Definition m_box.c:470
GMenu * menu_clones(glwin *view, int popm)
create the 'Clone(s)' submenu GTK4
Definition m_clones.c:180
GMenu * menu_coord(glwin *view, int popm)
create the 'Coordination' submenu GTK4
Definition m_coord.c:689
GMenu * menu_rings(glwin *view, int popm)
create the 'Ring(s)' submenu GTK4
Definition m_coord.c:705
GMenu * add_menu_coord(glwin *view, int popm, int id)
create a coordination type submenu
Definition m_coord.c:652
GMenu * color_item(glwin *view, gchar *act, int popm, int id, GCallback handler, gpointer data)
create a submenu to attach a color palette
Definition m_coord.c:479
GMenu * extract_section(glwin *view, int popm)
create the 'Extract/Rebuild' menu items GTK4
Definition m_edit.c:332
GMenu * menu_poly(glwin *view, int popm)
create the 'Chemistry -> Polyehdra' submenu - GTK4
Definition m_poly.c:490
GMenu * menu_fullscreen(glwin *view, int popm)
create the 'Fullscreen' menu item - GTK4
Definition m_rep.c:564
GMenu * menu_reset(glwin *view, int popm)
create the reset menu items - GTK4
Definition m_rep.c:548
GMenu * menu_view(glwin *view, int popm)
create the 'View' submenu - GTK4
Definition m_rep.c:579
GMenu * menu_tools(glwin *view, int popm)
create the 'Tools' submenu - GTK4
Definition m_tools.c:770
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
void alloc_proj_data(project *this_proj, int cid)
allocate data
Definition open_p.c:206
GtkWidget * selection_menu(glwin *view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
create popup submenu GTK3
Definition popup.c:3328
G_MODULE_EXPORT void remove_the_coord(GtkWidget *widg, gpointer data)
remove a type of coordination callback GTK3
Definition popup.c:1668
int action_atoms_from_project(project *this_proj, atom_search *asearch, gboolean visible)
apply atom edition action to project (motion, remove, replace, insert, random move)
atom_search * free_this_search_data(atom_search *this_search)
free atom search data structure
Definition popup.c:285
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
Definition w_coord.c:1469
atom_search * remove_search
Definition popup.c:175
void create_new_project_using_data(atom_selection *selection)
create new project using an atom selection
Definition popup.c:2059
int get_style(gchar *str)
get OpenGL rendering style id
Definition popup.c:254
G_MODULE_EXPORT void turn_rebuild(GtkWidget *widg, gpointer data)
rebuild menu items callback GTK3
Definition popup.c:3947
G_MODULE_EXPORT void to_center_this_molecule(GtkWidget *widg, gpointer data)
center this molecule menu item callback GTK4
Definition popup.c:3974
G_MODULE_EXPORT void select_action_for_all_bonds(GtkWidget *widg, gpointer data)
select action for all bonds based on menu item id callback GTK3
Definition popup.c:2757
gchar * get_object_from_action(GSimpleAction *action)
get object name from action name GTK4
Definition popup.c:393
tint atoid[CONTEXTACT][4]
Definition popup.c:187
G_MODULE_EXPORT void edit_coord(GtkWidget *widg, gpointer data)
create new project using coordination type and id callback GTK3
Definition popup.c:2275
int is_labelled
Definition popup.c:183
GtkWidget * create_selection_item(glwin *view, gchar *str, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data)
create new menu item for the popup menu GTK3
Definition popup.c:3214
G_MODULE_EXPORT void style_this_atom(GtkWidget *widg, gpointer data)
change OpenGL rendering style for this atom callback GTK3
Definition popup.c:1256
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1040
void popup_main_menu(glwin *view, double ptx, double pty)
create the OpenGL window popup menu
Definition popup.c:4131
atom_selection * bond_selection
Definition popup.c:185
G_MODULE_EXPORT void opengl_advanced(GtkWidget *widg, gpointer data)
create OpenGL rendering advanced window
Definition w_advance.c:1477
int selected_bspec
Definition popup.c:181
G_MODULE_EXPORT void select_unselect_this_atom(GtkWidget *widg, gpointer data)
select / unselect this atom callback GTK3
Definition popup.c:1177
void check_hidden_visible(project *this_proj)
check how many atom(s) are visible
Definition popup.c:869
GtkWidget * field_atom_menu(int p, int s, int a, int f)
void apply_project(gboolean showtools)
get project ready for calculation and initialize the OpenGL window
Definition callbacks.c:665
void to_remove_this_object(int type, gpointer data)
remove a type of object
Definition popup.c:312
int inserted_from_lib
Definition w_library.c:295
void reset_coordinates(project *this_proj, int status)
reset transformation and restore saved atomic coordinates
Definition atom_move.c:143
G_MODULE_EXPORT void remove_this_atom(GtkWidget *widg, gpointer data)
remove this atom callback GTK3
Definition popup.c:648
int is_selected
Definition popup.c:182
G_MODULE_EXPORT void select_action_for_all(GtkWidget *widg, gpointer data)
select action for all object(s) callback GTK3
Definition popup.c:2392
G_MODULE_EXPORT void replace_the_coord(GtkWidget *widg, gpointer data)
replace a coordination callback GTK3
Definition popup.c:1697
G_MODULE_EXPORT void reset_coords(GtkWidget *widg, gpointer data)
reset coordinates menu item callback GTK3
Definition popup.c:3914
G_MODULE_EXPORT void show_hide_others(GtkWidget *widg, gpointer data)
show all hidden / hide all visible atom(s) callback GTK3
Definition popup.c:1413
void popup_selection(glwin *view, double ptx, double pty, int spe, int mmod, int ati, int bti, int aoc)
create the contextual popup menu, right click on atom or bond
Definition popup.c:3666
void insert_object(int action, gpointer data)
insert object
Definition popup.c:663
void duplicate_material_and_lightning(image *new_img, image *old_img)
copy the material and lightning parameters of an image data structure
Definition ogl_draw.c:180
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
Definition atom_edit.c:392
G_MODULE_EXPORT void set_full_screen(GtkWidget *widg, gpointer data)
set full screen callback GTK3
Definition popup.c:229
G_MODULE_EXPORT void add_object(GtkWidget *widg, gpointer data)
add object call back GTK3
Definition popup.c:713
G_MODULE_EXPORT void label_unlabel_coord(GtkWidget *widg, gpointer data)
label / unlabel a type of coordination callback GTK3
Definition popup.c:1839
G_MODULE_EXPORT void replace_this_atom(GtkWidget *widg, gpointer data)
replace this atom callback GTK3
Definition popup.c:814
dint btoid
Definition popup.c:188
G_MODULE_EXPORT void copy_the_atoms(GtkWidget *widg, gpointer data)
copy selected atom(s) callback GTK3
Definition popup.c:1355
G_MODULE_EXPORT void copy_the_coord(GtkWidget *widg, gpointer data)
copy a coordination callback GTK3
Definition popup.c:1725
G_MODULE_EXPORT void show_hide_this_atom(GtkWidget *widg, gpointer data)
show / hide this atom callback GTK3
Definition popup.c:1019
void to_replace_this_object(int type, GtkWidget *widg, gpointer data)
replace a type of object GTK3
Definition popup.c:466
G_MODULE_EXPORT void label_unlabel_atoms(GtkWidget *widg, gpointer data)
label / unlabel a type of atom(s) callback GTK3
Definition popup.c:1503
int get_to_be_selected(glwin *view)
find which atom(s) are to be selected
Definition popup.c:197
G_MODULE_EXPORT void style_the_atoms(GtkWidget *widg, gpointer data)
change the OpenGL rendering style of a type of atom(s) callback GTK3
Definition popup.c:1617
G_MODULE_EXPORT void style_the_coord(GtkWidget *widg, gpointer data)
change OpenGL rendering style for a type of coordination callback GTK3
Definition popup.c:2007
int selected_atom
Definition popup.c:178
atom_in_selection * new_atom_in_selection(int id, int sp)
create a selected atom
Definition selection.c:428
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1551
void add_style_sub_menu(GtkWidget *item, GCallback handler, gpointer data)
add style submenu to menu item GTK3
Definition popup.c:3050
int is_filled
Definition popup.c:184
int selected_btom
Definition popup.c:179
gchar * mot[2][2]
Definition popup.c:3293
void check_all_trees(project *this_proj)
check all search trees
Definition w_search.c:450
void copy_bond_selection()
copy bond selection
Definition popup.c:581
G_MODULE_EXPORT void select_unselect_coord(GtkWidget *widg, gpointer data)
select / unselect a type of coordination callback GTK3
Definition popup.c:1915
vec3_t get_bary(project *this_proj, int status)
get barycenter of atomic coordinates
Definition atom_move.c:170
G_MODULE_EXPORT void to_add_object(GtkWidget *widg, gpointer data)
to add object callback GTK3
Definition popup.c:780
G_MODULE_EXPORT void edit_atoms(GtkWidget *widg, gpointer data)
create new project using atomic species callback GTK3
Definition popup.c:2342
void remove_object()
remove object using 'remove_search'
Definition popup.c:603
#define CONTEXTACT
Definition popup.c:152
G_MODULE_EXPORT void render_gl_image(GtkWidget *widg, gpointer data)
render image from the OpenGL window
Definition glwindow.c:429
G_MODULE_EXPORT void show_hide_the_coord(GtkWidget *widg, gpointer data)
show / hide a type of coordination callback GTK3
Definition popup.c:1788
int selected_aspec
Definition popup.c:180
G_MODULE_EXPORT void select_action_for_this_bond(GtkWidget *widg, gpointer data)
selection action for this bond callback GTK3
Definition popup.c:2599
G_MODULE_EXPORT void replace_the_atoms(GtkWidget *widg, gpointer data)
replace selected atom(s) callback GTK3
Definition popup.c:1326
void add_edition_sub_menu(GtkWidget *item, GCallback handler, gpointer data)
add edition submenu to menu item GTK3
Definition popup.c:3111
G_MODULE_EXPORT void view_shortcuts(GSimpleAction *action, GVariant *parameter, gpointer data)
G_MODULE_EXPORT void edit_in_new_project(GtkWidget *widg, gpointer data)
create new project using selection callback GTK3
Definition popup.c:2192
atom_search * insert_search
Definition popup.c:176
G_MODULE_EXPORT void show_hide_the_atoms(GtkWidget *widg, gpointer data)
show / hide a type of atom(s) callback GTK3
Definition popup.c:1456
gboolean insert_this_object
Definition popup.c:691
G_MODULE_EXPORT void label_unlabel_this_atom(GtkWidget *widg, gpointer data)
label / unlabel this atom callback GTK3
Definition popup.c:1128
G_MODULE_EXPORT void copy_this_atom(GtkWidget *widg, gpointer data)
copy this atom callback GTK3
Definition popup.c:842
void prepare_to_instert(gchar *key, project *this_proj, atom_search *asearch, gboolean visible)
prepare to insert something
insertion_menu mol[]
Definition w_library.c:193
gboolean wait_for_style
Definition popup.c:1234
G_MODULE_EXPORT void remove_the_atoms(GtkWidget *widg, gpointer data)
remove selected atom(s) callback GTK3
Definition popup.c:1297
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void active_project_changed(int id)
change the active project
Definition update_p.c:175
Definition global.h:97
int b
Definition global.h:99
int a
Definition global.h:98
Definition glwin.h:875
Definition glwin.h:277
gchar * type
Definition global.h:874
gchar * object
Definition global.h:875
coord_info * coord
Definition global.h:956
int id
Definition global.h:941
Definition global.h:104
int b
Definition global.h:106
int c
Definition global.h:107
int a
Definition global.h:105
Function declarations for the creation of the OpenGL window menus.
void menu_items_view(GMenu *menu, glwin *view, int popm)
GMenu * prepare_model_menu(glwin *view, int popm)
GMenu * prepare_coord_menu(glwin *view, int popm)
GMenu * prepare_opengl_menu(glwin *view, int popm)
GMenu * menu_shortcuts(glwin *view, int popm)
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160
int element
Definition w_periodic.c:61
void add_project_to_workspace()
add project(s) to the workspace tree
Definition workspace.c:594
GtkWidget * img
Definition workspace.c:70
GtkWidget * lab
Definition workspace.c:73
Function declarations for workspace managment.