135 var = g_malloc0 (
val*
sizeof*var);
149 GLuint ** var = NULL;
152 var = g_malloc (xal*
sizeof*var);
153 for ( i = 0 ; i < xal ; i ++ )
171 GLfloat ** var = NULL;
174 var = g_malloc (xal*
sizeof*var);
175 for ( i = 0 ; i < xal ; i ++ )
178 var[i] = g_malloc0 (yal*
sizeof*var[i]);
184 { 1.0f, 2.0f, 0.5f, 0.0f},
185 {-1.0f, 2.0f, -1.0f, 0.0f},
186 {-1.0f, -1.0f, 0.0f, 0.0f}};
198 double colors[118][3]={{1.00, 1.00, 1.00},
317 int Z = (
z < 1) ? 1 :
z;
342 int * bdim,
int bda[* bdim],
int bdb[* bdim],
343 double *
x,
double *
y,
double *
z)
354 for (i=0; i< * bdim; i++)
369 for (i=0; i< * bdim; i++)
394 for (i=1; i<dim; i++)
397 for (j=i-1; j>-1; j--)
399 if (tab[j] <=
val)
break;
452 gtk_gl_area_queue_render ((GtkGLArea *)view ->
plot);
475 view -> zoom_factor =
zoom * 0.1 * view -> anim -> last ->
img -> p_depth / (2.0 * view -> anim -> last ->
img -> gfar);
478 zoom *= (view -> anim -> last ->
img -> p_depth / view -> anim -> last ->
img -> gnear);
480 dw = view -> anim -> last ->
img -> c_shift[0]*2.0*
zoom;
481 dh = view -> anim -> last ->
img -> c_shift[1]*2.0*
zoom;
492 view -> anim -> last ->
img -> gleft = -w + dw;
493 view -> anim -> last ->
img -> gright = w + dw;
494 view -> anim -> last ->
img -> gbottom = -h + dh;
495 view -> anim -> last ->
img -> gtop = h + dh;
499 view -> projection_matrix = m4_frustum (view -> anim -> last ->
img -> gleft,
500 view -> anim -> last ->
img -> gright,
501 view -> anim -> last ->
img -> gbottom,
502 view -> anim -> last ->
img -> gtop,
503 view -> anim -> last ->
img -> gnear,
504 view -> anim -> last ->
img -> gfar);
508 view -> projection_matrix = m4_ortho (view -> anim -> last ->
img -> gleft,
509 view -> anim -> last ->
img -> gright,
510 view -> anim -> last ->
img -> gbottom,
511 view -> anim -> last ->
img -> gtop,
512 -view -> anim -> last ->
img -> gfar,
513 view -> anim -> last ->
img -> gfar);
535 if (GTK_IS_WIDGET(view -> win))
537 scale = gtk_widget_get_scale_factor (view -> win);
541 glViewport (0, 0, (GLsizei)
scale * width, (GLsizei)
scale * height);
542 view -> view_port = vec4 (0.0, 0.0, width, height);
543 aspect = (double) width / (
double) height;
573 gboolean check_edit = FALSE;
577 int ** frag =
allocdint (this_proj -> coord -> totcoord[2], 2);
580 for (i=0; i<this_proj -> natomes; i++)
586 move_search -> todo[i] = 1;
593 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
595 if (frag[i][1] && frag[i][1] < frag[i][0])
604 (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE);
609 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
622 view -> baryc[1] =
get_bary (this_proj, 1);
624 view -> prepare_motion = FALSE;
639 view -> mouseAction =
MOTION;
643 if (state & GDK_BUTTON1_MASK)
647 else if (state & GDK_BUTTON2_MASK)
651 view -> anim -> last ->
img -> c_shift[0] -= (double) (
x - view -> mouseX) / view -> pixels[0];
652 view -> anim -> last ->
img -> c_shift[1] += (double) (
y - view -> mouseY) / view -> pixels[1];
657 if (view -> rep_win -> camera_widg[i+5] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[i+5]))
659 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[i+5], - view -> anim -> last ->
img -> c_shift[i]);
667 vec3_t pos_b = vec3(view -> mouseX, - view -> mouseY, 0.75);
668 vec3_t trans_a = v3_un_project (pos_a, view -> view_port, view -> projection_matrix);
669 vec3_t trans_b = v3_un_project (pos_b, view -> view_port, view -> projection_matrix);
671 trans.
x = (trans_a.
x - trans_b.
x);
672 trans.
y = (trans_b.
y - trans_a.
y);
675 trans.
x *= view -> anim -> last ->
img -> p_depth;
676 trans.
y *= view -> anim -> last ->
img -> p_depth;
705G_MODULE_EXPORT gboolean on_motion (GtkWidget * widg, GdkEvent * event, gpointer data)
708 if (view -> mouseStatus !=
RELEASED)
710 GdkEventMotion * mevent = (GdkEventMotion *)event;
712 GdkModifierType state;
713 if (mevent -> is_hint)
715 gdk_window_get_device_position (mevent -> window, mevent -> device, &
x, &
y, & state);
719 x = (gint) mevent ->
x;
720 y = (gint) mevent ->
y;
721 state = (GdkModifierType) mevent -> state;
741 if (view -> mouseStatus !=
RELEASED)
743 motion (view, (gint)
x, (gint)
y, gtk_event_controller_get_current_event_state((GtkEventController*)motc));
774 gtk_gl_area_make_current (area);
775 if (gtk_gl_area_get_error (area) == NULL)
779 GdkWindow * win = gtk_widget_get_window (widg);
780 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win), view ->
glcontext))
783 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
787 if (view -> mouseButton)
process_the_hits (view, view -> mouseButton, view -> mouseX, view -> mouseY);
788 view -> to_pick = FALSE;
789 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
795 glXSwapBuffers (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win));
816 case GDK_BUTTON_PRESS:
820 view -> mouseButton = event_button;
821 if (event_button == 1)
825 view -> to_pick = FALSE;
829 case GDK_BUTTON_RELEASE:
845G_MODULE_EXPORT gboolean on_lib_pressed (GtkWidget * widg, GdkEvent * event, gpointer data)
847 GdkEventButton * bevent = (GdkEventButton*)event;
865 glwin_lib_pressed (
x,
y, GDK_BUTTON_PRESS, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
881 glwin_lib_pressed (
x,
y, GDK_BUTTON_RELEASE, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
899void glwin_button_event (
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
904 case GDK_BUTTON_PRESS:
906 view -> mouseX = event_x;
907 view -> mouseY = event_y;
908 view -> mouseButton = event_button;
909 clock_gettime (CLOCK_MONOTONIC, &
start_time);
910 if (event_button == 1 || event_button == 3)
914 view -> nth_copy = 0;
917 view -> to_pick = TRUE;
924 case GDK_BUTTON_RELEASE:
926 view -> mouseButton = 0;
927 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
936 if (view -> mode ==
EDITION && view -> mouseAction ==
MOTION)
941 if (event_button == 3)
968G_MODULE_EXPORT gboolean on_glwin_button_event (GtkWidget * widg, GdkEvent * event, gpointer data)
970 GdkEventButton * bevent = (GdkEventButton*)event;
971 glwin_button_event (bevent ->
x, bevent ->
y, bevent -> button, bevent -> type, bevent -> time, data);
988 glwin_button_event (
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_PRESS, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
1004 glwin_button_event (
x,
y, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), GDK_BUTTON_RELEASE, gtk_event_controller_get_current_event_time((GtkEventController *)gesture), data);
1019 view -> anim -> last ->
img ->
zoom += delta * view -> zoom_factor;
1020 if (view -> rep_win)
1022 if (view -> rep_win -> camera_widg[0] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[0]))
1024 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[0], 1.0-0.5*view -> anim -> last ->
img ->
zoom);
1039G_MODULE_EXPORT gboolean on_scrolled (GtkWidget * widg, GdkEvent * event, gpointer data)
1042 GdkEventScroll * sevent = (GdkEventScroll *)event;
1043 if (sevent -> direction == GDK_SCROLL_UP)
1047 else if (sevent -> direction == GDK_SCROLL_DOWN && view -> anim -> last ->
img ->
zoom >
ZOOM_MAX)
1099 q_a = axis_to_quat (
axis, -
pi*angle_y/180.0);
1103 q_b = axis_to_quat (
axis, -
pi*angle_x/180.0);
1104 q_c = q4_mul (q_a, q_b);
1105 view -> anim -> last ->
img -> c_angle[0] -= angle_x;
1106 view -> anim -> last ->
img -> c_angle[1] -= angle_y;
1110 if (fabs(view -> anim -> last ->
img -> c_angle[i]) > 180.0) view -> anim -> last ->
img -> c_angle[i] = 0.0;
1111 if (view -> rep_win)
1113 if (view -> rep_win -> camera_widg[i+3] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[i+3]))
1115 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[i+3], view -> anim -> last ->
img -> c_angle[i]);
1148 else if (depth < 100.0)
1152 else if (depth < 1000.0)
1172 glwin * view = this_proj -> modelgl;
1175 view -> anim -> last ->
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1176 view -> anim -> last ->
img -> m_depth =
get_max_depth (view -> anim -> last ->
img -> p_depth);
1179 view -> anim -> last ->
img -> gfar = view -> anim -> last ->
img -> p_depth*2.0;
1180 view -> anim -> last ->
img -> rotation_quaternion.w = 0.0;
1181 view -> anim -> last ->
img -> rotation_quaternion.x = 0.0;
1182 view -> anim -> last ->
img -> rotation_quaternion.y = 0.0;
1183 view -> anim -> last ->
img -> rotation_quaternion.z = 1.0;
1187 view -> anim -> last ->
img -> c_angle[i] = 0.0;
1193 if (view -> rep_win)
1195 if (view -> rep_win -> camera_widg[0] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[0]))
1197 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[0], 1.0 - 0.5*view -> anim -> last ->
img ->
zoom);
1199 if (view -> rep_win -> camera_widg[1] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[1]))
1201 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[1], view -> anim -> last ->
img -> p_depth);
1203 if (view -> rep_win -> camera_widg[2] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[2]))
1205 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[2], view -> anim -> last ->
img -> gnear);
1221 int nsp = this_proj -> nspec;
1224 for (i = 0; i < nsp; i++)
1244 for (i=0; i < nsp-1; i++)
1246 for (j=i+1; j < nsp; j++)
1248 img -> linerad[i][j] =
img -> linerad[j][i] =
min (
img -> linerad[i][i],
img -> linerad[j][j]);
1249 img -> linerad[i+nsp][j+nsp] =
img -> linerad[j+nsp][i+nsp] =
min (
img -> linerad[i+nsp][i+nsp],
img -> linerad[j+nsp][j+nsp]);
1250 img -> bondrad[i][j] =
img -> bondrad[j][i] =
min(
img -> bondrad[i][i],
img -> bondrad[j][j]);
1251 img -> bondrad[i+nsp][j+nsp] =
img -> bondrad[j+nsp][i+nsp] =
min(
img -> bondrad[i+nsp][i+nsp],
img -> bondrad[j+nsp][j+nsp]);
1267 int nsp = this_proj -> nspec;
1269 for (i = 0; i<2; i++)
1273 for (j=0; j<nsp; j++)
img -> show_atom[i][j] = TRUE;
1275 img -> at_color = g_malloc0 (2*nsp*
sizeof*
img -> at_color);
1282 for (i=0; i<10; i++)
1284 img -> spcolor[i] = NULL;
1287 img -> spcolor[i] = g_malloc (nsp*
sizeof*
img -> spcolor[i]);
1291 img -> spcolor[i] = g_malloc (1*
sizeof*
img -> spcolor[i]);
1292 img -> spcolor[i][0] = NULL;
1308 if (
img -> l_ghtning.spot) g_free (
img -> l_ghtning.spot);
1309 img -> l_ghtning.spot = g_malloc0 (
img -> l_ghtning.lights*
sizeof*
img -> l_ghtning.spot);
1312 if (this_proj -> cell.box)
1314 for (i=0; i<3; i++) size =
max (size, this_proj -> cell.box[0].param[0][i]);
1316 size = (size) ? size :
img -> p_depth;
1317 for (i=0; i<
img -> l_ghtning.lights; i++)
1322 if (
img -> p_depth <= 50.0)
1324 img -> l_ghtning.spot[i].intensity = v3_muls (
img -> l_ghtning.spot[i].intensity,
img -> p_depth/100.0);
1329 if (
img -> l_ghtning.spot[i].type)
1331 img -> l_ghtning.spot[i].position = v3_muls (
img -> l_ghtning.spot[i].position,
img -> p_depth);
1401 this_proj -> modelgl -> anim -> last ->
img = g_malloc0(
sizeof*this_proj -> modelgl -> anim -> last ->
img);
1402 image *
img = this_proj -> modelgl -> anim -> last ->
img;
1403 if (!
img -> back)
img -> back = g_malloc0(
sizeof*
img -> back);
1404 if (!
img -> abc)
img -> abc = g_malloc0(
sizeof*
img -> abc);
1405 if (!
img -> xyz)
img -> xyz = g_malloc0(
sizeof*
img -> xyz);
1407 this_proj -> modelgl -> p_moy =
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1411 for (i=0; i<2; i++)
img -> selected[i] = g_malloc0 (
sizeof*
img -> selected[i]);
1426 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
1429 if (g_strcmp0 (extension, (
const char*)glGetStringi(GL_EXTENSIONS, j)) == 0)
return TRUE;
1441 glEnable (GL_DEPTH_TEST);
1442 glDepthMask (GL_TRUE);
1443 glDepthFunc (GL_LEQUAL);
1444 glDepthRange (0.0f, 1.0f);
1445 glClearDepth (1.0f);
1446 glEnable (GL_NORMALIZE);
1448 glShadeModel(GL_SMOOTH);
1449 glCullFace(GL_BACK);
1450 glEnable (GL_CULL_FACE);
1454 glEnable (GL_PROGRAM_POINT_SIZE);
1455 glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
1456 glEnable (GL_POINT_SPRITE);
1458 glEnable (GL_POINT_SMOOTH);
1459 glHint (GL_POINT_SMOOTH_HINT, GL_NICEST);
1460 glEnable (GL_LINE_SMOOTH);
1461 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1463 glDisable (GL_POLYGON_SMOOTH);
1464 glEnable (GL_POLYGON_STIPPLE);
1465 glEnable (GL_POLYGON_OFFSET_FILL);
1467 glEnable (GL_BLEND);
1468 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1470 glPolygonOffset (1.0, 1.0);
1471 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
1473 glHint (GL_FOG_HINT, GL_NICEST);
1474 glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1498 for (l = 0; l < this_proj -> steps; l++)
1503 for (i = 0; i < this_proj -> natomes; i++)
1505 x += this_proj ->
atoms[l][i].x;
1506 y += this_proj ->
atoms[l][i].y;
1507 z += this_proj ->
atoms[l][i].z;
1509 x /= this_proj -> natomes;
1510 y /= this_proj -> natomes;
1511 z /= this_proj -> natomes;
1512 for (i = 0; i < this_proj -> natomes; i++)
1514 this_proj ->
atoms[l][i].x -=
x;
1515 this_proj ->
atoms[l][i].y -=
y;
1516 this_proj ->
atoms[l][i].z -=
z;
1521 if (this_proj -> modelgl -> volume_box[i])
1523 if (this_proj -> modelgl -> volume_box[i][l])
1525 this_proj -> modelgl -> volume_box[i][l][6] -=
x;
1526 this_proj -> modelgl -> volume_box[i][l][7] -=
y;
1527 this_proj -> modelgl -> volume_box[i][l][8] -=
z;
1528 rot = m4_rotation_anti_xyz (this_proj -> modelgl -> volume_box[i][l][3], this_proj -> modelgl -> volume_box[i][l][4], this_proj -> modelgl -> volume_box[i][l][5]);
1529 bini = m4_mul_coord (rot, vec3(this_proj -> modelgl -> volume_box[i][l][6], this_proj -> modelgl -> volume_box[i][l][7], this_proj -> modelgl -> volume_box[i][l][8]));
1533 rot = m4_rotation_xyz (this_proj -> modelgl -> volume_box[i][l][3], this_proj -> modelgl -> volume_box[i][l][4], this_proj -> modelgl -> volume_box[i][l][5]);
1534 bend = m4_mul_coord (rot, bini);
1535 this_proj -> modelgl -> volume_box[i][l][6] = bend.
x;
1536 this_proj -> modelgl -> volume_box[i][l][7] = bend.
y;
1537 this_proj -> modelgl -> volume_box[i][l][8] = bend.
z;
1540 if (this_proj -> modelgl -> frag_box[i])
1542 if (this_proj -> modelgl -> frag_box[i][l])
1544 for (j=0; j<this_proj -> coord -> totcoord[2]; j++)
1546 rot = m4_rotation_anti_xyz (this_proj -> modelgl -> frag_box[i][l][j][3], this_proj -> modelgl -> frag_box[i][l][j][4], this_proj -> modelgl -> frag_box[i][l][j][5]);
1547 bini = m4_mul_coord (rot, vec3(this_proj -> modelgl -> frag_box[i][l][j][6], this_proj -> modelgl -> frag_box[i][l][j][7], this_proj -> modelgl -> frag_box[i][l][j][8]));
1551 rot = m4_rotation_xyz (this_proj -> modelgl -> frag_box[i][l][j][3], this_proj -> modelgl -> frag_box[i][l][j][4], this_proj -> modelgl -> frag_box[i][l][j][5]);
1552 bend = m4_mul_coord (rot, bini);
1553 this_proj -> modelgl -> frag_box[i][l][j][6] = bend.
x;
1554 this_proj -> modelgl -> frag_box[i][l][j][7] = bend.
y;
1555 this_proj -> modelgl -> frag_box[i][l][j][8] = bend.
z;
1561 this_proj -> cell.crystal = FALSE;
1574 view -> insert_coords = vec3(0.0, 0.0, 0.0);
1577 view -> create_shaders[
PICKS] = TRUE;
1578 view -> create_shaders[
MDBOX] = TRUE;
1579 view -> create_shaders[
LABEL] = TRUE;
1580 view -> create_shaders[
MEASU] = TRUE;
1598 if (this_proj -> modelgl ->
colorp[i] != NULL)
1600 g_free (this_proj -> modelgl ->
colorp[i]);
1601 this_proj -> modelgl ->
colorp[i] = NULL;
1604 for (i=0; i<10; i++)
1606 k = (i > 2) ? 1 : spec;
1611 if (this_proj -> coord -> geolist[i][j] != NULL)
1613 g_free (this_proj -> coord -> geolist[i][j]);
1614 this_proj -> coord -> geolist[i][j] = NULL;
1617 this_proj -> coord -> geolist[i]=NULL;
1620 for (i=0; i<spec; i++)
1622 if (this_proj -> coord -> partial_geo[i] != NULL) g_free (this_proj -> coord -> partial_geo[i]);
1623 this_proj -> coord -> partial_geo[i] = NULL;
1625 g_free (this_proj -> coord -> partial_geo);
1626 this_proj -> coord -> partial_geo = NULL;
1642 this_proj -> modelgl ->
colorp[i] = NULL;
1643 this_proj -> modelgl ->
colorp[i] = g_malloc (nspec*2*
sizeof*this_proj -> modelgl ->
colorp[i]);
1644 for (j=0; j<nspec*2; j++)
1646 this_proj -> modelgl ->
colorp[i][j].a = this_proj -> id;
1647 this_proj -> modelgl ->
colorp[i][j].b = i;
1648 this_proj -> modelgl ->
colorp[i][j].c = j;
1655 for (i=0; i<10; i++)
1657 k = (i > 2) ? 1 : nspec;
1660 for (j = 0; j < 2; j++)
1662 this_proj -> modelgl -> oglmv[j][i] = NULL;
1663 this_proj -> modelgl -> oglmv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmv[j][i]);
1666 this_proj -> modelgl -> oglmc[j][i] = NULL;
1667 this_proj -> modelgl -> oglmc[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmc[j][i]);
1669 if (i < 2 || (i > 3 && i < 9))
1671 this_proj -> modelgl -> oglmpv[j][i] = NULL;
1672 this_proj -> modelgl -> oglmpv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmpv[j][i]);
1676 this_proj -> modelgl -> oglmv[j][i][l] = NULL;
1677 if (i < 9) this_proj -> modelgl -> oglmc[j][i][l] = NULL;
1678 if (i < 2 || (i > 3 && i < 9)) this_proj -> modelgl -> oglmpv[j][i][l] = NULL;
1684 this_proj -> coord -> geolist[i] = g_malloc0 (k*
sizeof*this_proj -> coord -> geolist[i]);
1687 this_proj -> coord -> geolist[i][j] = NULL;
1691 this_proj -> coord -> partial_geo = g_malloc0 (nspec*
sizeof*this_proj -> coord -> partial_geo);
1692 for (i=0; i<nspec; i++) this_proj -> coord -> partial_geo[i] = NULL;
1705 view -> anim = g_malloc0 (
sizeof*view -> anim);
1706 snapshot * snap = g_malloc0 (
sizeof*snap);
1707 view -> anim -> first = snap;
1708 view -> anim -> last = snap;
1713 view -> mouseAction =
ANALYZE;
1718 view -> bondid = g_malloc0 (this_proj -> steps*
sizeof*view -> bondid);
1719 view -> clones = g_malloc0 (this_proj -> steps*
sizeof*view -> clones);
1721 for (i=0; i < this_proj -> steps; i++)
1723 view -> bondid[i] = g_malloc0 (2*
sizeof*view -> bondid[i]);
1724 view -> clones[i] = NULL;
1730 view -> stop = TRUE;
1731 view -> speed = 100;
1734 view -> selection_mode =
ATOMS;
1736 view -> rebuild[0][0] = view -> rebuild[1][0] = (this_proj -> steps > 1) ? FALSE : TRUE;
1737 view -> init = TRUE;
1740 this_proj -> initgl = TRUE;
1742 if (view -> win) update_menu_bar (view);
1757 area = (GtkGLArea *)gtk_gl_area_new ();
1761 gtk_gl_area_make_current (area);
1763 gtk_gl_area_set_has_depth_buffer (area, TRUE);
1764 gtk_gl_area_set_has_stencil_buffer (area, TRUE);
1765 return gtk_gl_area_get_error (area);
1777G_MODULE_EXPORT
void on_realize (GtkGLArea * area, gpointer data)
1797 GdkWindow *
xwin = gtk_widget_get_window (view ->
plot);
1798 GLint attr_list[] = {GLX_DOUBLEBUFFER,
1805 XVisualInfo * visualinfo = glXChooseVisual (GDK_WINDOW_XDISPLAY (
xwin),
1806 gdk_screen_get_number (gdk_window_get_screen (
xwin)), attr_list);
1807 view ->
glcontext = glXCreateContext (GDK_WINDOW_XDISPLAY (
xwin), visualinfo, NULL, TRUE);
1808 g_free (visualinfo);
1809 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (
xwin), GDK_WINDOW_XID (
xwin), view ->
glcontext))
1816 gchar * errm = g_strdup_printf (
"Impossible to initialize the OpenGL 3D rendering ! \n %s\n", err -> message);
1833G_MODULE_EXPORT gboolean
on_expose (GtkGLArea * area, GdkGLContext * context, gpointer data)
1844G_MODULE_EXPORT gboolean
on_expose (GtkWidget * widg, cairo_t * cr, gpointer data)
1849 GdkEvent *
event = gtk_get_current_event ();
1850 if (event && event -> type == GDK_EXPOSE && ((GdkEventExpose *)event) -> count > 0)
return TRUE;
Binding to the Fortran90 subroutines.
integer(kind=c_int) function chemistry()
double scale(double axe)
find appropriate major tick spacing based on axis length
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
int ** allocdint(int xal, int yal)
allocate an int ** pointer
struct timespec start_time
gboolean * allocbool(int val)
allocate a gboolean * pointer
double ** allocddouble(int xal, int yal)
allocate a double ** pointer
double * allocdouble(int val)
allocate a double * pointer
int * allocint(int val)
allocate an int * pointer
double get_calc_time(struct timespec start, struct timespec stop)
get calculation time in s
struct timespec stop_time
Global variable declarations Global convenience function declarations Global data structure defin...
int get_widget_height(GtkWidget *widg)
retrive GtkWidget height
int get_widget_width(GtkWidget *widg)
retrive GtkWidget width
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
void show_the_widgets(GtkWidget *widg)
show GtkWidget
project * get_project_by_id(int p)
get project pointer using id number
void transform(glwin *view, double aspect)
transform the OpenGL window
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
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)
vec3_t get_arc_ball_vector(glwin *view, int x, int y)
G_MODULE_EXPORT void on_realize(GtkWidget *widg, gpointer data)
realize event for the OpenGL widget
atomic_object * create_object_from_frag_mol(project *this_proj, int coord, int geo, atom_search *remove)
create object from a fragment or a molecule
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
GLfloat ** allocdGLfloat(int xal, int yal)
allocate a GLfloat ** pointer
void render_this_gl_window(glwin *view, GtkWidget *widg, gint button)
render the OpenGL window
GLuint ** allocdgluint(int xal, int yal)
allocate a GLuint ** pointer
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
vec4_t old_rotation_quaternion
void update_labels(glwin *view)
update labels (on representation data update)
void arc_ball_rotation(glwin *view, int x, int y)
Perform arcball rotation.
void save_rotation_quaternion(glwin *view)
save the rotation quaternion of the last image
void update(glwin *view)
update the rendering of the OpenGL window
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 prepare_atom_edition(gpointer data, gboolean visible)
prepare atom edition
void duplicate_material(Material *new_mat, Material *old_mat)
duplicate material data
GError * init_gtk_gl_area(GtkGLArea *area)
initialize a GtkGLArea, return error if any
void duplicate_screen_label(screen_label *new_lab, screen_label *old_lab)
copy screen_label data structure
void init_img(project *this_proj)
initialize an image data structure
Light init_light_source(int type, float val, float vbl)
initialize a light source
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
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 zoom(glwin *view, int delta)
zoom in or zoom out in the OpenGL window
atom_search * allocate_atom_search(int proj, int action, int searchid, int tsize)
allocate atom search data structure
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)
void translate(project *this_proj, int status, int axis, vec3_t trans)
translate
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 setup_image_spec_data(project *this_proj, image *img)
initialize the chemical species related pointers in an image data structure
void update_atom_neighbors_(int *stp, int *at, int *nv)
update an atom number of neighbors from Fortran90
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
void reshape(glwin *view, int width, int height, gboolean use_ratio)
reshape (resize) the OpenGL window
void init_camera(project *this_proj, int get_depth)
initialize the OpenGL camera settings
void init_opengl()
initialize OpenGL rendering parameters
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
void edit_for_motion(glwin *view)
if edition mode is one some steps are required
void rotate_quat(project *this_proj, vec4_t q, int status, int axis)
rotate using quaternion
void process_the_hits(glwin *view, gint event_button, double ptx, double pty)
process a mouse click
void motion(glwin *view, gint x, gint y, GdkModifierType state)
mouse motion in the OpenGL window
ColRGBA set_default_color(int z)
pick the default color for an atom
void duplicate_fog(Fog *new_fog, Fog *old_fog)
duplicate fog data
GLuint * allocgluint(int val)
allocate a GLuint * pointer
vec3_t get_bary(project *this_proj, int status)
get barycenter of atomic coordinates
const float light_pos[MAX_LIGHTS][4]
void center_this_molecule(glwin *view)
center atomic coordinates around (0,0,0) and refresh shaders
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_glwin(glwin *view)
initialize a glwin pointer
void setup_default_species_parameters_for_image(project *this_proj, image *img)
setup default chemical species related parameters for image
void center_molecule(project *this_proj)
center atomic coordinates around (0,0,0)
gboolean is_GLExtension_Supported(const char *extension)
test if this GLExtension is support
G_MODULE_EXPORT gboolean on_glwin_pointer_scoll(GtkEventControllerScroll *event, gdouble dx, gdouble dy, gpointer data)
handle mouse scroll event on the OpenGL window
G_MODULE_EXPORT gboolean on_expose(GtkWidget *widg, cairo_t *cr, gpointer data)
OpenGL rendering widget expose event callback GTK3.
void update_this_neighbor_(int *stp, int *at, int *iv, int *nv)
update atom neighbor list from Fortran90
void sort(int dim, int *tab)
sort, nim to max, a table by integer value
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
atom_search * free_this_search_data(atom_search *this_search)
free atom search data structure
#define ZOOM_MAX
Maximum value for the OpenGL zoom factor.
#define ZOOM_FACTOR
Default value for the OpenGL zoom factor.
void draw(glwin *view)
main drawing subroutine for the OpenGL window
void re_create_md_shaders(int nshaders, int shaders[nshaders], project *this_proj)
re-initialize some MD dependent OpenGL shaders
void popup_main_menu(glwin *view, double ptx, double pty)
create the OpenGL window popup menu
void init_shaders(glwin *view)
initialize all the OpenGL shaders
#define MAX_LIGHTS
Maximum number of light sources.
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
#define DEFAULT_STYLE
Default OpenGL style: ball and stick.
vec3_t get_insertion_coordinates(glwin *view)
get the insertion coordinates to insert object in the 3D window
struct axis axis
axis layout data structure
shaders
The different types of shaders in the atomes program.
#define GL_TEXTURE_RECTANGLE_ARB
Function declarations to handle the atomic coordination data.
void set_advanced_bonding_menus(glwin *view)
void show_error(char *error, int val, GtkWidget *win)
show error message
Messaging function declarations.
background default_background
Lightning default_lightning
ColRGBA default_sel_color[2]
int default_acl_format[2]
ColRGBA get_spec_color(int z, element_color *clist)
retrieve the color of a chemical species
float get_radius(int object, int col, int z, element_radius *rad_list)
retrieve the radius/width of a species depending on style
element_color * default_atom_color[2]
void duplicate_box_data(box *new_box, box *old_box)
duplicate box_data data structure
gboolean * default_o_at_rs
Material default_material
element_radius * default_bond_rad[6]
gboolean default_mtilt[2]
void duplicate_background_data(background *new_back, background *old_back)
duplicate background data structure
void duplicate_axis_data(axis *new_axis, axis *old_axis)
duplicate axis_data data structure
element_radius * default_atomic_rad[16]
gboolean * default_o_bd_rw
screen_label default_label[5]
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...