atomes 1.1.17
atomes: an atomic scale modeling tool box
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
m_atoms.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2025 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'm_atoms.c'
24*
25* Contains:
26*
27
28 - The functions to create the 'Model -> Atom(s)' submenu
29
30*
31* List of functions:
32
33 gchar * label_atpts (project * this_proj, glwin * view, int id);
34
35 G_MODULE_EXPORT void show_hide_atoms (GtkWidget * widg, gpointer data);
36 G_MODULE_EXPORT void show_hide_labels (GtkWidget * widg, gpointer data);
37 G_MODULE_EXPORT void show_hide_all_atom_labels (GtkWidget * widg, gpointer data);
38 G_MODULE_EXPORT void show_hide_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
39 G_MODULE_EXPORT void show_hide_labels (GSimpleAction * action, GVariant * parameter, gpointer data);
40 G_MODULE_EXPORT void show_hide_all_atom_labels (GSimpleAction * action, GVariant * parameter, gpointer data);
41
42 GtkWidget * create_spec_menu (char * name, gboolean va, gboolean vb, GtkWidget * menu, GCallback handler, tint * data);
43 GtkWidget * create_atom_layout_widget (gchar * str, GtkWidget * widg, tint * data);
44 GtkWidget * show_atoms_submenu (glwin * view, int id, int at);
45 GtkWidget * color_atoms_submenu (glwin * view, int id, int at);
46 GtkWidget * label_atoms_submenu (glwin * view, int id, int at);
47 GtkWidget * menu_atoms (glwin * view, int id, int at);
48
49 GMenu * label_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive);
50 GMenu * color_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive);
51 GMenu * show_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive);
52 GMenu * menu_atoms (glwin * view, int popm, int at);
53
54*/
55
56#include "global.h"
57#include "glview.h"
58#include "glwindow.h"
59#include "color_box.h"
60
61extern void check_hidden_visible (project * this_proj);
62extern G_MODULE_EXPORT void set_atom_parameter (GtkWidget * widg, gpointer data);
63
73gchar * label_atpts (project * this_proj, glwin * view, int id)
74{
75 int i;
76 gchar * mot;
77 gchar * tmp;
78 gchar * str;
79
80 for (i=0; i < this_proj -> nspec; i++)
81 {
82 switch (id)
83 {
84 case 0:
85 str = g_strdup_printf ("%s [ %f Å ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> sphererad[i]);
86 break;
87 case 1:
88 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> pointrad[i]);
89 break;
90 case 2:
91 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> sphererad[i+this_proj -> nspec]);
92 break;
93 case 3:
94 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> pointrad[i+this_proj -> nspec]);
95 break;
96 default:
97 str = g_strdup_printf ("%s [ %f Å ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> atomicrad[i]);
98 break;
99 }
100 if (i == 0)
101 {
102 mot = g_strdup_printf ("%s", str);
103 }
104 else
105 {
106 tmp = g_strdup_printf ("%s", mot);
107 g_free (mot);
108 mot = g_strdup_printf ("%s\n%s", tmp, str);
109 g_free (tmp);
110 }
111 g_free (str);
112 }
113 return mot;
114}
115
116#ifdef GTK3
117extern G_MODULE_EXPORT void set_show_hide_all_atom_labels (GtkWidget * widg, gpointer data);
118extern G_MODULE_EXPORT void atom_properties (GtkWidget * widg, gpointer data);
119
128G_MODULE_EXPORT void show_hide_atoms (GtkWidget * widg, gpointer data)
129{
130 tint * the_data = (tint *) data;
131 int j = the_data -> b;
132 int k = the_data -> c;
133 int l, m;
134 project * this_proj = get_project_by_id(the_data -> a);
135 gboolean v = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
136 if (widg != this_proj -> modelgl -> ogl_spec[j][k])
137 {
138 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[j][k], v);
139 }
140 for (l=0; l<this_proj -> steps; l++)
141 {
142 for (m=0; m<this_proj -> natomes; m++)
143 {
144 if (this_proj -> atoms[l][m].sp == k) this_proj -> atoms[l][m].show[j] = v;
145 }
146 }
147 this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k] = v;
148 check_hidden_visible (this_proj);
149 init_default_shaders (this_proj -> modelgl);
150}
151
160G_MODULE_EXPORT void show_hide_labels (GtkWidget * widg, gpointer data)
161{
162 int l, m;
163 tint * id = (tint *) data;
164 int j = id -> b;
165 int k = id -> c;
166 project * this_proj = get_project_by_id(id -> a);
167 gboolean v = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
168 if (widg != this_proj -> modelgl -> ogl_lab[j][k])
169 {
170 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[j][k], v);
171 }
172 for (l=0; l<this_proj -> steps; l++)
173 {
174 for (m=0; m<this_proj -> natomes; m++)
175 {
176 if (this_proj -> atoms[l][m].sp == k)
177 {
178 if (this_proj -> atoms[l][m].label[j] != v)
179 {
180 this_proj -> atoms[l][m].label[j] = v;
181 }
182 }
183 }
184 }
185 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, j);
186 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
187 update (this_proj -> modelgl);
188}
189
198G_MODULE_EXPORT void show_hide_all_atom_labels (GtkWidget * widg, gpointer data)
199{
200 tint * id = (tint *) data;
201 int j = id -> b;
202 int k;
203 gboolean show = TRUE;
204 project * this_proj = get_project_by_id(id -> a);
205 for (k=0; k<this_proj -> nspec; k++)
206 {
207 if (plot -> show_label[j][k]) show = FALSE;
208 }
209 for (k=0; k<this_proj -> nspec; k++)
210 {
211 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[j][k], show);
212 }
213}
214
227GtkWidget * create_spec_menu (char * name, gboolean va, gboolean vb, GtkWidget * menu, GCallback handler, tint * data)
228{
229 GtkWidget * spec_widget = gtk3_menu_item (menu, name, IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, FALSE, va);
230 widget_set_sensitive (spec_widget, vb);
231 return spec_widget;
232}
233
243GtkWidget * create_atom_layout_widget (gchar * str, GtkWidget * widg, tint * data)
244{
245 GtkWidget * menu = gtk_menu_new ();
246 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menu);
247 GtkWidget * layout = create_menu_item (TRUE, str);
248 gtk_menu_shell_append ((GtkMenuShell *)menu, layout);
249 g_signal_connect (G_OBJECT (layout), "activate", G_CALLBACK(set_atom_parameter), data);
250 return layout;
251}
252
262GtkWidget * show_atoms_submenu (glwin * view, int id, int at)
263{
264 GtkWidget * mshow = gtk_menu_new ();
265 gchar * str;
266 gboolean sensitive = (! at) ? TRUE : view -> anim -> last -> img -> draw_clones;
267 project * this_proj = get_project_by_id (view -> proj);
268 if (id == 0)
269 {
270 view -> ogl_spec[at] = g_malloc (this_proj -> nspec*sizeof*view -> ogl_spec[at]);
271 }
272 int i;
273 for (i=0; i< this_proj -> nspec; i++)
274 {
275 if (at == 0)
276 {
277 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
278 }
279 else
280 {
281 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
282 }
283 if (id == 0)
284 {
285 view -> ogl_spec[at][i] = create_spec_menu (str,
286 view -> anim -> last -> img -> show_atom[at][i],
287 sensitive,
288 mshow,
289 G_CALLBACK(show_hide_atoms),
290 & view -> colorp[at][i]);
291
292 }
293 else
294 {
295 create_spec_menu (str, view -> anim -> last -> img -> show_atom[at][i],
296 sensitive,
297 mshow,
298 G_CALLBACK(show_hide_atoms),
299 & view -> colorp[at][i]);
300 }
301 g_free (str);
302 }
303 return mshow;
304}
305
315GtkWidget * color_atoms_submenu (glwin * view, int id, int at)
316{
317 GtkWidget * menuc = gtk_menu_new ();
318 project * this_proj = get_project_by_id (view -> proj);
319 gchar * str;
320 GtkWidget * sp;
321 int i, j;
322 if (at == 0)
323 {
324 j = 0;
325 }
326 else
327 {
328 j = this_proj -> nspec;
329 }
330 for (i=0; i< this_proj -> nspec; i++)
331 {
332 if (at == 0)
333 {
334 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
335 }
336 else
337 {
338 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
339 }
340 sp = create_menu_item (FALSE, str);
341 g_free (str);
342 gtk_menu_shell_append ((GtkMenuShell *)menuc, sp);
343 gtk_menu_item_set_submenu ((GtkMenuItem *)sp, color_box(view, i+j, 0, 0));
344 }
345 if (at == 1) widget_set_sensitive (menuc, view -> anim -> last -> img -> draw_clones);
346 return menuc;
347}
348
358GtkWidget * label_atoms_submenu (glwin * view, int id, int at)
359{
360 GtkWidget * menul = gtk_menu_new ();
361 GtkWidget * all = create_menu_item (FALSE, "Show/Hide all");
362 g_signal_connect (G_OBJECT (all), "activate", G_CALLBACK(show_hide_all_atom_labels), & view -> colorp[at][0]);
363 gtk_menu_shell_append ((GtkMenuShell *)menul, all);
364 GtkWidget * l_show = create_menu_item (FALSE, "Show");
365 gtk_menu_shell_append ((GtkMenuShell *)menul, l_show);
366 GtkWidget * mshow = gtk_menu_new ();
367 gtk_menu_item_set_submenu ((GtkMenuItem *)l_show, mshow);
368 project * this_proj = get_project_by_id (view -> proj);
369 gchar * str;
370 gboolean sensitive = (! at) ? TRUE : view -> anim -> last -> img -> draw_clones;
371 if (id == 0)
372 {
373 view -> ogl_lab[at] = g_malloc (this_proj -> nspec*sizeof*view -> ogl_lab[at]);
374 }
375 int i;
376 for (i=0; i< this_proj -> nspec; i++)
377 {
378 if (at == 0)
379 {
380 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
381 }
382 else
383 {
384 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
385 }
386 if (id == 0)
387 {
388 view -> ogl_lab[at][i] = create_spec_menu (str,
389 view -> anim -> last -> img -> show_label[at][i],
390 sensitive,
391 mshow,
392 G_CALLBACK(show_hide_labels),
393 & view -> colorp[at][i]);
394 }
395 else
396 {
397 create_spec_menu (str,
398 view -> anim -> last -> img -> show_label[at][i],
399 sensitive,
400 mshow,
401 G_CALLBACK(show_hide_labels),
402 & view -> colorp[at][i]);
403 }
404 }
405 if (at == 0 || id == 1)
406 {
407 GtkWidget * l_sel = create_menu_item (FALSE, "Select atom(s)");
408 gtk_menu_shell_append ((GtkMenuShell *)menul, l_sel);
409 g_signal_connect (G_OBJECT (l_sel), "activate",G_CALLBACK(atom_properties), & view -> colorp[at][2]);
410 if (id == 1) widget_set_sensitive (l_sel, sensitive);
411 GtkWidget * l_adv = add_advanced_item (menul, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][1], FALSE, 0, 0);
412 if (id == 1) widget_set_sensitive (l_adv, sensitive);
413 }
414 else
415 {
416 view -> ogl_clones[2] = create_menu_item (FALSE, "Select atom(s)");
417 gtk_menu_shell_append ((GtkMenuShell *)menul, view -> ogl_clones[2]);
418 g_signal_connect (G_OBJECT (view -> ogl_clones[2]), "activate",G_CALLBACK(atom_properties), & view -> colorp[at][2]);
419 widget_set_sensitive (view -> ogl_clones[2], sensitive);
420 view -> ogl_clones[3] = add_advanced_item (menul, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][1], FALSE, 0, 0);
421 widget_set_sensitive (view -> ogl_clones[3], sensitive);
422 }
423 return menul;
424}
425
435GtkWidget * menu_atoms (glwin * view, int id, int at)
436{
437 int i;
438 GtkWidget * widg;
439 gchar * str;
440 project * this_proj = get_project_by_id(view -> proj);
441 GtkWidget * menua = gtk_menu_new ();
442 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Show", TRUE, show_atoms_submenu (view, id, at)));
443 if (at == 1 && id == 0)
444 {
445 view -> ogl_clones[1] = color_atoms_submenu (view, id, at);
446 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Color(s)", ! (view -> anim -> last -> img -> color_map[0] != 0), view -> ogl_clones[1]));
447 }
448 else
449 {
450 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Color(s)", ! (view -> anim -> last -> img -> color_map[0] != 0), color_atoms_submenu (view, id, at)));
451 }
452 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Label(s)", TRUE, label_atoms_submenu (view, id, at)));
453
454 i = view -> anim -> last -> img -> style;
455 str = label_atpts (this_proj, view, 2*at);
456 if (id == 0)
457 {
458 view -> ogl_atoms[4*at] = create_menu_item(FALSE, "Radius(ii)");
459 gtk_menu_shell_append ((GtkMenuShell *)menua, view -> ogl_atoms[4*at]);
460 view -> ogl_atoms[4*at+1] = create_atom_layout_widget (str, view -> ogl_atoms[4*at], & view -> colorp[at][0]);
461 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
462 {
463 widget_set_sensitive (view -> ogl_atoms[4*at+1], 0);
464 }
465 }
466 else if (i == SPHERES || i == BALL_AND_STICK)
467 {
468 widg = create_menu_item (FALSE, "Radius(ii)");
469 gtk_menu_shell_append ((GtkMenuShell *)menua, widg);
470 widg = create_atom_layout_widget (str, widg, & view -> colorp[at][0]);
471 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
472 {
473 widget_set_sensitive (widg, 0);
474 }
475 }
476 g_free (str);
477
478 str = label_atpts (this_proj, view, 1+2*at);
479 if (id == 0)
480 {
481 view -> ogl_atoms[4*at+2] = create_menu_item(FALSE, "Point size(s)");
482 gtk_menu_shell_append ((GtkMenuShell *)menua, view -> ogl_atoms[4*at+2]);
483 view -> ogl_atoms[4*at+3] = create_atom_layout_widget (str, view -> ogl_atoms[4*at+2], & view -> colorp[at][1]);
484 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
485 {
486 widget_set_sensitive (view -> ogl_atoms[4*at+3], 0);
487 }
488 }
489 else if (i == WIREFRAME || i == PUNT)
490 {
491 widg = create_menu_item (FALSE, "Point size(s)");
492 gtk_menu_shell_append ((GtkMenuShell *)menua, widg);
493 widg = create_atom_layout_widget (str, widg, & view -> colorp[at][1]);
494 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
495 {
496 widget_set_sensitive (widg, 0);
497 }
498 }
499 g_free (str);
500 if (id == 0 && at == 1)
501 {
502 view -> ogl_clones[4] = add_advanced_item (menua, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][0], FALSE, 0, 0);
503 if (at == 1)
504 {
505 widget_set_sensitive (view -> ogl_clones[4], view -> anim -> last -> img -> draw_clones);
506 }
507 }
508 else
509 {
510 GtkWidget * advanced = add_advanced_item (menua, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][0], FALSE, 0, 0);
511 if (at == 1)
512 {
513 widget_set_sensitive (advanced, view -> anim -> last -> img -> draw_clones);
514 }
515 }
516 return menua;
517}
518#else
519
520extern G_MODULE_EXPORT void atom_properties (GSimpleAction * action, GVariant * state, gpointer data);
521
531G_MODULE_EXPORT void show_hide_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
532{
533 tint * the_data = (tint *) data;
534 int j = the_data -> b;
535 int k = the_data -> c;
536 int l, m;
537 gboolean doit = TRUE;
538 gboolean show;
539 project * this_proj = get_project_by_id (the_data -> a);
540 GVariant * state;
541 if (action)
542 {
543 state = g_action_get_state (G_ACTION (action));
544 show = ! g_variant_get_boolean (state);
545 const gchar * atom = g_action_get_name ((GAction *)action);
546 int lgt = strlen (atom);
547 gchar * name = g_strdup_printf ("%c%c", atom[lgt-2], atom[lgt-1]);
548 if (g_strcmp0(name, ".1") == 0)
549 {
550 g_free (name);
551 name = g_strdup_printf ("%.*s.0", lgt-2, atom);
552 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
553 g_free (name);
554 doit = FALSE;
555 }
556 }
557 else
558 {
559 show = this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k];
560 }
561 if (doit)
562 {
563 for (l=0; l<this_proj -> steps; l++)
564 {
565 for (m=0; m<this_proj -> natomes; m++)
566 {
567 if (this_proj -> atoms[l][m].sp == k) this_proj -> atoms[l][m].show[j] = show;
568 }
569 }
570 this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k] = show;
571 init_default_shaders (this_proj -> modelgl);
572 if (action)
573 {
574 g_action_change_state (G_ACTION (action), g_variant_new_boolean (show));
575 g_variant_unref (state);
576 }
577 }
578}
579
589G_MODULE_EXPORT void show_hide_labels (GSimpleAction * action, GVariant * parameter, gpointer data)
590{
591 tint * the_data = (tint *) data;
592 int j = the_data -> b;
593 int k = the_data -> c;
594 gboolean doit = TRUE;
595 gboolean show;
596 project * this_proj = get_project_by_id (the_data -> a);
597 GVariant * state;
598 if (action)
599 {
600 state = g_action_get_state (G_ACTION (action));
601 show = ! g_variant_get_boolean (state);
602 const gchar * label = g_action_get_name ((GAction *)action);
603 int lgt = strlen (label);
604 gchar * name = g_strdup_printf ("%c%c", label[lgt-2], label[lgt-1]);
605 if (g_strcmp0(name, ".1") == 0)
606 {
607 g_free (name);
608 name = g_strdup_printf ("%.*s.0", lgt-2, label);
609 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
610 g_free (name);
611 doit = FALSE;
612 }
613 }
614 else
615 {
616 show = ! this_proj -> modelgl -> anim -> last -> img -> show_label[j][k];
617 }
618 if (doit)
619 {
620 int l, m;
621 for (l=0; l<this_proj -> steps; l++)
622 {
623 for (m=0; m<this_proj -> natomes; m++)
624 {
625 if (this_proj -> atoms[l][m].sp == k)
626 {
627 if (this_proj -> atoms[l][m].label[j] != show)
628 {
629 this_proj -> atoms[l][m].label[j] = show;
630 }
631 }
632 }
633 }
634 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, j);
635 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
636 update (this_proj -> modelgl);
637 if (action)
638 {
639 g_action_change_state (G_ACTION (action), g_variant_new_boolean (show));
640 g_variant_unref (state);
641 }
642 }
643}
644
654G_MODULE_EXPORT void show_hide_all_atom_labels (GSimpleAction * action, GVariant * parameter, gpointer data)
655{
656 // Neither check, nor radio
657 tint * id = (tint *) data;
658 int i, j, k;
659 project * this_proj = get_project_by_id(id -> a);
660 i = id -> b;
661 gboolean show = ! this_proj -> atoms[0][0].label[i];
662 for (j=0; j<this_proj -> steps; j++)
663 {
664 for (k=0; k<this_proj -> natomes; k++)
665 {
666 this_proj -> atoms[j][k].label[i] = show;
667 }
668 }
669 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, i);
670 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
671 update (this_proj -> modelgl);
672 update_menu_bar (this_proj -> modelgl);
673}
674
685GMenu * label_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
686{
687 GMenu * menu = g_menu_new ();
688 append_opengl_item (view, menu, "Show/Hide All", (at) ? "clones-labels-all" : "atoms-labels-all", popm, popm, NULL, IMG_NONE, NULL,
689 FALSE, G_CALLBACK(show_hide_all_atom_labels), & view -> colorp[at][0], FALSE, FALSE, FALSE, sensitive);
690 GMenu * smenu = g_menu_new ();
691 project * this_proj = get_project_by_id (view -> proj);
692 gchar * str;
693 int i;
694 for (i=0; i< this_proj -> nspec; i++)
695 {
696 if (at == 0)
697 {
698 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
699 }
700 else
701 {
702 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
703 }
704 append_opengl_item (view, smenu, str, (! at) ? "atom-label" : "clone-label", popm, i, NULL, IMG_NONE, NULL,
705 FALSE, G_CALLBACK(show_hide_labels), & view -> colorp[at][i],
706 TRUE, view -> anim -> last -> img -> show_label[at][i], FALSE, sensitive);
707 }
708 append_submenu (menu, "Show", smenu);
709 append_opengl_item (view, menu, "Select atom(s)", (! at) ? "atom-select" : "clone-select", popm, i, NULL, IMG_NONE, NULL,
710 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][2], FALSE, FALSE, FALSE, sensitive);
711 append_opengl_item (view, menu, "Advanced", (! at) ? "atom-lab-adv" : "clone-lab-adv", popm, i, NULL, IMG_STOCK, DPROPERTIES,
712 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][1], FALSE, FALSE, FALSE, sensitive);
713 return menu;
714}
715
726GMenu * color_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
727{
728 GMenu * menu = g_menu_new ();
729 GMenu * menuc;
730 project * this_proj = get_project_by_id (view -> proj);
731 gchar * stra, * strb;
732 int i;
733 for (i=0; i< this_proj -> nspec; i++)
734 {
735 if (at == 0)
736 {
737 stra = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
738 }
739 else
740 {
741 stra = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
742 }
743 strb = g_strdup_printf ("%s", (! at) ? "atom-color" : "clone-color");
744 menuc = g_menu_new ();
745 append_opengl_item (view, menuc, strb, strb, popm, i, NULL, IMG_NONE, NULL, TRUE, NULL, NULL, FALSE, FALSE, FALSE, FALSE);
746 append_opengl_item (view, menuc, "More colors ...", strb, popm, i, NULL, IMG_NONE, NULL,
747 FALSE, G_CALLBACK(to_run_atom_color_window), & view -> colorp[0][i+at*this_proj -> nspec], FALSE, FALSE, FALSE, sensitive);
748 append_submenu (menu, stra, menuc);
749 g_free (stra);
750 g_free (strb);
751 g_object_unref (menuc);
752 }
753 return menu;
754}
755
766GMenu * show_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
767{
768 GMenu * menu = g_menu_new ();
769 gchar * str;
770 project * this_proj = get_project_by_id (view -> proj);
771 int i;
772 for (i=0; i<this_proj -> nspec; i++)
773 {
774 if (at == 0)
775 {
776 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
777 }
778 else
779 {
780 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
781 }
782 append_opengl_item (view, menu, str, (! at) ? "show-atom" : "show-clone", popm, i, NULL, IMG_NONE, NULL,
783 FALSE, G_CALLBACK(show_hide_atoms), & view -> colorp[at][i],
784 TRUE, view -> anim -> last -> img -> show_atom[at][i], FALSE, sensitive);
785 g_free (str);
786 }
787 return menu;
788}
789
799GMenu * menu_atoms (glwin * view, int popm, int at)
800{
801 int i = view -> anim -> last -> img -> style;
802 gboolean sensitive = (at) ? view -> anim -> last -> img -> draw_clones : TRUE;
803
804 GMenu * menu = g_menu_new ();
805 append_submenu (menu, "Show", show_atoms_submenu(view, popm, at, sensitive));
806 append_submenu (menu, "Color(s)", color_atoms_submenu (view, popm, at, sensitive));
807 append_submenu (menu, "Label(s)", label_atoms_submenu (view, popm, at, sensitive));
808 GMenuItem * item;
809 if (i == SPHERES || i == BALL_AND_STICK)
810 {
811 item = g_menu_item_new ("Radius(ii)", (sensitive) ? NULL : "None");
812 g_menu_item_set_attribute (item, "custom", "s", (at) ? "clone-radii" : "atom-radii", NULL);
813 g_menu_append_item (menu, item);
814 }
815 if (i == WIREFRAME || i == PUNT)
816 {
817 item = g_menu_item_new ("Point size(s)", (sensitive) ? NULL : "None");
818 g_menu_item_set_attribute (item, "custom", "s", (at) ? "clone-pts" : "atom-pts", NULL);
819 g_menu_append_item (menu, item);
820 }
821 append_opengl_item (view, menu, "Advanced", (! at) ? "atom-advanced" : "clone-advanced", popm, popm, NULL, IMG_STOCK, DPROPERTIES,
822 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][0],
823 FALSE, FALSE, FALSE, sensitive);
824 return menu;
825}
826#endif
gchar * mot[2][2]
Definition popup.c:3299
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 to_run_atom_color_window(GtkWidget *widg, gpointer data)
to run atom color selection window callback GTK3
Definition w_colors.c:223
PangoLayout * layout
Definition curve.c:79
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
int atoms[NUM_STYLES][2]
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
@ IMG_STOCK
Definition global.h:264
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)
project * proj
void append_submenu(GMenu *menu, const gchar *label, GMenu *submenu)
append a GMenuItem with a subenu to a GMenu, and use markup for the GMenuItem
Definition gui.c:727
GtkWidget * add_advanced_item(GtkWidget *menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
#define DPROPERTIES
Definition global.h:206
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:206
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:66
action
Definition glview.h:189
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1040
@ SPHERES
Definition glview.h:176
@ BALL_AND_STICK
Definition glview.h:173
@ WIREFRAME
Definition glview.h:174
@ PUNT
Definition glview.h:178
@ LABEL
Definition glwin.h:98
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)
GMenu * color_atoms_submenu(glwin *view, int popm, int at, gboolean sensitive)
create the 'Atom(s) -> Color(s)' submenu elements
Definition m_atoms.c:726
G_MODULE_EXPORT void atom_properties(GSimpleAction *action, GVariant *state, gpointer data)
atom(s) propery callback GTK4
Definition w_atoms.c:575
gchar * label_atpts(project *this_proj, glwin *view, int id)
prepare the text of a menu item in the 'Model -> Atom(s)' submenu
Definition m_atoms.c:73
void check_hidden_visible(project *this_proj)
check how many atom(s) are visible
Definition popup.c:869
G_MODULE_EXPORT void show_hide_labels(GSimpleAction *action, GVariant *parameter, gpointer data)
handle the show/hide label signal GTK4
Definition m_atoms.c:589
G_MODULE_EXPORT void show_hide_atoms(GSimpleAction *action, GVariant *parameter, gpointer data)
handle the show/hide signal GTK4
Definition m_atoms.c:531
GMenu * show_atoms_submenu(glwin *view, int popm, int at, gboolean sensitive)
create the 'Atom(s) -> Show' submenu elements
Definition m_atoms.c:766
GMenu * label_atoms_submenu(glwin *view, int popm, int at, gboolean sensitive)
create the 'Atom(s) -> Label(s)' submenu elements
Definition m_atoms.c:685
GMenu * menu_atoms(glwin *view, int popm, int at)
create the 'Atom(s)' submenu elements
Definition m_atoms.c:799
G_MODULE_EXPORT void show_hide_all_atom_labels(GSimpleAction *action, GVariant *parameter, gpointer data)
handle the show/hide all labels GTK4
Definition m_atoms.c:654
G_MODULE_EXPORT void set_atom_parameter(GtkWidget *widg, gpointer data)
set atom parameter - creating the dialog
Definition w_atoms.c:193
Definition global.h:884
Definition glwin.h:875
Definition global.h:104
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
GtkWidget * img
Definition workspace.c:70