atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
glwindow.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: 'glwindow.c'
24*
25* Contains:
26*
27
28 - The functions to create a project OpenGL window
29
30*
31* List of functions:
32
33 gboolean create_3d_model (int p, gboolean load);
34
35 G_MODULE_EXPORT gboolean on_key_pressed (GtkWidget * widg, GdkEventKey * event, gpointer data);
36 G_MODULE_EXPORT gboolean on_glwin_key_pressed (GtkEventControllerKey * self, guint keyval, guint keycode, GdkModifierType state, gpointer data);
37
38 void update_all_menus (glwin * view, int nats);
39 void menu_items_opengl (GtkWidget * menu, glwin * view, int pop);
40 void menu_items_model (GtkWidget * menu, glwin * view, int pop);
41 void menu_items_view (GtkWidget * menu, glwin * view, int popm);
42 void prepare_opengl_menu_bar (glwin * view);
43 void change_color_map (glwin * view, int col);
44 void set_motion (glwin * view, int axis, int da, int db, gboolean UpDown, GdkModifierType state);
45 void activate_glwin_action (gchar * action_string, gchar * action_name, glwin * view);
46 void glwin_key_pressed (guint keyval, GdkModifierType state, gpointer data);
47 void prep_model (int p);
48
49 G_MODULE_EXPORT void render_gl_image (GtkWidget * widg, gpointer data);
50 G_MODULE_EXPORT void on_win_realize (GtkWidget * widg, gpointer data);
51
52 GtkWidget * prep_rings_menu (glwin * view, int id);
53 GtkWidget * coord_menu (glwin * view);
54 GtkWidget * menu_opengl (glwin * view, int pop);
55 GtkWidget * menu_model (glwin * view, int pop);
56 GtkWidget * menu_view (glwin * view, int popm);
57
58 mat4_t insert_projection (glwin * view);
59
60 vec3_t get_insertion_coordinates (glwin * view);
61
62*/
63
64#include "global.h"
65#include "project.h"
66#include "calc.h"
67#include "glview.h"
68#include "initcoord.h"
69#include "submenus.h"
70#include "color_box.h"
71
72extern G_MODULE_EXPORT void opengl_advanced (GtkWidget * widg, gpointer data);
73extern G_MODULE_EXPORT void coord_properties (GtkWidget * widg, gpointer data);
74extern G_MODULE_EXPORT void set_style (GtkWidget * widg, gpointer data);
75extern G_MODULE_EXPORT void set_render (GtkWidget * widg, gpointer data);
76extern G_MODULE_EXPORT void set_mode (GtkWidget * widg, gpointer data);
77extern void set_sensitive_coord_menu (glwin * view, gboolean status);
78extern void set_color_map_sensitive (glwin * view);
79extern G_MODULE_EXPORT void set_selection_mode (GtkWidget * widg, gpointer data);
80
81extern gboolean spin (gpointer data);
82extern G_MODULE_EXPORT void spin_stop (GtkButton * but, gpointer data);
83extern G_MODULE_EXPORT void spin_go (GtkWidget * widg, gpointer data);
84extern void update_menus (glwin * view);
85extern G_MODULE_EXPORT void set_box_axis_style (GtkWidget * widg, gpointer data);
86extern G_MODULE_EXPORT void window_measures (GtkWidget * widg, gpointer data);
87extern G_MODULE_EXPORT void window_recorder (GtkWidget * widg, gpointer data);
88extern void window_encode (glwin * view, gboolean video);
89extern GtkWidget * menupoly (glwin * view, int jd, int id, gchar * poln);
90extern G_MODULE_EXPORT void set_color_map (GtkWidget * widg, gpointer data);
91#ifdef GTK4
92extern void update_menu_bar (glwin * view);
93extern G_MODULE_EXPORT void set_full_screen (GSimpleAction * action, GVariant * parameter, gpointer data);
94extern G_MODULE_EXPORT void add_object (GSimpleAction * action, GVariant * parameter, gpointer data);
95extern G_MODULE_EXPORT void label_unlabel_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
96extern G_MODULE_EXPORT void select_unselect_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
97extern G_MODULE_EXPORT void edit_in_new_project (GSimpleAction * action, GVariant * parameter, gpointer data);
98extern G_MODULE_EXPORT void remove_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
99extern G_MODULE_EXPORT void copy_the_atoms (GSimpleAction * action, GVariant * parameter, gpointer data);
100#else
101extern void prep_all_coord_menus (glwin * view);
102extern G_MODULE_EXPORT void set_full_screen (GtkWidget * widg, gpointer data);
103extern G_MODULE_EXPORT void to_reset_view (GtkWidget * widg, gpointer data);
104extern G_MODULE_EXPORT void add_object (GtkWidget * widg, gpointer data);
105extern G_MODULE_EXPORT void label_unlabel_atoms (GtkWidget * widg, gpointer data);
106extern G_MODULE_EXPORT void select_unselect_atoms (GtkWidget * widg, gpointer data);
107extern G_MODULE_EXPORT void remove_the_atoms (GtkWidget * widg, gpointer data);
108extern G_MODULE_EXPORT void copy_the_atoms (GtkWidget * widg, gpointer data);
109extern G_MODULE_EXPORT void edit_in_new_project (GtkWidget * widg, gpointer data);
110#endif
111extern void save_rotation_quaternion (glwin * view);
112extern void rotate_x_y (glwin * view, double angle_x, double angle_y);
113extern void translate (project * this_proj, int status, int axis, vec3_t trans);
114extern int selected_aspec;
115extern int is_selected;
116extern int is_labelled;
117extern G_MODULE_EXPORT void on_create_new_project (GtkWidget * widg, gpointer data);
118extern gchar * action_atoms[3];
119extern int get_selection_type (glwin * view);
120extern GtkWidget * shortcuts_window (int sections, int group_by_section[sections], int groups, int shortcut_by_group[groups],
121 gchar * section_names[sections], gchar * group_names[groups], shortcuts shortcs[]);
122
124
125gchar * opengl_section_names[]={ "General", "Analysis mode", "Edition mode" };
126int opengl_group_by_section[] = { 5, 4, 3 };
127gchar * opengl_group_names[]={"Styles", "Measures", "Selection mode", "Window management", "Mouse mode",
128 "Camera rotation", "Camera motion", "Camera spin", "Model interaction",
129 "Coordinates rotation", "Coordinates translation", "Model interaction"};
130int opengl_shortcut_by_group[] = { 10, 1, 4, 6, 2, // Global
131 4, 6, 6, 3, // Analysis
132 4, 6, 6 }; // Edition
133
135//
136// Global
137//
138 { "Atom(s) color map", "change atom(s) color map", GDK_KEY_a, "a" },
139 { "Polyhedra color map", "change polyhedra color map", GDK_KEY_p, "p" },
140 { "Ball and stick", "change global style to ball and stick", GDK_KEY_b, "b" },
141 { "Cylinders", "change global style to cylinders", GDK_KEY_w, "w" },
142 { "Spheres", "change global style to spheres", GDK_KEY_s, "s" },
143 { "Covalent radius", "change global style to cylinders", GDK_KEY_o, "o" },
144 { "Ionic radius", "change global style to cylinders", GDK_KEY_i, "i" },
145 { "Van der Waals radius", "change global style to van der Waals radius", GDK_KEY_v, "v" },
146 { "In crystal radius", "change global style to in crystal radius", GDK_KEY_r, "r" },
147 { "Wireframe", "change global style to wireframe", GDK_KEY_w, "w" },
148//
149 { "All measures for the selection, pressed:\n\n"
150 "\t- 1st time: show inter-atomic distance(s)\n"
151 "\t- 2nd time: show inter-atomic angles\n"
152 "\t- 3rd time: hide measures", "Show measures", GDK_KEY_m, "m" },
153//
154 { "Atom", "atom selection mode", GDK_KEY_a, "<Shift>a" },
155 { "Coordination", "coordination sphere selection mode", GDK_KEY_c, "<Shift>c" },
156 { "Fragment", "fragment selection mode", GDK_KEY_f, "<Shift>f" },
157 { "Molecule", "molecule selection mode", GDK_KEY_m, "<Shift>m" },
158//
159 { "Environments", "Environments window", GDK_KEY_e, "<Ctrl>e" },
160 { "Measures", "Measures window", GDK_KEY_m, "<Ctrl>m" },
161 { "Recorder", "Recorder window", GDK_KEY_r, "<Ctrl>r" },
162 { "Create new project", "Create new project", GDK_KEY_n, "<Ctrl>n" },
163 { "Enter fullscreen", "Enter fullscreen", GDK_KEY_f, "<Ctrl>f" },
164 { "Exit fullscreen", "Exit fullscreen", GDK_KEY_Escape, "Escape" },
165//
166#ifdef OSX
167 { "Analysis mode", "Analysis mode", GDK_KEY_a, "<Meta>a" },
168 { "Edition mode", "Edition mode", GDK_KEY_e, "<Meta>e" },
169#else
170 { "Analysis mode", "Analysis mode", GDK_KEY_a, "<Alt>a" },
171 { "Edition mode", "Edition mode", GDK_KEY_e, "<Alt>e" },
172#endif
173//
174// Analysis
175//
176 { "Rotate right", "rotate right", GDK_KEY_Right, "Right" },
177 { "Rotate left", "rotate left", GDK_KEY_Left, "Left" },
178 { "Rotate up", "rotate up", GDK_KEY_Up, "Up" },
179 { "Rotate down", "rotate down", GDK_KEY_Down, "Down" },
180//
181 { "Move right", "move camera right", GDK_KEY_Right, "<Ctrl>Right" },
182 { "Move left", "move camera left", GDK_KEY_Left, "<Ctrl>Left" },
183 { "Move up", "move camera up", GDK_KEY_Up, "<Ctrl>Up" },
184 { "Move down", "move camera down", GDK_KEY_Down, "<Ctrl>Down" },
185 { "Zoom in", "zoom camera in", GDK_KEY_Down, "<Shift>Up" },
186 { "Zoom out", "zoom camera out", GDK_KEY_Down, "<Shift>Down" },
187//
188 { "Spin right", "rotate right", GDK_KEY_Right, "<Ctrl><Shift>Right" },
189 { "Spin left", "rotate left", GDK_KEY_Left, "<Ctrl><Shift>Left" },
190 { "Spin up", "rotate up", GDK_KEY_Up, "<Ctrl><Shift>Up" },
191 { "Spin down", "rotate down", GDK_KEY_Down, "<Ctrl><Shift>Down" },
192 { "Pause / restart", "pause / restart spinning", GDK_KEY_space, "space" },
193 { "Stop", "stop spinning", GDK_KEY_s, "<Ctrl>s" },
194//
195 { "Label / unlabel all atom(s)", "Label / unlabel all atom(s)", GDK_KEY_l, "<Ctrl>l" },
196 { "Select / unselect all atom(s)", "Select / unselect all atom(s)", GDK_KEY_a, "<Ctrl>a" },
197 { "Copy selection", "Copy selection", GDK_KEY_c, "<Ctrl>c" },
198//
199// Edition
200//
201 { "Rotate right", "rotate right", GDK_KEY_Right, "Right" },
202 { "Rotate left", "rotate left", GDK_KEY_Left, "Left" },
203 { "Rotate up", "rotate up", GDK_KEY_Up, "Up" },
204 { "Rotate down", "rotate down", GDK_KEY_Down, "Down" },
205//
206 { "Translate right", "move camera right", GDK_KEY_Right, "<Ctrl>Right" },
207 { "Translate left", "move camera left", GDK_KEY_Left, "<Ctrl>Left" },
208 { "Translate up", "move camera up", GDK_KEY_Up, "<Ctrl>Up" },
209 { "Translate down", "move camera down", GDK_KEY_Down, "<Ctrl>Down" },
210 { "Zoom in", "zoom camera in", GDK_KEY_Up, "<Shift>Up" },
211 { "Zoom out", "zoom camera out", GDK_KEY_Down, "<Shift>Down" },
212//
213 { "Label / unlabel all atom(s)", "Label / unlabel all atom(s)", GDK_KEY_l, "<Ctrl>l" },
214 { "Select / unselect all atom(s)", "Select / unselect all atom(s)", GDK_KEY_a, "<Ctrl>a" },
215 { "Copy all selection", "Copy selection", GDK_KEY_c, "<Ctrl>c" },
216 { "Cut selection", "Cut selection", GDK_KEY_x, "<Ctrl>x" },
217 { "Paste selection", "Paste selection", GDK_KEY_v, "<Ctrl>v" },
218 { "Delete selection", "Delete selection", GDK_KEY_Delete, "Delete" }
219};
220
221#ifdef GTK3
230GtkWidget * prep_rings_menu (glwin * view, int id)
231{
232 if (id == 0)
233 {
234 return menu_rings (view, 0);
235 }
236 else
237 {
238 return menupoly (view, 0, 2, NULL);
239 }
240}
241
249GtkWidget * coord_menu (glwin * view)
250{
251 int i, j, k;
252 GtkWidget * widg;
253 for (j=4; j<10; j++)
254 {
255 if (j<9)
256 {
257 if (view -> ogl_poly[0][j] != NULL)
258 {
259 for (k=0; k<get_project_by_id(view -> proj) -> coord -> totcoord[j]; k++)
260 {
261 if (view -> ogl_poly[0][j][k] != NULL)
262 {
263 if (GTK_IS_WIDGET(view -> ogl_poly[0][j][k]))
264 {
265 widg = gtk_widget_get_parent (view -> ogl_poly[0][j][k]);
266 if (GTK_IS_WIDGET(widg))
267 {
268 g_object_ref (view -> ogl_poly[0][j][k]);
269 gtk_container_remove (GTK_CONTAINER(widg), view -> ogl_poly[0][j][k]);
270 }
271 }
272 }
273 }
274 }
275 }
276 if (view -> ogl_geom[0][j] != NULL)
277 {
278 for (k=0; k<get_project_by_id(view -> proj) -> coord -> totcoord[j]; k++)
279 {
280 if (view -> ogl_geom[0][j][k] != NULL)
281 {
282 if (GTK_IS_WIDGET(view -> ogl_geom[0][j][k]))
283 {
284 widg = gtk_widget_get_parent (view -> ogl_geom[0][j][k]);
285 if (GTK_IS_WIDGET(widg))
286 {
287 g_object_ref (view -> ogl_geom[0][j][k]);
288 gtk_container_remove (GTK_CONTAINER(widg), view -> ogl_geom[0][j][k]);
289 }
290 }
291 }
292 }
293 }
294 }
295 if (view -> ogl_chains[0]) view -> ogl_chains[0] = destroy_this_widget (view -> ogl_chains[0]);
296 for (i=0; i<2; i++)
297 {
298 for (j=2; j<4; j++)
299 {
300 detach_frag_mol_menu (view, i, j);
301 }
302 }
303 for (i=1; i<OGL_COORDS; i++)
304 {
305 view -> ogl_coord[i] = destroy_this_widget (view -> ogl_coord[i]);
306 }
307 for (i=0; i<2; i++)
308 {
309 view -> ogl_rings[i*6] = menu_item_new_with_submenu ("Ring(s)", view -> rings, prep_rings_menu (view, i*6));
310 }
311 view -> ogl_chains[0] = menu_item_new_with_submenu ("Chain(s)", view -> chains, add_menu_coord (view, 0, 9));
312 view -> ogl_coord[1] = menu_coord (view, 0);
313 view -> ogl_coord[2] = menu_item_new_with_submenu ("Polyhedra", TRUE, menu_poly (view, 0));
314 view -> ogl_coord[3] = menu_item_new_with_submenu ("Fragment(s)", get_project_by_id(view -> proj) -> coord -> totcoord[2], add_menu_coord (view, 0, 2));
315 view -> ogl_coord[4] = menu_item_new_with_submenu ("Molecule(s)", get_project_by_id(view -> proj) -> coord -> totcoord[3], add_menu_coord (view, 0, 3));
316 GtkWidget * menu = gtk_menu_new ();
317 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_coord[1]);
318 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_coord[2]);
319 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_rings[0]);
320 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_chains[0]);
321 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_coord[3]);
322 gtk_menu_shell_append ((GtkMenuShell *)menu, view -> ogl_coord[4]);
323 gtk3_menu_item (menu, "Advanced", IMG_NONE, NULL, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
324 // add_advanced_item (menu, G_CALLBACK(coord_properties), (gpointer)& view -> colorp[30][0], TRUE, GDK_KEY_e, GDK_CONTROL_MASK);
325 return menu;
326}
327#endif
328
337void update_all_menus (glwin * view, int nats)
338{
339#ifdef GTK3
340 int i, j, k, l;
341 i = view -> anim -> last -> img -> style;
342 j = (nats <= 1000) ? BALL_AND_STICK : DEFAULT_STYLE;
343 if (i != j)
344 {
345 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[j], FALSE);
346 if (i != SPACEFILL)
347 {
348 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[i], TRUE);
349 set_style (view -> ogl_styles[i], & view -> colorp[i][0]);
350 }
351 else
352 {
353 i = view -> anim -> last -> img -> filled_type;
354 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> filled_styles[i], TRUE);
355 set_style (view -> filled_styles[i], & view -> colorp[OGL_STYLES+i][0]);
356 }
357 }
358 i = view -> anim -> last -> img -> render;
359 j = FILL;
360 if (i != j)
361 {
362 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_render[j], FALSE);
363 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_render[i], TRUE);
364 set_render (view -> ogl_render[i], & view -> colorp[i][0]);
365 }
366
367 update_menus (view);
368 for (i=0; i<2; i++)
369 {
370 widget_set_sensitive (view -> ogl_box[i], active_cell -> ltype);
371 if (view -> anim -> last -> img -> box_axis[i] == NONE)
372 {
373 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_box_axis[i][0], FALSE);
374 set_box_axis_style (view -> ogl_box_axis[i][0], & view -> colorp[0][i]);
375 }
376 else
377 {
378 j = (view -> anim -> last -> img -> box_axis[i] == WIREFRAME) ? 1 : 2;
379 k = j*j;
380 l = (view -> anim -> last -> img -> box_axis[i] == WIREFRAME) ? CYLINDERS : WIREFRAME;
381 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_box_axis[i][0], TRUE);
382 set_box_axis_style (view -> ogl_box_axis[i][0], & view -> colorp[0][i]);
383 view -> anim -> last -> img -> box_axis[i] = l;
384 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_box_axis[i][j], TRUE);
385 set_box_axis_style (view -> ogl_box_axis[i][j], & view -> colorp[k][i]);
386 }
387 }
388 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_rep[view -> anim -> last -> img -> rep], TRUE);
389 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_rep[! view -> anim -> last -> img -> rep], FALSE);
390 for (i=0; i<5; i++) gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_box_axis[1][8+i], FALSE);
391 if (view -> anim -> last -> img -> axispos != CUSTOM)
392 {
393 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_box_axis[1][8+view -> anim -> last -> img -> axispos], TRUE);
394 }
396 widget_set_sensitive (view -> ogl_clones[0], view -> allbonds[1]);
397 update_rings_menus (view);
398 update_chains_menus (view);
399 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[0], view -> anim -> last -> img -> draw_clones);
400 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_clones[5], view -> anim -> last -> img -> cloned_poly);
401 int * cmap = save_color_map (view);
403 if (view -> color_styles[0])
404 {
405 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[0], TRUE);
406 set_color_map (view -> color_styles[0], & view -> colorp[0][0]);
407 }
408 if (view -> color_styles[ATOM_MAPS])
409 {
410 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[ATOM_MAPS], TRUE);
411 set_color_map (view -> color_styles[ATOM_MAPS], & view -> colorp[ATOM_MAPS][0]);
412 }
413 restore_color_map (view, cmap);
414 g_free (cmap);
415 gtk_range_set_value (GTK_RANGE(view -> ogl_quality), view -> anim -> last -> img -> quality);
416#else
417 update_menu_bar (view);
418#endif
419}
420
429G_MODULE_EXPORT void render_gl_image (GtkWidget * widg, gpointer data)
430{
431 glwin * view = (glwin *) data;
432 window_encode (view, FALSE);
433}
434
435#ifdef GTK4
445G_MODULE_EXPORT void view_shortcuts (GSimpleAction * action, GVariant * parameter, gpointer data)
446#else
455G_MODULE_EXPORT void view_shortcuts (GtkWidget * widg, gpointer data)
456#endif
457{
458 glwin * view = (glwin *)data;
459 view -> shortcuts = destroy_this_widget (view -> shortcuts);
462}
463
464#ifdef GTK3
465
475void menu_items_opengl (GtkWidget * menu, glwin * view, int pop)
476{
477 GtkWidget * style = gtk3_menu_item (menu, "Style", IMG_FILE, (gpointer)PACKAGE_MOL, NULL, NULL, FALSE, 0, 0, FALSE, FALSE, get_project_by_id(view -> proj) -> nspec);
478 gtk_menu_item_set_submenu ((GtkMenuItem *)style, menu_style(view, pop));
479 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Color Scheme(s)", get_project_by_id(view -> proj) -> nspec, menu_map(view, pop)));
480 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Render", get_project_by_id(view -> proj) -> nspec, menu_render(view, pop)));
481 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Quality", get_project_by_id(view -> proj) -> nspec, menu_quality(view, pop)));
482 gtk3_menu_item (menu, "Material And Light(s)", IMG_NONE, NULL, G_CALLBACK(opengl_advanced), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
483 gtk3_menu_item (menu, "Render Image", IMG_FILE, (gpointer)PACKAGE_IMG, G_CALLBACK(render_gl_image), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
484}
485
494GtkWidget * menu_opengl (glwin * view, int pop)
495{
496 GtkWidget * menu = gtk_menu_new ();
497 menu_items_opengl (menu, view, pop);
498 return menu;
499}
500
510void menu_items_model (GtkWidget * menu, glwin * view, int pop)
511{
512 if (get_project_by_id(view -> proj) -> nspec)
513 {
514 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Atom(s)", TRUE, menu_atoms (view, pop, 0)));
515 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Bond(s)", TRUE, menu_bonds (view, pop, 0)));
516 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Clone(s)", TRUE, menu_clones (view, pop)));
517 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_box_axis (view, 0, 0));
518 }
519}
520
529GtkWidget * menu_model (glwin * view, int pop)
530{
531 GtkWidget * menu = gtk_menu_new ();
532 menu_items_model (menu, view, pop);
533 return menu;
534}
535
545void menu_items_view (GtkWidget * menu, glwin * view, int popm)
546{
547 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Representation", TRUE, menu_rep (view, popm)));
548 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Projection", TRUE, menu_proj (view)));
549 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Background", TRUE, menu_back (view)));
550 if (get_project_by_id(view -> proj) -> nspec) gtk_menu_shell_append ((GtkMenuShell *)menu, menu_box_axis (view, popm, 1));
551 if (! popm)
552 {
553 add_menu_separator (menu);
554 gtk3_menu_item (menu, "Reset view", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_reset_view), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
555 gtk3_menu_item (menu, "Center molecule", IMG_STOCK, (gpointer)FITBEST, G_CALLBACK(to_center_this_molecule), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
556 add_menu_separator (menu);
557 gtk3_menu_item (menu, "Fullscreen", IMG_STOCK, (gpointer)FULLSCREEN, G_CALLBACK(set_full_screen), (gpointer)view, TRUE, GDK_KEY_f, GDK_CONTROL_MASK, FALSE, FALSE, FALSE);
558 }
559}
560
569GtkWidget * menu_view (glwin * view, int popm)
570{
571 GtkWidget * menu = gtk_menu_new ();
572 menu_items_view (menu, view, popm);
573 return menu;
574}
575
584GtkWidget * menu_help (glwin * view, int popm)
585{
586 GtkWidget * menu;
587 menu = gtk_menu_new ();
588 gtk3_menu_item (menu, "Shortcuts", IMG_NONE, NULL, G_CALLBACK(view_shortcuts), (gpointer)view, FALSE, 0, 0, FALSE, FALSE, FALSE);
589 return menu;
590}
591#endif
592
601{
602#ifdef GTK3
603 view -> ogl_coord[0] = destroy_this_widget (view -> ogl_coord[0]);
604#endif
605 view -> menu_bar = destroy_this_widget (view -> menu_bar);
606#ifdef GTK3
607 view -> menu_bar = gtk_menu_bar_new ();
608 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, menu_item_new_with_submenu ("OpenGL", TRUE, menu_opengl(view, 0)));
609 project * this_proj = get_project_by_id (view -> proj);
610 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, menu_item_new_with_submenu ("Model", this_proj -> nspec, menu_model(view, 0)));
611 view -> ogl_coord[0] = create_menu_item (FALSE, "Chemistry");
612 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, view -> ogl_coord[0]);
613 widget_set_sensitive (view -> ogl_coord[0], this_proj -> nspec);
614 if (this_proj -> nspec)
615 {
616 gtk_menu_item_set_submenu ((GtkMenuItem *)view -> ogl_coord[0], coord_menu (view));
617 }
618 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, menu_item_new_with_submenu ("Tools", TRUE, menu_tools(view, 0)));
619 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, menu_item_new_with_submenu ("View", TRUE, menu_view(view, 0)));
620 gtk_menu_shell_append ((GtkMenuShell *)view -> menu_bar, menu_anim (view, 0));
621
622 show_the_widgets (view -> menu_bar);
623
624 if (this_proj -> nspec) update_all_menus (view, this_proj -> natomes);
625 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, view -> menu_box, view -> menu_bar, TRUE, TRUE, 0);
626 GtkWidget * menu = gtk_menu_bar_new ();
627 gtk_menu_shell_append ((GtkMenuShell *)menu, menu_item_new_with_submenu ("Help", TRUE, menu_help(view, 0)));
628 add_box_child_end (view -> menu_box, menu, FALSE, FALSE, 0);
629 show_the_widgets (menu);
630 show_the_widgets (view -> menu_bar);
631#else
632 update_menu_bar (view);
633#endif
634}
635
644void change_color_map (glwin * view, int col)
645{
646 int i, j;
647 i = ATOM_MAPS-1;
648 if (view -> custom_map) i++;
649 if (view -> anim -> last -> img -> color_map[col] < i-1)
650 {
651 if (view -> anim -> last -> img -> color_map[col] < 2)
652 {
653 j = col*ATOM_MAPS + view -> anim -> last -> img -> color_map[col] + 1;
654 }
655 else if (view -> anim -> last -> img -> color_map[col] == 2 && view -> adv_bonding[0])
656 {
657 j = col*ATOM_MAPS + view -> anim -> last -> img -> color_map[col] + 1;
658 }
659 else if (view -> anim -> last -> img -> color_map[col] == 3 && view -> adv_bonding[1])
660 {
661 j = col*ATOM_MAPS + view -> anim -> last -> img -> color_map[col] + 1;
662 }
663 else if (view -> anim -> last -> img -> color_map[col] == 4 && get_project_by_id(view -> proj) -> force_field[0])
664 {
665 j = col*ATOM_MAPS + view -> anim -> last -> img -> color_map[col] + 1;
666 }
667 else
668 {
669 j = col*ATOM_MAPS + ((view -> custom_map) ? 6 : 0);
670 }
671 }
672 else
673 {
674 j = col*ATOM_MAPS;
675 }
676 gboolean was_input = reading_input;
677 reading_input = TRUE;
678#ifdef GTK3
679 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> color_styles[j], TRUE);
680 set_color_map (view -> color_styles[j], & view -> colorp[j][0]);
681#else
682 gchar * variant = g_strdup_printf ("set-%s.%d.0", (col) ? "pmap" : "amap", j);
683 g_action_group_activate_action ((GActionGroup *)view -> action_group, (col) ? "set-pmap" : "set-amap", g_variant_new_string((const gchar *)variant));
684 g_free (variant);
685#endif
686 reading_input = was_input;
687}
688
701void set_motion (glwin * view, int axis, int da, int db, gboolean UpDown, GdkModifierType state)
702{
703 if (state & GDK_CONTROL_MASK)
704 {
705 if (view -> mode == EDITION)
706 {
707 vec3_t trans;
708 if (axis)
709 {
710 trans = vec3(view -> anim -> last -> img -> p_depth*(double) da / view -> pixels[axis], 0.0, 0.0);
711 }
712 else
713 {
714 trans = vec3(0.0, view -> anim -> last -> img -> p_depth*(double) da / view -> pixels[axis], 0.0);
715 }
716 translate (get_project_by_id(view -> proj), 1, 1, trans);
718 update (view);
719 }
720 else if (state & GDK_SHIFT_MASK)
721 {
722 spin_go (NULL, & view -> colorp[db][axis]);
723 }
724 else
725 {
726 view -> anim -> last -> img -> c_shift[! axis] += (double) da / view -> pixels[axis];
727 if (view -> camera_widg[! axis + 5])
728 {
729 if (GTK_IS_WIDGET(view -> camera_widg[! axis + 5]))
730 {
731 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[! axis + 5], - view -> anim -> last -> img -> c_shift[! axis]);
732 }
733 }
734 update (view);
735 }
736 }
737 else if ((state & GDK_SHIFT_MASK) && UpDown)
738 {
739 if (db == 1 && view -> anim -> last -> img -> zoom > ZOOM_MAX) zoom (view, -1);
740 if (db == 3) zoom (view, 1);
741 update (view);
742 }
743 else if (state != GDK_SHIFT_MASK)
744 {
746 double cameraAngle[2] = {0.0, 0.0};
747 cameraAngle[axis] = 0.5*da;
748 rotate_x_y (view, cameraAngle[0], cameraAngle[1]);
749 update (view);
750 }
751}
752
761{
762 GLdouble w, h;
763 GLdouble dw, dh;
764 double gleft, gright, gbottom, gtop;
765 double zoom = view -> anim -> last -> img -> zoom;
766 zoom *= (view -> anim -> last -> img -> p_depth / view -> anim -> last -> img -> gnear);
767 dw = view -> anim -> last -> img -> c_shift[0]*2.0*zoom;
768 dh = view -> anim -> last -> img -> c_shift[1]*2.0*zoom;
769 double aspect = (double)view -> pixels[0] / (double)view -> pixels[1];
770 if (aspect > 1.0)
771 {
772 w = zoom * aspect;
773 h = zoom;
774 }
775 else
776 {
777 w = zoom;
778 h = zoom / aspect;
779 }
780 gleft = -w + dw;
781 gright = w + dw;
782 gbottom = -h + dh;
783 gtop = h + dh;
784 return m4_ortho (gleft, gright, gbottom, gtop, -view -> anim -> last -> img -> gfar, view -> anim -> last -> img -> gfar);
785}
786
795{
796 vec3_t pos;
797 mat4_t insert_pmv_matrix;
798 insert_pmv_matrix = m4_mul (insert_projection (view), view -> model_view_matrix);
799 pos = vec3 (view -> mouseX, view -> mouseY, 0.75);
800 return v3_un_project (pos, view -> view_port, insert_pmv_matrix);
801}
802
812void activate_glwin_action (gchar * action_string, gchar * action_name, glwin * view)
813{
814 GVariant * action_state = g_variant_new_string (action_string);
815 g_action_group_activate_action ((GActionGroup *)view -> action_group, action_name, action_state);
816 // g_variant_unref (action_state);
817}
818
828void glwin_key_pressed (guint keyval, GdkModifierType state, gpointer data)
829{
830 glwin * view = (glwin *)data;
831 int i;
832 switch (keyval)
833 {
834 case GDK_KEY_Escape:
835 if (view -> fullscreen)
836 {
837#ifdef GTK4
838 set_full_screen (NULL, NULL, view);
839#else
840 set_full_screen (NULL, view);
841#endif
842 }
843 break;
844 case GDK_KEY_Delete:
845 if (get_project_by_id(view -> proj) -> natomes && ! is_atom_win_active(view) && get_project_by_id(view -> proj) -> steps == 1 && view -> mode == EDITION)
846 {
848 is_selected = 1;
849 selected_aspec = -1;
850#ifdef GTK4
851 remove_the_atoms (NULL, NULL, & cut_sel);
852#else
853 remove_the_atoms (NULL, & cut_sel);
854#endif
855 }
856 break;
857 case GDK_KEY_space:
858 if (get_project_by_id(view -> proj) -> natomes)
859 {
860 if (view -> spin[0] || view -> spin[1])
861 {
862 for (i=0; i<2; i++)
863 {
864 view -> spin[i+2] = view -> spin[i];
865 view -> spin_speed[i+2] = view -> spin_speed[i];
866 view -> spin[i] = FALSE;
867 }
868 }
869 else if (view -> spin[2] || view -> spin[3])
870 {
871 for (i=0; i<2; i++)
872 {
873 view -> spin[i] = view -> spin[i+2];
874 view -> spin_speed[i] = view -> spin_speed[i+2];
875 g_timeout_add (REFRESH, (GSourceFunc) spin, & view -> colorp[0][i]);
876 view -> spin[i+2] = FALSE;
877 view -> spin_speed[i+2] = 0;
878 }
879 }
880 }
881 break;
882 case GDK_KEY_a:
883 if ((state & GDK_CONTROL_MASK) && get_project_by_id(view -> proj) -> natomes)
884 {
886 selected_aspec = -1;
887 i = get_selection_type (view);
888 if (view -> anim -> last -> img -> selected[i] -> selected == opengl_project -> natomes)
889 {
890#ifdef GTK4
891 select_unselect_atoms (NULL, NULL, & view -> colorp[0][0]);
892#else
893 select_unselect_atoms (NULL, & view -> colorp[0][0]);
894#endif
895 }
896 else
897 {
898#ifdef GTK4
899 select_unselect_atoms (NULL, NULL, & view -> colorp[0][1]);
900#else
901 select_unselect_atoms (NULL, & view -> colorp[0][1]);
902#endif
903 }
904 }
905#ifdef GTK4
906#ifdef OSX
907 else if (state & GDK_META_MASK)
908#else
909 else if (state & GDK_ALT_MASK)
910#endif
911#else
912 else if (state & GDK_MOD1_MASK)
913#endif
914 {
915 if (view -> mode == EDITION)
916 {
917#ifdef GTK4
918 activate_glwin_action ("set-mouse-mode.0.0", "set-mouse-mode", view);
919#else
920 // GTK3 Menu Action To Check
921 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_mode[0], TRUE);
922 set_mode (view -> ogl_mode[0], & view -> colorp[0][0]);
923#endif
924 }
925 }
926 else if (get_project_by_id(view -> proj) -> natomes)
927 {
928 change_color_map (view, 0);
929 update (view);
930 }
931 break;
932 case GDK_KEY_A:
933 if (get_project_by_id(view -> proj) -> natomes)
934 {
935 // selection mode to coordination sphere
936#ifdef GTK4
937 activate_glwin_action ("set-sel-mode.0.0", "set-sel-mode", view);
938#else
939 // GTK3 Menu Action To Check
940 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_smode[0], TRUE);
941 set_selection_mode (view -> ogl_smode[0], & view -> colorp[0][0]);
942#endif
943 }
944 break;
945 case GDK_KEY_b:
946 if (get_project_by_id(view -> proj) -> natomes)
947 {
948#ifdef GTK4
949 activate_glwin_action ("set-style.0.0", "set-style", view);
950#else
951 // GTK3 Menu Action To Check
952 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[BALL_AND_STICK], TRUE);
953 set_style (view -> ogl_styles[BALL_AND_STICK], & view -> colorp[BALL_AND_STICK][0]);
954#endif
955
956 }
957 break;
958 case GDK_KEY_c:
959 if (get_project_by_id(view -> proj) -> natomes)
960 {
961 if (state & GDK_CONTROL_MASK)
962 {
963 if (view -> anim -> last -> img -> selected[0] -> selected)
964 {
966 selected_aspec = -1;
967 is_selected = 1;
968 view -> nth_copy = 1;
969 view -> insert_coords = get_insertion_coordinates (view);
970#ifdef GTK4
971 copy_the_atoms (NULL, NULL, & cut_sel);
972#else
973 copy_the_atoms (NULL, & cut_sel);
974#endif
976 }
977 else
978 {
979 if (copied_object)
980 {
981 g_free (copied_object);
982 copied_object = NULL;
983 }
984 }
985 }
986 else
987 {
988#ifdef GTK4
989 activate_glwin_action ("set-style.8.0", "set-style", view);
990#else
991 // GTK3 Menu Action To Check
992 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[CYLINDERS], TRUE);
993 set_style (view -> ogl_styles[CYLINDERS], & view -> colorp[CYLINDERS][0]);
994#endif
995 }
996 }
997 break;
998 case GDK_KEY_C:
999 if (get_project_by_id(view -> proj) -> natomes)
1000 {
1001 // selection mode to coordination sphere
1002#ifdef GTK4
1003 activate_glwin_action ("set-sel-mode.1.0", "set-sel-mode", view);
1004#else
1005 // GTK3 Menu Action To Check
1006 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_smode[1], TRUE);
1007 set_selection_mode (view -> ogl_smode[1], & view -> colorp[1][0]);
1008#endif
1009 }
1010 break;
1011 case GDK_KEY_d:
1012 if (get_project_by_id(view -> proj) -> natomes)
1013 {
1014#ifdef GTK4
1015 activate_glwin_action ("set-style.9.0", "set-style", view);
1016#else
1017 // GTK3 Menu Action To Check
1018 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[PUNT], TRUE);
1019 set_style (view -> ogl_styles[PUNT], & view -> colorp[PUNT][0]);
1020#endif
1021 }
1022 break;
1023 case GDK_KEY_e:
1024 if (get_project_by_id(view -> proj) -> natomes)
1025 {
1026 if (state & GDK_CONTROL_MASK)
1027 {
1028 coord_properties (NULL, & view -> colorp[30][0]);
1029 }
1030#ifdef GTK4
1031#ifdef OSX
1032 else if (state & GDK_META_MASK)
1033#else
1034 else if (state & GDK_ALT_MASK)
1035#endif
1036#else
1037 else if (state & GDK_MOD1_MASK)
1038#endif
1039 {
1040 if (view -> mode == ANALYZE && get_project_by_id(view -> proj) -> steps == 1)
1041 {
1042#ifdef GTK4
1043 activate_glwin_action ("set-mouse-mode.1.0", "set-mouse-mode", view);
1044#else
1045 // GTK3 Menu Action To Check
1046 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_mode[1], TRUE);
1047 set_mode (view -> ogl_mode[1], & view -> colorp[1][0]);
1048#endif
1049 }
1050 }
1051 }
1052 break;
1053 case GDK_KEY_f:
1054#ifdef GTK4
1055 if (state & GDK_CONTROL_MASK) set_full_screen (NULL, NULL, view);
1056#else
1057 if (state & GDK_CONTROL_MASK) set_full_screen (NULL, view);
1058#endif
1059 break;
1060 case GDK_KEY_F:
1061 if (get_project_by_id(view -> proj) -> natomes)
1062 {
1063 // selection mode to coordination sphere
1064#ifdef GTK4
1065 activate_glwin_action ("set-sel-mode.2.0", "set-sel-mode", view);
1066#else
1067 // GTK3 Menu Action To Check
1068 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_smode[2], TRUE);
1069 set_selection_mode (view -> ogl_smode[2], & view -> colorp[2][0]);
1070#endif
1071 }
1072 break;
1073 case GDK_KEY_i:
1074 if (get_project_by_id(view -> proj) -> natomes)
1075 {
1076#ifdef GTK4
1077 activate_glwin_action ("set-style.3.0", "set-style", view);
1078#else
1079 // GTK3 Menu Action To Check
1080 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> filled_styles[1], TRUE);
1081 set_style (view -> filled_styles[1], & view -> colorp[OGL_STYLES+1][0]);
1082#endif
1083 }
1084 break;
1085 case GDK_KEY_l:
1086 if ((state & GDK_CONTROL_MASK) && get_project_by_id(view -> proj) -> natomes)
1087 {
1088 opengl_project_changed (view -> proj);
1090 if (view -> labelled == opengl_project -> natomes*opengl_project -> steps)
1091 {
1092#ifdef GTK4
1093 label_unlabel_atoms (NULL, NULL, & cut_lab);
1094#else
1095 label_unlabel_atoms (NULL, & cut_lab);
1096#endif
1097 }
1098 else
1099 {
1100#ifdef GTK4
1101 label_unlabel_atoms (NULL, NULL, & cut_sel);
1102#else
1103 label_unlabel_atoms (NULL, & cut_sel);
1104#endif
1105 }
1106 }
1107 break;
1108 case GDK_KEY_m:
1109 if (get_project_by_id(view -> proj) -> natomes)
1110 {
1111 if (state & GDK_CONTROL_MASK)
1112 {
1113 view -> anim -> last -> img -> m_is_pressed = 0;
1114 window_measures (NULL, view);
1115 }
1116 else if (view -> anim -> last -> img -> m_is_pressed < 2)
1117 {
1118 view -> anim -> last -> img -> m_is_pressed ++;
1119 }
1120 else
1121 {
1122 view -> anim -> last -> img -> m_is_pressed = 0;
1123 }
1124 view -> create_shaders[MEASU] = TRUE;
1125 update (view);
1126 }
1127 break;
1128 case GDK_KEY_M:
1129 if (get_project_by_id(view -> proj) -> natomes)
1130 {
1131 // selection mode to coordination sphere
1132#ifdef GTK4
1133 activate_glwin_action ("set-sel-mode.3.0", "set-sel-mode", view);
1134#else
1135 // GTK3 Menu Action To Check
1136 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_smode[3], TRUE);
1137 set_selection_mode (view -> ogl_smode[3], & view -> colorp[3][0]);
1138#endif
1139 }
1140 break;
1141 case GDK_KEY_n:
1142 if (state & GDK_CONTROL_MASK) on_create_new_project (NULL, NULL);
1143 break;
1144 case GDK_KEY_o:
1145 if (get_project_by_id(view -> proj) -> natomes)
1146 {
1147#ifdef GTK4
1148 activate_glwin_action ("set-style.2.0", "set-style", view);
1149#else
1150 // GTK3 Menu Action To Check
1151 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> filled_styles[0], TRUE);
1152 set_style (view -> filled_styles[0], & view -> colorp[OGL_STYLES][0]);
1153#endif
1154 }
1155 break;
1156 case GDK_KEY_p:
1157 if (get_project_by_id(view -> proj) -> natomes) change_color_map (view, 1);
1158 break;
1159 case GDK_KEY_r:
1160 if (get_project_by_id(view -> proj) -> natomes)
1161 {
1162 if (state & GDK_CONTROL_MASK)
1163 {
1164 window_recorder (NULL, (gpointer)view);
1165 }
1166 else
1167 {
1168#ifdef GTK4
1169 activate_glwin_action ("set-style.5.0", "set-style", view);
1170#else
1171 // GTK3 Menu Action To Check
1172 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> filled_styles[3], TRUE);
1173 set_style (view -> filled_styles[3], & view -> colorp[OGL_STYLES+3][0]);
1174#endif
1175 }
1176 }
1177 break;
1178 if ((state & GDK_CONTROL_MASK) && get_project_by_id(view -> proj) -> natomes) window_recorder (NULL, (gpointer)view);
1179 break;
1180 case GDK_KEY_s:
1181 if (get_project_by_id(view -> proj) -> natomes)
1182 {
1183 if (state & GDK_CONTROL_MASK)
1184 {
1185 spin_stop (NULL, data);
1186 }
1187 else
1188 {
1189#ifdef GTK4
1190 activate_glwin_action ("set-style.7.0", "set-style", view);
1191#else
1192 // GTK3 Menu Action To Check
1193 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[SPHERES], TRUE);
1194 set_style (view -> ogl_styles[SPHERES], & view -> colorp[SPHERES][0]);
1195#endif
1196 }
1197 }
1198 break;
1199 case GDK_KEY_v:
1200 if (state & GDK_CONTROL_MASK)
1201 {
1202 if (copied_object && ! is_atom_win_active(view) && get_project_by_id(view -> proj) -> steps == 1 && view -> mode == EDITION)
1203 {
1204 //i = (! get_project_by_id(view -> proj) -> natomes) ? 1 : 0;
1205 opengl_project_changed (view -> proj);
1206#ifdef GTK4
1207 add_object (NULL, NULL, & view -> colorp[0][0]);
1208#else
1209 add_object (NULL, & view -> colorp[0][0]);
1210#endif
1211 view -> nth_copy ++;
1212 /*if (i)
1213 {
1214 i = activep;
1215 active_project_changed (view -> proj);
1216 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
1217 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
1218 bonds_update = 1;
1219 on_calc_bonds_released (NULL, NULL);
1220 active_project_changed (i);
1221 }*/
1222 }
1223 }
1224 else if (get_project_by_id(view -> proj) -> natomes)
1225 {
1226#ifdef GTK4
1227 activate_glwin_action ("set-style.4.0", "set-style", view);
1228#else
1229 // GTK3 Menu Action To Check
1230 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> filled_styles[2], TRUE);
1231 set_style (view -> filled_styles[2], & view -> colorp[OGL_STYLES+2][0]);
1232#endif
1233 }
1234 break;
1235 case GDK_KEY_w:
1236 if (get_project_by_id(view -> proj) -> natomes)
1237 {
1238#ifdef GTK4
1239 activate_glwin_action ("set-style.1.0", "set-style", view);
1240#else
1241 // GTK3 Menu Action To Check
1242 gtk_check_menu_item_set_active ((GtkCheckMenuItem *)view -> ogl_styles[WIREFRAME], TRUE);
1243 set_style (view -> ogl_styles[WIREFRAME], & view -> colorp[WIREFRAME][0]);
1244#endif
1245 }
1246 break;
1247 case GDK_KEY_x:
1248 if ((state & GDK_CONTROL_MASK) && get_project_by_id(view -> proj) -> natomes)
1249 {
1250 if (! is_atom_win_active(view) && get_project_by_id(view -> proj) -> steps == 1 && view -> mode == EDITION)
1251 {
1252 if (view -> anim -> last -> img -> selected[0] -> selected)
1253 {
1254 opengl_project_changed (view -> proj);
1255 selected_aspec = -1;
1256 is_selected = 1;
1257#ifdef GTK4
1258 copy_the_atoms (NULL, NULL, & cut_sel);
1259 remove_the_atoms (NULL, NULL, & cut_sel);
1260#else
1261 copy_the_atoms (NULL, & cut_sel);
1262 remove_the_atoms (NULL, & cut_sel);
1263#endif
1264 }
1265 }
1266 }
1267 break;
1268 case GDK_KEY_Right:
1269 if (get_project_by_id(view -> proj) -> natomes) set_motion (view, 1, 1, 1, FALSE, state);
1270 break;
1271 case GDK_KEY_Left:
1272 if (get_project_by_id(view -> proj) -> natomes) set_motion (view, 1, -1, 3, FALSE, state);
1273 break;
1274 case GDK_KEY_Up:
1275 if (get_project_by_id(view -> proj) -> natomes) set_motion (view, 0, 1, 3, TRUE, state);
1276 break;
1277 case GDK_KEY_Down:
1278 if (get_project_by_id(view -> proj) -> natomes) set_motion (view, 0, -1, 1, TRUE, state);
1279 break;
1280 }
1281}
1282
1283#ifdef GTK3
1293G_MODULE_EXPORT gboolean on_key_pressed (GtkWidget * widg, GdkEventKey * event, gpointer data)
1294{
1295 if (event -> type == GDK_KEY_PRESS)
1296 {
1297 glwin_key_pressed (event -> keyval, event -> state, data);
1298 }
1299 return FALSE;
1300}
1301#else
1313G_MODULE_EXPORT gboolean on_glwin_key_pressed (GtkEventControllerKey * self, guint keyval, guint keycode, GdkModifierType state, gpointer data)
1314{
1315 glwin_key_pressed (keyval, state, data);
1316 return TRUE;
1317}
1318#endif
1319
1328G_MODULE_EXPORT void on_win_realize (GtkWidget * widg, gpointer data)
1329{
1330 glwin * view = (glwin *)data;
1331 int * pix = get_project_by_id(view -> proj) -> tmp_pixels;
1332 int shift = 0;
1333 if (GTK_IS_WIDGET(view -> menu_bar)) shift = get_widget_height (view -> menu_bar);
1334 if (pix[0] > 0 && pix[1] > 0)
1335 {
1336 resize_this_window (view -> win, pix[0], pix[1]+shift);
1337 pix[0] = pix[1] = -1;
1338 }
1339 else
1340 {
1341 resize_this_window (view -> win, 500, 500);
1342 }
1343}
1344
1345#ifdef GTK3
1346#ifdef LINUX
1354void gtk_window_change_gdk_visual (GtkWidget * win)
1355{
1356 // GTK+ > 3.15.1 uses an X11 visual optimized for GTK+'s OpenGL stuff
1357 // since revid dae447728d: https://github.com/GNOME/gtk/commit/dae447728d
1358 // However, in some cases it simply cannot start an OpenGL context.
1359 // This changes to the default X11 visual instead the GTK's default.
1360 GdkScreen * screen = gdk_screen_get_default ();
1361 GList * visuals = gdk_screen_list_visuals (screen);
1362 // printf("n visuals: %u\n", g_list_length(visuals));
1363 GdkX11Screen* x11_screen = GDK_X11_SCREEN (screen);
1364 g_assert (x11_screen != NULL);
1365 Visual * default_xvisual = DefaultVisual (GDK_SCREEN_XDISPLAY(x11_screen), GDK_SCREEN_XNUMBER(x11_screen));
1366 GdkVisual * default_visual = NULL;
1367 // int i = 0;
1368 while (visuals != NULL)
1369 {
1370 GdkVisual * visual = GDK_X11_VISUAL (visuals -> data);
1371 if (default_xvisual -> visualid == gdk_x11_visual_get_xvisual(GDK_X11_VISUAL (visuals -> data)) -> visualid)
1372 {
1373 // printf("Default visual %d\n", i);
1374 default_visual = visual;
1375 }
1376 // i++;
1377 visuals = visuals -> next;
1378 }
1379 gtk_widget_set_visual (win, default_visual);
1380}
1381#endif
1382#endif
1383
1384gboolean create_3d_model (int p, gboolean load)
1385{
1386 project * this_proj = get_project_by_id (p);
1387#ifndef GTKGLAREA
1388 if (! glXQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), NULL, NULL))
1389 {
1390 g_warning ("Sorry OpenGL is not supported !");
1391 return FALSE;
1392 }
1393 else
1394#endif
1395 {
1396 if (this_proj -> modelgl)
1397 {
1398 g_free (this_proj -> modelgl);
1399 this_proj -> modelgl = NULL;
1400 }
1401 this_proj -> modelgl = g_malloc0 (sizeof*this_proj -> modelgl);
1402 this_proj -> modelgl -> init = FALSE;
1403 this_proj -> modelgl -> proj = this_proj -> id;
1404 GtkWidget * gl_vbox;
1405 if (load)
1406 {
1407 gchar * str = g_strdup_printf ("%s - 3D view - [%s mode]", this_proj -> name, mode_name[0]);
1408 this_proj -> modelgl -> win = create_win (str, MainWindow, FALSE, TRUE);
1409#ifdef GTK3
1410#ifdef GTKGLAREA
1411#ifdef LINUX
1412 if (! atomes_visual) gtk_window_change_gdk_visual (this_proj -> modelgl -> win);
1413#endif
1414#endif
1415#endif
1416 // this_proj -> modelgl -> accel_group = gtk_accel_group_new ();
1417 // gtk_window_add_accel_group (GTK_WINDOW (this_proj -> modelgl -> win), this_proj -> modelgl -> accel_group);
1418 g_free (str);
1419 gl_vbox = create_vbox (BSEP);
1420 add_container_child (CONTAINER_WIN, this_proj -> modelgl -> win, gl_vbox);
1421 this_proj -> modelgl -> menu_box = create_hbox (0);
1422 add_box_child_start (GTK_ORIENTATION_VERTICAL, gl_vbox, this_proj -> modelgl -> menu_box, FALSE, FALSE, 0);
1423#ifdef GTK3
1424 this_proj -> modelgl -> menu_bar = gtk_menu_bar_new ();
1425 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, this_proj -> modelgl -> menu_box, this_proj -> modelgl -> menu_bar, TRUE, TRUE, 0);
1426#endif
1427 }
1428#ifdef GTKGLAREA
1429 this_proj -> modelgl -> plot = gtk_gl_area_new ();
1430 gtk_widget_set_can_focus (this_proj -> modelgl -> plot, TRUE);
1431#ifdef GTK4
1432 gtk_widget_set_focusable (this_proj -> modelgl -> plot, TRUE);
1433#endif
1434#else
1435 this_proj -> modelgl -> plot = gtk_drawing_area_new ();
1436#endif
1437 gtk_widget_set_size_request (this_proj -> modelgl -> plot, 100, 100);
1438#ifndef GTKGLAREA
1439 gtk_widget_set_double_buffered (this_proj -> modelgl -> plot, FALSE);
1440 this_proj -> modelgl -> glcontext = NULL;
1441#endif
1442 gtk_widget_set_hexpand (this_proj -> modelgl -> plot, TRUE);
1443 gtk_widget_set_vexpand (this_proj -> modelgl -> plot, TRUE);
1444#ifdef GTKGLAREA
1445#ifdef GTK3
1446 gtk_widget_add_events (GTK_WIDGET (this_proj -> modelgl -> plot),
1447 GDK_SCROLL_MASK |
1448 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
1449 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
1450#endif
1451#else
1452 gtk_widget_add_events (GTK_WIDGET (this_proj -> modelgl -> plot),
1453 GDK_SMOOTH_SCROLL_MASK |
1454 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK |
1455 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
1456#endif
1457#ifdef GTK4
1458 if (load)
1459 {
1460 add_widget_gesture_and_key_action (this_proj -> modelgl -> win, NULL, NULL, NULL,
1461 NULL, NULL, NULL,
1462 "glwin-key-pressed", G_CALLBACK(on_glwin_key_pressed), this_proj -> modelgl,
1463 NULL, NULL, NULL,
1464 NULL, NULL, NULL);
1465 add_widget_gesture_and_key_action (this_proj -> modelgl -> plot, "glwin-button-pressed", G_CALLBACK(on_glwin_button_pressed), this_proj -> modelgl,
1466 "glwin-button-released", G_CALLBACK(on_glwin_button_released), this_proj -> modelgl,
1467 NULL, NULL, NULL,
1468 "glwin-pointer-motion", G_CALLBACK(on_glwin_pointer_motion), this_proj -> modelgl,
1469 "glwin-pointer-scroll", G_CALLBACK(on_glwin_pointer_scoll), this_proj -> modelgl);
1470 }
1471 else
1472 {
1473 add_widget_gesture_and_key_action (this_proj -> modelgl -> plot, "glwin-button-pressed", G_CALLBACK(on_lib_button_pressed), this_proj -> modelgl,
1474 "glwin-button-released", G_CALLBACK(on_lib_button_released), this_proj -> modelgl,
1475 NULL, NULL, NULL,
1476 "glwin-pointer-motion", G_CALLBACK(on_glwin_pointer_motion), this_proj -> modelgl,
1477 NULL, NULL, NULL);
1478 }
1479#else
1480 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "motion-notify-event", G_CALLBACK(on_motion), this_proj -> modelgl);
1481 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "button-release-event", G_CALLBACK(on_glwin_button_event), this_proj -> modelgl);
1482 if (load)
1483 {
1484 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "button-press-event", G_CALLBACK(on_glwin_button_event), this_proj -> modelgl);
1485 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "scroll-event", G_CALLBACK(on_scrolled), this_proj -> modelgl);
1486 }
1487 else
1488 {
1489 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "button-press-event", G_CALLBACK(on_lib_pressed), this_proj -> modelgl);
1490 }
1491#endif
1492 if (load)
1493 {
1494 add_box_child_start (GTK_ORIENTATION_VERTICAL, gl_vbox, this_proj -> modelgl -> plot, FALSE, TRUE, 0);
1495#ifdef GTK3
1496 g_signal_connect (G_OBJECT (this_proj -> modelgl -> win), "key-press-event", G_CALLBACK(on_key_pressed), this_proj -> modelgl);
1497#endif
1498 g_signal_connect (G_OBJECT (this_proj -> modelgl -> win), "realize", G_CALLBACK(on_win_realize), this_proj -> modelgl);
1499 add_gtk_close_event (this_proj -> modelgl -> win, G_CALLBACK(hide_this_window), NULL);
1500 }
1501 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "realize", G_CALLBACK(on_realize), this_proj -> modelgl);
1502#ifdef GTKGLAREA
1503 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "render", G_CALLBACK(on_expose), this_proj -> modelgl);
1504#else
1505 g_signal_connect (G_OBJECT (this_proj -> modelgl -> plot), "draw", G_CALLBACK(on_expose), this_proj -> modelgl);
1506#endif
1507 return TRUE;
1508 }
1509}
1510
1518void prep_model (int p)
1519{
1520 project * this_proj = get_project_by_id (p);
1521 gboolean adv_bonding[2];
1522 if (this_proj -> modelgl == NULL)
1523 {
1524 if (create_3d_model (p, TRUE))
1525 {
1526 /*GtkWidget * dummy = create_menu_item (FALSE, "Dummy");
1527 gtk_menu_shell_append ((GtkMenuShell *)this_proj -> modelgl -> menu_bar, dummy);
1528 show_the_widgets (this_proj -> modelgl -> win);
1529 destroy_this_widget (dummy);*/
1530 show_the_widgets (this_proj -> modelgl -> win);
1531 }
1532 if (this_proj -> initgl)
1533 {
1535#ifdef GTK3
1536 // GTK3 Menu Action To Check
1537 active_glwin -> ogl_box_axis[0] = g_malloc0 (OGL_BOX*sizeof*active_glwin -> ogl_box_axis[0]);
1538 active_glwin -> ogl_box_axis[1] = g_malloc0 (OGL_AXIS*sizeof*active_glwin -> ogl_box_axis[1]);
1539#endif
1541 if (reading_input)
1542 {
1543 adv_bonding[0] = (active_project -> natomes > ATOM_LIMIT) ? 0 : tmp_adv_bonding[0];
1544 adv_bonding[1] = (active_project -> steps > STEP_LIMIT) ? 0 : tmp_adv_bonding[1];
1545 frag_update = (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
1546 mol_update = (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
1547 }
1548 else
1549 {
1550 frag_update = (force_mol) ? 1 : (active_project -> natomes > ATOM_LIMIT) ? 0 : 1;
1551 mol_update = (force_mol) ? 1 : (frag_update) ? ((active_project -> steps > STEP_LIMIT) ? 0 : 1) : 0;
1552 adv_bonding[0] = adv_bonding[1] = TRUE;
1553 }
1554 if (active_project -> natomes && adv_bonding[0] && adv_bonding[1])
1555 {
1556 bonds_update = 1;
1557 active_project -> runc[0] = FALSE;
1558 on_calc_bonds_released (NULL, NULL);
1559 }
1560 }
1561 }
1562 else
1563 {
1564 if (gtk_widget_get_visible(this_proj -> modelgl -> win))
1565 {
1566 hide_the_widgets (this_proj -> modelgl -> win);
1567 }
1568 else
1569 {
1570 show_the_widgets (this_proj -> modelgl -> win);
1571 }
1572 }
1573}
gchar * action_name[5]
Definition atom_edit.c:60
GtkWidget * coord_menu(glwin *view)
void restore_color_map(glwin *view, int *colm)
restore saved color maps
Definition bdcall.c:93
int * save_color_map(glwin *view)
save atoms and polyhedra color maps
Definition bdcall.c:77
gboolean force_mol
Definition calc.c:71
Variable declarations for the MD input preparation assistants.
gchar * groups[230]
Definition cbuild_sg.c:43
gchar * axis[3]
Definition w_axis.c:65
integer function chains()
Definition chains.F90:54
void update_insert_combos()
update some GtkComboBox in the workspace if a project is removed
Definition close_p.c:60
Structure definitions for color management Function declarations for color management.
color colorp[64]
ColRGBA col
Definition d_measures.c:77
int * shift
Definition d_measures.c:72
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
dint rep
Definition dlp_edit.c:2239
gboolean reading_input
Definition global.c:182
int mol_update
Definition global.c:171
gchar * PACKAGE_IMG
Definition global.c:81
gboolean tmp_adv_bonding[2]
Definition global.c:183
int frag_update
Definition global.c:170
GtkWidget * MainWindow
Definition global.c:201
int bonds_update
Definition global.c:169
gchar * mode_name[2]
Definition global.c:137
int atomes_visual
Definition global.c:165
gchar * PACKAGE_MOL
Definition global.c:99
GtkWidget * pop
Definition global.c:204
int tmp_pixels[2]
Definition global.c:173
Global variable declarations Global convenience function declarations Global data structure defin...
@ IMG_NONE
Definition global.h:260
@ IMG_STOCK
Definition global.h:264
@ IMG_FILE
Definition global.h:263
glwin * active_glwin
Definition project.c:53
void update_chains_menus(glwin *view)
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
#define FITBEST
Definition global.h:199
tint cut_lab
Definition gui.c:145
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)
gboolean is_atom_win_active(glwin *view)
is the model edition window visible ?
Definition atom_edit.c:71
void resize_this_window(GtkWidget *window, int x, int y)
resize this GtkWindow
Definition gtk-misc.c:581
GtkWidget * create_win(gchar *str, GtkWidget *parent, gboolean modal, gboolean resiz)
create a new GtkWindow
Definition gtk-misc.c:445
cell_info * active_cell
Definition project.c:50
project * proj
int get_widget_height(GtkWidget *widg)
retrive GtkWidget height
Definition gtk-misc.c:2419
#define BSEP
Definition global.h:245
void opengl_project_changed(int id)
change the OpenGL project
Definition update_p.c:245
G_MODULE_EXPORT gboolean hide_this_window(GtkWidget *win, GdkEvent *event, gpointer data)
hide a GtkWindow
Definition gtk-misc.c:2371
void add_gtk_close_event(GtkWidget *widg, GCallback handler, gpointer data)
add a close event signal and callback to a GtkWidget
Definition gtk-misc.c:2387
#define STEP_LIMIT
Definition global.h:277
G_MODULE_EXPORT void on_calc_bonds_released(GtkWidget *widg, gpointer data)
compute bonding properties
Definition bdcall.c:471
@ CONTAINER_WIN
Definition global.h:250
project * opengl_project
Definition project.c:54
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.
Definition gtk-misc.c:299
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_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:813
#define FULLSCREEN
Definition global.h:198
GtkWidget * create_menu_item(gboolean add_mnemo, gchar *action)
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2034
void add_box_child_end(GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the end position.
Definition gtk-misc.c:277
tint cut_sel
Definition gui.c:144
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:226
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:189
void add_menu_separator(GtkWidget *menu)
GtkWidget * menu_item_new_with_submenu(gchar *name, gboolean active, GtkWidget *sub_menu)
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:801
project * active_project
Definition project.c:47
void update_rings_menus(glwin *view)
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:173
project * get_project_by_id(int p)
get project pointer using id number
Definition project.c:120
G_MODULE_EXPORT void on_realize(GtkWidget *widg, gpointer data)
realize event for the OpenGL widget
Definition glview.c:1737
G_MODULE_EXPORT void on_glwin_pointer_motion(GtkEventControllerMotion *motc, gdouble x, gdouble y, gpointer data)
handle mouse motion event in the OpenGL window GTK4
Definition glview.c:727
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
G_MODULE_EXPORT void on_lib_button_released(GtkGesture *gesture, int n_press, double x, double y, gpointer data)
handle mouse button release event on the molecular library OpenGL window (limited interaction)
Definition glview.c:868
void zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
Definition glview.c:1006
G_MODULE_EXPORT void on_lib_button_pressed(GtkGesture *gesture, int n_press, double x, double y, gpointer data)
handle mouse button press event on the molecular library OpenGL window (limited interaction)
Definition glview.c:852
G_MODULE_EXPORT void on_glwin_button_released(GtkGesture *gesture, int n_press, double x, double y, gpointer data)
mouse button released signal on the OpenGL window
Definition glview.c:991
G_MODULE_EXPORT void on_glwin_button_pressed(GtkGesture *gesture, int n_press, double x, double y, gpointer data)
mouse button pressed signal on the OpenGL window
Definition glview.c:975
G_MODULE_EXPORT gboolean on_glwin_pointer_scoll(GtkEventControllerScroll *event, gdouble dx, gdouble dy, gpointer data)
handle mouse scroll event on the OpenGL window
Definition glview.c:1055
G_MODULE_EXPORT gboolean on_expose(GtkWidget *widg, cairo_t *cr, gpointer data)
OpenGL rendering widget expose event callback GTK3.
Definition glview.c:1794
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
image * plot
Definition ogl_draw.c:66
#define ZOOM_MAX
Maximum value for the OpenGL zoom factor.
Definition glview.h:125
@ CUSTOM
Definition glview.h:210
G_MODULE_EXPORT void to_center_this_molecule(GtkWidget *widg, gpointer data)
center this molecule menu item callback GTK4
Definition popup.c:3974
action
Definition glview.h:189
#define REFRESH
Refresh time for spinning the OpenGL window in milliseconds.
Definition glview.h:130
@ ANALYZE
Definition glview.h:157
@ EDITION
Definition glview.h:158
render
Definition glview.h:182
@ FILL
Definition glview.h:183
#define DEFAULT_STYLE
Default OpenGL style: ball and stick.
Definition glview.h:43
@ SPHERES
Definition glview.h:176
@ SPACEFILL
Definition glview.h:175
@ BALL_AND_STICK
Definition glview.h:173
@ CYLINDERS
Definition glview.h:177
@ WIREFRAME
Definition glview.h:174
@ NONE
Definition glview.h:172
@ PUNT
Definition glview.h:178
#define OGL_COORDS
Definition glwin.h:63
#define OGL_BOX
Definition glwin.h:58
#define OGL_STYLES
Definition glwin.h:106
@ MEASU
Definition glwin.h:99
#define OGL_AXIS
Definition glwin.h:59
#define ATOM_MAPS
Definition glwin.h:61
void activate_glwin_action(gchar *action_string, gchar *action_name, glwin *view)
the keyboard shortcut actions for the OpenGL window
Definition glwindow.c:812
void set_sensitive_coord_menu(glwin *view, gboolean status)
void glwin_key_pressed(guint keyval, GdkModifierType state, gpointer data)
the keyboard shortcut actions for the OpenGL window
Definition glwindow.c:828
void set_color_map_sensitive(glwin *view)
void window_encode(glwin *view, gboolean video)
encoding a movie - creating the dialog
Definition w_encode.c:319
G_MODULE_EXPORT void coord_properties(GtkWidget *widg, gpointer data)
create the environments configuration window
Definition w_coord.c:1469
G_MODULE_EXPORT void set_style(GtkWidget *widg, gpointer data)
set style callback
Definition m_style.c:171
gchar * opengl_group_names[]
Definition glwindow.c:127
int get_selection_type(glwin *view)
get selection type
Definition w_measures.c:83
void save_rotation_quaternion(glwin *view)
save the rotation quaternion of the last image
Definition glview.c:543
gchar * opengl_section_names[]
Definition glwindow.c:125
G_MODULE_EXPORT void set_selection_mode(GtkWidget *widg, gpointer data)
set selection mode callback
Definition m_tools.c:133
int opengl_shortcut_by_group[]
Definition glwindow.c:130
int is_labelled
Definition popup.c:183
void update_all_menus(glwin *view, int nats)
update all menus of the OpenGL window
Definition glwindow.c:337
void prep_model(int p)
prepare, or display, the OpenGL model window
Definition glwindow.c:1518
G_MODULE_EXPORT void opengl_advanced(GtkWidget *widg, gpointer data)
create OpenGL rendering advanced window
Definition w_advance.c:1477
G_MODULE_EXPORT gboolean on_glwin_key_pressed(GtkEventControllerKey *self, guint keyval, guint keycode, GdkModifierType state, gpointer data)
keyboard key press event for the OpenGL window GTK4
Definition glwindow.c:1313
G_MODULE_EXPORT void spin_go(GtkWidget *widg, gpointer data)
void update_menus(glwin *view)
G_MODULE_EXPORT void set_box_axis_style(GtkWidget *widg, gpointer data)
G_MODULE_EXPORT void on_win_realize(GtkWidget *widg, gpointer data)
realize event for the OpenGL window
Definition glwindow.c:1328
G_MODULE_EXPORT void set_render(GtkWidget *widg, gpointer data)
set OpenGL rendering mode callback
Definition m_render.c:56
int is_selected
Definition popup.c:182
G_MODULE_EXPORT void set_full_screen(GtkWidget *widg, gpointer data)
set full screen callback GTK3
Definition popup.c:229
GtkWidget * shortcuts_window(int sections, int group_by_section[sections], int groups, int shortcut_by_group[groups], gchar *section_names[sections], gchar *group_names[groups], shortcuts shortcs[])
Create the shortcuts information window.
Definition gui.c:181
G_MODULE_EXPORT void add_object(GtkWidget *widg, gpointer data)
add object call back GTK3
Definition popup.c:713
void prep_all_coord_menus(glwin *view)
G_MODULE_EXPORT void copy_the_atoms(GtkWidget *widg, gpointer data)
copy selected atom(s) callback GTK3
Definition popup.c:1355
void prepare_opengl_menu_bar(glwin *view)
update the OpenGL window menu bar
Definition glwindow.c:600
G_MODULE_EXPORT void view_shortcuts(GtkWidget *widg, gpointer data)
OpenGL window shortcuts callback GTK3.
Definition glwindow.c:455
G_MODULE_EXPORT void label_unlabel_atoms(GtkWidget *widg, gpointer data)
label / unlabel a type of atom(s) callback GTK3
Definition popup.c:1503
G_MODULE_EXPORT void window_recorder(GtkWidget *widg, gpointer data)
create video recorder window
Definition w_record.c:152
void translate(project *this_proj, int status, int axis, vec3_t trans)
translate
Definition atom_move.c:230
gboolean spin(gpointer data)
spin
Definition w_spiner.c:56
gchar * action_atoms[3]
Definition atom_edit.c:61
GtkWidget * menupoly(glwin *view, int jd, int id, gchar *poln)
G_MODULE_EXPORT void select_unselect_atoms(GtkWidget *widg, gpointer data)
select / unselect a type of atom(s) callback GTK3
Definition popup.c:1551
void change_color_map(glwin *view, int col)
change atom / polyhedra color map
Definition glwindow.c:644
gboolean create_3d_model(int p, gboolean load)
Definition glwindow.c:1384
G_MODULE_EXPORT void to_reset_view(GtkWidget *widg, gpointer data)
reset view callback - GTK3
Definition m_rep.c:200
shortcuts opengl_shortcuts[]
Definition glwindow.c:134
G_MODULE_EXPORT void window_measures(GtkWidget *widg, gpointer data)
create the measurements window
Definition w_measures.c:739
G_MODULE_EXPORT void render_gl_image(GtkWidget *widg, gpointer data)
render image from the OpenGL window
Definition glwindow.c:429
G_MODULE_EXPORT void set_mode(GtkWidget *widg, gpointer data)
set mouse mode callback
Definition m_tools.c:172
vec3_t get_insertion_coordinates(glwin *view)
get the insertion coordinates to insert object in the 3D window
Definition glwindow.c:794
int selected_aspec
Definition popup.c:180
G_MODULE_EXPORT void set_color_map(GtkWidget *widg, gpointer data)
set color map callback
Definition m_map.c:1011
G_MODULE_EXPORT void on_create_new_project(GtkWidget *widg, gpointer data)
create a new project
Definition work_menu.c:62
void rotate_x_y(glwin *view, double angle_x, double angle_y)
rotate the OpenGL camera
Definition glview.c:1081
G_MODULE_EXPORT void edit_in_new_project(GtkWidget *widg, gpointer data)
create new project using selection callback GTK3
Definition popup.c:2192
G_MODULE_EXPORT void spin_stop(GtkButton *but, gpointer data)
stop spin
Definition w_spiner.c:138
atomic_object * copied_object
Definition glwindow.c:123
void set_motion(glwin *view, int axis, int da, int db, gboolean UpDown, GdkModifierType state)
handle keyboard motion event on the OpenGL window
Definition glwindow.c:701
mat4_t insert_projection(glwin *view)
calculate the insertion projection matrix to insert object in the 3D window
Definition glwindow.c:760
int opengl_group_by_section[]
Definition glwindow.c:126
G_MODULE_EXPORT void remove_the_atoms(GtkWidget *widg, gpointer data)
remove selected atom(s) callback GTK3
Definition popup.c:1297
GLXContext glcontext
Function declarations to handle the atomic coordination data.
void set_advanced_bonding_menus(glwin *view)
GMenu * menu_anim(glwin *view, int popm)
create the 'Animate' submenu elements
Definition m_anim.c:139
GMenu * menu_atoms(glwin *view, int popm, int at)
create the 'Atom(s)' submenu elements
Definition m_atoms.c:797
GMenu * menu_back(glwin *view, int popm)
create the background color menu item GTK4
Definition m_back.c:68
GMenu * menu_bonds(glwin *view, int popm, int at)
create the 'Bond(s)' submenu GTK4
Definition m_bonds.c:367
GMenuItem * menu_box_axis(glwin *view, int popm, int ab)
create the 'Model -> Box' and 'View -> Axis' submenus GTK4
Definition m_box.c:470
GMenu * menu_clones(glwin *view, int popm)
create the 'Clone(s)' submenu GTK4
Definition m_clones.c:180
GMenu * menu_coord(glwin *view, int popm)
create the 'Coordination' submenu GTK4
Definition m_coord.c:689
GMenu * menu_rings(glwin *view, int popm)
create the 'Ring(s)' submenu GTK4
Definition m_coord.c:705
GMenu * add_menu_coord(glwin *view, int popm, int id)
create a coordination type submenu
Definition m_coord.c:652
GMenu * menu_map(glwin *view, int popm)
create the 'OpenGL -> Color Scheme(s)' submenu - GTK4
Definition m_map.c:1272
G_MODULE_EXPORT void cloned_poly(GtkWidget *widg, gpointer data)
cloned polyehdra callback - GTK3
Definition m_poly.c:181
GMenu * menu_poly(glwin *view, int popm)
create the 'Chemistry -> Polyehdra' submenu - GTK4
Definition m_poly.c:490
GMenu * menu_proj(glwin *view, int popm)
create the 'View -> Projection' submenu - GTK4
Definition m_proj.c:164
GMenu * menu_quality(glwin *view, int popm)
create the 'OpenGL -> Quality' menu item - GTK4
Definition m_quality.c:167
GMenu * menu_render(glwin *view, int popm)
create the 'OpenGL -> Render' submenu - GTK4
Definition m_render.c:182
GMenu * menu_rep(glwin *view, int popm)
create 'View -> Representation' submenu items - GTK4
Definition m_rep.c:513
GMenu * menu_view(glwin *view, int popm)
create the 'View' submenu - GTK4
Definition m_rep.c:579
GMenu * menu_style(glwin *view, int popm)
create the 'OpenGL -> Style' submenu - GTK4
Definition m_style.c:433
GMenu * menu_tools(glwin *view, int popm)
create the 'Tools' submenu - GTK4
Definition m_tools.c:770
Function declarations for reading atomes project file Function declarations for saving atomes proje...
void active_project_changed(int id)
change the active project
Definition update_p.c:175
GtkWidget * prep_rings_menu(glwin *view, int id)
Definition glwin.h:875
Function declarations for the creation of the OpenGL window menus.
void menu_items_view(GMenu *menu, glwin *view, int popm)
int status
Definition w_advance.c:160
GdkPixbuf * pix
Definition workspace.c:69
GtkWidget * img
Definition workspace.c:70