atomes 1.1.14
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 "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
 
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)
 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
 
void init_camera (project *this_proj, int get_depth)
 intialize the OpenGL camera settings
 
void image_init_spec_data (image *img, project *this_proj, int nsp)
 initialize the chemical species related pointers in an image data structure
 
void set_img_lights (project *this_proj, image *img)
 initialize lightning for an image data structure
 
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 (glwin *view)
 initialize OpenGL rendering parameters for a glwin pointer
 
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 206 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 392 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 161 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 139 of file glview.c.

◆ allocgluint()

GLuint * allocgluint ( int val)

allocate a GLuint * pointer

Parameters
valsize of the pointer to allocate

Definition at line 123 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 1437 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 1518 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.

◆ 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 554 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 1539 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.

◆ 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 887 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 1584 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 800 of file glview.c.

◆ image_init_spec_data()

void image_init_spec_data ( image * img,
project * this_proj,
int nsp )

initialize the chemical species related pointers in an image data structure

Parameters
imgthe target image
this_projthe target project
nspthe number of chemical species

Definition at line 1187 of file glview.c.

◆ init_camera()

void init_camera ( project * this_proj,
int get_depth )

intialize the OpenGL camera settings

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

Definition at line 1129 of file glview.c.

◆ init_glwin()

void init_glwin ( glwin * view)

initialize a glwin pointer

Parameters
viewthe target glwin

Definition at line 1649 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 1699 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 1276 of file glview.c.

◆ init_light_source()

Light init_light_source ( int type,
float val,
float vbl )
extern

initialize a light source

Parameters
typethe type of light
val
vbl

Definition at line 324 of file w_advance.c.

◆ init_opengl()

void init_opengl ( glwin * view)

initialize OpenGL rendering parameters for a glwin pointer

Parameters
viewthe target glwin

Definition at line 1389 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 1370 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 620 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 1805 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 972 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 988 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 724 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 1052 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 851 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 867 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 1733 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 459 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 757 of file glview.c.

◆ reshape()

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

reshape (resize) the OpenGL window

Parameters
viewthe target glwin
widthnew with
heightnew height

Definition at line 513 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 1078 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 537 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 187 of file glview.c.

◆ set_img_lights()

void set_img_lights ( project * this_proj,
image * img )

initialize lightning for an image data structure

Parameters
this_projthe target project
imgthe target image

Definition at line 1249 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 380 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 456 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 439 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 404 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 330 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 83 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 423 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 1003 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 175 of file glview.c.

◆ ogl_texture

GLenum ogl_texture

Definition at line 114 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 873 of file glview.c.