69extern G_MODULE_EXPORT
void set_camera_pos (GtkWidget * widg, gpointer data);
71extern G_MODULE_EXPORT
void set_full_screen (GSimpleAction *
action, GVariant * parameter, gpointer data);
73extern G_MODULE_EXPORT
void set_full_screen (GtkWidget * widg, gpointer data);
88 for (i=0; i<2; i++)
if (view -> anim -> last ->
img ->
labels[i].
scale) view -> create_shaders[
LABEL] = TRUE;
114 GLdouble
val = 10000.0;
124 the_rep = view -> rep_win;
125 p_depth = & view -> anim -> last ->
img -> p_depth;
126 c_angle = view -> anim -> last ->
img -> c_angle;
127 c_shift = view -> anim -> last ->
img -> c_shift;
128 gnear = & view -> anim -> last ->
img -> gnear;
135 *
zoom = 2.0*(1.0-value);
146 * p_depth = * gnear + 0.01;
147 gtk_spin_button_set_value ((GtkSpinButton *)the_rep -> camera_widg[1], * p_depth);
152 if (value < * p_depth)
158 * gnear = * p_depth - 0.01;
159 gtk_spin_button_set_value ((GtkSpinButton *)the_rep -> camera_widg[2], * gnear);
165 if (value != c_angle[cid ->
b - 3])
169 c_angle[cid ->
b - 3] = value;
173 v = c_angle[cid ->
b - 3] - value;
184 gtk_spin_button_set_value ((GtkSpinButton *)the_rep -> camera_widg[cid ->
b], value);
189 c_shift[cid ->
b - 5] = (value == 0.0) ? value : - value;
196 if (view -> anim -> last ->
img -> xyz ->
axis !=
NONE) view -> create_shaders[
MAXIS] = TRUE;
209G_MODULE_EXPORT
void reset_view (GtkButton * but, gpointer data)
218 for (i=0; i<2; i++)
tmp_rep -> c_shift[i] = 0.0;
224 gtk_spin_button_set_value ((GtkSpinButton *)
pref_rep_win -> camera_widg[2],
tmp_rep -> gnear);
230 gtk_spin_button_set_value ((GtkSpinButton *)
pref_rep_win -> camera_widg[i+3],
tmp_rep -> c_angle[i]);
234 gtk_spin_button_set_value ((GtkSpinButton *)
pref_rep_win -> camera_widg[i+5],
tmp_rep -> c_shift[i]);
265G_MODULE_EXPORT
void to_reset_view (GSimpleAction *
action, GVariant * parameter, gpointer data)
291G_MODULE_EXPORT gboolean
scroll_set_camera (GtkRange * range, GtkScrollType scroll, gdouble value, gpointer data)
305G_MODULE_EXPORT
void set_camera (GtkRange * range, gpointer data)
332G_MODULE_EXPORT gboolean
on_rep_delete (GtkWindow * widg, gpointer data)
343G_MODULE_EXPORT gboolean
on_rep_delete (GtkWidget * widg, GdkEvent * event, gpointer data)
350 if (view -> rep_win -> camera_widg[i]) view -> rep_win -> camera_widg[i] =
destroy_this_widget(view -> rep_win -> camera_widg[i]);
376 view = (
glwin *)data;
377 the_rep = view -> rep_win;
378 view -> anim -> last ->
img ->
rep =
rep;
385 if (the_rep -> camera_widg[i] && GTK_IS_WIDGET(the_rep -> camera_widg[i]))
426 gchar * cam_opts[7]={
"Zoom",
"<b>P</b>erspective depth",
"<b>C</b>amera depth",
427 "Camera pitch",
"Camera heading",
428 "Camera right/left",
"Camera up/down"};
430 double smax[7] = {1.0, 100.0, 100.0, 180.0, 180.0, 100.0, 100.0};
431 double smin[7] = {-2.0, 0.0, 0.0, -180.0, -180.0, -100.0, -100.0};
432 double sdel[7] = {0.001, 0.01, 0.01, 0.1, 0.1, 0.01, 0.01};
433 int sdig[7] = {3, 2, 2, 1, 1, 2, 2};
440 GtkWidget * phbox, * pvbox;
443 gboolean build_win = TRUE;
454 view = (
glwin *)data;
455 max_depth = view -> anim -> last ->
img -> m_depth;
458 if (view -> rep_win -> win && GTK_IS_WIDGET(view -> rep_win -> win))
466 view -> rep_win = g_malloc0(
sizeof*view -> rep_win);
467 the_rep = view -> rep_win;
469 the_rep -> win =
create_win (str, view -> win, FALSE, FALSE);
472 rep = view -> anim -> last ->
img ->
rep;
485 gchar * projection[6]={
"Right [1, 0, 0]",
"Left [-1, 0, 0]",
"Top [0, 1, 0]",
"Bottom [0, -1, 0]",
"Front [0, 0, 1]",
"Back [0, 0, -1]"};
491 gtk_widget_set_size_request (combo, 150, -1);
495 adv_box (
vbox,
"<b>Representation</b>", 10, 120, 0.0);
508 gtk_widget_set_size_request (combo, 150, -1);
512 adv_box (
vbox,
"<b>OpenGL camera set-up</b>", 10, 120, 0.0);
532 v = view -> anim -> last ->
img -> p_depth;
546 v = (
tmp_rep -> c_shift[i-5] == 0.0) ? 0.0 : -
tmp_rep -> c_shift[i-5];
550 v = (view -> anim -> last ->
img -> c_shift[i-5] == 0.0) ? 0.0 : - view -> anim -> last ->
img -> c_shift[i-5];
555 if (the_rep -> camera_widg[i]) the_rep -> camera_widg[i] =
destroy_this_widget (the_rep -> camera_widg[i]);
556 v_max = (i == 1) ? max_depth : (
preferences && i == 2) ? 10000.0 : smax[i];
561 str = g_strdup_printf (
"in [%.1f, %.1f]", smin[i], smax[i]);
565 str = g_strdup_printf (
"in [<b>C</b>. depth, %.1f]", max_depth);
569 str = (
preferences) ? g_strdup_printf (
"in [%.1f, <b>P</b>. depth<sup>*</sup>]", smin[i]) : g_strdup_printf (
"in [%.1f, <b>P</b>. depth]", smin[i]);
578 add_box_child_start (GTK_ORIENTATION_HORIZONTAL,
hbox,
create_button((
preferences) ?
"Reset" :
"Reset view",
IMG_NONE, NULL, 100, 25, GTK_RELIEF_NORMAL, G_CALLBACK(
reset_view), view), FALSE, FALSE, 200);
586 append_comments (the_rep -> win,
"<sup>*</sup>",
"Perspective depth evaluated from the model");
599G_MODULE_EXPORT
void set_rep (GtkWidget * widg, gpointer data)
604 i = this_proj -> modelgl -> anim -> last ->
img ->
rep;
609 if (i != j && gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
612 this_proj -> modelgl -> anim -> last ->
img ->
rep =
NONE;
615 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[i], FALSE);
616 if (widg != this_proj -> modelgl -> ogl_rep[j])
618 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[j], TRUE);
621 this_proj -> modelgl -> anim -> last ->
img ->
rep = j;
624 if (this_proj -> modelgl -> rep_win)
626 if (this_proj -> modelgl -> rep_win -> camera_widg[i] && GTK_IS_WIDGET(this_proj -> modelgl -> rep_win -> camera_widg[i]))
632 this_proj -> modelgl -> create_shaders[
MAXIS] = TRUE;
633 update (this_proj -> modelgl);
637 else if (i == j && ! gtk_check_menu_item_get_active ((GtkCheckMenuItem *)widg))
639 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)this_proj -> modelgl -> ogl_rep[j], TRUE);
656 GtkWidget * menur = gtk_menu_new ();
657 j = view -> anim -> last ->
img ->
rep;
662 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);
669 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);
688 const gchar *
rep = g_variant_get_string (parameter, NULL);
689 int lgt = strlen (
rep);
690 gchar * name = g_strdup_printf (
"%c%c",
rep[lgt-2],
rep[lgt-1]);
691 if (g_strcmp0(name,
".1") == 0)
694 name = g_strdup_printf (
"%.*s.0", lgt-2,
rep);
695 g_action_group_activate_action ((GActionGroup *)view -> action_group,
"set-rep", g_variant_new_string((
const gchar *)name));
700 const gchar *
rep = g_variant_get_string (parameter, NULL);
701 gchar * rep_name = NULL;
705 rep_name = g_strdup_printf (
"set-rep.%d.0", i);
706 if (g_strcmp0(
rep, (
const gchar *)rep_name) == 0)
716 g_action_change_state (G_ACTION (
action), parameter);
744 GMenu * menu = g_menu_new ();
746 i = view -> anim -> last ->
img ->
rep;
749 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);
751 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);
779 GMenu * menu = g_menu_new ();
780 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);
781 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);
795 GMenu * menu = g_menu_new ();
796 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);
810 GMenu * menu = g_menu_new ();
817 g_menu_append_section (menu, NULL, (GMenuModel*)
menu_reset(view, popm));
818 g_menu_append_section (menu, NULL, (GMenuModel*)
menu_fullscreen(view, popm));
double scale(double axe)
find appropriate major tick spacing based on axis length
Global variable declarations Global convenience function declarations Global data structure defin...
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
void append_comments(GtkWidget *vbox, gchar *symbol, gchar *legend)
append comments to a vertical box
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 combo_set_active(GtkWidget *combo, int pos)
set the active item's position
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 * create_combo()
create a GtkCombox widget, note deprecated in GTK4
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
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
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
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)
initialize 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...
#define CAMERA_ANGLE_X
Default value for the OpenGL camera pitch in °
#define ZOOM
Default value for the OpenGL zoom.
#define CAMERA_ANGLE_Y
Default value for the OpenGL camera heading in °
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
G_MODULE_EXPORT void set_projection_combo(GtkComboBox *box, gpointer data)
change projection combo callback
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
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 set_camera_pos(GtkWidget *widg, gpointer data)
set camera position callback
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
G_MODULE_EXPORT void set_rep_combo(GtkComboBox *box, gpointer data)
change representation combo callback
GMenu * menu_view(glwin *view, int popm)
create the 'View' submenu - GTK4
gchar * text_reps[OGL_REPS]
rep_edition * pref_rep_win
GtkWidget * adv_box(GtkWidget *box, char *lab, int vspace, int size, float xalign)
create a box with markup label
Preference variable declarations.