69extern G_MODULE_EXPORT
void set_full_screen (GSimpleAction *
action, GVariant * parameter, gpointer data);
71extern G_MODULE_EXPORT
void set_full_screen (GtkWidget * widg, gpointer data);
86 for (i=0; i<2; i++)
if (view -> anim -> last ->
img -> labels_scale[i]) view -> create_shaders[
LABEL] = TRUE;
87 if (view -> anim -> last ->
img -> labels_scale[2]) view -> create_shaders[
MAXIS] = TRUE;
88 if (view -> anim -> last ->
img -> labels_scale[3]) view -> create_shaders[
MEASU] = TRUE;
107 this_proj -> modelgl -> anim -> last ->
img ->
zoom = 2.0*(1.0-value);
112 if (value > this_proj -> modelgl -> anim -> last ->
img -> gnear)
114 this_proj -> modelgl -> anim -> last ->
img -> p_depth = value;
118 this_proj -> modelgl -> anim -> last ->
img -> p_depth = this_proj -> modelgl -> anim -> last ->
img -> gnear + 0.01;
119 gtk_spin_button_set_value ((GtkSpinButton *)this_proj -> modelgl -> camera_widg[1], this_proj -> modelgl -> anim -> last ->
img -> p_depth);
124 if (value < this_proj -> modelgl -> anim -> last ->
img -> p_depth)
126 this_proj -> modelgl -> anim -> last ->
img -> gnear = value;
130 this_proj -> modelgl -> anim -> last ->
img -> gnear = this_proj -> modelgl -> anim -> last ->
img -> p_depth - 0.01;
131 gtk_spin_button_set_value ((GtkSpinButton *)this_proj -> modelgl -> camera_widg[2], this_proj -> modelgl -> anim -> last ->
img -> gnear);
137 if (value != this_proj -> modelgl -> anim -> last ->
img -> c_angle[cid ->
b - 3])
139 v = this_proj -> modelgl -> anim -> last ->
img -> c_angle[cid ->
b - 3] - value;
153 this_proj -> modelgl -> anim -> last ->
img -> c_shift[cid ->
b - 5] = (value == 0.0) ? value : - value;
158 update (this_proj -> modelgl);
169G_MODULE_EXPORT
void reset_view (GtkButton * but, gpointer data)
172 int i = view -> mode;
190G_MODULE_EXPORT
void to_reset_view (GSimpleAction *
action, GVariant * parameter, gpointer data)
216G_MODULE_EXPORT gboolean
scroll_set_camera (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
230G_MODULE_EXPORT
void set_camera (GtkRange * range, gpointer data)
257G_MODULE_EXPORT gboolean
on_rep_delete (GtkWindow * widg, gpointer data)
268G_MODULE_EXPORT gboolean
on_rep_delete (GtkWidget * widg, GdkEvent * event, gpointer data)
275 if (view -> camera_widg[i]) view -> camera_widg[i] =
destroy_this_widget(view -> camera_widg[i]);
292 gchar * cam_opts[7]={
"Zoom:",
"Perspective depth:",
"Camera depth:",
293 "Camera pitch:",
"Camera heading:",
294 "Camera right/left",
"Camera up/down"};
296 double smax[7] = {1.0, 100.0, 100.0, 180.0, 180.0, 100.0, 100.0};
297 double smin[7] = {-2.0, 0.0, 0.0, -180.0, -180.0, -100.0, -100.0};
298 double sdel[7] = {0.001, 0.01, 0.01, 0.1, 0.1, 0.01, 0.01};
299 int sdig[7] = {3, 2, 2, 1, 1, 2, 2};
303 GtkWidget * arep =
create_win (str, view -> win, FALSE, FALSE);
314 v = 1.0-0.5*view -> anim -> last ->
img ->
zoom;
317 v = view -> anim -> last ->
img -> p_depth;
320 v = view -> anim -> last ->
img -> gnear;
325 v = view -> anim -> last ->
img -> c_angle[i-3];
329 v = (view -> anim -> last ->
img -> c_shift[i-5] == 0.0) ? 0.0 : - view -> anim -> last ->
img -> c_shift[i-5];
333 if (view -> camera_widg[i]) view -> camera_widg[i] =
destroy_this_widget(view -> camera_widg[i]);
335 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box, view -> camera_widg[i], FALSE, FALSE, 10);
338 str = g_strdup_printf (
"in [%.1f, %.1f]", smin[i], smax[i]);
342 str = g_strdup_printf (
"in [C. depth, %.1f]", smax[i]);
346 str = g_strdup_printf (
"in [%.1f, P. depth]", smin[i]);
354 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, box,
create_button(
"Reset view",
IMG_NONE, NULL, 100, 25, GTK_RELIEF_NORMAL, G_CALLBACK(
reset_view), view), FALSE, FALSE, 200);
367G_MODULE_EXPORT
void set_rep (GtkWidget * widg, gpointer data)
372 i = this_proj -> modelgl -> anim -> last ->
img ->
rep;
377 if (i != j && gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
380 this_proj -> modelgl -> anim -> last ->
img ->
rep =
NONE;
383 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[i], FALSE);
384 if (widg != this_proj -> modelgl -> ogl_rep[j])
386 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[j], TRUE);
389 this_proj -> modelgl -> anim -> last ->
img ->
rep = j;
394 if (this_proj -> modelgl -> camera_widg[i])
396 if (GTK_IS_WIDGET(this_proj -> modelgl -> camera_widg[i]))
403 this_proj -> modelgl -> create_shaders[
MAXIS] = TRUE;
404 update (this_proj -> modelgl);
408 else if (i == j && ! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
410 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[j], TRUE);
427 GtkWidget * menur = gtk_menu_new ();
428 j = view -> anim -> last ->
img ->
rep;
433 view -> ogl_rep[
i] =
gtk3_menu_item (menur,
text_reps[i],
IMG_NONE, NULL, G_CALLBACK(
set_rep), & view ->
colorp[i][0], FALSE, 0, 0, TRUE, TRUE, (i == j) ? TRUE : FALSE);
440 gtk3_menu_item (menur,
text_reps[i],
IMG_NONE, NULL, G_CALLBACK(
set_rep), & view ->
colorp[i][0], FALSE, 0, 0, TRUE, TRUE, (i == j) ? TRUE : FALSE);
459 const gchar *
rep = g_variant_get_string (parameter, NULL);
460 int lgt = strlen (
rep);
461 gchar * name = g_strdup_printf (
"%c%c",
rep[lgt-2],
rep[lgt-1]);
462 if (g_strcmp0(name,
".1") == 0)
465 name = g_strdup_printf (
"%.*s.0", lgt-2,
rep);
466 g_action_group_activate_action ((GActionGroup *)view -> action_group,
"set-rep", g_variant_new_string((
const gchar *)name));
471 const gchar *
rep = g_variant_get_string (parameter, NULL);
472 gchar * rep_name = NULL;
476 rep_name = g_strdup_printf (
"set-rep.%d.0", i);
477 if (g_strcmp0(
rep, (
const gchar *)rep_name) == 0)
487 g_action_change_state (G_ACTION (
action), parameter);
515 GMenu * menu = g_menu_new ();
517 i = view -> anim -> last ->
img ->
rep;
520 append_opengl_item (view, menu,
text_reps[j],
"rep", popm, j, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
change_rep_radio), (gpointer)view, FALSE, (i == j) ? TRUE : FALSE, TRUE, TRUE);
522 append_opengl_item (view, menu,
"Advanced",
"rep-adv", popm, j, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
to_rep_advanced), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
550 GMenu * menu = g_menu_new ();
551 append_opengl_item (view, menu,
"Reset view",
"reset-view", popm, popm, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
to_reset_view), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
552 append_opengl_item (view, menu,
"Center molecule",
"center-mol", popm, popm, NULL,
IMG_NONE, NULL, FALSE, G_CALLBACK(
to_center_molecule), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
566 GMenu * menu = g_menu_new ();
567 append_opengl_item (view, menu,
"Fullscreen",
"full", popm, popm,
"<CTRL>F",
IMG_STOCK, (gpointer)
FULLSCREEN, FALSE, G_CALLBACK(
set_full_screen), (gpointer)view, FALSE, FALSE, FALSE, TRUE);
581 GMenu * menu = g_menu_new ();
588 g_menu_append_section (menu, NULL, (GMenuModel*)
menu_reset(view, popm));
589 g_menu_append_section (menu, NULL, (GMenuModel*)
menu_fullscreen(view, popm));
Global variable declarations Global convenience function declarations Global data structure defin...
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)
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
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
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
GtkWidget * spin_button(GCallback handler, double value, double start, double end, double step, int digits, int dim, gpointer data)
create a spin button
GtkWidget * add_advanced_item(GtkWidget *menu, GCallback handler, gpointer data, gboolean accel, guint key, GdkModifierType mod)
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
GtkWidget * abox(GtkWidget *box, char *lab, int vspace)
box creating routine, to help design faster elements for the GUI
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
void update(glwin *view)
update the rendering of the OpenGL window
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
void init_camera(project *this_proj, int get_depth)
intialize the OpenGL camera settings
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
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)
Messaging function declarations.
GMenu * menu_back(glwin *view, int popm)
create the background color menu item GTK4
GMenuItem * menu_box_axis(glwin *view, int popm, int ab)
create the 'Model -> Box' and 'View -> Axis' submenus GTK4
GMenu * menu_proj(glwin *view, int popm)
create the 'View -> Projection' submenu - GTK4
G_MODULE_EXPORT void to_center_molecule(GSimpleAction *action, GVariant *parameter, gpointer data)
center molecule callback - GTK4
void update_labels(glwin *view)
update labels (on representation data update)
void save_rotation_quaternion(glwin *view)
save the rotation quaternion of the last image
GMenu * menu_fullscreen(glwin *view, int popm)
create the 'Fullscreen' menu item - GTK4
GMenu * menu_reset(glwin *view, int popm)
create the reset menu items - GTK4
G_MODULE_EXPORT void change_rep_radio(GSimpleAction *action, GVariant *parameter, gpointer data)
change representation radio items callback - GTK4
void camera_has_changed(gdouble value, gpointer data)
update camera data
G_MODULE_EXPORT void reset_view(GtkButton *but, gpointer data)
reset view callback
G_MODULE_EXPORT void set_full_screen(GtkWidget *widg, gpointer data)
set full screen callback GTK3
G_MODULE_EXPORT void set_rep(GtkWidget *widg, gpointer data)
change representation callback - GTK3
G_MODULE_EXPORT gboolean on_rep_delete(GtkWidget *widg, GdkEvent *event, gpointer data)
representation window delete event - GTK3
G_MODULE_EXPORT void set_camera(GtkRange *range, gpointer data)
update camera data callback - range callback
GMenu * menu_rep(glwin *view, int popm)
create 'View -> Representation' submenu items - GTK4
G_MODULE_EXPORT void to_reset_view(GtkWidget *widg, gpointer data)
reset view callback - GTK3
G_MODULE_EXPORT void to_rep_advanced(GSimpleAction *action, GVariant *parameter, gpointer data)
change representation callback - GTK4
G_MODULE_EXPORT gboolean scroll_set_camera(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data)
update camera data callback - scroll callback
void rotate_x_y(glwin *view, double angle_x, double angle_y)
rotate the OpenGL camera
G_MODULE_EXPORT void set_camera_spin(GtkSpinButton *res, gpointer data)
update camera data callback - spin button
G_MODULE_EXPORT void representation_advanced(GtkWidget *widg, gpointer data)
open advanced representation dialog
GMenu * menu_view(glwin *view, int popm)
create the 'View' submenu - GTK4
gchar * text_reps[OGL_REPS]