127 var = g_malloc0 (
val*
sizeof*var);
141 GLuint ** var = NULL;
144 var = g_malloc (xal*
sizeof*var);
145 for ( i = 0 ; i < xal ; i ++ )
163 GLfloat ** var = NULL;
166 var = g_malloc (xal*
sizeof*var);
167 for ( i = 0 ; i < xal ; i ++ )
170 var[i] = g_malloc0 (yal*
sizeof*var[i]);
176 { 1.0f, 2.0f, 0.5f, 0.0f},
177 {-1.0f, 2.0f, -1.0f, 0.0f},
178 {-1.0f, -1.0f, 0.0f, 0.0f}};
190 double colors[116][3]={{1.00, 1.00, 1.00},
306 int Z = (
z < 1) ? 1 :
z;
331 int * bdim,
int bda[* bdim],
int bdb[* bdim],
332 double *
x,
double *
y,
double *
z)
343 for (i=0; i< * bdim; i++)
358 for (i=0; i< * bdim; i++)
383 for (i=1; i<dim; i++)
386 for (j=i-1; j>-1; j--)
388 if (tab[j] <=
val)
break;
441 gtk_gl_area_queue_render ((GtkGLArea *)view ->
plot);
464 view -> zoom_factor =
zoom * 0.1 * view -> anim -> last ->
img -> p_depth / (2.0 * view -> anim -> last ->
img -> gfar);
467 zoom *= (view -> anim -> last ->
img -> p_depth / view -> anim -> last ->
img -> gnear);
469 dw = view -> anim -> last ->
img -> c_shift[0]*2.0*
zoom;
470 dh = view -> anim -> last ->
img -> c_shift[1]*2.0*
zoom;
481 view -> anim -> last ->
img -> gleft = -w + dw;
482 view -> anim -> last ->
img -> gright = w + dw;
483 view -> anim -> last ->
img -> gbottom = -h + dh;
484 view -> anim -> last ->
img -> gtop = h + dh;
488 view -> projection_matrix = m4_frustum (view -> anim -> last ->
img -> gleft,
489 view -> anim -> last ->
img -> gright,
490 view -> anim -> last ->
img -> gbottom,
491 view -> anim -> last ->
img -> gtop,
492 view -> anim -> last ->
img -> gnear,
493 view -> anim -> last ->
img -> gfar);
497 view -> projection_matrix = m4_ortho (view -> anim -> last ->
img -> gleft,
498 view -> anim -> last ->
img -> gright,
499 view -> anim -> last ->
img -> gbottom,
500 view -> anim -> last ->
img -> gtop,
501 -view -> anim -> last ->
img -> gfar,
502 view -> anim -> last ->
img -> gfar);
524 if (GTK_IS_WIDGET(view -> win))
526 scale = gtk_widget_get_scale_factor (view -> win);
530 glViewport (0, 0, (GLsizei)
scale * width, (GLsizei)
scale * height);
531 view -> view_port = vec4 (0.0, 0.0, width, height);
532 aspect = (double) width / (
double) height;
562 gboolean check_edit = FALSE;
566 int ** frag =
allocdint (this_proj -> coord -> totcoord[2], 2);
569 for (i=0; i<this_proj -> natomes; i++)
575 move_search -> todo[i] = 1;
582 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
584 if (frag[i][1] && frag[i][1] < frag[i][0])
593 (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE);
598 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
611 view -> baryc[1] =
get_bary (this_proj, 1);
613 view -> prepare_motion = FALSE;
628 view -> mouseAction =
MOTION;
632 if (state & GDK_BUTTON1_MASK)
636 else if (state & GDK_BUTTON2_MASK)
640 view -> anim -> last ->
img -> c_shift[0] -= (double) (
x - view -> mouseX) / view -> pixels[0];
641 view -> anim -> last ->
img -> c_shift[1] += (double) (
y - view -> mouseY) / view -> pixels[1];
644 if (view -> camera_widg[i+5])
646 if (GTK_IS_WIDGET(view -> camera_widg[i+5]))
648 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+5], - view -> anim -> last ->
img -> c_shift[i]);
656 vec3_t pos_b = vec3(view -> mouseX, - view -> mouseY, 0.75);
657 vec3_t trans_a = v3_un_project (pos_a, view -> view_port, view -> projection_matrix);
658 vec3_t trans_b = v3_un_project (pos_b, view -> view_port, view -> projection_matrix);
660 trans.
x = (trans_a.
x - trans_b.
x);
661 trans.
y = (trans_b.
y - trans_a.
y);
664 trans.
x *= view -> anim -> last ->
img -> p_depth;
665 trans.
y *= view -> anim -> last ->
img -> p_depth;
694G_MODULE_EXPORT gboolean on_motion (GtkWidget * widg, GdkEvent * event, gpointer data)
697 if (view -> mouseStatus !=
RELEASED)
699 GdkEventMotion * mevent = (GdkEventMotion *)event;
701 GdkModifierType state;
702 if (mevent -> is_hint)
704 gdk_window_get_device_position (mevent -> window, mevent -> device, &
x, &
y, & state);
708 x = (gint) mevent ->
x;
709 y = (gint) mevent ->
y;
710 state = (GdkModifierType) mevent -> state;
730 if (view -> mouseStatus !=
RELEASED)
732 motion (view, (gint)
x, (gint)
y, gtk_event_controller_get_current_event_state((GtkEventController*)motc));
763 gtk_gl_area_make_current (area);
764 if (gtk_gl_area_get_error (area) == NULL)
768 GdkWindow * win = gtk_widget_get_window (widg);
769 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win), view ->
glcontext))
772 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
776 if (view -> mouseButton)
process_the_hits (view, view -> mouseButton, view -> mouseX, view -> mouseY);
777 view -> to_pick = FALSE;
778 reshape (view, view -> pixels[0], view -> pixels[1], TRUE);
784 glXSwapBuffers (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win));
805 case GDK_BUTTON_PRESS:
809 view -> mouseButton = event_button;
810 if (event_button == 1)
814 view -> to_pick = FALSE;
818 case GDK_BUTTON_RELEASE:
834G_MODULE_EXPORT gboolean on_lib_pressed (GtkWidget * widg, GdkEvent * event, gpointer data)
836 GdkEventButton * bevent = (GdkEventButton*)event;
854 glwin_lib_pressed (
x,
y, GDK_BUTTON_PRESS, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
870 glwin_lib_pressed (
x,
y, GDK_BUTTON_RELEASE, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
888void glwin_button_event (
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
893 case GDK_BUTTON_PRESS:
895 view -> mouseX = event_x;
896 view -> mouseY = event_y;
897 view -> mouseButton = event_button;
898 clock_gettime (CLOCK_MONOTONIC, &
start_time);
899 if (event_button == 1 || event_button == 3)
903 view -> nth_copy = 0;
906 view -> to_pick = TRUE;
913 case GDK_BUTTON_RELEASE:
915 view -> mouseButton = 0;
916 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
925 if (view -> mode ==
EDITION && view -> mouseAction ==
MOTION)
930 if (event_button == 3)
957G_MODULE_EXPORT gboolean on_glwin_button_event (GtkWidget * widg, GdkEvent * event, gpointer data)
959 GdkEventButton * bevent = (GdkEventButton*)event;
960 glwin_button_event (bevent ->
x, bevent ->
y, bevent -> button, bevent -> type, bevent -> time, data);
977 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);
993 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);
1008 view -> anim -> last ->
img ->
zoom += delta * view -> zoom_factor;
1009 if (view -> camera_widg[0])
1011 if (GTK_IS_WIDGET(view -> camera_widg[0]))
1013 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[0], 1.0-0.5*view -> anim -> last ->
img ->
zoom);
1028G_MODULE_EXPORT gboolean on_scrolled (GtkWidget * widg, GdkEvent * event, gpointer data)
1031 GdkEventScroll * sevent = (GdkEventScroll *)event;
1032 if (sevent -> direction == GDK_SCROLL_UP)
1036 else if (sevent -> direction == GDK_SCROLL_DOWN && view -> anim -> last ->
img ->
zoom >
ZOOM_MAX)
1088 q_a = axis_to_quat (
axis, -
pi*angle_y/180.0);
1092 q_b = axis_to_quat (
axis, -
pi*angle_x/180.0);
1093 q_c = q4_mul (q_a, q_b);
1094 view -> anim -> last ->
img -> c_angle[0] -= angle_x;
1095 view -> anim -> last ->
img -> c_angle[1] -= angle_y;
1099 if (fabs(view -> anim -> last ->
img -> c_angle[i]) > 180.0) view -> anim -> last ->
img -> c_angle[i] = 0.0;
1100 if (view -> camera_widg[i+3])
1102 if (GTK_IS_WIDGET(view -> camera_widg[i+3]))
1104 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+3], view -> anim -> last ->
img -> c_angle[i]);
1134 glwin * view = this_proj -> modelgl;
1135 if (get_depth) view -> anim -> last ->
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1136 if (view -> camera_widg[1])
1138 if (GTK_IS_WIDGET(view -> camera_widg[1]))
1140 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[1], view -> anim -> last ->
img -> p_depth);
1143 view -> anim -> last ->
img -> gnear = 6.0;
1144 if (view -> camera_widg[2])
1146 if (GTK_IS_WIDGET(view -> camera_widg[2]))
1148 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[2], view -> anim -> last ->
img -> gnear);
1151 view -> anim -> last ->
img -> gfar = view -> anim -> last ->
img -> p_depth*2.0;
1152 view -> anim -> last ->
img -> rotation_quaternion.w = 0.0;
1153 view -> anim -> last ->
img -> rotation_quaternion.x = 0.0;
1154 view -> anim -> last ->
img -> rotation_quaternion.y = 0.0;
1155 view -> anim -> last ->
img -> rotation_quaternion.z = 1.0;
1159 view -> anim -> last ->
img -> c_shift[i] = 0.0;
1160 view -> anim -> last ->
img -> c_angle[i] = 0.0;
1161 if (view -> camera_widg[i+5])
1163 if (GTK_IS_WIDGET(view -> camera_widg[i+5]))
1165 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+5], view -> anim -> last ->
img -> c_shift[i]);
1172 if (view -> camera_widg[0])
1174 if (GTK_IS_WIDGET(view -> camera_widg[0]))
1176 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[0], 1.0 - 0.5*view -> anim -> last ->
img ->
zoom);
1194 for (i = 0; i<2; i++)
1198 for (j=0; j<nsp; j++)
img -> show_atom[i][j] = TRUE;
1200 img -> at_color = g_malloc0 (2*nsp*
sizeof*
img -> at_color);
1206 for (i = 0; i < nsp; i++)
1213 img -> bondrad[i][i] =
img -> bondrad[i+nsp][i+nsp] =
min(1.0,
img -> sphererad[i]/2.0);
1215 for (i=0; i < nsp-1; i++)
1217 for (j=i+1; j < nsp; j++)
1219 img -> linerad[i][j] =
img -> linerad[j][i]
1220 =
img -> linerad[i+nsp][j+nsp]
1222 img -> bondrad[i][j] =
min(1.0,
img -> sphererad[i]/2.0);
1223 img -> bondrad[i][j] =
min(
img -> bondrad[i][j],
img -> sphererad[j]/2.0);
1224 img -> bondrad[j][i] =
img -> bondrad[i+nsp][j+nsp]
1225 =
img -> bondrad[j+nsp][i+nsp]
1226 =
img -> bondrad[i][j];
1229 for (i=0; i<10; i++)
1231 img -> spcolor[i] = NULL;
1234 img -> spcolor[i] = g_malloc (nsp*
sizeof*
img -> spcolor[i]);
1238 img -> spcolor[i] = g_malloc (1*
sizeof*
img -> spcolor[i]);
1239 img -> spcolor[i][0] = NULL;
1255 if (
img -> l_ght) g_free (
img -> l_ght);
1256 img -> l_ght = g_malloc0 (3*
sizeof*
img -> l_ght);
1258 if (this_proj -> cell.box)
1260 val = (this_proj -> cell.box[0].param[0][0] == 0.0) ?
img -> p_depth : this_proj -> cell.box[0].param[0][0];
1266 float vbl =
img -> p_depth;
1282 this_proj -> modelgl -> anim -> last ->
img = g_malloc0(
sizeof*this_proj -> modelgl -> anim -> last ->
img);
1283 image *
img = this_proj -> modelgl -> anim -> last ->
img;
1284 img -> backcolor.red = 0.0;
1285 img -> backcolor.green = 0.0;
1286 img -> backcolor.blue = 0.0;
1287 img -> backcolor.alpha = 1.0;
1288 img -> box_color.red = 0.0;
1289 img -> box_color.green = 1.0;
1290 img -> box_color.blue = 0.0;
1291 img -> box_color.alpha = 1.0;
1292 img -> color_map[0] = 0;
1293 img -> color_map[1] = 0;
1294 img -> box_axis_rad[
BOX] = 0.05;
1297 img -> box_axis_rad[
AXIS] = 0.1;
1300 img -> axis_color = NULL;
1301 img -> axis_pos[0] = 50.0;
1302 img -> axis_pos[1] = 50.0;
1303 img -> axis_pos[2] = 0.0;
1304 img -> axis_labels = 1;
1313 if (this_proj -> cell.pbc)
1324 img -> labels_position[i] = 1;
1327 img -> labels_font[i] = g_strdup_printf (
"Sans Bold 12");
1329 img -> mtilt = TRUE;
1331 img -> mwidth = 1.0;
1334 img -> labels_font[3+i] = g_strdup_printf (
"Courier New Bold 18");
1335 img -> labels_color[3+i] = g_malloc (
sizeof*
img -> labels_color[3]);
1336 img -> labels_color[3+i][0].red = 1.0;
1337 img -> labels_color[3+i][0].green = 1.0;
1338 img -> labels_color[3+i][0].blue = 1.0;
1339 img -> labels_color[3+i][0].alpha = 1.0;
1340 img -> selected[i] = g_malloc0 (
sizeof*
img -> selected[i]);
1346 img -> radall[0] =
img -> radall[1] = 0.1;
1349 this_proj -> modelgl -> p_moy =
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1351 img -> m_terial.predefine = 4;
1352 img -> m_terial.albedo = vec3(0.5, 0.5, 0.5);
1360 img -> f_g.density = 0.005;
1361 img -> f_g.depth[0] = 1.0;
1362 img -> f_g.depth[1] = 90.0;
1363 img -> f_g.color = vec3 (0.01f, 0.01f, 0.01f);
1377 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
1380 if (g_strcmp0 (extension, (
const char*)glGetStringi(GL_EXTENSIONS, j)) == 0)
return TRUE;
1392 glEnable (GL_DEPTH_TEST);
1393 glDepthMask (GL_TRUE);
1394 glDepthFunc (GL_LEQUAL);
1395 glDepthRange (0.0f, 1.0f);
1396 glClearDepth (1.0f);
1397 glEnable (GL_NORMALIZE);
1399 glShadeModel(GL_SMOOTH);
1400 glCullFace(GL_BACK);
1401 glEnable (GL_CULL_FACE);
1405 glEnable (GL_PROGRAM_POINT_SIZE);
1406 glEnable (GL_VERTEX_PROGRAM_POINT_SIZE);
1407 glEnable (GL_POINT_SPRITE);
1409 glEnable (GL_POINT_SMOOTH);
1410 glHint (GL_POINT_SMOOTH_HINT, GL_NICEST);
1411 glEnable (GL_LINE_SMOOTH);
1412 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
1414 glDisable (GL_POLYGON_SMOOTH);
1415 glEnable (GL_POLYGON_STIPPLE);
1416 glEnable (GL_POLYGON_OFFSET_FILL);
1418 glEnable (GL_BLEND);
1419 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1421 glPolygonOffset (1.0, 1.0);
1422 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
1424 glHint (GL_FOG_HINT, GL_NICEST);
1425 glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1449 for (l = 0; l < this_proj -> steps; l++)
1454 for (i = 0; i < this_proj -> natomes; i++)
1456 x += this_proj ->
atoms[l][i].x;
1457 y += this_proj ->
atoms[l][i].y;
1458 z += this_proj ->
atoms[l][i].z;
1460 x /= this_proj -> natomes;
1461 y /= this_proj -> natomes;
1462 z /= this_proj -> natomes;
1463 for (i = 0; i < this_proj -> natomes; i++)
1465 this_proj ->
atoms[l][i].x -=
x;
1466 this_proj ->
atoms[l][i].y -=
y;
1467 this_proj ->
atoms[l][i].z -=
z;
1472 if (this_proj -> modelgl -> volume_box[i])
1474 if (this_proj -> modelgl -> volume_box[i][l])
1476 this_proj -> modelgl -> volume_box[i][l][6] -=
x;
1477 this_proj -> modelgl -> volume_box[i][l][7] -=
y;
1478 this_proj -> modelgl -> volume_box[i][l][8] -=
z;
1479 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]);
1480 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]));
1484 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]);
1485 bend = m4_mul_coord (rot, bini);
1486 this_proj -> modelgl -> volume_box[i][l][6] = bend.
x;
1487 this_proj -> modelgl -> volume_box[i][l][7] = bend.
y;
1488 this_proj -> modelgl -> volume_box[i][l][8] = bend.
z;
1491 if (this_proj -> modelgl -> frag_box[i])
1493 if (this_proj -> modelgl -> frag_box[i][l])
1495 for (j=0; j<this_proj -> coord -> totcoord[2]; j++)
1497 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]);
1498 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]));
1502 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]);
1503 bend = m4_mul_coord (rot, bini);
1504 this_proj -> modelgl -> frag_box[i][l][j][6] = bend.
x;
1505 this_proj -> modelgl -> frag_box[i][l][j][7] = bend.
y;
1506 this_proj -> modelgl -> frag_box[i][l][j][8] = bend.
z;
1512 this_proj -> cell.crystal = FALSE;
1525 view -> insert_coords = vec3(0.0, 0.0, 0.0);
1528 view -> create_shaders[
PICKS] = TRUE;
1529 view -> create_shaders[
MDBOX] = TRUE;
1530 view -> create_shaders[
LABEL] = TRUE;
1531 view -> create_shaders[
MEASU] = TRUE;
1549 if (this_proj -> modelgl ->
colorp[i] != NULL)
1551 g_free (this_proj -> modelgl ->
colorp[i]);
1552 this_proj -> modelgl ->
colorp[i] = NULL;
1555 for (i=0; i<10; i++)
1557 k = (i > 2) ? 1 : spec;
1562 if (this_proj -> coord -> geolist[i][j] != NULL)
1564 g_free (this_proj -> coord -> geolist[i][j]);
1565 this_proj -> coord -> geolist[i][j] = NULL;
1568 this_proj -> coord -> geolist[i]=NULL;
1571 for (i=0; i<spec; i++)
1573 if (this_proj -> coord -> partial_geo[i] != NULL) g_free (this_proj -> coord -> partial_geo[i]);
1574 this_proj -> coord -> partial_geo[i] = NULL;
1576 g_free (this_proj -> coord -> partial_geo);
1577 this_proj -> coord -> partial_geo = NULL;
1593 this_proj -> modelgl ->
colorp[i] = NULL;
1594 this_proj -> modelgl ->
colorp[i] = g_malloc (nspec*2*
sizeof*this_proj -> modelgl ->
colorp[i]);
1595 for (j=0; j<nspec*2; j++)
1597 this_proj -> modelgl ->
colorp[i][j].a = this_proj -> id;
1598 this_proj -> modelgl ->
colorp[i][j].b = i;
1599 this_proj -> modelgl ->
colorp[i][j].c = j;
1606 for (i=0; i<10; i++)
1608 k = (i > 2) ? 1 : nspec;
1611 for (j = 0; j < 2; j++)
1613 this_proj -> modelgl -> oglmv[j][i] = NULL;
1614 this_proj -> modelgl -> oglmv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmv[j][i]);
1617 this_proj -> modelgl -> oglmc[j][i] = NULL;
1618 this_proj -> modelgl -> oglmc[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmc[j][i]);
1620 if (i < 2 || (i > 3 && i < 9))
1622 this_proj -> modelgl -> oglmpv[j][i] = NULL;
1623 this_proj -> modelgl -> oglmpv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmpv[j][i]);
1627 this_proj -> modelgl -> oglmv[j][i][l] = NULL;
1628 if (i < 9) this_proj -> modelgl -> oglmc[j][i][l] = NULL;
1629 if (i < 2 || (i > 3 && i < 9)) this_proj -> modelgl -> oglmpv[j][i][l] = NULL;
1635 this_proj -> coord -> geolist[i] = g_malloc0 (k*
sizeof*this_proj -> coord -> geolist[i]);
1638 this_proj -> coord -> geolist[i][j] = NULL;
1642 this_proj -> coord -> partial_geo = g_malloc0 (nspec*
sizeof*this_proj -> coord -> partial_geo);
1643 for (i=0; i<nspec; i++) this_proj -> coord -> partial_geo[i] = NULL;
1656 view -> anim = g_malloc0 (
sizeof*view -> anim);
1657 snapshot * snap = g_malloc0 (
sizeof*snap);
1658 view -> anim -> first = snap;
1659 view -> anim -> last = snap;
1663 view -> mouseAction =
ANALYZE;
1668 view -> bondid = g_malloc0 (this_proj -> steps*
sizeof*view -> bondid);
1669 view -> clones = g_malloc0 (this_proj -> steps*
sizeof*view -> clones);
1671 for (i=0; i < this_proj -> steps; i++)
1673 view -> bondid[i] = g_malloc0 (2*
sizeof*view -> bondid[i]);
1674 view -> clones[i] = NULL;
1680 view -> stop = TRUE;
1681 view -> speed = 100;
1684 view -> selection_mode =
ATOMS;
1686 view -> rebuild[0][0] = view -> rebuild[1][0] = (this_proj -> steps > 1) ? FALSE : TRUE;
1687 view -> init = TRUE;
1690 this_proj -> initgl = TRUE;
1692 if (view -> win) update_menu_bar (view);
1707 area = (GtkGLArea *)gtk_gl_area_new ();
1711 gtk_gl_area_make_current (area);
1713 gtk_gl_area_set_has_depth_buffer (area, TRUE);
1714 gtk_gl_area_set_has_stencil_buffer (area, TRUE);
1715 return gtk_gl_area_get_error (area);
1727G_MODULE_EXPORT
void on_realize (GtkGLArea * area, gpointer data)
1747 GdkWindow *
xwin = gtk_widget_get_window (view ->
plot);
1748 GLint attr_list[] = {GLX_DOUBLEBUFFER,
1755 XVisualInfo * visualinfo = glXChooseVisual (GDK_WINDOW_XDISPLAY (
xwin),
1756 gdk_screen_get_number (gdk_window_get_screen (
xwin)), attr_list);
1757 view ->
glcontext = glXCreateContext (GDK_WINDOW_XDISPLAY (
xwin), visualinfo, NULL, TRUE);
1758 g_free (visualinfo);
1759 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (
xwin), GDK_WINDOW_XID (
xwin), view ->
glcontext))
1766 gchar * errm = g_strdup_printf (
"Impossible to initialize the OpenGL 3D rendering ! \n %s\n", err -> message);
1783G_MODULE_EXPORT gboolean
on_expose (GtkGLArea * area, GdkGLContext * context, gpointer data)
1794G_MODULE_EXPORT gboolean
on_expose (GtkWidget * widg, cairo_t * cr, gpointer data)
1799 GdkEvent *
event = gtk_get_current_event ();
1800 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 prepare_atom_edition(gpointer data, gboolean visible)
prepare atom edition
GError * init_gtk_gl_area(GtkGLArea *area)
initialize a GtkGLArea, return error if any
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 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)
intialize 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 set_img_lights(project *this_proj, image *img)
initialize lightning for an image data structure
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
void init_glwin(glwin *view)
initialize a glwin pointer
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 image_init_spec_data(image *img, project *this_proj, int nsp)
initialize the chemical species related pointers in an image data structure
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...
#define DEFAULT_LIGHTNING
Default OpenGL material ligthning.
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 DEFAULT_AMBIANT_OCCLUSION
Default OpenGL material ambiant occlusion.
#define DEFAULT_GAMMA_CORRECTION
Default OpenGL material gamma correction.
#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 CAMERA_ANGLE_X
Default value for the OpenGL camera pitch in °
#define MAX_LIGHTS
Maximum number of light sources.
#define DEFAULT_OPACITY
Default OpenGL opacity.
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_ROUGHNESS
Default OpenGL material roughness.
#define DEFAULT_METALLIC
Default OpenGL material metallic.
#define ZOOM
Default value for the OpenGL zoom.
#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
#define QUALITY
Default OpenGL quality (number of polygons)
#define CAMERA_ANGLE_Y
Default value for the OpenGL camera heading in °
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.
Function declarations for reading atomes project file Function declarations for saving atomes proje...