atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
popup.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
24/*
25* This file: 'popup.c'
26*
27* Contains:
28*
29
30 - The functions to create the OpenGL window popup menus:
31 - The main popup menu
32 - The contextual, atom or bond related, popup menus
33
34*
35* List of functions:
36
37 int get_to_be_selected (glwin * view);
38 int get_style (gchar * str);
39 int check_label_numbers (project * this_proj, int types);
40
41 gchar * get_object_from_action (GSimpleAction * action);
42
43 void to_remove_this_object (int type, gpointer data);
44 void to_replace_this_object (int type, GSimpleAction * action, gpointer data);
45 void to_replace_this_object (int type, GtkWidget * widg, gpointer data);
46 void copy_bond_selection ();
47 void remove_object ();
48 void insert_object (int action, gpointer data);
49 void check_hidden_visible (project * this_proj);
50 void create_new_project_using_data (atom_selection * selection);
51 void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data);
52 void add_edition_sub_menu (GtkWidget * item, GCallback handler, gpointer data);
53 void create_selection_item (GMenu * menu, glwin * view, gchar * str, gchar * act, int aid, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data);
54 void analyze_popup_attach_color_palettes (glwin * view, GtkWidget * menu, int ato, int spc, int totc, int parc, int frag, int mol);
55 void popup_selection (glwin * view, double ptx, double pty, int spe, int mmod, int ati, int bti, int aoc);
56 void analyze_menu_attach_color_palettes (glwin * view, GtkWidget * menu);
57 void popup_main_menu (glwin * view, double ptx, double pty);
58
59 G_MODULE_EXPORT void set_full_screen (GSimpleAction * action, GVariant * parameter, gpointer data);
60 G_MODULE_EXPORT void set_full_screen (GtkWidget * widg, gpointer data);
61 G_MODULE_EXPORT void remove_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
62 G_MODULE_EXPORT void remove_this_atom (GtkWidget * widg, gpointer data);
63 G_MODULE_EXPORT void add_object (GSimpleAction * action, GVariant * parameter, gpointer data);
64 G_MODULE_EXPORT void add_object (GtkWidget * widg, gpointer data);
65 G_MODULE_EXPORT void to_add_object (GSimpleAction * action, GVariant * parameter, gpointer data);
66 G_MODULE_EXPORT void to_add_object (GtkWidget * widg, gpointer data);
67 G_MODULE_EXPORT void replace_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
68 G_MODULE_EXPORT void replace_this_atom (GtkWidget * widg, gpointer data);
69 G_MODULE_EXPORT void copy_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
70 G_MODULE_EXPORT void copy_this_atom (GtkWidget * widg, gpointer data);
71 G_MODULE_EXPORT void show_hide_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
72 G_MODULE_EXPORT void show_hide_this_atom (GtkWidget * widg, gpointer data);
73 G_MODULE_EXPORT void label_unlabel_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
74 G_MODULE_EXPORT void label_unlabel_this_atom (GtkWidget * widg, gpointer data);
75 G_MODULE_EXPORT void select_unselect_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
76 G_MODULE_EXPORT void select_unselect_this_atom (GtkWidget * widg, gpointer data);
77 G_MODULE_EXPORT void style_this_atom (GSimpleAction * action, GVariant * parameter, gpointer data);
78 G_MODULE_EXPORT void style_this_atom (GtkWidget * widg, gpointer data);
79 G_MODULE_EXPORT void remove_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
80 G_MODULE_EXPORT void remove_the_atoms (GtkWidget * widg, gpointer data);
81 G_MODULE_EXPORT void replace_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
82 G_MODULE_EXPORT void replace_the_atoms (GtkWidget * widg, gpointer data);
83 G_MODULE_EXPORT void copy_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
84 G_MODULE_EXPORT void copy_the_atoms (GtkWidget * widg, gpointer data);
85 G_MODULE_EXPORT void show_hide_others (GSimpleAction * action, GVariant * parameter, gpointer data);
86 G_MODULE_EXPORT void show_hide_others (GtkWidget * widg, gpointer data);
87 G_MODULE_EXPORT void show_hide_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
88 G_MODULE_EXPORT void show_hide_the_atoms (GtkWidget * widg, gpointer data);
89 G_MODULE_EXPORT void label_unlabel_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
90 G_MODULE_EXPORT void label_unlabel_atoms (GtkWidget * widg, gpointer data);
91 G_MODULE_EXPORT void select_unselect_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
92 G_MODULE_EXPORT void select_unselect_atoms (GtkWidget * widg, gpointer data);
93 G_MODULE_EXPORT void style_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
94 G_MODULE_EXPORT void style_the_atoms (GtkWidget * widg, gpointer data);
95 G_MODULE_EXPORT void remove_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
96 G_MODULE_EXPORT void remove_the_coord (GtkWidget * widg, gpointer data);
97 G_MODULE_EXPORT void replace_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
98 G_MODULE_EXPORT void replace_the_coord (GtkWidget * widg, gpointer data);
99 G_MODULE_EXPORT void copy_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
100 G_MODULE_EXPORT void copy_the_coord (GtkWidget * widg, gpointer data);
101 G_MODULE_EXPORT void show_hide_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
102 G_MODULE_EXPORT void show_hide_the_coord (GtkWidget * widg, gpointer data);
103 G_MODULE_EXPORT void label_unlabel_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
104 G_MODULE_EXPORT void label_unlabel_coord (GtkWidget * widg, gpointer data);
105 G_MODULE_EXPORT void select_unselect_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
106 G_MODULE_EXPORT void select_unselect_coord (GtkWidget * widg, gpointer data);
107 G_MODULE_EXPORT void style_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
108 G_MODULE_EXPORT void style_the_coord (GtkWidget * widg, gpointer data);
109 G_MODULE_EXPORT void edit_in_new_project (GSimpleAction * action, GVariant * parameter, gpointer data);
110 G_MODULE_EXPORT void edit_in_new_project (GtkWidget * widg, gpointer data);
111 G_MODULE_EXPORT void edit_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
112 G_MODULE_EXPORT void edit_coord (GtkWidget * widg, gpointer data);
113 G_MODULE_EXPORT void edit_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
114 G_MODULE_EXPORT void edit_atoms (GtkWidget * widg, gpointer data);
115 G_MODULE_EXPORT void select_action_for_all (GSimpleAction * action, GVariant * parameter, gpointer data);
116 G_MODULE_EXPORT void select_action_for_all (GtkWidget * widg, gpointer data);
117 G_MODULE_EXPORT void select_action_for_this_bond (GSimpleAction * action, GVariant * parameter, gpointer data);
118 G_MODULE_EXPORT void select_action_for_this_bond (GtkWidget * widg, gpointer data);
119 G_MODULE_EXPORT void select_action_for_all_bonds (GSimpleAction * action, GVariant * parameter, gpointer data);
120 G_MODULE_EXPORT void select_action_for_all_bonds (GtkWidget * widg, gpointer data);
121 G_MODULE_EXPORT void reset_coords (GSimpleAction * action, GVariant * parameter, gpointer data);
122 G_MODULE_EXPORT void reset_coords (GtkWidget * widg, gpointer data);
123 G_MODULE_EXPORT void turn_rebuild (GSimpleAction * action, GVariant * parameter, gpointer data);
124 G_MODULE_EXPORT void turn_rebuild (GtkWidget * widg, gpointer data);
125 G_MODULE_EXPORT void to_center_this_molecule (GtkWidget * widg, gpointer data);
126
127 GtkWidget * create_selection_item (glwin * view, gchar * str, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data);
128 GtkWidget * selection_menu (glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c);
129
130 GMenu * add_edition_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data);
131 GMenu * add_style_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data);
132 GMenu * selection_menu (int aid, glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c);
133 GMenu * tools_section (glwin * view);
134 GMenu * anim_section (glwin * view);
135
136 atom_search * free_this_search_data (atom_search * this_search);
137
138*/
139
140#include "global.h"
141#include "callbacks.h"
142#include "interface.h"
143#include "workspace.h"
144#include "project.h"
145#include "glview.h"
146#include "glwindow.h"
147#include "submenus.h"
148#include "color_box.h"
149#include "bind.h"
150#include "atom_edit.h"
151
152#define CONTEXTACT 12
153
154extern atom_search * allocate_atom_search (int proj, int action, int searchid, int tsize);
155extern void check_all_trees (project * this_proj);
156extern int action_atoms_from_project (project * this_proj, atom_search * asearch, gboolean visible);
157extern G_MODULE_EXPORT void opengl_advanced (GtkWidget * widg, gpointer data);
158extern G_MODULE_EXPORT void render_gl_image (GtkWidget * widg, gpointer data);
159extern G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data);
160extern void apply_project (gboolean showtools);
161extern GtkWidget * field_atom_menu (int p, int s, int a, int f);
162extern void reset_coordinates (project * this_proj, int status);
163extern vec3_t get_bary (project * this_proj, int status);
164extern void prepare_to_instert (gchar * key, project * this_proj, atom_search * asearch, gboolean visible);
165extern insertion_menu mol[];
166extern atom_in_selection * new_atom_in_selection (int id, int sp);
167extern int inserted_from_lib;
168extern void duplicate_material_and_lightning (image * new_img, image * old_img);
169#ifdef GTK4
170extern GSimpleActionGroup * view_pop_actions;
171extern G_MODULE_EXPORT void window_color_coord (GSimpleAction * action, GVariant * parameter, gpointer data);
172extern GtkWidget * color_palette (glwin * view, int ideo, int spec, int geo);
173#endif
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 gtk_widget_hide (view -> menu_bar);
236 view -> fullscreen = TRUE;
237 }
238 else
239 {
240 gtk_window_unfullscreen (GTK_WINDOW(view -> win));
241 gtk_widget_show (view -> menu_bar);
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) atof ((const gchar *)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 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 (sel -> a == 2 || (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, k;
1792 for (i=0; i<opengl_project -> steps; i++)
1793 {
1794 k = 0;
1795 for (j=0; j<opengl_project -> natomes; j++)
1796 {
1797 if (sel -> a < 2)
1798 {
1799 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1800 {
1801 opengl_project -> atoms[i][j].show[0] = sel -> c;
1802 opengl_project -> atoms[i][j].show[1] = sel -> c;
1803 }
1804 }
1805 else
1806 {
1807 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1808 {
1809 opengl_project -> atoms[i][j].show[0] = sel -> c;
1810 opengl_project -> atoms[i][j].show[1] = sel -> c;
1811 k ++;
1812 }
1813 }
1814 }
1815 }
1818}
1819
1820#ifdef GTK4
1830G_MODULE_EXPORT void label_unlabel_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1831#else
1840G_MODULE_EXPORT void label_unlabel_coord (GtkWidget * widg, gpointer data)
1841#endif
1842{
1843 tint * sel = (tint * )data;
1844 int i, j, k, l, m;
1845 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
1846 for (i=0; i<opengl_project -> steps; i++)
1847 {
1848 for (j=0; j<opengl_project -> natomes; j++)
1849 {
1850 if (sel -> a < 2)
1851 {
1852 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1853 {
1854 opengl_project -> atoms[i][j].label[0] = sel -> c;
1855 opengl_project -> atoms[i][j].label[1] = sel -> c;
1856 if (opengl_project -> modelgl -> selection_mode == 1)
1857 {
1858 for (l=0; l<opengl_project -> atoms[i][j].numv; l++)
1859 {
1860 m = opengl_project -> atoms[i][j].vois[l];
1861 opengl_project -> atoms[i][m].label[0] = sel -> c;
1862 opengl_project -> atoms[i][m].label[1] = sel -> c;
1863 }
1864 }
1865 }
1866 }
1867 else if (sel -> a < 4)
1868 {
1869 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1870 {
1871 opengl_project -> atoms[i][j].label[0] = sel -> c;
1872 opengl_project -> atoms[i][j].label[1] = sel -> c;
1873 }
1874 }
1875 else
1876 {
1877 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
1878 {
1879 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
1880 {
1881 opengl_project -> atoms[i][j].label[0] = sel -> c;
1882 opengl_project -> atoms[i][j].label[1] = sel -> c;
1883 }
1884 }
1885 }
1886 }
1887 }
1888 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1889 if (check_label)
1890 {
1891 opengl_project -> modelgl -> labelled = check_label_numbers (opengl_project, 2);
1892 update (opengl_project -> modelgl);
1893 }
1894}
1895
1896#ifdef GTK4
1906G_MODULE_EXPORT void select_unselect_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1907#else
1916G_MODULE_EXPORT void select_unselect_coord (GtkWidget * widg, gpointer data)
1917#endif
1918{
1919 tint * sel = (tint * )data;
1920 int h, i, j, k;
1921 h = get_to_be_selected (opengl_project -> modelgl);
1922 save_all_selections (opengl_project -> modelgl, h);
1923 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
1924 for (i=0; i<opengl_project -> steps; i++)
1925 {
1926 for (j=0; j<opengl_project -> natomes; j++)
1927 {
1928 if (sel -> a < 2)
1929 {
1930 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1931 {
1932 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1933 {
1934 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1935 }
1936 else
1937 {
1938 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1939 }
1940 }
1941 }
1942 else if (sel -> a < 4)
1943 {
1944 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
1945 {
1946 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1947 {
1948 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1949 }
1950 else
1951 {
1952 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1953 }
1954 }
1955 }
1956 else
1957 {
1958 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
1959 {
1960 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
1961 {
1962 if (i == opengl_project -> modelgl -> anim -> last -> img -> step)
1963 {
1964 if (opengl_project -> atoms[i][j].pick[h] != sel -> c) process_selected_atom (opengl_project, opengl_project -> modelgl, j, 0, 0, h);
1965 }
1966 else
1967 {
1968 opengl_project -> atoms[i][j].pick[h] = sel -> c;
1969 }
1970 }
1971 }
1972 }
1973 }
1974 }
1975 update_all_selections (opengl_project -> modelgl, h);
1976 int shader[1] = {SELEC};
1978 opengl_project -> modelgl -> create_shaders[LABEL] = TRUE;
1979 opengl_project -> modelgl -> create_shaders[MEASU] = TRUE;
1980 if (opengl_project -> modelgl -> mode == EDITION)
1981 {
1982 if (opengl_project -> modelgl -> rebuild[0][1]) opengl_project -> modelgl -> rebuild[0][0] = TRUE;
1983 if (opengl_project -> modelgl -> rebuild[1][1]) opengl_project -> modelgl -> rebuild[1][0] = TRUE;
1984 }
1985 update (opengl_project -> modelgl);
1986}
1987
1988#ifdef GTK4
1998G_MODULE_EXPORT void style_the_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
1999#else
2008G_MODULE_EXPORT void style_the_coord (GtkWidget * widg, gpointer data)
2009#endif
2010{
2011 tint * sel = (tint * )data;
2012 int i, j, k, l;
2013 if (sel -> a > 3) k = opengl_project -> coord -> geolist[sel -> a][0][sel -> b] - 1;
2014#ifdef GTK4
2015 l = get_style ((gchar *)g_action_get_name(G_ACTION(action)));
2016#else
2017 l = get_style ((char *)gtk_menu_item_get_label (GTK_MENU_ITEM(widg)));
2018#endif
2019 for (i=0; i<opengl_project -> steps; i++)
2020 {
2021 for (j=0; j<opengl_project -> natomes; j++)
2022 {
2023 if (sel -> a < 2)
2024 {
2025 if (opengl_project -> atoms[i][j].sp == selected_aspec && opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
2026 {
2027 opengl_project -> atoms[i][j].style = l;
2028 }
2029 }
2030 else if (sel -> a < 4)
2031 {
2032 if (opengl_project -> atoms[i][j].coord[sel -> a] == sel -> b)
2033 {
2034 opengl_project -> atoms[i][j].style = l;
2035 }
2036 }
2037 else
2038 {
2039 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k])
2040 {
2041 if (opengl_project -> atoms[i][j].rings[sel -> a-4][k][0])
2042 {
2043 opengl_project -> atoms[i][j].style = l;
2044 }
2045 }
2046 }
2047 }
2048 }
2050 update (opengl_project -> modelgl);
2051}
2052
2061{
2062 int i, j, k, l;
2063 int nspec = 0;
2064 int * pos_sp, * specs;
2065 atom_in_selection * tmp;
2066
2067 pos_sp = allocint (opengl_project -> nspec);
2068 specs = allocint (opengl_project -> nspec);
2069 for (i=0; i<opengl_project -> nspec; i++)
2070 {
2071 specs[i] = 0;
2072 pos_sp[i] = -1;
2073 }
2074
2075 tmp = selection -> first;
2076 j = -1;
2077 for (i=0; i<selection -> selected; i++)
2078 {
2079 specs[tmp -> sp] ++;
2080 if (pos_sp[tmp -> sp] < 0)
2081 {
2082 j ++;
2083 pos_sp[tmp -> sp] = j;
2084 }
2085 if (tmp -> next != NULL) tmp = tmp -> next;
2086 }
2087
2088 for (i=0; i<opengl_project -> nspec; i++) if (specs[i] > 0) nspec ++;
2089
2090 init_project (TRUE);
2091 active_project -> nspec = nspec;
2092 active_project -> natomes = selection -> selected;
2093 active_project -> steps = 1;
2096
2097 if (active_project -> natomes == opengl_project -> natomes)
2098 {
2099 active_cell -> ltype = opengl_project -> cell.ltype;
2100 active_cell -> pbc = opengl_project -> cell.pbc;
2101 k = (active_cell -> npt) ? opengl_project -> modelgl -> anim -> last -> img -> step : 0;
2102 for (i=0; i<3; i++)
2103 {
2104 for (j=0; j<3; j++)
2105 {
2106 if (i < 2) active_box -> param[i][j] = opengl_project -> cell.box[k].param[i][j];
2107 active_box -> vect[i][j] = opengl_project -> cell.box[k].vect[i][j];
2108 }
2109 }
2110 }
2111
2112 for (i=0; i<opengl_project -> nspec; i++)
2113 {
2114 if (pos_sp[i] > -1)
2115 {
2116 k = pos_sp[i];
2117 active_chem -> label[k] = g_strdup_printf ("%s", opengl_project -> chemistry -> label[i]);
2118 active_chem -> element[k] = g_strdup_printf ("%s", opengl_project -> chemistry -> element[i]);
2119 active_chem -> nsps[k] = specs[i];
2120 for (j=0; j<CHEM_PARAMS; j++) active_chem -> chem_prop[j][k] = opengl_project -> chemistry -> chem_prop[j][i];
2121 for (j=0; j<opengl_project -> nspec; j++)
2122 {
2123 if (pos_sp[j] > -1)
2124 {
2125 l = pos_sp[j];
2126 active_chem -> cutoffs[k][l] = opengl_project -> chemistry -> cutoffs[i][j];
2127 }
2128 }
2129 }
2130 }
2131 active_chem -> grtotcutoff = opengl_project -> chemistry -> grtotcutoff;
2132
2133 tmp = selection -> first;
2134 for (i=0; i<active_project -> steps; i++)
2135 {
2136 tmp = selection -> first;
2137 for (j=0; j<active_project -> natomes; j++)
2138 {
2139 k = tmp -> id;
2140 active_project -> atoms[i][j].id = j;
2141 active_project -> atoms[i][j].sp = pos_sp[tmp -> sp];
2142 active_project -> atoms[i][j].x = opengl_project -> atoms[i][k].x;
2143 active_project -> atoms[i][j].y = opengl_project -> atoms[i][k].y;
2144 active_project -> atoms[i][j].z = opengl_project -> atoms[i][k].z;
2145 active_project -> atoms[i][j].show[0] = TRUE;
2146 active_project -> atoms[i][j].show[1] = TRUE;
2147 active_project -> atoms[i][j].label[0] = FALSE;
2148 active_project -> atoms[i][j].label[1] = FALSE;
2149 active_project -> atoms[i][j].pick[0] = FALSE;
2150 active_project -> atoms[i][j].cloned = FALSE;
2151 // Next line for style, to initialize style use: NONE
2152 active_project -> atoms[i][j].style = opengl_project -> atoms[i][k].style;
2153 if (tmp -> next != NULL) tmp = tmp -> next;
2154 }
2155 }
2156 active_project -> runok[BD] = TRUE;
2157 active_project -> runok[RI] = TRUE;
2158 active_project -> runok[CH] = TRUE;
2159 active_project -> runok[SP] = TRUE;
2162 i = opengl_project -> modelgl -> anim -> last -> img -> style;
2163 apply_project (FALSE);
2164 active_image -> style = i;
2166 g_free (pos_sp);
2167 g_free (specs);
2168 // Duplicate lightning and material
2169 duplicate_material_and_lightning (active_image, opengl_project -> modelgl -> anim -> last -> img);
2171}
2172
2173#ifdef GTK4
2183G_MODULE_EXPORT void edit_in_new_project (GSimpleAction * action, GVariant * parameter, gpointer data)
2184#else
2193G_MODULE_EXPORT void edit_in_new_project (GtkWidget * widg, gpointer data)
2194#endif
2195{
2196 tint * sel = (tint * )data;
2197 int h, i, j;
2198 atom_selection * selected;
2200 selected = g_malloc0 (sizeof*selected);
2201 h = get_to_be_selected (opengl_project -> modelgl);
2202 if (! sel -> b)
2203 {
2204 if (sel -> c)
2205 {
2206 selected = opengl_project -> modelgl -> anim -> last -> img -> selected[h];
2207 }
2208 else
2209 {
2210 selected -> selected = opengl_project -> natomes - opengl_project -> modelgl -> anim -> last -> img -> selected[h] -> selected;
2211 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2212 for (i=0; i<opengl_project -> natomes; i++)
2213 {
2214 if (! opengl_project -> atoms[j][i].pick[h])
2215 {
2216 if (selected -> first)
2217 {
2218 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2219 tmp_a = tmp_a -> next;
2220 }
2221 else
2222 {
2223 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2224 tmp_a = selected -> first;
2225 }
2226 }
2227 }
2228 }
2229 }
2230 else
2231 {
2232 selected -> selected = (is_labelled) ? opengl_project -> modelgl -> labelled : opengl_project -> natomes - opengl_project -> modelgl -> labelled;
2233 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2234 for (i=0; i<opengl_project -> natomes; i++)
2235 {
2236 if (opengl_project -> atoms[j][i].label[0] == is_labelled)
2237 {
2238 if (selected -> first)
2239 {
2240 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2241 tmp_a = tmp_a -> next;
2242 }
2243 else
2244 {
2245 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2246 tmp_a = selected -> first;
2247 }
2248 }
2249 }
2250 }
2251 if (selected -> selected > 0) create_new_project_using_data (selected);
2252 selected = NULL;
2253 g_free (selected);
2254}
2255
2256#ifdef GTK4
2266G_MODULE_EXPORT void edit_coord (GSimpleAction * action, GVariant * parameter, gpointer data)
2267#else
2276G_MODULE_EXPORT void edit_coord (GtkWidget * widg, gpointer data)
2277#endif
2278{
2279 tint * sel = (tint * )data;
2280 int i, j;
2281 atom_selection * selected;
2283 gboolean save_it;
2284
2285 selected = g_malloc0 (sizeof*selected);
2286 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2287 for (i=0; i<opengl_project -> natomes; i++)
2288 {
2289 save_it = FALSE;
2290 if (sel -> a < 2)
2291 {
2292 if (opengl_project -> atoms[j][i].sp == selected_aspec && opengl_project -> atoms[j][i].coord[sel -> a] == sel -> b)
2293 {
2294 save_it = TRUE;
2295 }
2296 }
2297 else
2298 {
2299 if (opengl_project -> atoms[j][i].coord[sel -> a] == sel -> b)
2300 {
2301 save_it = TRUE;
2302 }
2303 }
2304 if (save_it)
2305 {
2306 if (selected -> first)
2307 {
2308 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2309 tmp_a = tmp_a -> next;
2310 }
2311 else
2312 {
2313 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2314 tmp_a = selected -> first;
2315 }
2316 selected -> selected ++;
2317 }
2318 }
2319 if (selected -> selected > 0) create_new_project_using_data (selected);
2320 g_free (selected);
2321}
2322
2323#ifdef GTK4
2333G_MODULE_EXPORT void edit_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
2334#else
2343G_MODULE_EXPORT void edit_atoms (GtkWidget * widg, gpointer data)
2344#endif
2345{
2346 int i, j;
2347 atom_selection * selected;
2349
2350 selected = g_malloc0 (sizeof*selected);
2351 j = opengl_project -> modelgl -> anim -> last -> img -> step;
2352 for (i=0; i<opengl_project -> natomes; i++)
2353 {
2354 if (opengl_project -> atoms[j][i].sp == selected_aspec || selected_aspec == -1)
2355 {
2356 if (selected -> first)
2357 {
2358 tmp_a -> next = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2359 tmp_a = tmp_a -> next;
2360 }
2361 else
2362 {
2363 selected -> first = new_atom_in_selection (i, opengl_project -> atoms[j][i].sp);
2364 tmp_a = selected -> first;
2365 }
2366 selected -> selected ++;
2367 }
2368 }
2369 if (selected -> selected > 0) create_new_project_using_data (selected);
2370 g_free (selected);
2371}
2372
2373#ifdef GTK4
2383G_MODULE_EXPORT void select_action_for_all (GSimpleAction * action, GVariant * parameter, gpointer data)
2384#else
2393G_MODULE_EXPORT void select_action_for_all (GtkWidget * widg, gpointer data)
2394#endif
2395{
2396 int i = GPOINTER_TO_INT(data);
2397 selected_aspec = -1;
2398#ifdef DEBUG
2399 g_debug ("Action for All= %d", i);
2400#endif // DEBUG
2401#ifdef GTK4
2402 switch (i)
2403 {
2404 case 0:
2405 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][1]);
2406 break;
2407 case 1:
2408 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
2409 break;
2410 case 2:
2411 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][1]);
2412 break;
2413 case 3:
2414 label_unlabel_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[0][0]);
2415 break;
2416 case 4:
2417 show_hide_the_atoms (NULL, NULL, & atoid[0][0]);
2418 break;
2419 case 5:
2420 show_hide_the_atoms (NULL, NULL, & atoid[1][1]);
2421 break;
2422 case 6:
2423 style_the_atoms (action, NULL, & atoid[0][1]);
2424 break;
2425 // No case 7 = color
2426 case 8:
2427 edit_in_new_project (NULL, NULL, & opengl_project -> modelgl -> colorp[0][is_selected]);
2428 break;
2429 case 9:
2430 remove_the_atoms (action, NULL, & cut_sel);
2431 break;
2432 case 10:
2433 replace_the_atoms (action, NULL, & cut_sel);
2434 break;
2435 case 11:
2436 copy_the_atoms (action, NULL, & cut_sel);
2437 break;
2438 case CONTEXTACT:
2439 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[1][1]);
2440 break;
2441 case CONTEXTACT+1:
2442 select_unselect_atoms (NULL, NULL, & opengl_project -> modelgl -> colorp[1][0]);
2443 break;
2444 case CONTEXTACT+2:
2445 is_selected = -1;
2446 label_unlabel_atoms (NULL, NULL, & atoid[0][0]);
2447 break;
2448 case CONTEXTACT+3:
2449 is_selected = -1;
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 break;
2501 case 3:
2502 label_unlabel_atoms (NULL, & opengl_project -> modelgl -> colorp[0][0]);
2503 break;
2504 case 4:
2505 show_hide_the_atoms (NULL, & atoid[0][0]);
2506 break;
2507 case 5:
2508 show_hide_the_atoms (NULL, & atoid[1][1]);
2509 break;
2510 case 6:
2511 style_the_atoms (widg, & atoid[0][1]);
2512 break;
2513 // No case 7 = color
2514 case 8:
2515 edit_in_new_project (NULL, & opengl_project -> modelgl -> colorp[0][is_selected]);
2516 break;
2517 case 9:
2518 remove_the_atoms (widg, & cut_sel);
2519 break;
2520 case 10:
2521 replace_the_atoms (widg, & cut_sel);
2522 break;
2523 case 11:
2524 copy_the_atoms (widg, & cut_sel);
2525 break;
2526 case CONTEXTACT:
2527 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[1][1]);
2528 break;
2529 case CONTEXTACT+1:
2530 select_unselect_atoms (NULL, & opengl_project -> modelgl -> colorp[1][0]);
2531 break;
2532 case CONTEXTACT+2:
2533 is_selected = -1;
2534 label_unlabel_atoms (NULL, & atoid[0][0]);
2535 break;
2536 case CONTEXTACT+3:
2537 is_selected = -1;
2538 label_unlabel_atoms (NULL, & atoid[1][0]);
2539 break;
2540 case CONTEXTACT+4:
2541 is_selected = -1;
2542 show_hide_the_atoms (NULL, & atoid[0][0]);
2543 break;
2544 case CONTEXTACT+5:
2545 is_selected = -1;
2546 show_hide_the_atoms (NULL, & atoid[1][0]);
2547 break;
2548 case CONTEXTACT+6:
2549 is_selected = -1;
2550 style_the_atoms (widg, & atoid[0][0]);
2551 break;
2552 case CONTEXTACT+8:
2553 is_selected = -1;
2554 edit_in_new_project (NULL, & opengl_project -> modelgl -> colorp[1][1]);
2555 break;
2556 case CONTEXTACT+9:
2557 is_selected = -1;
2558 remove_the_atoms (widg, & cut_sel);
2559 break;
2560 case CONTEXTACT+10:
2561 is_selected = -1;
2562 replace_the_atoms (widg, & cut_sel);
2563 break;
2564 case CONTEXTACT+11:
2565 is_selected = -1;
2566 copy_the_atoms (widg, & cut_sel);
2567 break;
2568 case 2*CONTEXTACT+4:
2569 is_selected = -1;
2570 show_hide_the_atoms (NULL, & atoid[0][1]);
2571 break;
2572 case 2*CONTEXTACT+5:
2573 is_selected = -1;
2574 show_hide_the_atoms (NULL, & atoid[1][1]);
2575 break;
2576 }
2577#endif
2578}
2579
2580#ifdef GTK4
2590G_MODULE_EXPORT void select_action_for_this_bond (GSimpleAction * action, GVariant * parameter, gpointer data)
2591#else
2600G_MODULE_EXPORT void select_action_for_this_bond (GtkWidget * widg, gpointer data)
2601#endif
2602{
2603 int i, s;
2604 i = GPOINTER_TO_INT(data);
2605#ifdef GTK4
2606 switch (i)
2607 {
2608 case 0:
2609 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2610 select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2611 break;
2612 case 1:
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 2:
2617 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2618 label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2619 break;
2620 case 3:
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 4:
2625 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_atom));
2626 show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(selected_btom));
2627 break;
2628 case 5:
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 6:
2633 style_this_atom (action, NULL, GINT_TO_POINTER(selected_atom));
2634 style_this_atom (action, NULL, GINT_TO_POINTER(selected_btom));
2635 break;
2636 default:
2637 // 8 = create project
2638 // 9 = remove
2639 // 10 = replace
2640 // 11 = copy
2641 bond_selection = g_malloc0(sizeof*bond_selection);
2642 s = opengl_project -> modelgl -> anim -> last -> img -> step;
2644 bond_selection -> selected ++;
2646 bond_selection -> selected ++;
2647 switch (i)
2648 {
2649 case 8:
2651 break;
2652 case 9:
2653 to_remove_this_object (3, NULL);
2654 remove_object ();
2655 break;
2656 case 10:
2657 to_replace_this_object (3, action, data);
2658 to_remove_this_object (3, data);
2659 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
2661 break;
2662 case 11:
2664 break;
2665 }
2666 break;
2667 g_free (bond_selection);
2668 bond_selection = NULL;
2669 }
2670#else
2671 switch (i)
2672 {
2673 case 0:
2674 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2675 select_unselect_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2676 break;
2677 case 1:
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 2:
2682 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2683 label_unlabel_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2684 break;
2685 case 3:
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 4:
2690 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_atom));
2691 show_hide_this_atom (NULL, GINT_TO_POINTER(selected_btom));
2692 break;
2693 case 5:
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 6:
2698 style_this_atom (widg, GINT_TO_POINTER(selected_atom));
2699 style_this_atom (widg, GINT_TO_POINTER(selected_btom));
2700 break;
2701 default:
2702 // 8 = create project
2703 // 9 = remove
2704 // 10 = replace
2705 // 11 = copy
2706 bond_selection = g_malloc0(sizeof*bond_selection);
2707 s = opengl_project -> modelgl -> anim -> last -> img -> step;
2709 bond_selection -> selected ++;
2711 bond_selection -> selected ++;
2712 switch (i)
2713 {
2714 case 8:
2716 break;
2717 case 9:
2718 to_remove_this_object (3, NULL);
2719 remove_object ();
2720 break;
2721 case 10:
2722 to_replace_this_object (3, widg, data);
2723 to_remove_this_object (3, data);
2724 insert_object (1, & opengl_project -> modelgl -> colorp[0][0]);
2726 break;
2727 case 11:
2729 break;
2730 }
2731 break;
2732 g_free (bond_selection);
2733 bond_selection = NULL;
2734 }
2735#endif
2736}
2737
2738#ifdef GTK4
2748G_MODULE_EXPORT void select_action_for_all_bonds (GSimpleAction * action, GVariant * parameter, gpointer data)
2749#else
2758G_MODULE_EXPORT void select_action_for_all_bonds (GtkWidget * widg, gpointer data)
2759#endif
2760{
2761 int g, h, i, j, k, l, m, n, o;
2762 int mid = GPOINTER_TO_INT(data);
2763 int s = opengl_project -> modelgl -> anim -> last -> img -> step;
2764 g = get_to_be_selected (opengl_project -> modelgl);
2765 gboolean doit;
2766 gboolean eqtc, eqpc;
2767 bond_selection = NULL;
2769 if (mid == 6 || mid == 6+CONTEXTACT || mid == 6+2*CONTEXTACT) wait_for_style = TRUE;
2770 for (h=0; h<2; h++)
2771 {
2772 for (i=0; i<opengl_project -> modelgl -> bonds[s][h]; i++)
2773 {
2774 doit = FALSE;
2775 k = opengl_project -> modelgl -> bondid[s][h][i][0];
2776 j = opengl_project -> modelgl -> bondid[s][h][i][1];
2777 l = opengl_project -> atoms[s][k].coord[0];
2778 m = opengl_project -> atoms[s][j].coord[0];
2779 n = opengl_project -> atoms[s][k].coord[1];
2780 o = opengl_project -> atoms[s][j].coord[1];
2781 if ((opengl_project -> atoms[s][j].sp == selected_aspec && opengl_project -> atoms[s][k].sp == selected_bspec) ||
2782 (opengl_project -> atoms[s][k].sp == selected_aspec && opengl_project -> atoms[s][j].sp == selected_bspec)) doit = TRUE;
2783 if (doit)
2784 {
2785 if (opengl_project -> atoms[s][j].sp == selected_aspec && opengl_project -> atoms[s][k].sp == selected_bspec)
2786 {
2787 eqtc = ((l == atoid[0][0].b && m == btoid.a) || (l == btoid.a && m == atoid[0][0].b)) ? TRUE : FALSE;
2788 eqpc = ((n == atoid[0][1].b && o == btoid.b) || (n == btoid.b && o == atoid[0][1].b)) ? TRUE : FALSE;
2789 }
2790 else
2791 {
2792 eqtc = ((l == atoid[0][0].b && m == btoid.a) || (l == btoid.a && m == atoid[0][0].b)) ? TRUE : FALSE;
2793 eqpc = ((n == atoid[0][1].b && o == btoid.b) || (n == btoid.b && o == atoid[0][1].b)) ? TRUE : FALSE;
2794 }
2795#ifdef GTK4
2796 if (mid == 0 || (mid == CONTEXTACT && eqtc) || (mid == 2*CONTEXTACT && eqpc))
2797 {
2798 if (! opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2799 if (! opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2800 }
2801 else if (mid == 1 || (mid == CONTEXTACT+1 && eqtc) || (mid == 2*CONTEXTACT+1 && eqpc))
2802 {
2803 if (opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2804 if (opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2805 }
2806 else if (mid == 2 || (mid == CONTEXTACT+2 && eqtc) || (mid == 2*CONTEXTACT+2 && eqpc))
2807 {
2808 if (! opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2809 if (! opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2810 }
2811 else if (mid == 3 || (mid == CONTEXTACT+3 && eqtc) || (mid == 2*CONTEXTACT+3 && eqpc))
2812 {
2813 if (opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2814 if (opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2815 }
2816 else if (mid == 4 || (mid == CONTEXTACT+4 && eqtc) || (mid == 2*CONTEXTACT+4 && eqpc))
2817 {
2818 if (! opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2819 if (! opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2820 }
2821 else if (mid == 5 || (mid == CONTEXTACT+5 && eqtc) || (mid == 2*CONTEXTACT+5 && eqpc))
2822 {
2823 if (opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(j));
2824 if (opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, NULL, GINT_TO_POINTER(k));
2825 }
2826 else if (mid == 6 || (mid == CONTEXTACT+6 && eqtc) || (mid == 2*CONTEXTACT+6 && eqpc))
2827 {
2828 style_this_atom (action, NULL, GINT_TO_POINTER(j));
2829 style_this_atom (action, NULL, GINT_TO_POINTER(k));
2830 }
2831#else
2832 if (mid == 0 || (mid == CONTEXTACT && eqtc) || (mid == 2*CONTEXTACT && eqpc))
2833 {
2834 if (! opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(j));
2835 if (! opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(k));
2836 }
2837 else if (mid == 1 || (mid == CONTEXTACT+1 && eqtc) || (mid == 2*CONTEXTACT+1 && eqpc))
2838 {
2839 if (opengl_project -> atoms[s][j].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(j));
2840 if (opengl_project -> atoms[s][k].pick[g]) select_unselect_this_atom (NULL, GINT_TO_POINTER(k));
2841 }
2842 else if (mid == 2 || (mid == CONTEXTACT+2 && eqtc) || (mid == 2*CONTEXTACT+2 && eqpc))
2843 {
2844 if (! opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
2845 if (! opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(k));
2846 }
2847 else if (mid == 3 || (mid == CONTEXTACT+3 && eqtc) || (mid == 2*CONTEXTACT+3 && eqpc))
2848 {
2849 if (opengl_project -> atoms[s][j].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(j));
2850 if (opengl_project -> atoms[s][k].label[0]) label_unlabel_this_atom (NULL, GINT_TO_POINTER(k));
2851 }
2852 else if (mid == 4 || (mid == CONTEXTACT+4 && eqtc) || (mid == 2*CONTEXTACT+4 && eqpc))
2853 {
2854 if (! opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(j));
2855 if (! opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(k));
2856 }
2857 else if (mid == 5 || (mid == CONTEXTACT+5 && eqtc) || (mid == 2*CONTEXTACT+5 && eqpc))
2858 {
2859 if (opengl_project -> atoms[s][j].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(j));
2860 if (opengl_project -> atoms[s][k].show[0]) show_hide_this_atom (NULL, GINT_TO_POINTER(k));
2861 }
2862 else if (mid == 6 || (mid == CONTEXTACT+6 && eqtc) || (mid == 2*CONTEXTACT+6 && eqpc))
2863 {
2864 style_this_atom (widg, GINT_TO_POINTER(j));
2865 style_this_atom (widg, GINT_TO_POINTER(k));
2866 }
2867#endif
2868 else if ((mid == 8 || (mid == CONTEXTACT+8 && eqtc) || (mid == 2*CONTEXTACT+8 && eqpc))
2869 || (mid == 9 || (mid == CONTEXTACT+9 && eqtc) || (mid == 2*CONTEXTACT+9 && eqpc))
2870 || (mid == 10 || (mid == CONTEXTACT+10 && eqtc) || (mid == 2*CONTEXTACT+10 && eqpc))
2871 || (mid == 11 || (mid == CONTEXTACT+11 && eqtc) || (mid == 2*CONTEXTACT+11 && eqpc)))
2872 {
2873 if (! bond_selection)
2874 {
2875 bond_selection = g_malloc0 (sizeof*bond_selection);
2876 bond_selection -> first = new_atom_in_selection (j, opengl_project -> atoms[s][j].sp);
2877 tmp_a = bond_selection -> first;
2878 }
2879 else
2880 {
2881 tmp_a -> next = new_atom_in_selection (j, opengl_project -> atoms[s][j].sp);
2882 tmp_a = tmp_a -> next;
2883 }
2884 bond_selection -> selected ++;
2885 tmp_a -> next = new_atom_in_selection (k, opengl_project -> atoms[s][k].sp);
2886 tmp_a = tmp_a -> next;
2887 bond_selection -> selected ++;
2888 }
2889 }
2890 }
2891 }
2892 if (mid == 6 || mid == CONTEXTACT+6 || mid == 2*CONTEXTACT+6)
2893 {
2895 update (opengl_project -> modelgl);
2896 wait_for_style = FALSE;
2897 }
2898 else if (mid == 8 || mid == CONTEXTACT+8 || mid == 2*CONTEXTACT+8)
2899 {
2901 g_free (bond_selection);
2902 bond_selection = NULL;
2903 }
2904 else if (mid == 9 || mid == CONTEXTACT+9 || mid == 2*CONTEXTACT+9)
2905 {
2906 if (bond_selection)
2907 {
2908 to_remove_this_object (3, data);
2909 remove_object ();
2910 g_free (bond_selection);
2911 bond_selection = NULL;
2912 }
2913 }
2914 else if (mid == 10 || mid == CONTEXTACT+10 || mid == 2*CONTEXTACT+10)
2915 {
2916 if (bond_selection)
2917 {
2918#ifdef GTK4
2919 to_replace_this_object (3, action, data);
2920#else
2921 to_replace_this_object (3, widg, data);
2922#endif
2923 to_remove_this_object (3, data);
2924 insert_object (1, data);
2925 g_free (bond_selection);
2926 bond_selection = NULL;
2927 }
2928 }
2929 else if (mid == 11 || mid == CONTEXTACT+11 || mid == 2*CONTEXTACT+11)
2930 {
2931 if (bond_selection)
2932 {
2934 g_free (bond_selection);
2935 bond_selection = NULL;
2936 }
2937 }
2938}
2939
2940#ifdef GTK4
2952GMenu * add_edition_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data)
2953{
2954 GMenu * menu = g_menu_new ();
2955 GMenu * menus;
2956 gchar * word, * name, * str;
2957 gchar * eact = g_strdup_printf ("mol-ins-%s-%d", act, aid);
2958 int i, j;
2959 for (i=0; mol[i].type || mol[i].object; i++)
2960 {
2961 if (mol[i].type)
2962 {
2963 menus = g_menu_new ();
2964 append_submenu (menu, mol[i].type, menus);
2965
2966 }
2967 if (mol[i].object)
2968 {
2969 append_opengl_item (view, menus, mol[i].object, eact, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
2970 }
2971 }
2972 g_free (eact);
2973
2974 gboolean doit = FALSE;
2975 for (i=0; i<nprojects; i++)
2976 {
2977 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2978 {
2979 doit = TRUE;
2980 break;
2981 }
2982 }
2983
2984 if (doit)
2985 {
2986 GMenu * menup = g_menu_new ();
2987 GMenu * menups;
2988 eact = g_strdup_printf ("ifp-%s-%d", act, aid);
2989 for (i=0; i<nprojects; i++)
2990 {
2991 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
2992 {
2993 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
2994 menups = g_menu_new ();
2995 for (j=0; j<3; j++)
2996 {
2997 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
2998 str = g_strdup_printf ("%s-%d", eact, j);
2999 append_opengl_item (view, menups, word, str, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
3000 g_free (word);
3001 g_free (str);
3002 }
3003 append_submenu (menup, name, menups);
3004 g_object_unref (menups);
3005 g_free (name);
3006 }
3007 }
3008 g_free (eact);
3009 append_submenu (menu, "Import From Project", menup);
3010 g_object_unref (menup);
3011 }
3012 eact = g_strdup_printf ("cp-%s-%d", act, aid);
3013 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);
3014 g_free (eact);
3015 return menu;
3016}
3017
3029GMenu * add_style_sub_menu (glwin * view, gchar * act, int aid, GCallback handler, gpointer data)
3030{
3031 GMenu * menu = g_menu_new ();
3032 gchar * actc = g_strdup_printf ("%s-%d", act, aid);
3033 int i;
3034 for (i=0; i<OGL_STYLES; i++)
3035 {
3036 append_opengl_item (view, menu, text_styles[i], actc, 1, i, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
3037 }
3038 g_free (actc);
3039 return menu;
3040}
3041#else
3051void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3052{
3053 GtkWidget * menu = gtk_menu_new ();
3054 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3055 int i; //, j;
3056 for (i=0; i<OGL_STYLES; i++)
3057 {
3058 //if (i != SPACEFILL)
3059 {
3060 gtk3_menu_item (menu, text_styles[i], IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3061 }
3062 /* else
3063 {
3064 GtkWidget *widg = create_menu_item (FALSE, "Spacefilled");
3065 gtk_menu_shell_append ((GtkMenuShell *)menu, widg);
3066 GtkWidget * menuf = gtk_menu_new ();
3067 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menuf);
3068 for (j=0; j < FILLED_STYLES; j++)
3069 {
3070 gtk3_menu_item (menuf, text_filled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3071 }
3072 } */
3073 }
3074}
3075
3076/*void add_style_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3077{
3078 GtkWidget * menu = gtk_menu_new ();
3079 GtkWidget * pmenu;
3080 GtkWidget * sitem, * pitem;
3081 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3082 int i, j;
3083 for (i=0; i<OGL_STYLES; i++)
3084 {
3085 if (i != SPACEFILL)
3086 {
3087 sitem = gtk3_menu_item (menu, text_stylesled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, TRUE, FALSE);
3088 }
3089 else
3090 {
3091 sitem = create_menu_item (FALSE, "Spacefilled");
3092 gtk_menu_shell_append ((GtkMenuShell *)menu, sitem);
3093 pmenu = gtk_menu_new ();
3094 gtk_menu_item_set_submenu ((GtkMenuItem *)sitem, pmenu);
3095 for (j=0; j < FILLED_STYLES; j++)
3096 {
3097 pitem = gtk3_menu_item (menu, text_filled[j], IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, TRUE, FALSE);
3098 }
3099 }
3100 }
3101}*/
3102
3112void add_edition_sub_menu (GtkWidget * item, GCallback handler, gpointer data)
3113{
3114 GtkWidget * menu = gtk_menu_new ();
3115 GtkWidget * smenu, * pmenu;
3116 GtkWidget * titem, * sitem;
3117 gchar * word, * name;
3118 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu);
3119 int i, j;
3120
3121 for (i=0; mol[i].type || mol[i].object; i++)
3122 {
3123 if (mol[i].type != NULL)
3124 {
3125 titem = create_menu_item (TRUE, mol[i].type);
3126 gtk_menu_shell_append ((GtkMenuShell *)menu, titem);
3127 smenu = gtk_menu_new ();
3128 gtk_menu_item_set_submenu ((GtkMenuItem *)titem, smenu);
3129 }
3130 if (mol[i].object != NULL)
3131 {
3132 gtk3_menu_item (smenu, mol[i].object, IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3133 }
3134 }
3135
3136 gboolean doit = FALSE;
3137 for (i=0; i<nprojects; i++)
3138 {
3139 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
3140 {
3141 doit = TRUE;
3142 break;
3143 }
3144 }
3145
3146 if (doit)
3147 {
3148 titem = create_menu_item (TRUE, "Import From Project");
3149 gtk_menu_shell_append ((GtkMenuShell *)menu, titem);
3150 smenu = gtk_menu_new ();
3151 gtk_menu_item_set_submenu ((GtkMenuItem *)titem, smenu);
3152 for (i=0; i<nprojects; i++)
3153 {
3154 if (get_project_by_id(i) -> steps == 1 && get_project_by_id(i) -> natomes)
3155 {
3156 name = g_strdup_printf ("%s (%d)", get_project_by_id(i) -> name, i+1);
3157 sitem = create_menu_item_from_widget (markup_label(name, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3158 //child = gtk_bin_get_child (GTK_BIN (sitem));
3159 //gtk_label_set_use_markup (GTK_LABEL(child), 1);
3160 //g_signal_connect (G_OBJECT (sitem), "activate", handler, data);
3161 gtk_menu_shell_append ((GtkMenuShell *)smenu, sitem);
3162 pmenu = gtk_menu_new ();
3163 gtk_menu_item_set_submenu ((GtkMenuItem *)sitem, pmenu);
3164 for (j=0; j<3; j++)
3165 {
3166 word = g_strdup_printf ("%s in %s", action_atoms[j], name);
3167 gtk3_menu_item (pmenu, word, IMG_NONE, NULL, handler, data, FALSE, 0, 0, FALSE, FALSE, FALSE);
3168 g_free (word);
3169 }
3170 g_free (name);
3171 }
3172 }
3173 }
3174 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);
3175 if (! copied_object) widget_set_sensitive (pastem, 0);
3176}
3177#endif
3178
3179#ifdef GTK4
3197void 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)
3198{
3199 gchar * actc = g_strdup_printf ("%s-%d", act, aid);
3200#else
3215GtkWidget * create_selection_item (glwin * view, gchar * str, int mid, int gid, int cid, int aoc, GCallback handler, gpointer data)
3216{
3217 GtkWidget * sel_item = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3218#endif
3219 int i, j;
3220 if (mid == 6)
3221 {
3222#ifdef GTK4
3223 append_submenu (menu, str, add_style_sub_menu (view, act, aid, handler, data));
3224#else
3225 add_style_sub_menu (sel_item, handler, data);
3226#endif
3227 }
3228 else if (mid == 7)
3229 {
3230 if (cid < 0)
3231 {
3232 i = get_project_by_id (view -> proj) -> nspec;
3233#ifdef GTK4
3234 append_submenu (menu, str, color_item(view, actc, mid, G_CALLBACK(to_run_atom_color_window), & view -> colorp[0][selected_aspec+aoc*i]));
3235#else
3236 gtk_menu_item_set_submenu ((GtkMenuItem *)sel_item, color_box(view, selected_aspec+aoc*i, 0, 0));
3237#endif
3238 }
3239 else
3240 {
3241#ifdef GTK4
3242 i = cid;
3243 if (gid < 2)
3244 {
3245 for (j=0; j<selected_aspec; j++) i += opengl_project -> coord -> ntg[gid][j];
3246 }
3247 append_submenu (menu, str, color_item(view, actc, mid, G_CALLBACK(window_color_coord), & view -> gcid[gid][i][gid]));
3248#else
3249 int k;
3250 j = 2*opengl_project -> nspec;
3251 for (i=0; i < gid; i++)
3252 {
3253 j += opengl_project -> coord -> totcoord[i];
3254 }
3255 if (gid < 2)
3256 {
3257 for (i=0; i<selected_aspec; i++)
3258 {
3259 j += opengl_project -> coord -> ntg[gid][i];
3260 }
3261 k = selected_aspec;
3262 }
3263 else
3264 {
3265 k = gid;
3266 }
3267 gtk_menu_item_set_submenu ((GtkMenuItem *)sel_item, color_box(view, j+cid, k, cid));
3268#endif
3269 }
3270 }
3271 else if (mid == 10)
3272 {
3273#ifdef GTK4
3274 append_submenu (menu, str, add_edition_sub_menu (view, act, aid, handler, data));
3275#else
3276 add_edition_sub_menu (sel_item, handler, data);
3277#endif
3278 }
3279 else
3280 {
3281#ifdef GTK4
3282 append_opengl_item (view, menu, str, actc, 1, 0, NULL, IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
3283#else
3284 g_signal_connect (G_OBJECT (sel_item), "activate", handler, data);
3285#endif
3286 }
3287#ifdef GTK4
3288 g_free (actc);
3289#else
3290 return sel_item;
3291#endif
3292}
3293
3294gchar * mot[2][2]={{"All Non-Selected Atom(s)/Bond(s)", "All Selected Atom(s)/Bond(s)"},
3295 {"All Non-Labelled Atom(s)/Bond(s)", "All Labelled Atom(s)/Bond(s)"}};
3296
3297#ifdef GTK4
3313GMenu * selection_menu (int aid, glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
3314#else
3329GtkWidget * selection_menu (glwin * view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
3330#endif
3331{
3332 int p = view -> proj;
3333 int s = view -> anim -> last -> img -> step;
3334 int spa, spb;
3335 int i, j, k;
3336 gchar * str;
3337
3338#ifdef GTK4
3339 gchar * strb;
3340 GMenu * menu = g_menu_new ();
3341#else
3342 GtkWidget * sel;
3343 GtkWidget * menu = gtk_menu_new ();
3344#endif
3345 project * this_proj = get_project_by_id(p);
3346 spa = this_proj -> atoms[s][ati].sp;
3347 if (bti > -1) spb = this_proj -> atoms[s][bti].sp;
3348 if (bti < 0 && (((mid == 5 || mid == 6) && this_proj -> atoms[s][ati].show[aoc])
3349 || (mid == 0 && ! is_selected) || (mid == 1 && is_selected)
3350 || (mid == 2 && ! is_labelled) || (mid == 3 && is_labelled) || (mid > 8 && mid < 11)))
3351 {
3352 str = g_strdup_printf ("This Atom: %s<sub>%d</sub>", exact_name(this_proj -> chemistry -> label[spa]), ati+1);
3353#ifdef GTK4
3354 if (mid == 6)
3355 {
3356 append_submenu (menu, str, add_style_sub_menu (view, "tas", aid, handler_a, GINT_TO_POINTER(ati)));
3357 }
3358 else if (mid == 10)
3359 {
3360 append_submenu (menu, str, add_edition_sub_menu (view, "tae", aid, handler_a, GINT_TO_POINTER(ati)));
3361 }
3362 else
3363 {
3364 strb = g_strdup_printf ("act-%d-%d", aid, mid);
3365 append_opengl_item (view, menu, str, strb, 1, 0, NULL, IMG_NONE, NULL, FALSE, handler_a, GINT_TO_POINTER(ati), FALSE, FALSE, FALSE, TRUE);
3366 g_free (strb);
3367 }
3368#else
3369 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3370 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3371 if (mid == 6)
3372 {
3373 add_style_sub_menu (sel, handler_a, GINT_TO_POINTER(ati));
3374 }
3375 else if (mid == 10)
3376 {
3377 add_edition_sub_menu (sel, handler_a, GINT_TO_POINTER(ati));
3378 }
3379 else
3380 {
3381 g_signal_connect (G_OBJECT (sel), "activate", handler_a, GINT_TO_POINTER(ati));
3382 }
3383#endif
3384 }
3385 else if (bti > -1 && mid != 4 && mid != 7)
3386 {
3387 str = g_strdup_printf ("This Bond: %s<sub>%d</sub> - %s<sub>%d</sub>",
3388 exact_name(this_proj -> chemistry -> label[spa]), ati+1,
3389 exact_name(this_proj -> chemistry -> label[spb]), bti+1);
3390#ifdef GTK4
3391 if (mid == 6)
3392 {
3393 append_submenu (menu, str, add_style_sub_menu (view, "tb-s", aid, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid)));
3394 }
3395 else if (mid == 10)
3396 {
3397 append_submenu (menu, str, add_edition_sub_menu (view, "tb-e", aid, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid)));
3398 }
3399 else
3400 {
3401 strb = g_strdup_printf ("act-%d-%d", aid, mid);
3402 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);
3403 g_free (strb);
3404 }
3405#else
3406 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3407 if (mid == 6)
3408 {
3409 add_style_sub_menu (sel, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3410 }
3411 else if (mid == 10)
3412 {
3413 add_edition_sub_menu (sel, G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3414 }
3415 else
3416 {
3417 g_signal_connect (G_OBJECT (sel), "activate", G_CALLBACK(select_action_for_this_bond), GINT_TO_POINTER(mid));
3418 }
3419 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3420#endif
3421 g_free (str);
3422 }
3423
3424 if (mid != 7)
3425 {
3426 k = 0;
3427 for (j=0; j<2; j++)
3428 {
3429 if (mid<2 && j==0)
3430 {
3431 i = mid;
3432 }
3433 else if ((mid > 1 && mid < 4) && j==1)
3434 {
3435 i = mid - 2;
3436 }
3437 else
3438 {
3439 i = (j) ? is_labelled : is_selected;
3440 }
3441#ifdef GTK4
3442 if (mid == 6)
3443 {
3444 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)));
3445 }
3446 else if (mid == 10)
3447 {
3448 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)));
3449 }
3450 else
3451 {
3452 strb = g_strdup_printf ("act-all-%d-%d", aid, mid+k);
3453 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);
3454 g_free (strb);
3455 }
3456#else
3457 sel = create_menu_item_from_widget (markup_label (mot[j][i], -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3458 if (mid == 6)
3459 {
3460 add_style_sub_menu (sel, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3461 }
3462 else if (mid == 10)
3463 {
3464 add_edition_sub_menu (sel, G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3465 }
3466 else
3467 {
3468 g_signal_connect (G_OBJECT (sel), "activate", G_CALLBACK(select_action_for_all), GINT_TO_POINTER(mid+k));
3469 }
3470 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3471#endif
3472 k = CONTEXTACT;
3473 }
3474 }
3475
3476 for (i=0; i<2; i++)
3477 {
3478 if (this_proj -> modelgl -> adv_bonding[i])
3479 {
3480 j = this_proj -> atoms[s][ati].coord[2+i];
3481 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j+1) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j+1);
3482#ifdef GTK4
3483 create_selection_item (menu, view, str, (! i) ? "afm" : "amo", aid, mid, 2+i, j, aoc, handler_b, & atoid[mid][2+i]);
3484#else
3485 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item (view, str, mid, 2+i, j, aoc, handler_b, & atoid[mid][2+i]));
3486#endif
3487 g_free (str);
3488 }
3489 }
3490 if (bti < 0)
3491 {
3492 if (this_proj -> atoms[s][ati].coord[0] > -1)
3493 {
3494 i = this_proj -> atoms[s][ati].coord[0];
3495 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]));
3496#ifdef GTK4
3497 create_selection_item (menu, view, str, "atc", aid, mid, 0, i, aoc, handler_b, & atoid[mid][0]);
3498#else
3499 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 0, i, aoc, handler_b, & atoid[mid][0]));
3500#endif
3501 g_free (str);
3502 }
3503 if (this_proj -> atoms[s][ati].coord[1] > -1)
3504 {
3505 i = this_proj -> atoms[s][ati].coord[1];
3506 str = g_strdup_printf ("All <b>%s</b> Coordinations", env_name (this_proj, i, spa, 1, NULL));
3507#ifdef GTK4
3508 create_selection_item (menu, view, str, "apc", aid, mid, 1, i, aoc, handler_b, & atoid[mid][1]);
3509#else
3510 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 1, i, aoc, handler_b, & atoid[mid][1]));
3511#endif
3512 g_free (str);
3513 }
3514 if (! aoc)
3515 {
3516 str = g_strdup_printf ("All <b>%s</b> Atoms", exact_name(this_proj -> chemistry -> label[spa]));
3517 }
3518 else
3519 {
3520 str = g_strdup_printf ("All <b>%s*</b> Clones", exact_name(this_proj -> chemistry -> label[spa]));
3521 }
3522#ifdef GTK4
3523 create_selection_item (menu, view, str, "asp", aid, mid, 0, -1, aoc, handler_c, & atoid[mid][2]);
3524#else
3525 gtk_menu_shell_append ((GtkMenuShell *)menu, create_selection_item(view, str, mid, 0, -1, aoc, handler_c, & atoid[mid][2]));
3526#endif
3527 g_free (str);
3528 }
3529 else
3530 {
3531 if (this_proj -> atoms[s][ati].coord[0] > -1 && this_proj -> atoms[s][bti].coord[0] > -1)
3532 {
3533 i = this_proj -> atoms[s][ati].coord[0];
3534 j = this_proj -> atoms[s][bti].coord[0];
3535 str = g_strdup_printf ("All %s <b>%d</b> - %s <b>%d</b> Bonds",
3536 exact_name(this_proj -> chemistry -> label[spa]), this_proj -> coord -> geolist[0][spa][i],
3537 exact_name(this_proj -> chemistry -> label[spb]), this_proj -> coord -> geolist[0][spb][j]);
3538#ifdef GTK4
3539 create_selection_item (menu, view, str, "atcb", aid, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid+CONTEXTACT));
3540#else
3541 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)));
3542#endif
3543 g_free (str);
3544 }
3545 if (this_proj -> atoms[s][ati].coord[1] > -1 && this_proj -> atoms[s][bti].coord[1] > -1)
3546 {
3547 i = this_proj -> atoms[s][ati].coord[1];
3548 j = this_proj -> atoms[s][bti].coord[1];
3549 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));
3550#ifdef GTK4
3551 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));
3552#else
3553 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)));
3554#endif
3555 g_free (str);
3556 }
3557 str = g_strdup_printf ("All %s - %s Bonds", exact_name(this_proj -> chemistry -> label[spa]), exact_name(this_proj -> chemistry -> label[spb]));
3558#ifdef GTK4
3559 create_selection_item (menu, view, str, "acb", aid, mid, -1, -1, aoc, G_CALLBACK(select_action_for_all_bonds), GINT_TO_POINTER(mid));
3560#else
3561 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)));
3562#endif
3563 g_free (str);
3564 }
3565 if (mid > 3 && mid < 6)
3566 {
3567 gchar * mat[2]={"All Hidden Atom(s)/Bond(s)", "All Visible Atom(s)/Bond(s)"};
3568#ifdef GTK4
3569 strb = g_strdup_printf ("all-hv-%d-%d", aid, mid);
3570 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);
3571 g_free (strb);
3572#else
3573 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);
3574#endif
3575 }
3576 return menu;
3577}
3578
3579#ifdef GTK4
3594void analyze_popup_attach_color_palettes (glwin * view, GtkWidget * menu, int ato, int spc, int totc, int parc, int frag, int mol)
3595{
3596 /* Here we need to attached color palettes for:
3597 - The chemical species of the atom in selection
3598 - The total coordination of the atom in selection
3599 - The partial coordination of the atom in selection
3600 - The fragment of the atom in selection
3601 - The molecule of the atom in selection
3602 This is a work in progress since the 'gtk_popover_menu_bar_add_child' to use to insert widget is bugged:
3603 https://gitlab.gnome.org/GNOME/gtk/-/issues/5955
3604 */
3605 int i, j;
3606 project * this_proj = get_project_by_id (view -> proj);
3607 // The chemical species of the atom in selection
3608 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, ato*this_proj -> nspec+spc, -1, -1), "set-asp-7.7"))
3609 {
3610 g_debug ("Color palette error: species in selection - custom= set-asp-7.7");
3611 }
3612 // The total coordination
3613 i = 0;
3614 for (j=0; j<spc; j++)
3615 {
3616 i += this_proj -> coord -> ntg[0][j];
3617 }
3618 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+i, -1, -1), "set-atc-7.7"))
3619 {
3620 g_debug ("Color palette error: total coordination in selection - custom= set-atc-7.7");
3621 }
3622 // The partial coordination
3623 i = this_proj -> coord -> totcoord[0];
3624 for (j=0; j<spc; j++)
3625 {
3626 i += this_proj -> coord -> ntg[1][j];
3627 }
3628 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+i, -1, -1), "set-apc-7.7"))
3629 {
3630 g_debug ("Color palette error: partial coordination in selection - custom= set-apc-7.7");
3631 }
3632 if (view -> adv_bonding[0])
3633 {
3634 // The fragment of the atom in selection
3635 i = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + frag;
3636 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i, 2, 0), "set-afm-7.7"))
3637 {
3638 g_debug ("Color palette error: fragment in selection - custom= set-afm-7.7");
3639 }
3640 }
3641 if (view -> adv_bonding[1])
3642 {
3643 // The molecule of the atom in selection
3644 i = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + this_proj -> coord -> totcoord[2] + mol;
3645 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i, 3, 0), "set-amo-7.7"))
3646 {
3647 g_debug ("Color palette error: fragment in selection - custom= set-amo-7.7");
3648 }
3649 }
3650}
3651#endif
3652
3667void popup_selection (glwin * view, double ptx, double pty, int spe, int mmod, int ati, int bti, int aoc)
3668{
3669 int p = view -> proj;
3670 int s = view -> anim -> last -> img -> step;
3671 int i, j;
3672 gchar * str, * strp;
3673 gchar * menu_names[CONTEXTACT] = {"Select", "Unselect", "Label", "Unlabel", "Show", "Hide", "Style", "Color", "Edit as New Project", "Remove", "Replace", "Copy"};
3674 GCallback handlers[CONTEXTACT][3] = {{G_CALLBACK(select_unselect_this_atom), G_CALLBACK(select_unselect_coord), G_CALLBACK(select_unselect_atoms)},
3675 {G_CALLBACK(select_unselect_this_atom), G_CALLBACK(select_unselect_coord), G_CALLBACK(select_unselect_atoms)},
3676 {G_CALLBACK(label_unlabel_this_atom), G_CALLBACK(label_unlabel_coord), G_CALLBACK(label_unlabel_atoms)},
3677 {G_CALLBACK(label_unlabel_this_atom), G_CALLBACK(label_unlabel_coord), G_CALLBACK(label_unlabel_atoms)},
3678 {G_CALLBACK(show_hide_this_atom), G_CALLBACK(show_hide_the_coord), G_CALLBACK(show_hide_the_atoms)},
3679 {G_CALLBACK(show_hide_this_atom), G_CALLBACK(show_hide_the_coord), G_CALLBACK(show_hide_the_atoms)},
3680 {G_CALLBACK(style_this_atom), G_CALLBACK(style_the_coord), G_CALLBACK(style_the_atoms)},
3681 {NULL, NULL, NULL},
3682 {NULL, G_CALLBACK(edit_coord), G_CALLBACK(edit_atoms)},
3683 {G_CALLBACK(remove_this_atom), G_CALLBACK(remove_the_coord), G_CALLBACK(remove_the_atoms)},
3684 {G_CALLBACK(replace_this_atom), G_CALLBACK(replace_the_coord), G_CALLBACK(replace_the_atoms)},
3685 {G_CALLBACK(copy_this_atom), G_CALLBACK(copy_the_coord), G_CALLBACK(copy_the_atoms)}};
3686#ifdef GTK4
3687 if (view_pop_actions) g_object_unref (view_pop_actions);
3688 view_pop_actions = g_simple_action_group_new ();
3689 GMenu * gmenu = g_menu_new ();
3690#else
3691 GtkWidget * menu = gtk_menu_new ();
3692 GtkWidget * sel;
3693#endif
3694#ifdef DEBUG
3695 g_debug ("POP_SEL:: spe= %d, ati= %d, bti= %d, aoc= %d", spe, ati, bti, aoc);
3696#endif // DEBUG
3697
3699 selected_atom = ati;
3700 selected_btom = bti;
3701 selected_aspec = opengl_project -> atoms[s][ati].sp;
3702 selected_bspec = -1;
3703 selected_status = ! opengl_project -> atoms[s][ati].pick[get_to_be_selected (view)];
3704 is_selected = opengl_project -> atoms[s][ati].pick[mmod];
3705 is_labelled = opengl_project -> atoms[s][ati].label[aoc];
3706#ifdef DEBUG
3707 if (is_selected != spe) g_debug ("Something is wrong in popup");
3708#endif // DEBUG
3709
3710 for (i=0; i<CONTEXTACT; i++)
3711 {
3712 for (j=0; j<4; j++)
3713 {
3714 atoid[i][j].a = j;
3715 atoid[i][j].b = opengl_project -> atoms[s][ati].coord[j];
3716 atoid[i][j].c = ((i-2*(i/2)) == 0 ? 1 : 0);
3717/*#ifdef DEBUG
3718 g_debug ("atoid[%d][%d].a= %d, atoid[%d][%d].b= %d, atoid[%d][%d].c= %d",
3719 i, j, atoid[i][j].a, i, j, atoid[i][j].b, i, j, atoid[i][j].c);
3720#endif*/
3721 }
3722 }
3723 if (bti > -1)
3724 {
3725 btoid.a = opengl_project -> atoms[s][bti].coord[0];
3726 btoid.b = opengl_project -> atoms[s][bti].coord[1];
3727 selected_bspec = opengl_project -> atoms[s][bti].sp;
3728 distance dist = distance_3d (& opengl_project -> cell, (opengl_project -> cell.npt) ? s : 0, & opengl_project -> atoms[s][ati], & opengl_project -> atoms[s][bti]);
3729 if (aoc == 0)
3730 {
3731 str = g_strdup_printf ("%s<sub>%d</sub> - %s<sub>%d</sub>",
3733 }
3734 else
3735 {
3736 str = g_strdup_printf ("%s<sub>%d</sub> - %s<sub>%d</sub>",
3738 }
3739 if (dist.pbc)
3740 {
3741 strp = g_strdup_printf ("<b>%s \t d= %.3f Ã… (PBC)</b>", str, dist.length);
3742 }
3743 else
3744 {
3745 strp = g_strdup_printf ("<b>%s \t d= %.3f Ã…</b>", str, dist.length);
3746 }
3747#ifdef GTK4
3748 append_opengl_item (view, gmenu, strp, "w-dist", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3749#else
3750 sel = create_menu_item_from_widget (markup_label (strp, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3751 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3752#endif
3753 g_free (strp);
3754 for (i=0; i<2; i++)
3755 {
3756 if (view -> adv_bonding[i])
3757 {
3758 j = opengl_project -> atoms[s][ati].coord[2+i] + 1;
3759 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j);
3760#ifdef GTK4
3761 append_opengl_item (view, gmenu, str, "w-dist-fm", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3762#else
3763 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3764 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3765#endif
3766 g_free (str);
3767 }
3768 }
3769 }
3770 else
3771 {
3772 if (aoc == 0)
3773 {
3774 str = g_strdup_printf ("<b>%s<sub>%d</sub></b>", exact_name(opengl_project -> chemistry -> label[selected_aspec]), ati+1);
3775 }
3776 else
3777 {
3778 str = g_strdup_printf ("<b>%s<sub>%d</sub><sup>*</sup></b>", exact_name(opengl_project -> chemistry -> label[selected_aspec]), ati+1);
3779 }
3780#ifdef GTK4
3781 append_opengl_item (view, gmenu, str, "w-ac", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3782#else
3783 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3784 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3785#endif
3786 g_free (str);
3787 str = g_strdup_printf ("\tx : <b>%f</b>\n\ty : <b>%f</b>\n\tz : <b>%f</b>",
3788 opengl_project -> atoms[s][ati].x, opengl_project -> atoms[s][ati].y, opengl_project -> atoms[s][ati].z);
3789#ifdef GTK4
3790 append_opengl_item (view, gmenu, str, "xyz", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3791#else
3792 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3793 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3794#endif
3795 g_free (str);
3796 if (opengl_project -> atoms[s][ati].coord[0] > -1)
3797 {
3798 i = opengl_project -> atoms[s][ati].coord[0];
3799 str = g_strdup_printf ("Total Coordination: <b>%d</b>", opengl_project -> coord -> geolist[0][selected_aspec][i]);
3800#ifdef GTK4
3801 append_opengl_item (view, gmenu, str, "w-tc", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3802#else
3803 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3804 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3805#endif
3806 g_free (str);
3807 i = opengl_project -> atoms[s][ati].coord[1];
3808 str = g_strdup_printf ("Partial Coordination: <b>%s</b>",
3809 env_name (opengl_project, i, selected_aspec, 1, NULL));
3810#ifdef GTK4
3811 append_opengl_item (view, gmenu, str, "w-pc", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3812#else
3813 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3814 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3815#endif
3816 g_free (str);
3817 }
3818 for (i=0; i<2; i++)
3819 {
3820 if (view -> adv_bonding[i])
3821 {
3822 j = opengl_project -> atoms[s][ati].coord[2+i] + 1;
3823 str = (! i) ? g_strdup_printf ("Fragment N°:\t<b>%d</b>", j) : g_strdup_printf ("Molecule N°:\t<b>%d</b>", j);
3824#ifdef GTK4
3825 append_opengl_item (view, gmenu, str, "w-fm", 1, 0, NULL, IMG_NONE, NULL, FALSE, NULL, NULL, FALSE, FALSE, FALSE, TRUE);
3826#else
3827 sel = create_menu_item_from_widget (markup_label (str, -1, -1, 0.0, 0.5), FALSE, FALSE, FALSE);
3828 gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3829#endif
3830 g_free (str);
3831 }
3832 }
3833 }
3834
3835 //if (fc)
3836 //{
3837 // gtk_menu_shell_append ((GtkMenuShell *)menu, sel);
3838 // add_menu_separator (menu);
3839 // atoms menu
3840 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_atom_menu(p, s, ati, fc-2));
3841 // bonds menu, if ati involved in bonding, or bti > -1
3842 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_bond_menu(p, s, ati, bti));
3843 // angles menu, if ati involved in bonding with more than 2 neighbors
3844 //gtk_menu_shell_append ((GtkMenuShell *)menu, field_angle_menu(p, s, ati, bti));
3845 //}
3846
3847#ifdef GTK4
3848 GMenu * menua = g_menu_new ();
3849 g_menu_append_section (gmenu, NULL, (GMenuModel *)menua);
3850#else
3851 add_menu_separator (menu);
3852#endif
3853 gboolean go;
3854
3855 for (i=0; i<12; i++)
3856 {
3857 go = TRUE;
3858 if (i < 9 && view -> mode == EDITION) go = FALSE;
3859 if ((i > 8 && i < 11) && view -> mode == ANALYZE) go = FALSE;
3860 if (i == 0 && view -> anim -> last -> img -> selected[mmod] -> selected == opengl_project -> natomes) go = FALSE;
3861 if (i == 1 && view -> anim -> last -> img -> selected[mmod] -> selected == 0) go = FALSE;
3862 if (i == 2 && view -> labelled == opengl_project -> natomes*opengl_project -> steps) go = FALSE;
3863 if (i == 3 && view -> labelled == 0) go = FALSE;
3864 if (bti > -1 && i == 7) go = FALSE;
3865 j = (i == 8 && view -> mode == ANALYZE) ? 11 : (i == 11 && view -> mode == ANALYZE) ? 8 : i;
3866 if (go)
3867 {
3868#ifdef GTK4
3869 append_submenu (menua, menu_names[j], selection_menu (i, view, ati, bti, aoc, j, handlers[j][0], handlers[j][1], handlers[j][2]));
3870#else
3871 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])));
3872#endif
3873 }
3874 }
3875#ifdef GTK4
3876 GtkWidget * menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)gmenu, GTK_POPOVER_MENU_NESTED);
3877 // Color palettes here
3878 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);
3879
3880 gtk_widget_set_parent (menu, view -> win);
3881 str = g_strdup_printf ("gl-%d", view -> action_id);
3882 gtk_widget_insert_action_group (menu, str, G_ACTION_GROUP(view_pop_actions));
3883 g_free (str);
3884 i = (view -> mode == ANALYZE) ? (is_selected) ? 385 : 355 : 230;
3885 i += (view -> adv_bonding[0] && bti < 0) ? 30 : 0;
3886 i += (view -> adv_bonding[1] && bti < 0) ? 30 : 0;
3887 if (bti > -1) i -= (view -> mode == ANALYZE) ? 70 : 50;
3888 gtk_widget_set_size_request (menu, -1, i);
3889 pop_menu_at_pointer (menu, ptx, pty);
3890#else
3891 pop_menu_at_pointer (menu, NULL);
3892#endif
3893}
3894
3895#ifdef GTK4
3905G_MODULE_EXPORT void reset_coords (GSimpleAction * action, GVariant * parameter, gpointer data)
3906#else
3915G_MODULE_EXPORT void reset_coords (GtkWidget * widg, gpointer data)
3916#endif
3917{
3918 glwin * view = (glwin *)data;
3920 int shaders[5] = {ATOMS, BONDS, POLYS, RINGS, SELEC};
3922 view -> create_shaders[MEASU] = TRUE;
3923 view -> create_shaders[PICKS] = TRUE;
3924 init_coordinates (get_project_by_id(view -> proj), 1, FALSE, TRUE);
3925 update (view);
3926}
3927
3928#ifdef GTK4
3938G_MODULE_EXPORT void turn_rebuild (GSimpleAction * action, GVariant * parameter, gpointer data)
3939#else
3948G_MODULE_EXPORT void turn_rebuild (GtkWidget * widg, gpointer data)
3949#endif
3950{
3951 tint * dat =(tint *)data;
3952 glwin * view = get_project_by_id(dat -> a) -> modelgl;
3953#ifdef GTK4
3954 view -> rebuild[dat -> b][0] = ! view -> rebuild[dat -> b][0];
3955 view -> rebuild[dat -> b][1] = view -> rebuild[dat -> b][0];
3956 update_menu_bar (view);
3957#else
3958 view -> rebuild[dat -> b][0] = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
3959 view -> rebuild[dat -> b][1] = view -> rebuild[dat -> b][0];
3960 if (widg != view -> rbuild[dat -> b])
3961 {
3962 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> rbuild[dat -> b], view -> rebuild[dat -> b][0]);
3963 }
3964#endif
3965}
3966
3975G_MODULE_EXPORT void to_center_this_molecule (GtkWidget * widg, gpointer data)
3976{
3977 glwin * view = (glwin *)data;
3978 gboolean center = ! get_project_by_id(view -> proj) -> cell.crystal ? TRUE :
3979 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);
3980 if (center) center_this_molecule (view);
3981}
3982
3983#ifdef GTK4
3991GMenu * tools_section (glwin * view)
3992{
3993 GMenu * menu = g_menu_new ();
3994 append_submenu (menu, "Tools", menu_tools(view, 1));
3995 return menu;
3996}
3997
4005GMenu * anim_section (glwin * view)
4006{
4007 GMenu * menu = g_menu_new ();
4008 append_submenu (menu, "Animate", menu_anim(view, 1));
4009 return menu;
4010}
4011
4020void analyze_menu_attach_color_palettes (glwin * view, GtkWidget * menu)
4021{
4022 /* Here we need to attached color palettes for:
4023 - Box
4024 - Atoms
4025 - Clones
4026 - Total coordination(s)
4027 - Partial coordination(s)
4028 - Fragment(s) and molecule(s)
4029 - Ring(s)
4030 - Background
4031 This is a work in progress since the 'gtk_popover_menu_bar_add_child' to use to insert widget is bugged:
4032 https://gitlab.gnome.org/GNOME/gtk/-/issues/5955
4033 */
4034 int i, j, k, l, m;
4035 gchar * str;
4036 project * this_proj = get_project_by_id (view -> proj);
4037 // Box
4038 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -1, -1, -1), "set-box-color.0"))
4039 {
4040 g_debug ("Color palette error: box - custom= set-box-color.0");
4041 }
4042 // Atom(s) and clone(s)
4043 for (i=0; i<2; i++)
4044 {
4045 for (j=0; j<this_proj -> nspec; j++)
4046 {
4047 str = g_strdup_printf ("set-%s.%d", (! i) ? "atom-color" : "clone-color", j);
4048 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, i*this_proj -> nspec+j, -1, -1), (const gchar *)str))
4049 {
4050 g_debug ("Color palette error: %s - %d - custom= %s", (! i) ? "atom-color" : "clone-color", j+1, str);
4051 }
4052 g_free (str);
4053 }
4054 }
4055 // Coordinations
4056 for (i=0; i<2; i++)
4057 {
4058 if (this_proj -> coord -> ntg[i])
4059 {
4060 for (j=0; j<this_proj -> nspec; j++)
4061 {
4062 for (k=0; k<this_proj -> coord -> ntg[i][j]; k++)
4063 {
4064 m = 0;
4065 for (l=0; l<j; l++)
4066 {
4067 m += this_proj -> coord -> ntg[i][l];
4068 }
4069 if (i)
4070 {
4071 str = g_strdup_printf ("set-%s-c.%d", exact_name (env_name (this_proj, k, j, 1, NULL)), m);
4072 }
4073 else
4074 {
4075 str = g_strdup_printf ("set-%d-c.%d", this_proj -> coord -> geolist[i][j][k], m);
4076 }
4077 m += (i) ? this_proj -> coord -> totcoord[0] : 0;
4078 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, 2*this_proj -> nspec+m, -1, -1), (const gchar *)str))
4079 {
4080 g_debug ("Color palette error: %s - spec= %d - coord= %d, custom= %s", (! i) ? "total-coord" : "partial-coord", j+1, k+1, str);
4081 }
4082 g_free (str);
4083 }
4084 }
4085 }
4086 }
4087 // Fragment(s) and molecule(s)
4088 for (i=2; i<4; i++)
4089 {
4090 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
4091 {
4092 str = g_strdup_printf ("set-%s-%d", (i == 2) ? "fcol" : "mcol", j);
4093 k = 2*this_proj -> nspec + this_proj -> coord -> totcoord[0] + this_proj -> coord -> totcoord[1] + j;
4094 if (i == 3) k += this_proj -> coord -> totcoord[2];
4095 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, k, i, 0), (const gchar *)str))
4096 {
4097 g_debug ("Color palette error: %s - %d, custom= %s", (i == 2) ? "fragment" : "molecule", j+1, str);
4098 }
4099 g_free (str);
4100 }
4101 }
4102 // Rings
4103 for (i=4; i<9; i++)
4104 {
4105 for (j=0; j<this_proj -> coord -> totcoord[i]; j++)
4106 {
4107 str = g_strdup_printf ("set-rcol-%d-%d", i, j);
4108 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -3, i-4, 0), (const gchar *)str))
4109 {
4110 g_debug ("Color palette error: rings - %d - %d, custom= %s", i, j+1, str);
4111 }
4112 g_free (str);
4113 }
4114 }
4115 // Background
4116 if (! gtk_popover_menu_add_child ((GtkPopoverMenu *)menu, color_palette (view, -2, -1, -1), "set-back-color.0"))
4117 {
4118 g_debug ("Color palette error: background - custom= set-back-color.0");
4119 }
4120}
4121#endif
4122
4132void popup_main_menu (glwin * view, double ptx, double pty)
4133{
4134 GtkWidget * menu;
4135 opengl_project_changed (view -> proj);
4136#ifdef GTK4
4137 if (view_pop_actions) g_object_unref (view_pop_actions);
4138 view_pop_actions = g_simple_action_group_new ();
4139 GMenu * gmenu = g_menu_new ();
4140 if (view -> mode == ANALYZE)
4141 {
4142 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_opengl_menu(view, 1));
4143 if (get_project_by_id(view -> proj) -> natomes)
4144 {
4145 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_model_menu(view, 1));
4146 g_menu_append_section (gmenu, NULL, (GMenuModel *)prepare_coord_menu(view, 1));
4147 }
4148 g_menu_append_section (gmenu, NULL, (GMenuModel *)tools_section(view));
4149 g_menu_append_section (gmenu, NULL, (GMenuModel *)menu_view(view, 1));
4150 g_menu_append_section (gmenu, NULL, (GMenuModel *)anim_section(view));
4151 }
4152 else
4153 {
4154 g_menu_append_section (gmenu, NULL, (GMenuModel *)tools_section(view));
4155 append_submenu (gmenu, "Insert", add_edition_sub_menu (view, "ins", 0, G_CALLBACK(to_add_object), & view -> colorp[0][0]));
4156 if (opengl_project -> steps == 1) g_menu_append_section (gmenu, NULL, (GMenuModel *)extract_section(view, 1));
4157 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);
4158 }
4159 g_menu_append_section (gmenu, NULL, (GMenuModel*)menu_reset(view, 1));
4160 g_menu_append_section (gmenu, NULL, (GMenuModel*)menu_fullscreen(view, 1));
4161
4162 menu = gtk_popover_menu_new_from_model_full ((GMenuModel *)gmenu, GTK_POPOVER_MENU_NESTED);
4163 if (view -> mode == ANALYZE) analyze_menu_attach_color_palettes (view, menu);
4164
4165 gtk_popover_present ((GtkPopover *)menu);
4166 gchar * str = g_strdup_printf ("gl-%d", view -> action_id);
4167 gtk_widget_insert_action_group (menu, str, G_ACTION_GROUP(view_pop_actions));
4168 g_free (str);
4169 gtk_widget_set_parent (menu, view -> win);
4170 gtk_widget_set_size_request (menu, -1, (view -> mode == ANALYZE) ? 742 : 242);
4171 pop_menu_at_pointer (menu, ptx, pty);
4172#else
4173 menu = gtk_menu_new ();
4174 GtkWidget * item;
4175 if (view -> mode == ANALYZE)
4176 {
4177 menu_items_opengl (menu, view, 1);
4178 add_menu_separator (menu);
4179 if (get_project_by_id(view -> proj) -> nspec)
4180 {
4181 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Atom(s)", TRUE, menu_atoms (view, 1, 0)));
4182 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Bond(s)", TRUE, menu_bonds (view, 1, 0)));
4183 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Clone(s)", TRUE, menu_clones (view, 1)));
4184 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_box_axis (view, 1, 0));
4185 add_menu_separator (menu);
4186 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_coord (view, 1));
4187 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Polyhedra", TRUE, menu_poly (view, 1)));
4188 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Rings", view -> rings, menu_rings (view, 1)));
4189 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Chain(s)", view -> chains, add_menu_coord (view, 1, 9)));
4190 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Fragment(s)", opengl_project -> coord -> totcoord[2], add_menu_coord (view, 1, 2)));
4191 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Molecule(s)", opengl_project -> coord -> totcoord[3], add_menu_coord (view, 1, 3)));
4192 gtk3_menu_item (menu, "Advanced", IMG_NONE, NULL, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
4193 // add_advanced_item (menu, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK);
4194 add_menu_separator (menu);
4195 }
4196 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Tools", TRUE, menu_tools(view, 1)));
4197 add_menu_separator (menu);
4198 menu_items_view (menu, view, 1);
4199 add_menu_separator (menu);
4200 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_anim (view, 1));
4201 }
4202 else
4203 {
4204 item = create_menu_item (TRUE, "Tools");
4205 gtk_menu_item_set_submenu ((GtkMenuItem *)item, menu_tools(view, 1));
4206 gtk_menu_shell_append ((GtkMenuShell *)menu, item);
4207 add_menu_separator (menu);
4208
4209 item = create_menu_item (TRUE, "Insert");
4210 add_edition_sub_menu (item, G_CALLBACK(to_add_object), & view -> colorp[0][0]);
4211 gtk_menu_shell_append ((GtkMenuShell *)menu, item);
4212 add_menu_separator (menu);
4213
4214 if (opengl_project -> steps == 1)
4215 {
4216 gtk3_menu_item (menu, "Extract/Rebuild on Motion", IMG_STOCK, (gpointer)ECUT, G_CALLBACK(turn_rebuild), & view -> colorp[0][0], FALSE, 0, 0, TRUE, FALSE, view -> rebuild[0][0]);
4217 gtk3_menu_item (menu, "Extract/Rebuild on Copy", IMG_STOCK, (gpointer)ECUT, G_CALLBACK(turn_rebuild), & view -> colorp[1][0], FALSE, 0, 0, TRUE, FALSE, view -> rebuild[1][0]);
4218 }
4219 gtk3_menu_item (menu, "Reset Motion", IMG_STOCK, (gpointer)MEDIA_LOOP, G_CALLBACK(reset_coords), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4220 }
4221 add_menu_separator (menu);
4222 gtk3_menu_item (menu, "Reset View", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_reset_view), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4223 gtk3_menu_item (menu, "Center Molecule", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_center_this_molecule), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
4224 add_menu_separator (menu);
4225 if (! view -> fullscreen)
4226 {
4227 gtk3_menu_item (menu, "Fullscreen", IMG_STOCK, (gpointer)FULLSCREEN, G_CALLBACK(set_full_screen), (gpointer)view, TRUE, GDK_KEY_f, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
4228 }
4229 else
4230 {
4231 gtk3_menu_item (menu, "Exit Fullscreen", IMG_STOCK, (gpointer)FULLSCREEN, G_CALLBACK(set_full_screen), (gpointer)view, TRUE, GDK_KEY_Escape, 0, FALSE, FALSE, FALSE);
4232 }
4233 pop_menu_at_pointer (menu, NULL);
4234#endif
4235}
void prepare_atom_edition(gpointer data, gboolean visible)
prepare atom edition
Definition atom_edit.c:459
void clean_other_window_after_edit(project *this_proj)
update other windows after model edition if required
Definition atom_edit.c:110
gchar * action_atoms[3]
Definition atom_edit.c:61
Function declarations for the mode edition window.
atomic_object * create_object_from_selection(project *this_proj)
create object from atom selection
void init_coordinates(project *this_proj, int status, gboolean win, gboolean init)
preserve atomic coordinates
Definition atom_move.c:197
int get_selected_object_id(gboolean visible, int p, gchar *str, atom_search *asearch)
get the id of the object selected (in contextual menu, or in combo box)
Definition w_search.c:2385
tint ulam_coord(glwin *view)
shift insertion position for object not to have overlapping objects for multiple/repeated insertions
atomic_object * duplicate_atomic_object(atomic_object *old_obj)
duplicate an insert object
void to_insert_in_project(int stat, int orig, project *this_proj, atom_search *asearch, gboolean visible)
to insert object in project
void allocate_todo(atom_search *asearch, int tsize)
allocate the selection list data buffer
Definition w_search.c:3717
Binding to the Fortran90 subroutines.
Callback declarations for main window.
G_MODULE_EXPORT void cut_this_slab(GtkButton *but, gpointer data)
cut this slab callback
Definition cell_cut.c:493
integer function chains()
Definition chains.F90:54
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
GtkWidget * color_box(glwin *view, int ideo, int spec, int geo)
create the color palette pointers and menus GTK3 version
Definition color_box.c:254
Structure definitions for color management Function declarations for color management.
color colorp[64]
G_MODULE_EXPORT void window_color_coord(GtkWidget *widg, gpointer data)
create a window to select a color callback GTK3
Definition w_colors.c:277
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:216
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:342
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:326
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:232
@ IMG_STOCK
Definition global.h:236
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:171
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:161
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:2277
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:602
#define CHEM_PARAMS
Definition global.h:268
#define RI
Definition global.h:300
box_info * active_box
Definition project.c:51
#define BD
Definition global.h:298
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
Definition gtk-misc.c:1565
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:186
#define FULLSCREEN
Definition global.h:170
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
tint cut_sel
Definition gui.c:129
#define ECUT
Definition global.h:177
void add_menu_separator(GtkWidget *menu)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
#define SP
Definition global.h:302
project * active_project
Definition project.c:47
atomic_object * copied_object
Definition glwindow.c:121
#define CH
Definition global.h:301
image * active_image
Definition project.c:52
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
Definition glview.c:1518
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
action
Definition glview.h:189
gboolean is_coord_in_menu(int id, project *this_proj)
is this coordination in a menu ?
Definition m_coord.c:74
gboolean pick
void update_all_menus(glwin *view, int nats)
update all menus of the OpenGL window
Definition glwindow.c:239
@ ANALYZE
Definition glview.h:157
@ EDITION
Definition glview.h:158
int step
Definition ogl_draw.c:70
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
@ REPLACE
Definition glview.h:225
@ REMOVE
Definition glview.h:226
@ INSERT
Definition glview.h:227
@ SPACEFILL
Definition glview.h:175
@ NONE
Definition glview.h:172
#define FILLED_STYLES
Definition glwin.h:105
char * text_filled[FILLED_STYLES]
Definition m_style.c:61
#define OGL_STYLES
Definition glwin.h:106
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
@ BONDS
Definition glwin.h:90
@ PICKS
Definition glwin.h:97
@ LABEL
Definition glwin.h:98
@ POLYS
Definition glwin.h:92
@ SELEC
Definition glwin.h:91
@ MEASU
Definition glwin.h:99
@ ATOMS
Definition glwin.h:89
@ RINGS
Definition glwin.h:96
#define NSELECTION
Definition glwin.h:67
char * text_styles[OGL_STYLES]
Definition m_style.c:54
G_MODULE_EXPORT void to_reset_view(GtkWidget *widg, gpointer data)
reset view callback - GTK3
Definition m_rep.c:200
Function declarations for the creation of the OpenGL window.
void append_opengl_item(glwin *view, GMenu *menu, const gchar *name, gchar *key, int mpop, int item_id, gchar *accel, int image_format, gpointer icon, gboolean custom, GCallback handler, gpointer data, gboolean check, gboolean status, gboolean radio, gboolean sensitive)
void init_project(gboolean alloc_box)
initialize a new project
Definition init_p.c:72
void show_info(char *information, int val, GtkWidget *win)
add / show information message to widget
Definition interface.c:234
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
Definition interface.c:889
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
GMenu * menu_anim(glwin *view, int popm)
create the 'Animate' submenu elements
Definition m_anim.c:139
GMenu * menu_atoms(glwin *view, int popm, int at)
create the 'Atom(s)' submenu elements
Definition m_atoms.c:797
GMenu * menu_bonds(glwin *view, int popm, int at)
create the 'Bond(s)' submenu GTK4
Definition m_bonds.c:367
GMenuItem * menu_box_axis(glwin *view, int popm, int ab)
create the 'Model -> Box' and 'View -> Axis' submenus GTK4
Definition m_box.c:470
GMenu * menu_clones(glwin *view, int popm)
create the 'Clone(s)' submenu GTK4
Definition m_clones.c:180
GMenu * menu_coord(glwin *view, int popm)
create the 'Coordination' submenu GTK4
Definition m_coord.c:689
GMenu * menu_rings(glwin *view, int popm)
create the 'Ring(s)' submenu GTK4
Definition m_coord.c:705
GMenu * add_menu_coord(glwin *view, int popm, int id)
create a coordination type submenu
Definition m_coord.c:652
GMenu * color_item(glwin *view, gchar *act, int popm, int id, GCallback handler, gpointer data)
create a submenu to attach a color palette
Definition m_coord.c:479
GMenu * extract_section(glwin *view, int popm)
create the 'Extract/Rebuild' menu items GTK4
Definition m_edit.c:332
GMenu * menu_poly(glwin *view, int popm)
create the 'Chemistry -> Polyehdra' submenu - GTK4
Definition m_poly.c:490
GMenu * menu_fullscreen(glwin *view, int popm)
create the 'Fullscreen' menu item - GTK4
Definition m_rep.c:564
GMenu * menu_reset(glwin *view, int popm)
create the reset menu items - GTK4
Definition m_rep.c:548
GMenu * menu_view(glwin *view, int popm)
create the 'View' submenu - GTK4
Definition m_rep.c:579
GMenu * menu_tools(glwin *view, int popm)
create the 'Tools' submenu - GTK4
Definition m_tools.c:770
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
void alloc_proj_data(project *this_proj, int cid)
allocate data
Definition open_p.c:206
GtkWidget * selection_menu(glwin *view, int ati, int bti, int aoc, int mid, GCallback handler_a, GCallback handler_b, GCallback handler_c)
create popup submenu GTK3
Definition popup.c:3329
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:1483
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:2060
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:3948
G_MODULE_EXPORT void to_center_this_molecule(GtkWidget *widg, gpointer data)
center this molecule menu item callback GTK4
Definition popup.c:3975
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:2758
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:2276
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:3215
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:4132
atom_selection * bond_selection
Definition popup.c:184
G_MODULE_EXPORT void opengl_advanced(GtkWidget *widg, gpointer data)
create OpenGL rendering advanced window
Definition w_advance.c:1477
int selected_bspec
Definition popup.c: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:665
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:2393
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:3915
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:3667
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:180
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
Definition atom_edit.c:392
G_MODULE_EXPORT void set_full_screen(GtkWidget *widg, gpointer data)
set full screen callback GTK3
Definition popup.c: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:1840
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:2008
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:3051
int is_filled
Definition popup.c:183
int selected_btom
Definition popup.c:178
gchar * mot[2][2]
Definition popup.c:3294
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:1916
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:2343
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:331
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:2600
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:3112
G_MODULE_EXPORT void edit_in_new_project(GtkWidget *widg, gpointer data)
create new project using selection callback GTK3
Definition popup.c:2193
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:91
int b
Definition global.h:93
int a
Definition global.h:92
Definition glwin.h:875
Definition glwin.h:277
gchar * type
Definition global.h:828
gchar * object
Definition global.h:829
coord_info * coord
Definition global.h:908
int id
Definition global.h:893
Definition global.h:98
int b
Definition global.h:100
int c
Definition global.h:101
int a
Definition global.h:99
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)
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
int status
Definition w_advance.c:160
int element
Definition w_periodic.c:61
void add_project_to_workspace()
add project(s) to the workspace tree
Definition workspace.c:594
GtkWidget * img
Definition workspace.c:70
GtkWidget * lab
Definition workspace.c:73
Function declarations for workspace managment.