135 var = g_malloc0(
val*
sizeof*var);
149 GLuint ** var = NULL;
152 var = g_malloc0(xal*
sizeof*var);
153 for ( i = 0 ; i < xal ; i ++ )
171 GLfloat ** var = NULL;
174 var = g_malloc0(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;
318 col.red = colors[Z-1][0];
319 col.green = colors[Z-1][1];
320 col.blue = colors[Z-1][2];
342 int * bdim,
int bda[* bdim],
int bdb[* bdim],
343 double *
x,
double *
y,
double *
z)
365 for (i=0; i< * bdim; i++)
380 for (i=0; i< * bdim; i++)
405 for (i=1; i<dim; i++)
408 for (j=i-1; j>-1; j--)
410 if (tab[j] <=
val)
break;
463 gtk_gl_area_queue_render ((GtkGLArea *)view ->
plot);
486 view -> zoom_factor =
zoom * 0.1 * view -> anim -> last ->
img -> p_depth / (2.0 * view -> anim -> last ->
img -> gfar);
489 zoom *= (view -> anim -> last ->
img -> p_depth / view -> anim -> last ->
img -> gnear);
491 dw = view -> anim -> last ->
img -> c_shift[0]*2.0*
zoom;
492 dh = view -> anim -> last ->
img -> c_shift[1]*2.0*
zoom;
503 view -> anim -> last ->
img -> gleft = -w + dw;
504 view -> anim -> last ->
img -> gright = w + dw;
505 view -> anim -> last ->
img -> gbottom = -h + dh;
506 view -> anim -> last ->
img -> gtop = h + dh;
510 view -> projection_matrix = m4_frustum (view -> anim -> last ->
img -> gleft,
511 view -> anim -> last ->
img -> gright,
512 view -> anim -> last ->
img -> gbottom,
513 view -> anim -> last ->
img -> gtop,
514 view -> anim -> last ->
img -> gnear,
515 view -> anim -> last ->
img -> gfar);
519 view -> projection_matrix = m4_ortho (view -> anim -> last ->
img -> gleft,
520 view -> anim -> last ->
img -> gright,
521 view -> anim -> last ->
img -> gbottom,
522 view -> anim -> last ->
img -> gtop,
523 -view -> anim -> last ->
img -> gfar,
524 view -> anim -> last ->
img -> gfar);
546 if (GTK_IS_WIDGET(view -> win))
548 scale = gtk_widget_get_scale_factor (view -> win);
552 glViewport (0, 0, (GLsizei)
scale * width, (GLsizei)
scale * height);
553 view -> view_port = vec4 (0.0, 0.0, width, height);
554 aspect = (double) width / (
double) height;
584 gboolean check_edit = FALSE;
588 int ** frag =
allocdint (this_proj -> coord -> totcoord[2], 2);
591 for (i=0; i<this_proj -> natomes; i++)
593 k = this_proj ->
atoms[0][i].coord[2];
597 move_search -> todo[i] = 1;
604 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
606 if (frag[i][1] && frag[i][1] < frag[i][0])
615 (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE);
620 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
633 view -> baryc[1] =
get_bary (this_proj, 1);
635 view -> prepare_motion = FALSE;
650 view -> mouseAction =
MOTION;
654 if (state & GDK_BUTTON1_MASK)
658 else if (state & GDK_BUTTON2_MASK)
662 view -> anim -> last ->
img -> c_shift[0] -= (double) (
x - view -> mouseX) / view -> pixels[0];
663 view -> anim -> last ->
img -> c_shift[1] += (double) (
y - view -> mouseY) / view -> pixels[1];
668 if (view -> rep_win -> camera_widg[i+5] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[i+5]))
670 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[i+5], - view -> anim -> last ->
img -> c_shift[i]);
678 vec3_t pos_b = vec3(view -> mouseX, - view -> mouseY, 0.75);
679 vec3_t trans_a = v3_un_project (pos_a, view -> view_port, view -> projection_matrix);
680 vec3_t trans_b = v3_un_project (pos_b, view -> view_port, view -> projection_matrix);
682 trans.
x = (trans_a.
x - trans_b.
x);
683 trans.
y = (trans_b.
y - trans_a.
y);
686 trans.
x *= view -> anim -> last ->
img -> p_depth;
687 trans.
y *= view -> anim -> last ->
img -> p_depth;
716G_MODULE_EXPORT gboolean on_motion (GtkWidget * widg, GdkEvent * event, gpointer data)
719 if (view -> mouseStatus !=
RELEASED)
721 GdkEventMotion * mevent = (GdkEventMotion *)event;
723 GdkModifierType state;
724 if (mevent -> is_hint)
726 gdk_window_get_device_position (mevent -> window, mevent -> device, &
x, &
y, & state);
730 x = (gint) mevent ->
x;
731 y = (gint) mevent ->
y;
732 state = (GdkModifierType) mevent -> state;
752 if (view -> mouseStatus !=
RELEASED)
754 motion (view, (gint)
x, (gint)
y, gtk_event_controller_get_current_event_state((GtkEventController*)motc));
785 gtk_gl_area_make_current (area);
786 if (gtk_gl_area_get_error (area) == NULL)
790 GdkWindow * win = gtk_widget_get_window (widg);
791 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win), view ->
glcontext))
794 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
798 if (view -> mouseButton)
process_the_hits (view, view -> mouseButton, view -> mouseX, view -> mouseY);
799 view -> to_pick = FALSE;
800 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
806 glXSwapBuffers (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win));
827 case GDK_BUTTON_PRESS:
831 view -> mouseButton = event_button;
832 if (event_button == 1)
836 view -> to_pick = FALSE;
840 case GDK_BUTTON_RELEASE:
856G_MODULE_EXPORT gboolean on_lib_pressed (GtkWidget * widg, GdkEvent * event, gpointer data)
858 GdkEventButton * bevent = (GdkEventButton*)event;
876 glwin_lib_pressed (
x,
y, GDK_BUTTON_PRESS, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
892 glwin_lib_pressed (
x,
y, GDK_BUTTON_RELEASE, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
910void glwin_button_event (
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
915 case GDK_BUTTON_PRESS:
917 view -> mouseX = event_x;
918 view -> mouseY = event_y;
919 view -> mouseButton = event_button;
920 clock_gettime (CLOCK_MONOTONIC, &
start_time);
921 if (event_button == 1 || event_button == 3)
925 view -> nth_copy = 0;
928 view -> to_pick = TRUE;
935 case GDK_BUTTON_RELEASE:
937 view -> mouseButton = 0;
938 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
947 if (view -> mode ==
EDITION && view -> mouseAction ==
MOTION)
952 if (event_button == 3)
979G_MODULE_EXPORT gboolean on_glwin_button_event (GtkWidget * widg, GdkEvent * event, gpointer data)
981 GdkEventButton * bevent = (GdkEventButton*)event;
982 glwin_button_event (bevent ->
x, bevent ->
y, bevent -> button, bevent -> type, bevent -> time, data);
999 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);
1015 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);
1030 view -> anim -> last ->
img ->
zoom += delta * view -> zoom_factor;
1031 if (view -> rep_win)
1033 if (view -> rep_win -> camera_widg[0] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[0]))
1035 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[0], 1.0-0.5*view -> anim -> last ->
img ->
zoom);
1050G_MODULE_EXPORT gboolean on_scrolled (GtkWidget * widg, GdkEvent * event, gpointer data)
1053 GdkEventScroll * sevent = (GdkEventScroll *)event;
1054 if (sevent -> direction == GDK_SCROLL_UP)
1058 else if (sevent -> direction == GDK_SCROLL_DOWN && view -> anim -> last ->
img ->
zoom >
ZOOM_MAX)
1110 q_a = axis_to_quat (
axis, -
pi*angle_y/180.0);
1114 q_b = axis_to_quat (
axis, -
pi*angle_x/180.0);
1115 q_c = q4_mul (q_a, q_b);
1116 view -> anim -> last ->
img -> c_angle[0] -= angle_x;
1117 view -> anim -> last ->
img -> c_angle[1] -= angle_y;
1121 if (fabs(view -> anim -> last ->
img -> c_angle[i]) > 180.0) view -> anim -> last ->
img -> c_angle[i] = 0.0;
1122 if (view -> rep_win)
1124 if (view -> rep_win -> camera_widg[i+3] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[i+3]))
1126 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[i+3], view -> anim -> last ->
img -> c_angle[i]);
1159 else if (depth < 100.0)
1163 else if (depth < 1000.0)
1182 glwin * view = this_proj -> modelgl;
1184 view -> anim -> last ->
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1185 view -> anim -> last ->
img -> m_depth =
get_max_depth (view -> anim -> last ->
img -> p_depth);
1187 view -> anim -> last ->
img -> gfar = view -> anim -> last ->
img -> p_depth*2.0;
1188 view -> anim -> last ->
img -> rotation_quaternion.w = 0.0;
1189 view -> anim -> last ->
img -> rotation_quaternion.x = 0.0;
1190 view -> anim -> last ->
img -> rotation_quaternion.y = 0.0;
1191 view -> anim -> last ->
img -> rotation_quaternion.z = 1.0;
1195 view -> anim -> last ->
img -> c_angle[i] = 0.0;
1196 view -> anim -> last ->
img -> c_shift[i] =
default_rep.c_shift[i];
1201 if (view -> rep_win)
1203 if (view -> rep_win -> camera_widg[0] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[0]))
1205 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[0], 1.0 - 0.5*view -> anim -> last ->
img ->
zoom);
1207 if (view -> rep_win -> camera_widg[1] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[1]))
1209 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[1], view -> anim -> last ->
img -> p_depth);
1211 if (view -> rep_win -> camera_widg[2] && GTK_IS_WIDGET(view -> rep_win -> camera_widg[2]))
1213 gtk_spin_button_set_value ((GtkSpinButton *)view -> rep_win -> camera_widg[2], view -> anim -> last ->
img -> gnear);
1229 int nsp = this_proj -> nspec;
1232 for (i = 0; i < nsp; i++)
1252 for (i=0; i < nsp-1; i++)
1254 for (j=i+1; j < nsp; j++)
1256 img -> linerad[i][j] =
img -> linerad[j][i] =
min (
img -> linerad[i][i],
img -> linerad[j][j]);
1257 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]);
1258 img -> bondrad[i][j] =
img -> bondrad[j][i] =
min(
img -> bondrad[i][i],
img -> bondrad[j][j]);
1259 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]);
1275 int nsp = this_proj -> nspec;
1277 for (i = 0; i<2; i++)
1281 for (j=0; j<nsp; j++)
img -> show_atom[i][j] = TRUE;
1283 img -> at_color = g_malloc0(2*nsp*
sizeof*
img -> at_color);
1290 for (i=0; i<10; i++)
1292 img -> spcolor[i] = NULL;
1295 img -> spcolor[i] = g_malloc0(nsp*
sizeof*
img -> spcolor[i]);
1299 img -> spcolor[i] = g_malloc0(1*
sizeof*
img -> spcolor[i]);
1300 img -> spcolor[i][0] = NULL;
1316 if (
img -> l_ghtning.spot) g_free (
img -> l_ghtning.spot);
1317 img -> l_ghtning.spot = g_malloc0(
img -> l_ghtning.lights*
sizeof*
img -> l_ghtning.spot);
1319 for (i=0; i<
img -> l_ghtning.lights; i++)
1327 if (
img -> l_ghtning.spot[i] -> type)
1330 img -> l_ghtning.spot[i] -> attenuation.y /=
img -> p_depth;
1331 img -> l_ghtning.spot[i] -> attenuation.z /= (
img -> p_depth*
img -> p_depth);
1402 this_proj -> modelgl -> anim -> last ->
img = g_malloc0(
sizeof*this_proj -> modelgl -> anim -> last ->
img);
1403 image *
img = this_proj -> modelgl -> anim -> last ->
img;
1404 if (!
img -> back)
img -> back = g_malloc0(
sizeof*
img -> back);
1405 if (!
img -> abc)
img -> abc = g_malloc0(
sizeof*
img -> abc);
1406 if (!
img -> xyz)
img -> xyz = g_malloc0(
sizeof*
img -> xyz);
1408 this_proj -> modelgl -> p_moy =
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1412 for (i=0; i<2; i++)
img -> selected[i] = g_malloc0(
sizeof*
img -> selected[i]);
1427 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
1430 if (g_strcmp0 (extension, (
const char*)glGetStringi(GL_EXTENSIONS, j)) == 0)
return TRUE;
1442 glEnable (GL_DEPTH_TEST);
1443 glDepthMask (GL_TRUE);
1444 glDepthFunc (GL_LEQUAL);
1445 glDepthRange (0.0f, 1.0f);
1446 glClearDepth (1.0f);
1447 glEnable (GL_NORMALIZE);
1449 glShadeModel(GL_SMOOTH);
1450 glCullFace(GL_BACK);
1451 glEnable (GL_CULL_FACE);
1455 glEnable (GL_PROGRAM_POINT_SIZE);
1456 glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
1457 glEnable (GL_POINT_SPRITE);
1459 glEnable (GL_POINT_SMOOTH);
1460 glHint (GL_POINT_SMOOTH_HINT, GL_NICEST);
1461 glEnable (GL_LINE_SMOOTH);
1462 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1464 glDisable (GL_POLYGON_SMOOTH);
1465 glEnable (GL_POLYGON_STIPPLE);
1466 glEnable (GL_POLYGON_OFFSET_FILL);
1468 glEnable (GL_BLEND);
1470 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1476 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1480 glPolygonOffset (1.0, 1.0);
1481 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
1483 glHint (GL_FOG_HINT, GL_NICEST);
1484 glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1508 for (l = 0; l < this_proj -> steps; l++)
1513 for (i = 0; i < this_proj -> natomes; i++)
1515 x += this_proj ->
atoms[l][i].x;
1516 y += this_proj ->
atoms[l][i].y;
1517 z += this_proj ->
atoms[l][i].z;
1519 x /= this_proj -> natomes;
1520 y /= this_proj -> natomes;
1521 z /= this_proj -> natomes;
1522 for (i = 0; i < this_proj -> natomes; i++)
1524 this_proj ->
atoms[l][i].x -=
x;
1525 this_proj ->
atoms[l][i].y -=
y;
1526 this_proj ->
atoms[l][i].z -=
z;
1531 if (this_proj -> modelgl -> volume_box[i])
1533 if (this_proj -> modelgl -> volume_box[i][l])
1535 this_proj -> modelgl -> volume_box[i][l][6] -=
x;
1536 this_proj -> modelgl -> volume_box[i][l][7] -=
y;
1537 this_proj -> modelgl -> volume_box[i][l][8] -=
z;
1538 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]);
1539 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]));
1543 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]);
1544 bend = m4_mul_coord (rot, bini);
1545 this_proj -> modelgl -> volume_box[i][l][6] = bend.
x;
1546 this_proj -> modelgl -> volume_box[i][l][7] = bend.
y;
1547 this_proj -> modelgl -> volume_box[i][l][8] = bend.
z;
1550 if (this_proj -> modelgl -> frag_box[i])
1552 if (this_proj -> modelgl -> frag_box[i][l])
1554 for (j=0; j<this_proj -> coord -> totcoord[2]; j++)
1556 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]);
1557 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]));
1561 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]);
1562 bend = m4_mul_coord (rot, bini);
1563 this_proj -> modelgl -> frag_box[i][l][j][6] = bend.
x;
1564 this_proj -> modelgl -> frag_box[i][l][j][7] = bend.
y;
1565 this_proj -> modelgl -> frag_box[i][l][j][8] = bend.
z;
1571 this_proj -> cell.crystal = FALSE;
1584 view -> insert_coords = vec3(0.0, 0.0, 0.0);
1587 view -> create_shaders[
PICKS] = TRUE;
1588 view -> create_shaders[
MDBOX] = TRUE;
1589 view -> create_shaders[
LABEL] = TRUE;
1590 view -> create_shaders[
MEASU] = TRUE;
1608 if (this_proj -> modelgl ->
colorp[i] != NULL)
1610 g_free (this_proj -> modelgl ->
colorp[i]);
1611 this_proj -> modelgl ->
colorp[i] = NULL;
1614 for (i=0; i<10; i++)
1616 k = (i > 2) ? 1 : spec;
1621 if (this_proj -> coord -> geolist[i][j] != NULL)
1623 g_free (this_proj -> coord -> geolist[i][j]);
1624 this_proj -> coord -> geolist[i][j] = NULL;
1627 this_proj -> coord -> geolist[i]=NULL;
1630 for (i=0; i<spec; i++)
1632 if (this_proj -> coord -> partial_geo[i] != NULL) g_free (this_proj -> coord -> partial_geo[i]);
1633 this_proj -> coord -> partial_geo[i] = NULL;
1635 g_free (this_proj -> coord -> partial_geo);
1636 this_proj -> coord -> partial_geo = NULL;
1652 this_proj -> modelgl ->
colorp[i] = NULL;
1653 this_proj -> modelgl ->
colorp[i] = g_malloc0(nspec*2*
sizeof*this_proj -> modelgl ->
colorp[i]);
1654 for (j=0; j<nspec*2; j++)
1656 this_proj -> modelgl ->
colorp[i][j].a = this_proj -> id;
1657 this_proj -> modelgl ->
colorp[i][j].b = i;
1658 this_proj -> modelgl ->
colorp[i][j].c = j;
1665 for (i=0; i<10; i++)
1667 k = (i > 2) ? 1 : nspec;
1670 for (j = 0; j < 2; j++)
1672 this_proj -> modelgl -> oglmv[j][i] = NULL;
1673 this_proj -> modelgl -> oglmv[j][i] = g_malloc0(k*
sizeof*this_proj -> modelgl -> oglmv[j][i]);
1676 this_proj -> modelgl -> oglmc[j][i] = NULL;
1677 this_proj -> modelgl -> oglmc[j][i] = g_malloc0(k*
sizeof*this_proj -> modelgl -> oglmc[j][i]);
1679 if (i < 2 || (i > 3 && i < 9))
1681 this_proj -> modelgl -> oglmpv[j][i] = NULL;
1682 this_proj -> modelgl -> oglmpv[j][i] = g_malloc0(k*
sizeof*this_proj -> modelgl -> oglmpv[j][i]);
1686 this_proj -> modelgl -> oglmv[j][i][l] = NULL;
1687 if (i < 9) this_proj -> modelgl -> oglmc[j][i][l] = NULL;
1688 if (i < 2 || (i > 3 && i < 9)) this_proj -> modelgl -> oglmpv[j][i][l] = NULL;
1694 this_proj -> coord -> geolist[i] = g_malloc0(k*
sizeof*this_proj -> coord -> geolist[i]);
1697 this_proj -> coord -> geolist[i][j] = NULL;
1701 this_proj -> coord -> partial_geo = g_malloc0(nspec*
sizeof*this_proj -> coord -> partial_geo);
1702 for (i=0; i<nspec; i++) this_proj -> coord -> partial_geo[i] = NULL;
1715 view -> anim = g_malloc0(
sizeof*view -> anim);
1716 snapshot * snap = g_malloc0(
sizeof*snap);
1717 view -> anim -> first = snap;
1718 view -> anim -> last = snap;
1723 view -> mouseAction =
ANALYZE;
1728 view -> bondid = g_malloc0(this_proj -> steps*
sizeof*view -> bondid);
1729 view -> clones = g_malloc0(this_proj -> steps*
sizeof*view -> clones);
1731 for (i=0; i < this_proj -> steps; i++)
1733 view -> bondid[i] = g_malloc0(2*
sizeof*view -> bondid[i]);
1734 view -> clones[i] = NULL;
1740 view -> stop = TRUE;
1741 view -> speed = 100;
1744 view -> selection_mode =
ATOMS;
1746 view -> rebuild[0][0] = view -> rebuild[1][0] = (this_proj -> steps > 1) ? FALSE : TRUE;
1747 view -> init = TRUE;
1750 this_proj -> initgl = TRUE;
1752 if (view -> win) update_menu_bar (view);
1767 area = (GtkGLArea *)gtk_gl_area_new ();
1771 gtk_gl_area_make_current (area);
1773 gtk_gl_area_set_has_depth_buffer (area, TRUE);
1774 gtk_gl_area_set_has_stencil_buffer (area, TRUE);
1775 return gtk_gl_area_get_error (area);
1787G_MODULE_EXPORT
void on_realize (GtkGLArea * area, gpointer data)
1807 GdkWindow *
xwin = gtk_widget_get_window (view ->
plot);
1808 GLint attr_list[] = {GLX_DOUBLEBUFFER,
1815 XVisualInfo * visualinfo = glXChooseVisual (GDK_WINDOW_XDISPLAY (
xwin),
1816 gdk_screen_get_number (gdk_window_get_screen (
xwin)), attr_list);
1817 view ->
glcontext = glXCreateContext (GDK_WINDOW_XDISPLAY (
xwin), visualinfo, NULL, TRUE);
1818 g_free (visualinfo);
1819 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (
xwin), GDK_WINDOW_XID (
xwin), view ->
glcontext))
1826 gchar * errm = g_strdup_printf (_(
"Impossible to initialize the OpenGL 3D rendering ! \n %s\n"), err -> message);
1843G_MODULE_EXPORT gboolean
on_expose (GtkGLArea * area, GdkGLContext * context, gpointer data)
1854G_MODULE_EXPORT gboolean
on_expose (GtkWidget * widg, cairo_t * cr, gpointer data)
1859 GdkEvent *
event = gtk_get_current_event ();
1860 if (event && event -> type == GDK_EXPOSE && ((GdkEventExpose *)event) -> count > 0)
return TRUE;
vec4_t old_rotation_quaternion
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
Light * init_light_source(int type, float size)
initialize a light source
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
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
void init_camera(project *this_proj)
initialize the OpenGL camera settings
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_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
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...