60extern G_MODULE_EXPORT
void coord_properties (GtkWidget * widg, gpointer data);
63extern GtkWidget * color_palette (
glwin * view,
int ideo,
int spec,
int geo);
76 if (((
id == 2 ||
id == 3) && this_proj -> coord -> totcoord[
id] <=
COORD_MAX_MENU) || id < 2 || id > 3)
112 gboolean doit = TRUE;
123 j += this_proj -> coord -> ntg[g][i];
128 show = (widg) ? gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg) : this_proj -> modelgl -> anim -> last ->
img -> show_coord[g][j];
133 state = g_action_get_state (G_ACTION (
action));
134 show = ! g_variant_get_boolean (state);
135 const gchar * coord = g_action_get_name ((GAction *)
action);
136 int lgt = strlen (coord);
137 gchar * name = g_strdup_printf (
"%c%c", coord[lgt-2], coord[lgt-1]);
138 if (g_strcmp0(name,
".1") == 0)
140 name = g_strdup_printf (
"%.*s.0", lgt-2, coord);
141 g_action_group_activate_action ((GActionGroup *)this_proj -> modelgl -> action_group, (
const gchar *)name, NULL);
148 show = this_proj -> modelgl -> anim -> last ->
img -> show_coord[g][j];
152 g_debug (
"SHOW_HIDE_COORD:: p= %d, s= %d, c= %d, g= %d, show= %d", this_proj ->
id, s,
c, g, show);
161 if (widg != this_proj -> modelgl -> ogl_geom[i][g][j])
163 if (GTK_IS_WIDGET(this_proj -> modelgl -> ogl_geom[i][g][j]))
165 if (gtk_check_menu_item_get_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[i][g][j]) != show)
167 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_geom[i][g][j], show);
176 this_proj -> modelgl -> anim -> last ->
img -> show_coord[g][j] = show;
177 for (i=0; i<this_proj -> steps; i++)
179 for (j=0; j<this_proj -> natomes; j++)
183 if (this_proj ->
atoms[i][j].sp == s && this_proj ->
atoms[i][j].coord[g] ==
c)
185 this_proj ->
atoms[i][j].show[0] = this_proj ->
atoms[i][j].show[1] = show;
190 if (this_proj ->
atoms[i][j].coord[g] ==
c)
192 this_proj ->
atoms[i][j].show[0] = this_proj ->
atoms[i][j].show[1] = show;
197 k = this_proj -> coord -> geolist[g][0][
c] - 1;
198 if (this_proj ->
atoms[i][j].rings[s][k] != NULL)
200 if (this_proj ->
atoms[i][j].rings[s][k][0])
202 this_proj ->
atoms[i][j].show[0] = this_proj ->
atoms[i][j].show[1] = show;
208 k = this_proj -> coord -> geolist[g][0][
c] - 1;
209 if (this_proj ->
atoms[i][j].chain[k] != NULL)
211 if (this_proj ->
atoms[i][j].chain[k][0])
213 this_proj ->
atoms[i][j].show[0] = this_proj ->
atoms[i][j].show[1] = show;
223 g_action_change_state (G_ACTION (
action), g_variant_new_boolean (show));
224 g_variant_unref (state);
240void detach_frag_mol_menu (
glwin * view,
int id,
int jd)
243 if (view -> oglmc[
id][jd] != NULL)
245 if (view -> oglmc[
id][jd][0] != NULL)
247 if (GTK_IS_WIDGET(view -> oglmc[
id][jd][0]))
249 widg = gtk_menu_get_attach_widget (GTK_MENU(view -> oglmc[
id][jd][0]));
250 if (GTK_IS_WIDGET(widg))
252 g_object_ref (view -> oglmc[
id][jd][0]);
253 gtk_menu_detach (GTK_MENU(view -> oglmc[
id][jd][0]));
258 if (view -> oglmv[
id][jd] != NULL)
260 if (view -> oglmv[
id][jd][0] != NULL)
262 if (GTK_IS_WIDGET(view -> oglmv[
id][jd][0]))
264 widg = gtk_menu_get_attach_widget (GTK_MENU(view -> oglmv[
id][jd][0]));
265 if (GTK_IS_WIDGET(widg))
267 g_object_ref (view -> oglmv[
id][jd][0]);
268 gtk_menu_detach (GTK_MENU(view -> oglmv[
id][jd][0]));
290 GtkWidget * menuct = gtk_menu_new ();
293 if (jd == 2 || jd == 3) detach_frag_mol_menu(view,
id, jd);
295 gtk_menu_shell_append ((GtkMenuShell *)menuct, colt);
296 if (jd < 2 || jd > 3)
298 menucts = gtk_menu_new ();
299 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, menucts);
310 gtk_menu_shell_append ((GtkMenuShell *)menucts, colt);
311 menucts = gtk_menu_new ();
312 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, menucts);
314 j = (jd < 2) ? this_proj -> nspec : this_proj -> coord -> totcoord[jd];
319 if (view -> oglmv[
id][jd])
321 if (GTK_IS_WIDGET(view -> oglmv[
id][jd][i]))
323 widg = gtk_widget_get_parent (view -> oglmv[
id][jd][i]);
324 if (GTK_IS_WIDGET(widg))
326 g_object_ref (view -> oglmv[
id][jd][i]);
327 gtk_container_remove (GTK_CONTAINER(widg), view -> oglmv[
id][jd][i]);
329 gtk_menu_shell_append ((GtkMenuShell *)menucts, view -> oglmv[
id][jd][i]);
335 if (view -> ogl_geom[
id][jd])
337 if (GTK_IS_WIDGET(view -> ogl_geom[
id][jd][i]))
339 widg = gtk_widget_get_parent (view -> ogl_geom[
id][jd][i]);
340 if (GTK_IS_WIDGET(widg))
342 g_object_ref (view -> ogl_geom[
id][jd][i]);
343 gtk_container_remove (GTK_CONTAINER(widg), view -> ogl_geom[
id][jd][i]);
345 gtk_menu_shell_append ((GtkMenuShell *)menucts, view -> ogl_geom[
id][jd][i]);
351 else if ((jd == 2 && view -> adv_bonding[0]) || (jd == 3 && view -> adv_bonding[1]))
353 if (view -> oglmv[
id][jd])
355 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, view -> oglmv[
id][jd][0]);
361 gtk_menu_shell_append ((GtkMenuShell *)menuct, colt);
365 menucts = gtk_menu_new ();
366 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, menucts);
367 if (view -> oglmc[
id][jd])
369 for (i=0;
i<this_proj -> nspec;
i++)
371 if (GTK_IS_WIDGET(view -> oglmc[
id][jd][i]))
373 widg = gtk_widget_get_parent (view -> oglmc[
id][jd][i]);
374 if (GTK_IS_WIDGET(widg))
376 g_object_ref (view -> oglmc[
id][jd][i]);
377 gtk_container_remove (GTK_CONTAINER(widg), view -> oglmc[
id][jd][i]);
379 gtk_menu_shell_append ((GtkMenuShell *)menucts, view -> oglmc[
id][jd][i]);
384 else if ((jd == 2 && view -> adv_bonding[0]) || (jd == 3 && view -> adv_bonding[1]))
386 if (view -> oglmc[
id][jd])
388 if (GTK_IS_WIDGET(view -> oglmc[
id][jd][0]))
390 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, view -> oglmc[
id][jd][0]);
394 else if ((jd > 3 && jd < 9) && view -> rings)
396 if (view -> oglmc[
id][jd])
398 if (GTK_IS_WIDGET(view -> oglmc[
id][jd][0]))
400 widg = gtk_menu_get_attach_widget (GTK_MENU(view -> oglmc[
id][jd][0]));
401 if (GTK_IS_WIDGET(widg))
403 g_object_ref (view -> oglmc[
id][jd][0]);
404 gtk_menu_detach (GTK_MENU(view -> oglmc[
id][jd][0]));
406 gtk_menu_item_set_submenu ((GtkMenuItem *)colt, view -> oglmc[
id][jd][0]);
426 GtkWidget * menuc = gtk_menu_new ();
427 gtk_menu_item_set_submenu ((GtkMenuItem *)menuco, menuc);
444 GtkWidget * menuco = gtk_menu_new ();
450 if (view -> ring_max[i])
455 gtk_menu_shell_append ((GtkMenuShell *)menuco, view -> ogl_rings[i+1]);
479GMenu *
color_item (
glwin * view, gchar * act,
int popm,
int id, GCallback handler, gpointer data)
481 GMenu * menu = g_menu_new ();
482 append_opengl_item (view, menu, act, act, popm,
id, NULL,
IMG_NONE, NULL, TRUE, NULL, NULL, FALSE, FALSE, FALSE, FALSE);
483 append_opengl_item (view, menu,
"More colors ...", act, popm,
id, NULL,
IMG_NONE, NULL, FALSE, handler, data, FALSE, FALSE, FALSE, TRUE);
499 GMenu * menu = g_menu_new ();
502 gchar * stra, * strb;
504 for (i=0; i<this_proj -> nspec; i++)
506 menus = g_menu_new ();
507 if (this_proj -> coord)
509 if (this_proj -> coord -> ntg[
id])
514 j += this_proj -> coord -> ntg[id][k];
516 for (k=0; k < this_proj -> coord -> ntg[id][i]; k++)
524 stra = g_strdup_printf (
"%d", this_proj -> coord -> geolist[
id][i][k]);
528 strb = g_strdup_printf (
"%s-s", stra);
529 append_opengl_item (view, menus, stra, strb, popm, k+j, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
show_hide_coord), & view -> gcid[
id][k+j][
id],
530 TRUE, view -> anim -> last ->
img -> show_coord[
id][k+j], FALSE, TRUE);
534 strb = g_strdup_printf (
"%s-c", stra);
543 g_object_unref (menus);
574 GMenu * menu = g_menu_new ();
578 gchar * stra, * strb;
580 for (i=0; i < this_proj -> coord -> totcoord[id]; i++)
582 stra = g_strdup_printf (
"%s N°%d", (
id == 2) ?
"Fragment" :
"Molecule", i+1);
583 strb = g_strdup_printf (
"%s-%d", (
id == 2) ?
"frag" :
"mol", i+1);
586 append_opengl_item (view, menu, stra, strb, popm, i, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
show_hide_coord), & view -> gcid[
id][i][
id],
587 TRUE, view -> anim -> last ->
img -> show_coord[
id][i], FALSE, TRUE);
613 GMenu * menu = g_menu_new ();
617 menus = g_menu_new ();
618 append_submenu (menu, (
id < 9) ?
"Atoms In Ring(s) of Size " :
"Atoms In Chain(s) of Size ", menus);
621 gchar * rin = g_strdup_printf (
"rcol-%d",
id);
624 for (i=0; i < this_proj -> coord -> totcoord[id]; i++)
626 str = g_strdup_printf (
"rshow-%d", this_proj -> coord -> geolist[
id][0][i]);
629 append_opengl_item (view, menus, str, str, popm, i, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
show_hide_coord), & view -> gcid[
id][i][
id],
630 TRUE, view -> anim -> last ->
img -> show_coord[
id][i], FALSE, TRUE);
639 if (! mid) g_object_unref (menus);
654 GMenu * menu = g_menu_new ();
656 gchar * menu_name[2] = {
"Show/Hide",
"Color"};
675 append_opengl_item (view, menu,
"Advanced",
"adv-c", popm,
id, NULL,
IMG_STOCK, (gpointer)
DPROPERTIES, FALSE,
691 GMenu * menu = g_menu_new ();
707 GMenu * menu = g_menu_new ();
713 if (view -> ring_max[i])
integer(kind=c_int) function chemistry()
G_MODULE_EXPORT void window_color_coord(GtkWidget *widg, gpointer data)
create a window to select a color callback GTK3
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
Global variable declarations Global convenience function declarations Global data structure defin...
coord_info * active_coord
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
GtkWidget * add_advanced_item(GtkWidget *menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
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
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
#define COORD_MAX_MENU
Maximum number of fragments or molecules to build the related menu items.
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)
gchar * env_name(project *this_proj, int g, int s, int f, GtkTextBuffer *buffer)
ouput the name of a coordination sphere
gchar * exact_name(gchar *name)
short cut to print string without spaces
Messaging function declarations.
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
gboolean is_coord_in_menu(int id, project *this_proj)
is this coordination in a menu ?
GMenu * menu_coord(glwin *view, int popm)
create the 'Coordination' submenu GTK4
G_MODULE_EXPORT void show_hide_coord(GtkWidget *widg, gpointer data)
show/hide coordination callback GTK3
GMenu * menu_rings(glwin *view, int popm)
create the 'Ring(s)' submenu GTK4
G_MODULE_EXPORT void to_coord_properties(GSimpleAction *action, GVariant *parameter, gpointer data)
open advancedd coordination properties GTK4 callback
GMenu * add_menu_coord(glwin *view, int popm, int id)
create a coordination type submenu
GMenu * menu_show_frag_mol(glwin *view, int popm, int id, int mid)
create a fragment/molecule coordination submenu
GMenu * color_item(glwin *view, gchar *act, int popm, int id, GCallback handler, gpointer data)
create a submenu to attach a color palette
GMenu * menu_show_coord(glwin *view, int popm, int id, int mid)
create the coordination 'Show' or 'Color' submenus
GMenu * menu_show_rings(glwin *view, int popm, int id, int mid)
create a ring coordination submenu