atomes 1.1.14
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
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-2024 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 G_MODULE_EXPORT void set_atom_parameter (GtkWidget * widg, gpointer data);
62
72gchar * label_atpts (project * this_proj, glwin * view, int id)
73{
74 int i;
75 gchar * mot;
76 gchar * tmp;
77 gchar * str;
78
79 for (i=0; i < this_proj -> nspec; i++)
80 {
81 switch (id)
82 {
83 case 0:
84 str = g_strdup_printf ("%s [ %f Å ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> sphererad[i]);
85 break;
86 case 1:
87 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> pointrad[i]);
88 break;
89 case 2:
90 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> sphererad[i+this_proj -> nspec]);
91 break;
92 case 3:
93 str = g_strdup_printf ("%s [ %f pts ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> pointrad[i+this_proj -> nspec]);
94 break;
95 default:
96 str = g_strdup_printf ("%s [ %f Å ]", this_proj -> chemistry -> label[i], view -> anim -> last -> img -> atomicrad[i]);
97 break;
98 }
99 if (i == 0)
100 {
101 mot = g_strdup_printf ("%s", str);
102 }
103 else
104 {
105 tmp = g_strdup_printf ("%s", mot);
106 g_free (mot);
107 mot = g_strdup_printf ("%s\n%s", tmp, str);
108 g_free (tmp);
109 }
110 g_free (str);
111 }
112 return mot;
113}
114
115#ifdef GTK3
116extern G_MODULE_EXPORT void set_show_hide_all_atom_labels (GtkWidget * widg, gpointer data);
117extern G_MODULE_EXPORT void atom_properties (GtkWidget * widg, gpointer data);
118
127G_MODULE_EXPORT void show_hide_atoms (GtkWidget * widg, gpointer data)
128{
129 tint * the_data = (tint *) data;
130 int j = the_data -> b;
131 int k = the_data -> c;
132 int l, m;
133 project * this_proj = get_project_by_id(the_data -> a);
134 gboolean v = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
135 if (widg != this_proj -> modelgl -> ogl_spec[j][k])
136 {
137 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_spec[j][k], v);
138 }
139 for (l=0; l<this_proj -> steps; l++)
140 {
141 for (m=0; m<this_proj -> natomes; m++)
142 {
143 if (this_proj -> atoms[l][m].sp == k) this_proj -> atoms[l][m].show[j] = v;
144 }
145 }
146 this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k] = v;
147 init_default_shaders (this_proj -> modelgl);
148}
149
158G_MODULE_EXPORT void show_hide_labels (GtkWidget * widg, gpointer data)
159{
160 int l, m;
161 tint * id = (tint *) data;
162 int j = id -> b;
163 int k = id -> c;
164 project * this_proj = get_project_by_id(id -> a);
165 gboolean v = gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg);
166 if (widg != this_proj -> modelgl -> ogl_lab[j][k])
167 {
168 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[j][k], v);
169 }
170 for (l=0; l<this_proj -> steps; l++)
171 {
172 for (m=0; m<this_proj -> natomes; m++)
173 {
174 if (this_proj -> atoms[l][m].sp == k)
175 {
176 if (this_proj -> atoms[l][m].label[j] != v)
177 {
178 this_proj -> atoms[l][m].label[j] = v;
179 }
180 }
181 }
182 }
183 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, j);
184 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
185 update (this_proj -> modelgl);
186}
187
196G_MODULE_EXPORT void show_hide_all_atom_labels (GtkWidget * widg, gpointer data)
197{
198 tint * id = (tint *) data;
199 int j = id -> b;
200 int k;
201 gboolean show = TRUE;
202 project * this_proj = get_project_by_id(id -> a);
203 for (k=0; k<this_proj -> nspec; k++)
204 {
205 if (plot -> show_label[j][k]) show = FALSE;
206 }
207 for (k=0; k<this_proj -> nspec; k++)
208 {
209 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_lab[j][k], show);
210 }
211}
212
225GtkWidget * create_spec_menu (char * name, gboolean va, gboolean vb, GtkWidget * menu, GCallback handler, tint * data)
226{
227 GtkWidget * spec_widget = gtk3_menu_item (menu, name, IMG_NONE, NULL, handler, data, FALSE, 0, 0, TRUE, FALSE, va);
228 widget_set_sensitive (spec_widget, vb);
229 return spec_widget;
230}
231
241GtkWidget * create_atom_layout_widget (gchar * str, GtkWidget * widg, tint * data)
242{
243 GtkWidget * menu = gtk_menu_new ();
244 gtk_menu_item_set_submenu ((GtkMenuItem *)widg, menu);
245 GtkWidget * layout = create_menu_item (TRUE, str);
246 gtk_menu_shell_append ((GtkMenuShell *)menu, layout);
247 g_signal_connect (G_OBJECT (layout), "activate", G_CALLBACK(set_atom_parameter), data);
248 return layout;
249}
250
260GtkWidget * show_atoms_submenu (glwin * view, int id, int at)
261{
262 GtkWidget * mshow = gtk_menu_new ();
263 gchar * str;
264 gboolean sensitive = (! at) ? TRUE : view -> anim -> last -> img -> draw_clones;
265 project * this_proj = get_project_by_id (view -> proj);
266 if (id == 0)
267 {
268 view -> ogl_spec[at] = g_malloc (this_proj -> nspec*sizeof*view -> ogl_spec[at]);
269 }
270 int i;
271 for (i=0; i< this_proj -> nspec; i++)
272 {
273 if (at == 0)
274 {
275 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
276 }
277 else
278 {
279 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
280 }
281 if (id == 0)
282 {
283 view -> ogl_spec[at][i] = create_spec_menu (str,
284 view -> anim -> last -> img -> show_atom[at][i],
285 sensitive,
286 mshow,
287 G_CALLBACK(show_hide_atoms),
288 & view -> colorp[at][i]);
289
290 }
291 else
292 {
293 create_spec_menu (str, view -> anim -> last -> img -> show_atom[at][i],
294 sensitive,
295 mshow,
296 G_CALLBACK(show_hide_atoms),
297 & view -> colorp[at][i]);
298 }
299 g_free (str);
300 }
301 return mshow;
302}
303
313GtkWidget * color_atoms_submenu (glwin * view, int id, int at)
314{
315 GtkWidget * menuc = gtk_menu_new ();
316 project * this_proj = get_project_by_id (view -> proj);
317 gchar * str;
318 GtkWidget * sp;
319 int i, j;
320 if (at == 0)
321 {
322 j = 0;
323 }
324 else
325 {
326 j = this_proj -> nspec;
327 }
328 for (i=0; i< this_proj -> nspec; i++)
329 {
330 if (at == 0)
331 {
332 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
333 }
334 else
335 {
336 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
337 }
338 sp = create_menu_item (FALSE, str);
339 g_free (str);
340 gtk_menu_shell_append ((GtkMenuShell *)menuc, sp);
341 gtk_menu_item_set_submenu ((GtkMenuItem *)sp, color_box(view, i+j, 0, 0));
342 }
343 if (at == 1) widget_set_sensitive (menuc, view -> anim -> last -> img -> draw_clones);
344 return menuc;
345}
346
356GtkWidget * label_atoms_submenu (glwin * view, int id, int at)
357{
358 GtkWidget * menul = gtk_menu_new ();
359 GtkWidget * all = create_menu_item (FALSE, "Show/Hide all");
360 g_signal_connect (G_OBJECT (all), "activate", G_CALLBACK(show_hide_all_atom_labels), & view -> colorp[at][0]);
361 gtk_menu_shell_append ((GtkMenuShell *)menul, all);
362 GtkWidget * l_show = create_menu_item (FALSE, "Show");
363 gtk_menu_shell_append ((GtkMenuShell *)menul, l_show);
364 GtkWidget * mshow = gtk_menu_new ();
365 gtk_menu_item_set_submenu ((GtkMenuItem *)l_show, mshow);
366 project * this_proj = get_project_by_id (view -> proj);
367 gchar * str;
368 gboolean sensitive = (! at) ? TRUE : view -> anim -> last -> img -> draw_clones;
369 if (id == 0)
370 {
371 view -> ogl_lab[at] = g_malloc (this_proj -> nspec*sizeof*view -> ogl_lab[at]);
372 }
373 int i;
374 for (i=0; i< this_proj -> nspec; i++)
375 {
376 if (at == 0)
377 {
378 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
379 }
380 else
381 {
382 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
383 }
384 if (id == 0)
385 {
386 view -> ogl_lab[at][i] = create_spec_menu (str,
387 view -> anim -> last -> img -> show_label[at][i],
388 sensitive,
389 mshow,
390 G_CALLBACK(show_hide_labels),
391 & view -> colorp[at][i]);
392 }
393 else
394 {
395 create_spec_menu (str,
396 view -> anim -> last -> img -> show_label[at][i],
397 sensitive,
398 mshow,
399 G_CALLBACK(show_hide_labels),
400 & view -> colorp[at][i]);
401 }
402 }
403 if (at == 0 || id == 1)
404 {
405 GtkWidget * l_sel = create_menu_item (FALSE, "Select atom(s)");
406 gtk_menu_shell_append ((GtkMenuShell *)menul, l_sel);
407 g_signal_connect (G_OBJECT (l_sel), "activate",G_CALLBACK(atom_properties), & view -> colorp[at][2]);
408 if (id == 1) widget_set_sensitive (l_sel, sensitive);
409 GtkWidget * l_adv = add_advanced_item (menul, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][1], FALSE, 0, 0);
410 if (id == 1) widget_set_sensitive (l_adv, sensitive);
411 }
412 else
413 {
414 view -> ogl_clones[2] = create_menu_item (FALSE, "Select atom(s)");
415 gtk_menu_shell_append ((GtkMenuShell *)menul, view -> ogl_clones[2]);
416 g_signal_connect (G_OBJECT (view -> ogl_clones[2]), "activate",G_CALLBACK(atom_properties), & view -> colorp[at][2]);
417 widget_set_sensitive (view -> ogl_clones[2], sensitive);
418 view -> ogl_clones[3] = add_advanced_item (menul, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][1], FALSE, 0, 0);
419 widget_set_sensitive (view -> ogl_clones[3], sensitive);
420 }
421 return menul;
422}
423
433GtkWidget * menu_atoms (glwin * view, int id, int at)
434{
435 int i;
436 GtkWidget * widg;
437 gchar * str;
438 project * this_proj = get_project_by_id(view -> proj);
439 GtkWidget * menua = gtk_menu_new ();
440 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Show", TRUE, show_atoms_submenu (view, id, at)));
441 if (at == 1 && id == 0)
442 {
443 view -> ogl_clones[1] = color_atoms_submenu (view, id, at);
444 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]));
445 }
446 else
447 {
448 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)));
449 }
450 gtk_menu_shell_append ((GtkMenuShell *)menua, menu_item_new_with_submenu ("Label(s)", TRUE, label_atoms_submenu (view, id, at)));
451
452 i = view -> anim -> last -> img -> style;
453 str = label_atpts (this_proj, view, 2*at);
454 if (id == 0)
455 {
456 view -> ogl_atoms[4*at] = create_menu_item(FALSE, "Radius(ii)");
457 gtk_menu_shell_append ((GtkMenuShell *)menua, view -> ogl_atoms[4*at]);
458 view -> ogl_atoms[4*at+1] = create_atom_layout_widget (str, view -> ogl_atoms[4*at], & view -> colorp[at][0]);
459 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
460 {
461 widget_set_sensitive (view -> ogl_atoms[4*at+1], 0);
462 }
463 }
464 else if (i == SPHERES || i == BALL_AND_STICK)
465 {
466 widg = create_menu_item (FALSE, "Radius(ii)");
467 gtk_menu_shell_append ((GtkMenuShell *)menua, widg);
468 widg = create_atom_layout_widget (str, widg, & view -> colorp[at][0]);
469 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
470 {
471 widget_set_sensitive (widg, 0);
472 }
473 }
474 g_free (str);
475
476 str = label_atpts (this_proj, view, 1+2*at);
477 if (id == 0)
478 {
479 view -> ogl_atoms[4*at+2] = create_menu_item(FALSE, "Point size(s)");
480 gtk_menu_shell_append ((GtkMenuShell *)menua, view -> ogl_atoms[4*at+2]);
481 view -> ogl_atoms[4*at+3] = create_atom_layout_widget (str, view -> ogl_atoms[4*at+2], & view -> colorp[at][1]);
482 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
483 {
484 widget_set_sensitive (view -> ogl_atoms[4*at+3], 0);
485 }
486 }
487 else if (i == WIREFRAME || i == PUNT)
488 {
489 widg = create_menu_item (FALSE, "Point size(s)");
490 gtk_menu_shell_append ((GtkMenuShell *)menua, widg);
491 widg = create_atom_layout_widget (str, widg, & view -> colorp[at][1]);
492 if (at == 1 && ! view -> anim -> last -> img -> draw_clones)
493 {
494 widget_set_sensitive (widg, 0);
495 }
496 }
497 g_free (str);
498 if (id == 0 && at == 1)
499 {
500 view -> ogl_clones[4] = add_advanced_item (menua, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][0], FALSE, 0, 0);
501 if (at == 1)
502 {
503 widget_set_sensitive (view -> ogl_clones[4], view -> anim -> last -> img -> draw_clones);
504 }
505 }
506 else
507 {
508 GtkWidget * advanced = add_advanced_item (menua, G_CALLBACK(atom_properties), (gpointer)& view -> colorp[at][0], FALSE, 0, 0);
509 if (at == 1)
510 {
511 widget_set_sensitive (advanced, view -> anim -> last -> img -> draw_clones);
512 }
513 }
514 return menua;
515}
516#else
517
518extern G_MODULE_EXPORT void atom_properties (GSimpleAction * action, GVariant * state, gpointer data);
519
529G_MODULE_EXPORT void show_hide_atoms (GSimpleAction * action, GVariant * parameter, gpointer data)
530{
531 tint * the_data = (tint *) data;
532 int j = the_data -> b;
533 int k = the_data -> c;
534 int l, m;
535 gboolean doit = TRUE;
536 gboolean show;
537 project * this_proj = get_project_by_id (the_data -> a);
538 GVariant * state;
539 if (action)
540 {
541 state = g_action_get_state (G_ACTION (action));
542 show = ! g_variant_get_boolean (state);
543 const gchar * atom = g_action_get_name ((GAction *)action);
544 int lgt = strlen (atom);
545 gchar * name = g_strdup_printf ("%c%c", atom[lgt-2], atom[lgt-1]);
546 if (g_strcmp0(name, ".1") == 0)
547 {
548 g_free (name);
549 name = g_strdup_printf ("%.*s.0", lgt-2, atom);
550 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
551 g_free (name);
552 doit = FALSE;
553 }
554 }
555 else
556 {
557 show = this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k];
558 }
559 if (doit)
560 {
561 for (l=0; l<this_proj -> steps; l++)
562 {
563 for (m=0; m<this_proj -> natomes; m++)
564 {
565 if (this_proj -> atoms[l][m].sp == k) this_proj -> atoms[l][m].show[j] = show;
566 }
567 }
568 this_proj -> modelgl -> anim -> last -> img -> show_atom[j][k] = show;
569 init_default_shaders (this_proj -> modelgl);
570 if (action)
571 {
572 g_action_change_state (G_ACTION (action), g_variant_new_boolean (show));
573 g_variant_unref (state);
574 }
575 }
576}
577
587G_MODULE_EXPORT void show_hide_labels (GSimpleAction * action, GVariant * parameter, gpointer data)
588{
589 tint * the_data = (tint *) data;
590 int j = the_data -> b;
591 int k = the_data -> c;
592 gboolean doit = TRUE;
593 gboolean show;
594 project * this_proj = get_project_by_id (the_data -> a);
595 GVariant * state;
596 if (action)
597 {
598 state = g_action_get_state (G_ACTION (action));
599 show = ! g_variant_get_boolean (state);
600 const gchar * label = g_action_get_name ((GAction *)action);
601 int lgt = strlen (label);
602 gchar * name = g_strdup_printf ("%c%c", label[lgt-2], label[lgt-1]);
603 if (g_strcmp0(name, ".1") == 0)
604 {
605 g_free (name);
606 name = g_strdup_printf ("%.*s.0", lgt-2, label);
607 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (const gchar *)name, NULL);
608 g_free (name);
609 doit = FALSE;
610 }
611 }
612 else
613 {
614 show = ! this_proj -> modelgl -> anim -> last -> img -> show_label[j][k];
615 }
616 if (doit)
617 {
618 int l, m;
619 for (l=0; l<this_proj -> steps; l++)
620 {
621 for (m=0; m<this_proj -> natomes; m++)
622 {
623 if (this_proj -> atoms[l][m].sp == k)
624 {
625 if (this_proj -> atoms[l][m].label[j] != show)
626 {
627 this_proj -> atoms[l][m].label[j] = show;
628 }
629 }
630 }
631 }
632 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, j);
633 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
634 update (this_proj -> modelgl);
635 if (action)
636 {
637 g_action_change_state (G_ACTION (action), g_variant_new_boolean (show));
638 g_variant_unref (state);
639 }
640 }
641}
642
652G_MODULE_EXPORT void show_hide_all_atom_labels (GSimpleAction * action, GVariant * parameter, gpointer data)
653{
654 // Neither check, nor radio
655 tint * id = (tint *) data;
656 int i, j, k;
657 project * this_proj = get_project_by_id(id -> a);
658 i = id -> b;
659 gboolean show = ! this_proj -> atoms[0][0].label[i];
660 for (j=0; j<this_proj -> steps; j++)
661 {
662 for (k=0; k<this_proj -> natomes; k++)
663 {
664 this_proj -> atoms[j][k].label[i] = show;
665 }
666 }
667 this_proj -> modelgl -> labelled = check_label_numbers (this_proj, i);
668 this_proj -> modelgl -> create_shaders[LABEL] = TRUE;
669 update (this_proj -> modelgl);
670 update_menu_bar (this_proj -> modelgl);
671}
672
683GMenu * label_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
684{
685 GMenu * menu = g_menu_new ();
686 append_opengl_item (view, menu, "Show/Hide All", (at) ? "clones-labels-all" : "atoms-labels-all", popm, popm, NULL, IMG_NONE, NULL,
687 FALSE, G_CALLBACK(show_hide_all_atom_labels), & view -> colorp[at][0], FALSE, FALSE, FALSE, sensitive);
688 GMenu * smenu = g_menu_new ();
689 project * this_proj = get_project_by_id (view -> proj);
690 gchar * str;
691 int i;
692 for (i=0; i< this_proj -> nspec; i++)
693 {
694 if (at == 0)
695 {
696 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
697 }
698 else
699 {
700 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
701 }
702 append_opengl_item (view, smenu, str, (! at) ? "atom-label" : "clone-label", popm, i, NULL, IMG_NONE, NULL,
703 FALSE, G_CALLBACK(show_hide_labels), & view -> colorp[at][i],
704 TRUE, view -> anim -> last -> img -> show_label[at][i], FALSE, sensitive);
705 }
706 append_submenu (menu, "Show", smenu);
707 append_opengl_item (view, menu, "Select atom(s)", (! at) ? "atom-select" : "clone-select", popm, i, NULL, IMG_NONE, NULL,
708 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][2], FALSE, FALSE, FALSE, sensitive);
709 append_opengl_item (view, menu, "Advanced", (! at) ? "atom-lab-adv" : "clone-lab-adv", popm, i, NULL, IMG_STOCK, DPROPERTIES,
710 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][1], FALSE, FALSE, FALSE, sensitive);
711 return menu;
712}
713
724GMenu * color_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
725{
726 GMenu * menu = g_menu_new ();
727 GMenu * menuc;
728 project * this_proj = get_project_by_id (view -> proj);
729 gchar * stra, * strb;
730 int i;
731 for (i=0; i< this_proj -> nspec; i++)
732 {
733 if (at == 0)
734 {
735 stra = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
736 }
737 else
738 {
739 stra = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
740 }
741 strb = g_strdup_printf ("%s", (! at) ? "atom-color" : "clone-color");
742 menuc = g_menu_new ();
743 append_opengl_item (view, menuc, strb, strb, popm, i, NULL, IMG_NONE, NULL, TRUE, NULL, NULL, FALSE, FALSE, FALSE, FALSE);
744 append_opengl_item (view, menuc, "More colors ...", strb, popm, i, NULL, IMG_NONE, NULL,
745 FALSE, G_CALLBACK(to_run_atom_color_window), & view -> colorp[0][i+at*this_proj -> nspec], FALSE, FALSE, FALSE, sensitive);
746 append_submenu (menu, stra, menuc);
747 g_free (stra);
748 g_free (strb);
749 g_object_unref (menuc);
750 }
751 return menu;
752}
753
764GMenu * show_atoms_submenu (glwin * view, int popm, int at, gboolean sensitive)
765{
766 GMenu * menu = g_menu_new ();
767 gchar * str;
768 project * this_proj = get_project_by_id (view -> proj);
769 int i;
770 for (i=0; i<this_proj -> nspec; i++)
771 {
772 if (at == 0)
773 {
774 str = g_strdup_printf ("%s", this_proj -> chemistry -> label[i]);
775 }
776 else
777 {
778 str = g_strdup_printf ("%s*", this_proj -> chemistry -> label[i]);
779 }
780 append_opengl_item (view, menu, str, (! at) ? "show-atom" : "show-clone", popm, i, NULL, IMG_NONE, NULL,
781 FALSE, G_CALLBACK(show_hide_atoms), & view -> colorp[at][i],
782 TRUE, view -> anim -> last -> img -> show_atom[at][i], FALSE, sensitive);
783 g_free (str);
784 }
785 return menu;
786}
787
797GMenu * menu_atoms (glwin * view, int popm, int at)
798{
799 int i = view -> anim -> last -> img -> style;
800 gboolean sensitive = (at) ? view -> anim -> last -> img -> draw_clones : TRUE;
801
802 GMenu * menu = g_menu_new ();
803 append_submenu (menu, "Show", show_atoms_submenu(view, popm, at, sensitive));
804 append_submenu (menu, "Color(s)", color_atoms_submenu (view, popm, at, sensitive));
805 append_submenu (menu, "Label(s)", label_atoms_submenu (view, popm, at, sensitive));
806 GMenuItem * item;
807 if (i == SPHERES || i == BALL_AND_STICK)
808 {
809 item = g_menu_item_new ("Radius(ii)", (sensitive) ? NULL : "None");
810 g_menu_item_set_attribute (item, "custom", "s", (at) ? "clone-radii" : "atom-radii", NULL);
811 g_menu_append_item (menu, item);
812 }
813 if (i == WIREFRAME || i == PUNT)
814 {
815 item = g_menu_item_new ("Point size(s)", (sensitive) ? NULL : "None");
816 g_menu_item_set_attribute (item, "custom", "s", (at) ? "clone-pts" : "atom-pts", NULL);
817 g_menu_append_item (menu, item);
818 }
819 append_opengl_item (view, menu, "Advanced", (! at) ? "atom-advanced" : "clone-advanced", popm, popm, NULL, IMG_STOCK, DPROPERTIES,
820 FALSE, G_CALLBACK(atom_properties), & view -> colorp[at][0],
821 FALSE, FALSE, FALSE, sensitive);
822 return menu;
823}
824#endif
gchar * mot[2][2]
Definition popup.c:3294
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:216
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:232
@ IMG_STOCK
Definition global.h:236
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:602
GtkWidget * add_advanced_item(GtkWidget *menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
#define DPROPERTIES
Definition global.h:178
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:186
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:1039
@ 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:724
G_MODULE_EXPORT void atom_properties(GSimpleAction *action, GVariant *state, gpointer data)
atom(s) propery callback GTK4
Definition w_atoms.c:573
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:72
G_MODULE_EXPORT void show_hide_labels(GSimpleAction *action, GVariant *parameter, gpointer data)
handle the show/hide label signal GTK4
Definition m_atoms.c:587
G_MODULE_EXPORT void show_hide_atoms(GSimpleAction *action, GVariant *parameter, gpointer data)
handle the show/hide signal GTK4
Definition m_atoms.c:529
GMenu * show_atoms_submenu(glwin *view, int popm, int at, gboolean sensitive)
create the 'Atom(s) -> Show' submenu elements
Definition m_atoms.c:764
GMenu * label_atoms_submenu(glwin *view, int popm, int at, gboolean sensitive)
create the 'Atom(s) -> Label(s)' submenu elements
Definition m_atoms.c:683
GMenu * menu_atoms(glwin *view, int popm, int at)
create the 'Atom(s)' submenu elements
Definition m_atoms.c:797
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:652
G_MODULE_EXPORT void set_atom_parameter(GtkWidget *widg, gpointer data)
set atom parameter - creating the dialog
Definition w_atoms.c:192
Definition global.h:839
Definition glwin.h:875
Definition global.h:98
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