atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
glview.h
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
23/*
24* This header file: 'glview.h'
25*
26* Contains:
27
28 - Variable declarations related to the OpenGL window
29 - Function declaration related to the OpenGL window
30
31*/
32
33#ifndef GL_VIEW_H_
34#define GL_VIEW_H_
35
39#define QUALITY 30
43#define DEFAULT_STYLE 1
44
45#define DEFAULT_SIZE 1
49#define DEFAULT_LIGHTNING 1.00
50
54#define DEFAULT_METALLIC 0.35
55
59#define DEFAULT_ROUGHNESS 0.15
60
64#define DEFAULT_AMBIANT_OCCLUSION 1.00
65
69#define DEFAULT_GAMMA_CORRECTION 1.50
70
74#define DEFAULT_OPACITY 1.00
75
76// default light data
80#define MAX_LIGHTS 10
81
85#define DEFAULT_INTENSITY 10.0
86
90#define NEAR_PLANE 1.0
91
95#define FAR_PLANE 10.0
96
100#define CAMERA_ANGLE_X 5.0 // Pitch in degree
101
105#define CAMERA_ANGLE_Y -25.0 // Heading in degree
106
110#define CAMERA_ANGLE_Z 0.0
111
115#define ZOOM 1.5
116
120#define ZOOM_FACTOR 0.05
121
125#define ZOOM_MAX 0.001
126
130#define REFRESH 10
131
135#define MAX_IN_SELECTION 21
139#define COORD_MAX_MENU 20
140
142enum radii {
143 VDW = 0,
144 INC = 1,
145 COV = 2,
146 ION = 3
148
154
167
168#define NUM_STYLES 7
169
180
182enum render {
183 FILL = 0,
184 LINE = 1,
185 PTS = 2
187
189enum action {
190 ROTATE = 0,
191 MOVE = 1,
192 SELECT = 2,
194 SPIN = 4
196
202
212
221
224 DISPL = 2,
226 REMOVE = 4,
227 INSERT = 5,
228 RANMOVE = 6
230
236
237/*enum material {
238 AMBIENT = 0,
239 DIFFUSE = 1,
240 SPECULAR = 2,
241 EMISSION = 3,
242 OPACITY = 4
243};*/
244
245extern GLfloat ** allocdGLfloat (int xal, int yal);
246extern GLfloat initlights[4][4];
247extern gboolean pick;
248extern glwin * wingl;
249extern project * proj_gl;
250extern coord_info * coord_gl;
251extern box_info * box_gl;
252extern cell_info * cell_gl;
253extern int proj_sp;
254extern int proj_at;
255extern image * plot;
256extern int qual;
257extern int acolorm;
258extern int pcolorm;
259extern int step;
260extern int gColorID[3];
261extern int field_object;
262extern GLenum ogl_texture;
263
264extern gboolean create_bond (int ac, int bid, int ba, int bb, int sel, double length);
265extern void draw_cylinder_bond (atom a, atom b, int bid, int ci, int bi);
266extern void draw_cylinder_bond_to_pick (atom a, atom b, int bid);
267extern void draw_wireframe_bond (atom a, atom b, int ci, int bi);
268extern gboolean create_atom (GLUquadricObj * quadric, int aid, int ac, int sp, int sel);
269
270extern void draw_vertices (int id);
271extern void draw_atom_to_pick (atom at);
272extern void draw_atom (atom at, double al);
273extern void draw_rings_gl (int se, int ge, int ta, int id);
274extern void draw_box ();
275extern void prepare_cuboid (vec3_t position, int id);
276extern void prepare_axis ();
277extern void draw (glwin * view);
278extern void render_all_strings (int glsl, int id);
279extern void prepare_string (char * text, int id, ColRGBA col, vec3_t pos, float lshift[3],
280 atom * at, atom * bt, atom * ct);
281
282ColRGBA init_color (int id, int numid);
284extern void sort (int dim, int * tab);
286void setup_bonds (glwin * view);
287void update (glwin * view);
288void center_this_molecule (glwin * view);
289G_MODULE_EXPORT void to_center_this_molecule (GtkWidget * widg, gpointer data);
290#ifdef GTK3
291G_MODULE_EXPORT gboolean on_lib_pressed (GtkWidget * widg, GdkEvent * event, gpointer data);
292G_MODULE_EXPORT gboolean on_glwin_button_event (GtkWidget * widg, GdkEvent * event, gpointer data);
293G_MODULE_EXPORT gboolean on_motion (GtkWidget * widg, GdkEvent * event, gpointer data);
294G_MODULE_EXPORT gboolean on_scrolled (GtkWidget * widg, GdkEvent * event, gpointer data);
295#else
296G_MODULE_EXPORT void on_lib_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
297G_MODULE_EXPORT void on_lib_button_released (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
298G_MODULE_EXPORT void on_glwin_button_pressed (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
299G_MODULE_EXPORT void on_glwin_button_released (GtkGesture * gesture, int n_press, double x, double y, gpointer data);
300G_MODULE_EXPORT void on_glwin_pointer_motion (GtkEventControllerMotion * motion, gdouble x, gdouble y, gpointer data);
301G_MODULE_EXPORT gboolean on_glwin_pointer_scoll (GtkEventControllerScroll * event, gdouble dx, gdouble dy, gpointer data);
302#endif
303void reshape (glwin * view, int width, int height, gboolean use_ratio);
304void zoom (glwin * view, int delta);
305
306void init_opengl ();
307void init_camera (project * this_proj, gboolean get_depth);
308
309#ifdef GTKGLAREA
310 G_MODULE_EXPORT void on_realize (GtkGLArea * area, gpointer data);
311 G_MODULE_EXPORT gboolean on_expose (GtkGLArea * area, GdkGLContext * context, gpointer data);
312#else
313 G_MODULE_EXPORT void on_realize (GtkWidget * area, gpointer data);
314 G_MODULE_EXPORT gboolean on_expose (GtkWidget * widg, cairo_t * cr, gpointer data);
315#endif
316
317extern void debug_image (image img, int i);
318
319extern distance distance_2d (atom * at, atom * bt);
320extern distance distance_3d (cell_info * cell, int mdstep, atom * at, atom * bt);
321extern angle angle_2d (atom * at, atom * bt, atom * ct);
322extern angle angle_3d (cell_info * cell, int mdstep, atom * at, atom * bt, atom * ct);
323extern angle dihedral_3d (cell_info * cell, int mdstep, atom * at, atom * bt, atom * ct, atom * dt);
324
325extern atom * duplicate_atom (atom * at);
326extern void at_shift (atom * at, float * shift);
327extern void at_unshift (atom * at, float * shift);
328extern int check_label_numbers (project * this_proj, int types);
329
330extern mat4_t create_axis_matrices (int type);
332
333extern int nbs, nbl, nba;
334extern void re_create_all_md_shaders (glwin * view);
335extern void re_create_md_shaders (int nshaders, int shaders[nshaders], project * this_proj);
336extern void cleaning_shaders (glwin * view, int shader);
337extern void init_default_shaders (glwin * view);
338extern void init_shaders(glwin * view);
339
340extern glsl_program * init_shader_program (int object, int object_id,
341 const GLchar * vertex, const GLchar * geometry, const GLchar * fragment,
342 GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d * obj);
343
344extern void update_selection_list (atom_selection * at_list, atom * at, gboolean add);
345extern void update_all_selections (glwin * view, int pi);
346extern void save_all_selections (glwin * view, int pi);
347
348extern void process_selected_atom (project * this_proj, glwin * view, int id, int ac, int se, int pi);
349
350extern void update_selection_tree (glwin * view, int pi, int id);
351extern void update_all_menus (glwin * view, int nats);
352
353extern gboolean is_coord_in_menu (int id, project * this_proj);
354
355extern atom_search * free_this_search_data (atom_search * this_search);
356#ifdef GTK3
357extern G_MODULE_EXPORT void show_hide_clones (GtkWidget * widg, gpointer data);
358extern G_MODULE_EXPORT void set_rep (GtkWidget * widg, gpointer data);
359#else
360extern G_MODULE_EXPORT void show_hide_clones (GSimpleAction * action, GVariant * state, gpointer data);
361#endif
362
363extern void popup_selection (glwin * view, double ptx, double pty, int se, int pe, int ai, int bi, int ac);
364extern void popup_main_menu (glwin * view, double ptx, double pty);
365
368{
370 double x, y;
371 int pts[5];
372};
373
374extern gl_pop_info to_pop;
375
376#endif
ColRGBA col
Definition d_measures.c:77
atom * ta
Definition d_measures.c:70
int * shift
Definition d_measures.c:72
GtkTreeSelection * sel
Definition datab.c:102
gchar * text
Definition datab.c:105
double pi
Definition global.c:195
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
Definition glview.c:626
image * plot
Definition ogl_draw.c:66
int nba
Definition glview.h:333
angle dihedral_3d(cell_info *cell, int mdstep, atom *at, atom *bt, atom *ct, atom *dt)
dihedral between atom a, b, c and d in 3D
Definition ogl_utils.c:204
void re_create_all_md_shaders(glwin *view)
re-initialize all MD dependent OpenGL shaders
texts
Definition glview.h:232
@ SIMPLE_TEXT
Definition glview.h:233
@ BETTER_TEXT
Definition glview.h:234
atom_search * free_this_search_data(atom_search *this_search)
free atom search data structure
Definition popup.c:285
int field_object
Definition dlp_field.c:979
GLfloat ** allocdGLfloat(int xal, int yal)
allocate a GLfloat ** pointer
Definition glview.c:161
axisposition
Definition glview.h:204
@ CENTER
Definition glview.h:209
@ BOTTOM_RIGHT
Definition glview.h:207
@ TOP_LEFT
Definition glview.h:206
@ BOTTOM_LEFT
Definition glview.h:208
@ CUSTOM
Definition glview.h:210
@ TOP_RIGHT
Definition glview.h:205
GLfloat initlights[4][4]
distance distance_2d(atom *at, atom *bt)
distance between atom a and b in 2D
Definition ogl_utils.c:60
void draw_atom(atom at, double al)
void prepare_cuboid(vec3_t position, int id)
OpenGL 3D light object rendering.
Definition d_box.c:433
G_MODULE_EXPORT void to_center_this_molecule(GtkWidget *widg, gpointer data)
center this molecule menu item callback GTK4
Definition popup.c:3974
void draw(glwin *view)
main drawing subroutine for the OpenGL window
Definition ogl_draw.c:461
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
gboolean create_atom(GLUquadricObj *quadric, int aid, int ac, int sp, int sel)
action
Definition glview.h:189
@ SELECT
Definition glview.h:192
@ ROTATE
Definition glview.h:190
@ ZOOM_IN_OUT
Definition glview.h:193
@ MOVE
Definition glview.h:191
@ SPIN
Definition glview.h:194
int gColorID[3]
Definition d_atoms.c:60
void at_unshift(atom *at, float *shift)
correct atomic coordinates modified to display image in cell replica
Definition ogl_draw.c:447
void prepare_string(char *text, int id, ColRGBA col, vec3_t pos, float lshift[3], atom *at, atom *bt, atom *ct)
prepare a screen string to be rendered
Definition ogl_text.c:691
void update(glwin *view)
update the rendering of the OpenGL window
Definition glview.c:439
project * proj_gl
Definition ogl_draw.c:60
glwin * wingl
Definition ogl_draw.c:59
gboolean is_coord_in_menu(int id, project *this_proj)
is this coordination in a menu ?
Definition m_coord.c:74
gboolean pick
void update_all_menus(glwin *view, int nats)
update all menus of the OpenGL window
Definition glwindow.c:337
int check_label_numbers(project *this_proj, int types)
check how many atom label(s) are visible
Definition popup.c:1040
void popup_main_menu(glwin *view, double ptx, double pty)
create the OpenGL window popup menu
Definition popup.c:4131
mat4_t create_axis_matrices(int type)
create axis OpenGL rendering matrices
Definition d_axis.c:101
void init_shaders(glwin *view)
initialize all the OpenGL shaders
radii
Definition glview.h:142
@ VDW
Definition glview.h:143
@ INC
Definition glview.h:144
@ COV
Definition glview.h:145
@ ION
Definition glview.h:146
GLenum ogl_texture
Definition glview.c:114
int proj_sp
Definition ogl_draw.c:61
angle angle_2d(atom *at, atom *bt, atom *ct)
angle between atom a, b and c in 2D
Definition ogl_utils.c:156
G_MODULE_EXPORT void show_hide_clones(GSimpleAction *action, GVariant *state, gpointer data)
show/hide clones menu item callback
Definition m_clones.c:139
void draw_cylinder_bond(atom a, atom b, int bid, int ci, int bi)
void at_shift(atom *at, float *shift)
modify atomic coordinates to display image in cell replica
Definition ogl_draw.c:432
void draw_wireframe_bond(atom a, atom b, int ci, int bi)
gl_pop_info to_pop
Definition glview.c:874
void draw_box()
void update_selection_list(atom_selection *at_list, atom *at, gboolean add)
update the selection list adding or removing an atom
Definition selection.c:445
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
G_MODULE_EXPORT void on_realize(GtkWidget *area, gpointer data)
realize event for the OpenGL widget
Definition glview.c:1737
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
modes
Definition glview.h:156
@ MOTION
Definition glview.h:159
@ LAAMPS
Definition glview.h:161
@ CPMD_AI
Definition glview.h:162
@ CP2K_MM
Definition glview.h:165
@ CP2K_QMMM
Definition glview.h:164
@ CP2K_AI
Definition glview.h:163
@ DL_POLY
Definition glview.h:160
@ ANALYZE
Definition glview.h:157
@ EDITION
Definition glview.h:158
void draw_rings_gl(int se, int ge, int ta, int id)
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
box_info * box_gl
Definition ogl_draw.c:64
render
Definition glview.h:182
@ FILL
Definition glview.h:183
@ LINE
Definition glview.h:184
@ PTS
Definition glview.h:185
void prepare_axis()
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
void popup_selection(glwin *view, double ptx, double pty, int se, int pe, int ai, int bi, int ac)
create the contextual popup menu, right click on atom or bond
Definition popup.c:3666
representation
Definition glview.h:150
@ PERSPECTIVE
Definition glview.h:152
@ ORTHOGRAPHIC
Definition glview.h:151
mouse_status
Definition glview.h:198
@ RELEASED
Definition glview.h:200
@ CLICKED
Definition glview.h:199
int nbs
Definition d_atoms.c:176
void reshape(glwin *view, int width, int height, gboolean use_ratio)
reshape (resize) the OpenGL window
Definition glview.c:516
void init_opengl()
initialize OpenGL rendering parameters
Definition glview.c:1390
void cleaning_shaders(glwin *view, int shader)
re-initialize an OpenGL shader
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
void init_camera(project *this_proj, gboolean get_depth)
void setup_bonds(glwin *view)
int qual
Definition ogl_draw.c:67
mat4_t create_label_matrices()
create label projection matrices
Definition d_label.c:56
ColRGBA set_default_color(int z)
pick the default color for an atom
Definition glview.c:187
void process_selected_atom(project *this_proj, glwin *view, int id, int ac, int se, int pi)
process selected atom
Definition selection.c:514
void draw_vertices(int id)
Draw OpenGL shader program.
int step
Definition ogl_draw.c:70
labels
Definition glview.h:214
@ ELEMENT_NAME
Definition glview.h:215
@ NUM
Definition glview.h:218
@ SYMBOL_AND_NUM
Definition glview.h:217
@ ID_IN_MOLECULE
Definition glview.h:219
@ SYMBOL
Definition glview.h:216
void update_selection_tree(glwin *view, int pi, int id)
update measurements tree view
Definition w_measures.c:381
int pcolorm
Definition ogl_draw.c:69
void render_all_strings(int glsl, int id)
render all string to be rendered for a label list
Definition ogl_text.c:549
angle angle_3d(cell_info *cell, int mdstep, atom *at, atom *bt, atom *ct)
angle between atom a, b and c in 3D
Definition ogl_utils.c:179
int nbl
Definition glview.h:333
int acolorm
Definition ogl_draw.c:68
gboolean create_bond(int ac, int bid, int ba, int bb, int sel, double length)
vec3_t get_insertion_coordinates(glwin *view)
get the insertion coordinates to insert object in the 3D window
Definition glwindow.c:794
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
Definition glview.c:1522
atom * duplicate_atom(atom *at)
copy (partially) an atom data structure
Definition ogl_draw.c:396
void update_all_selections(glwin *view, int pi)
update the selection data: bonds, angles and dihedrals
Definition selection.c:387
void save_all_selections(glwin *view, int pi)
save all selection data
Definition selection.c:372
coord_info * coord_gl
Definition ogl_draw.c:63
void debug_image(image img, int i)
glsl_program * init_shader_program(int object, int object_id, const GLchar *vertex, const GLchar *geometry, const GLchar *fragment, GLenum type_of_vertices, int narray, int nunif, gboolean lightning, object_3d *obj)
create an OpenGL shader program
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
int proj_at
Definition ogl_draw.c:62
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 void on_glwin_pointer_motion(GtkEventControllerMotion *motion, gdouble x, gdouble y, gpointer data)
handle mouse motion event in the OpenGL window GTK4
Definition glview.c:727
cell_info * cell_gl
Definition ogl_draw.c:65
G_MODULE_EXPORT gboolean on_expose(GtkWidget *widg, cairo_t *cr, gpointer data)
OpenGL rendering widget expose event callback GTK3.
Definition glview.c:1794
void draw_cylinder_bond_to_pick(atom a, atom b, int bid)
void sort(int dim, int *tab)
sort, nim to max, a table by integer value
Definition glview.c:380
actions
Definition glview.h:223
@ DISPL
Definition glview.h:224
@ RANMOVE
Definition glview.h:228
@ REPLACE
Definition glview.h:225
@ REMOVE
Definition glview.h:226
@ INSERT
Definition glview.h:227
styles
Definition glview.h:171
@ 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
void draw_atom_to_pick(atom at)
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
shaders
The different types of shaders in the atomes program.
Definition glwin.h:88
position
Definition m_proj.c:47
G_MODULE_EXPORT void set_rep(GtkWidget *widg, gpointer data)
change representation callback - GTK3
Definition m_rep.c:367
GLUquadricObj * quadric
Definition ogl_draw.c:58
double z
Definition ogl_draw.c:57
double y
Definition ogl_draw.c:57
double x
Definition ogl_draw.c:57
Definition glwin.h:114
Definition global.h:886
int action
Definition glview.h:369
double y
Definition glview.h:370
int pts[5]
Definition glview.h:371
double x
Definition glview.h:370
Definition glwin.h:875
Definition glwin.h:277
int b
Definition tab-1.c:95
int a
Definition tab-1.c:95
gchar * al[3]
Definition w_axis.c:67
GtkWidget * img
Definition workspace.c:70