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