atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
glview.c File Reference

Callbacks of the OpenGL window. More...

#include "global.h"
#include "interface.h"
#include "preferences.h"
#include "initcoord.h"
#include "bind.h"
#include "project.h"
#include "glview.h"
+ Include dependency graph for glview.c:

Go to the source code of this file.

Functions

void process_the_hits (glwin *view, gint event_button, double ptx, double pty)
 process a mouse click
 
void arc_ball_rotation (glwin *view, int x, int y)
 Perform arcball rotation.
 
vec3_t get_arc_ball_vector (glwin *view, int x, int y)
 
Light init_light_source (int type, float val, float vbl)
 initialize a light source
 
void rotate_quat (project *this_proj, vec4_t q, int status, int axis)
 rotate using quaternion
 
void translate (project *this_proj, int status, int axis, vec3_t trans)
 translate
 
vec3_t get_bary (project *this_proj, int status)
 get barycenter of atomic coordinates
 
void update_labels (glwin *view)
 update labels (on representation data update)
 
void prepare_atom_edition (gpointer data, gboolean visible)
 prepare atom edition
 
atom_searchallocate_atom_search (int proj, int action, int searchid, int tsize)
 allocate atom search data structure
 
int action_atoms_from_project (project *this_proj, atom_search *asearch, gboolean visible)
 apply atom edition action to project (motion, remove, replace, insert, random move)
 
atomic_objectcreate_object_from_frag_mol (project *this_proj, int coord, int geo, atom_search *remove)
 create object from a fragment or a molecule
 
void duplicate_material (Material *new_mat, Material *old_mat)
 duplicate material data
 
void duplicate_fog (Fog *new_fog, Fog *old_fog)
 duplicate fog data
 
void duplicate_screen_label (screen_label *new_lab, screen_label *old_lab)
 copy screen_label data structure
 
GLuint * allocgluint (int val)
 allocate a GLuint * pointer
 
GLuint ** allocdgluint (int xal, int yal)
 allocate a GLuint ** pointer
 
GLfloat ** allocdGLfloat (int xal, int yal)
 allocate a GLfloat ** pointer
 
ColRGBA set_default_color (int z)
 pick the default color for an atom
 
void update_bonds_ (int *bd, int *stp, int *bdim, int bda[*bdim], int bdb[*bdim], double *x, double *y, double *z)
 update bonding information from Fortran90
 
void sort (int dim, int *tab)
 sort, nim to max, a table by integer value
 
void update_atom_neighbors_ (int *stp, int *at, int *nv)
 update an atom number of neighbors from Fortran90
 
void update_this_neighbor_ (int *stp, int *at, int *iv, int *nv)
 update atom neighbor list from Fortran90
 
void update (glwin *view)
 update the rendering of the OpenGL window
 
void transform (glwin *view, double aspect)
 transform the OpenGL window
 
void reshape (glwin *view, int width, int height, gboolean use_ratio)
 reshape (resize) the OpenGL window
 
void save_rotation_quaternion (glwin *view)
 save the rotation quaternion of the last image
 
void edit_for_motion (glwin *view)
 if edition mode is one some steps are required
 
void motion (glwin *view, gint x, gint y, GdkModifierType state)
 mouse motion in the OpenGL window
 
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
 
void render_this_gl_window (glwin *view, GtkWidget *widg, gint button)
 render the OpenGL window
 
void glwin_lib_pressed (double x, double y, guint event_type, guint event_button, gpointer data)
 handle mouse button event on the molecular library OpenGL window
 
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)
 
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)
 
void glwin_button_event (double event_x, double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
 handle mouse button event on the OpenGL window
 
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
 
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
 
void zoom (glwin *view, int delta)
 zoom in or zoom out in the OpenGL window
 
G_MODULE_EXPORT gboolean on_glwin_pointer_scoll (GtkEventControllerScroll *event, gdouble dx, gdouble dy, gpointer data)
 handle mouse scroll event on the OpenGL window
 
void rotate_x_y (glwin *view, double angle_x, double angle_y)
 rotate the OpenGL camera
 
GLdouble get_max_depth (GLdouble depth)
 guess a reasonable maximum OpenGL window depth
 
void init_camera (project *this_proj, int get_depth)
 initialize the OpenGL camera settings
 
void setup_default_species_parameters_for_image (project *this_proj, image *img)
 setup default chemical species related parameters for image
 
void setup_image_spec_data (project *this_proj, image *img)
 initialize the chemical species related pointers in an image data structure
 
void setup_default_lights (project *this_proj, image *img)
 initialize lightning for an image data structure
 
void setup_default_image (project *this_proj, image *img)
 setup default image parameters
 
void init_img (project *this_proj)
 initialize an image data structure
 
gboolean is_GLExtension_Supported (const char *extension)
 test if this GLExtension is support
 
void init_opengl ()
 initialize OpenGL rendering parameters
 
void center_molecule (project *this_proj)
 center atomic coordinates around (0,0,0)
 
void center_this_molecule (glwin *view)
 center atomic coordinates around (0,0,0) and refresh shaders
 
void free_glwin_spec_data (project *this_proj, int spec)
 free the memory used by the chemical species related data in a glwin data structure
 
void glwin_init_spec_data (project *this_proj, int nspec)
 initialize the glwin chemical species related pointers
 
void init_glwin (glwin *view)
 initialize a glwin pointer
 
GError * init_gtk_gl_area (GtkGLArea *area)
 initialize a GtkGLArea, return error if any
 
G_MODULE_EXPORT void on_realize (GtkWidget *widg, gpointer data)
 realize event for the OpenGL widget
 
G_MODULE_EXPORT gboolean on_expose (GtkWidget *widg, cairo_t *cr, gpointer data)
 OpenGL rendering widget expose event callback GTK3.
 

Variables

vec3_t arc_ball_init
 
vec4_t old_rotation_quaternion
 
GLenum ogl_texture
 
const float light_pos [MAX_LIGHTS][4]
 
gl_pop_info to_pop
 

Detailed Description

Callbacks of the OpenGL window.

Author
Sébastien Le Roux sebas.nosp@m.tien.nosp@m..lero.nosp@m.ux@i.nosp@m.pcms..nosp@m.unis.nosp@m.tra.f.nosp@m.r

Definition in file glview.c.

Function Documentation

◆ action_atoms_from_project()

int action_atoms_from_project ( project * this_proj,
atom_search * asearch,
gboolean visible )
extern

apply atom edition action to project (motion, remove, replace, insert, random move)

Parameters
this_projthe target project
asearchthe target atom search
visibleis the 'model edition' window visible (1/0)

Definition at line 211 of file atom_action.c.

◆ allocate_atom_search()

atom_search * allocate_atom_search ( int proj,
int action,
int searchid,
int tsize )
extern

allocate atom search data structure

Parameters
projthe target project id
actionthe edition action
searchidthe atom search id
tsizethe atom search object list size

Definition at line 386 of file atom_edit.c.

◆ allocdGLfloat()

GLfloat ** allocdGLfloat ( int xal,
int yal )

allocate a GLfloat ** pointer

Parameters
xal1st dimension size of the pointer to allocate
yal2nd dimension size of the pointer to allocate

Definition at line 169 of file glview.c.

◆ allocdgluint()

GLuint ** allocdgluint ( int xal,
int yal )

allocate a GLuint ** pointer

Parameters
xal1st dimension size of the pointer to allocate
yal2nd dimension size of the pointer to allocate

Definition at line 147 of file glview.c.

◆ allocgluint()

GLuint * allocgluint ( int val)

allocate a GLuint * pointer

Parameters
valsize of the pointer to allocate

Definition at line 131 of file glview.c.

◆ arc_ball_rotation()

void arc_ball_rotation ( glwin * view,
int x,
int y )
extern

Perform arcball rotation.

Parameters
viewthe target glwin
xx position
yy position

Definition at line 73 of file arcball.c.

◆ center_molecule()

void center_molecule ( project * this_proj)

center atomic coordinates around (0,0,0)

Parameters
this_projthe target project

Definition at line 1490 of file glview.c.

◆ center_this_molecule()

void center_this_molecule ( glwin * view)

center atomic coordinates around (0,0,0) and refresh shaders

Parameters
viewthe target glwin

Definition at line 1571 of file glview.c.

◆ create_object_from_frag_mol()

atomic_object * create_object_from_frag_mol ( project * this_proj,
int coord,
int geo,
atom_search * remove )
extern

create object from a fragment or a molecule

Parameters
this_projthe target project
coord2 = fragment, 3 = molecule
geofragment or molecule id
removeremove search, if any

Definition at line 928 of file atom_object.c.

◆ duplicate_fog()

void duplicate_fog ( Fog * new_fog,
Fog * old_fog )
extern

duplicate fog data

Parameters
new_fogthe new fog data
old_fogthe old fog data to be copied

Definition at line 203 of file ogl_draw.c.

◆ duplicate_material()

void duplicate_material ( Material * new_mat,
Material * old_mat )
extern

duplicate material data

Parameters
new_matthe new material data
old_matthe old material data to be copied

Definition at line 186 of file ogl_draw.c.

◆ duplicate_screen_label()

void duplicate_screen_label ( screen_label * new_lab,
screen_label * old_lab )
extern

copy screen_label data structure

Parameters
new_labthe new screen_label structure
old_labthe old screen_label structure to be copied

Definition at line 239 of file ogl_draw.c.

◆ edit_for_motion()

void edit_for_motion ( glwin * view)

if edition mode is one some steps are required

Parameters
viewthe target glwin

Definition at line 571 of file glview.c.

◆ free_glwin_spec_data()

void free_glwin_spec_data ( project * this_proj,
int spec )

free the memory used by the chemical species related data in a glwin data structure

Parameters
this_projthe target project
specthe number of chemical species

Definition at line 1592 of file glview.c.

◆ get_arc_ball_vector()

vec3_t get_arc_ball_vector ( glwin * view,
int x,
int y )
extern

Definition at line 46 of file arcball.c.

◆ get_bary()

vec3_t get_bary ( project * this_proj,
int status )
extern

get barycenter of atomic coordinates

Parameters
this_projthe target project
statusselection status, 0 = non selected atom(s), 1 = selected atom(s), 2 = all atom(s)

Definition at line 170 of file atom_move.c.

◆ get_max_depth()

GLdouble get_max_depth ( GLdouble depth)

guess a reasonable maximum OpenGL window depth

Parameters
depththe calculated model depth

Definition at line 1142 of file glview.c.

◆ glwin_button_event()

void glwin_button_event ( double event_x,
double event_y,
guint event_button,
guint event_type,
guint32 event_time,
gpointer data )

handle mouse button event on the OpenGL window

Parameters
event_xx position
event_yy position
event_buttonevent button
event_typeevent type
event_timeevent time
datathe associated data pointer

Definition at line 899 of file glview.c.

◆ glwin_init_spec_data()

void glwin_init_spec_data ( project * this_proj,
int nspec )

initialize the glwin chemical species related pointers

Parameters
this_projthe target project
nspecthe number of chemical species

Definition at line 1637 of file glview.c.

◆ glwin_lib_pressed()

void glwin_lib_pressed ( double x,
double y,
guint event_type,
guint event_button,
gpointer data )

handle mouse button event on the molecular library OpenGL window

Parameters
xx position
yy position
event_typeevent type
event_buttonevent button
datathe associated data pointer

Definition at line 811 of file glview.c.

◆ init_camera()

void init_camera ( project * this_proj,
int get_depth )

initialize the OpenGL camera settings

Parameters
this_projthe target project
get_depthestimate the OpenGL depth ? (1/0)

Definition at line 1170 of file glview.c.

◆ init_glwin()

void init_glwin ( glwin * view)

initialize a glwin pointer

Parameters
viewthe target glwin

Definition at line 1702 of file glview.c.

◆ init_gtk_gl_area()

GError * init_gtk_gl_area ( GtkGLArea * area)

initialize a GtkGLArea, return error if any

Parameters
areathe GtkGLArea point to initialize

Definition at line 1753 of file glview.c.

◆ init_img()

void init_img ( project * this_proj)

initialize an image data structure

Parameters
this_projthe target project

Definition at line 1399 of file glview.c.

◆ init_light_source()

Light init_light_source ( int type,
float size,
float depth )
extern

initialize a light source

Parameters
typethe type of light
sizedepth or max (a,b,c)
depthfield depth
intens

Definition at line 337 of file w_advance.c.

◆ init_opengl()

void init_opengl ( )

initialize OpenGL rendering parameters

Definition at line 1439 of file glview.c.

◆ is_GLExtension_Supported()

gboolean is_GLExtension_Supported ( const char * extension)

test if this GLExtension is support

Parameters
extensionthe target GLExtension

Definition at line 1422 of file glview.c.

◆ motion()

void motion ( glwin * view,
gint x,
gint y,
GdkModifierType state )

mouse motion in the OpenGL window

Parameters
viewthe target glwin
xx position
yy position
stateThe keyboard modifier (Ctrl, Alt ...)

Definition at line 637 of file glview.c.

◆ on_expose()

G_MODULE_EXPORT gboolean on_expose ( GtkWidget * widg,
cairo_t * cr,
gpointer data )

OpenGL rendering widget expose event callback GTK3.

Parameters
widgthe GtkWidget sending the signal
crthe cairo drawing context to use for the draw
datathe associated data pointer

Definition at line 1844 of file glview.c.

◆ on_glwin_button_pressed()

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

Parameters
gesturethe GtkGesture sending the signal
n_pressnumber of times it was pressed
xx position
yy position
datathe associated data pointer

Definition at line 986 of file glview.c.

◆ on_glwin_button_released()

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

Parameters
gesturethe GtkGesture sending the signal
n_pressnumber of times it was pressed
xx position
yy position
datathe associated data pointer

Definition at line 1002 of file glview.c.

◆ on_glwin_pointer_motion()

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

Parameters
motcThe GtkEvenController sending the signal
xx position
yy position
datathe associated data pointer

Definition at line 738 of file glview.c.

◆ on_glwin_pointer_scoll()

G_MODULE_EXPORT gboolean on_glwin_pointer_scoll ( GtkEventControllerScroll * event,
gdouble dx,
gdouble dy,
gpointer data )

handle mouse scroll event on the OpenGL window

Parameters
eventthe GtkEventControllerScroll sending the signal
dxx position
dyy position
datathe associated data pointer

Definition at line 1066 of file glview.c.

◆ on_lib_button_pressed()

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)

Parameters
gesturethe GtkGesture sending the signal
n_pressnumber of times it was pressed
xx position
yy position
datathe associated data pointer

Definition at line 863 of file glview.c.

◆ on_lib_button_released()

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)

Parameters
gesturethe GtkGesture sending the signal
n_pressnumber of times it was pressed
xx position
yy position
datathe associated data pointer

Definition at line 879 of file glview.c.

◆ on_realize()

G_MODULE_EXPORT void on_realize ( GtkWidget * widg,
gpointer data )

realize event for the OpenGL widget

Parameters
widgthe GtkWidget sending the signal
datathe associated data pointer

Definition at line 1787 of file glview.c.

◆ prepare_atom_edition()

void prepare_atom_edition ( gpointer data,
gboolean visible )
extern

prepare atom edition

Parameters
datathe associated data pointer
visibleis the window visible (1/0)

Definition at line 453 of file atom_edit.c.

◆ process_the_hits()

void process_the_hits ( glwin * view,
gint event_button,
double ptx,
double pty )
extern

process a mouse click

Parameters
viewthe target glwin
event_buttonthe event button
ptxx position
ptyy position

Definition at line 590 of file selection.c.

◆ render_this_gl_window()

void render_this_gl_window ( glwin * view,
GtkWidget * widg,
gint button )

render the OpenGL window

Parameters
viewthe target glwin
widgthe GtkWidget sending the signal
buttonthe button id

Definition at line 768 of file glview.c.

◆ reshape()

void reshape ( glwin * view,
int width,
int height,
gboolean use_ratio )

reshape (resize) the OpenGL window

Parameters
viewthe target glwin
widthnew with
heightnew height
use_ratiouse widget rendering ratio

Definition at line 527 of file glview.c.

◆ rotate_quat()

void rotate_quat ( project * this_proj,
vec4_t q,
int status,
int axis )
extern

rotate using quaternion

Parameters
this_projthe target project
qrotation quaternion
statusselection status, 0 = non selected atom(s), 1 = selected atom(s), 2 = all atom(s)
axis0 = model, 1 = eye

Definition at line 269 of file atom_move.c.

◆ rotate_x_y()

void rotate_x_y ( glwin * view,
double angle_x,
double angle_y )

rotate the OpenGL camera

Parameters
viewthe target glwin
angle_xcamera angle on x axis
angle_ycamera angle on y axis

Definition at line 1092 of file glview.c.

◆ save_rotation_quaternion()

void save_rotation_quaternion ( glwin * view)

save the rotation quaternion of the last image

Parameters
viewthe target glwin

Definition at line 554 of file glview.c.

◆ set_default_color()

ColRGBA set_default_color ( int z)

pick the default color for an atom

Parameters
zatomic number

Definition at line 195 of file glview.c.

◆ setup_default_image()

void setup_default_image ( project * this_proj,
image * img )

setup default image parameters

Parameters
this_projthe target project
imgthe target image

Definition at line 1344 of file glview.c.

◆ setup_default_lights()

void setup_default_lights ( project * this_proj,
image * img )

initialize lightning for an image data structure

Parameters
this_projthe target project
imgthe target image

Definition at line 1305 of file glview.c.

◆ setup_default_species_parameters_for_image()

void setup_default_species_parameters_for_image ( project * this_proj,
image * img )

setup default chemical species related parameters for image

Parameters
this_projthe target project
imgthe target image

Definition at line 1218 of file glview.c.

◆ setup_image_spec_data()

void setup_image_spec_data ( project * this_proj,
image * img )

initialize the chemical species related pointers in an image data structure

Parameters
this_projthe target project
imgthe target image

Definition at line 1264 of file glview.c.

◆ sort()

void sort ( int dim,
int * tab )

sort, nim to max, a table by integer value

Parameters
dimthe number of value
tabthe table to sort

Definition at line 391 of file glview.c.

◆ transform()

void transform ( glwin * view,
double aspect )

transform the OpenGL window

Parameters
viewthe target glwin
aspectnew aspect ratio

Definition at line 469 of file glview.c.

◆ translate()

void translate ( project * this_proj,
int status,
int axis,
vec3_t trans )
extern

translate

Parameters
this_projthe target project
statusselection status, 0 = non selected atom(s), 1 = selected atom(s), 2 = all atom(s)
axis0 = model, 1 = eye
transtranslation vector

Definition at line 230 of file atom_move.c.

◆ update()

void update ( glwin * view)

update the rendering of the OpenGL window

Parameters
viewthe target glwin

Definition at line 450 of file glview.c.

◆ update_atom_neighbors_()

void update_atom_neighbors_ ( int * stp,
int * at,
int * nv )

update an atom number of neighbors from Fortran90

Parameters
stpthe MD step
atatom id
nvnumber of neighbor atom(s)

Definition at line 415 of file glview.c.

◆ update_bonds_()

void update_bonds_ ( int * bd,
int * stp,
int * bdim,
int bda[ *bdim],
int bdb[ *bdim],
double * x,
double * y,
double * z )

update bonding information from Fortran90

Parameters
bdbonds (0) or clones (1)
stpthe MD step
bdimnumber of bonds (or clone bonds)
bdabond "ab" list atom a
bdbbond "ab" list atom b
xclone(s) x coordinates
yclone(s) y coordinates
zclone(s) z coordinates

Definition at line 341 of file glview.c.

◆ update_labels()

void update_labels ( glwin * view)
extern

update labels (on representation data update)

Parameters
viewthe target glwin

Definition at line 85 of file m_rep.c.

◆ update_this_neighbor_()

void update_this_neighbor_ ( int * stp,
int * at,
int * iv,
int * nv )

update atom neighbor list from Fortran90

Parameters
stpthe MD step
atatom id
ivneighbor index
nvneighbor id

Definition at line 434 of file glview.c.

◆ zoom()

void zoom ( glwin * view,
int delta )

zoom in or zoom out in the OpenGL window

Parameters
viewthe target glwin
deltathe zoom modification

Definition at line 1017 of file glview.c.

Variable Documentation

◆ arc_ball_init

vec3_t arc_ball_init
extern

Definition at line 42 of file arcball.c.

◆ light_pos

const float light_pos[MAX_LIGHTS][4]
Initial value:
= {{-0.1f, 0.1f, 1.0f, 0.0f},
{ 1.0f, 2.0f, 0.5f, 0.0f},
{-1.0f, 2.0f, -1.0f, 0.0f},
{-1.0f, -1.0f, 0.0f, 0.0f}}

Definition at line 183 of file glview.c.

◆ ogl_texture

GLenum ogl_texture

Definition at line 122 of file glview.c.

◆ old_rotation_quaternion

vec4_t old_rotation_quaternion
extern

Definition at line 44 of file arcball.c.

◆ to_pop

gl_pop_info to_pop

Definition at line 885 of file glview.c.