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);
443 gtk_widget_hide (view ->
plot);
444 gtk_widget_show (view ->
plot);
462 view -> zoom_factor =
zoom * 0.1 * view -> anim -> last ->
img -> p_depth / (2.0 * view -> anim -> last ->
img -> gfar);
465 zoom *= (view -> anim -> last ->
img -> p_depth / view -> anim -> last ->
img -> gnear);
467 dw = view -> anim -> last ->
img -> c_shift[0]*2.0*
zoom;
468 dh = view -> anim -> last ->
img -> c_shift[1]*2.0*
zoom;
479 view -> anim -> last ->
img -> gleft = -w + dw;
480 view -> anim -> last ->
img -> gright = w + dw;
481 view -> anim -> last ->
img -> gbottom = -h + dh;
482 view -> anim -> last ->
img -> gtop = h + dh;
486 view -> projection_matrix = m4_frustum (view -> anim -> last ->
img -> gleft,
487 view -> anim -> last ->
img -> gright,
488 view -> anim -> last ->
img -> gbottom,
489 view -> anim -> last ->
img -> gtop,
490 view -> anim -> last ->
img -> gnear,
491 view -> anim -> last ->
img -> gfar);
495 view -> projection_matrix = m4_ortho (view -> anim -> last ->
img -> gleft,
496 view -> anim -> last ->
img -> gright,
497 view -> anim -> last ->
img -> gbottom,
498 view -> anim -> last ->
img -> gtop,
499 -view -> anim -> last ->
img -> gfar,
500 view -> anim -> last ->
img -> gfar);
519 if (GTK_IS_WIDGET(view -> win))
521 scale = gtk_widget_get_scale_factor (view -> win);
524 glViewport (0, 0, (GLsizei)
scale * width, (GLsizei)
scale * height);
525 view -> view_port = vec4 (0.0, 0.0, width, height);
526 aspect = (double) width / (
double) height;
556 gboolean check_edit = FALSE;
560 int ** frag =
allocdint (this_proj -> coord -> totcoord[2], 2);
563 for (i=0; i<this_proj -> natomes; i++)
569 move_search -> todo[i] = 1;
576 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
578 if (frag[i][1] && frag[i][1] < frag[i][0])
587 (this_proj -> modelgl -> atom_win) ? this_proj -> modelgl -> atom_win -> visible : FALSE);
592 for (i=0; i<this_proj -> coord -> totcoord[2]; i++)
605 view -> baryc[1] =
get_bary (this_proj, 1);
607 view -> prepare_motion = FALSE;
622 view -> mouseAction =
MOTION;
624 if (view -> mouseStatus ==
CLICKED)
628 if (state & GDK_BUTTON1_MASK)
632 else if (state & GDK_BUTTON2_MASK)
636 view -> anim -> last ->
img -> c_shift[0] -= (double) (
x - view -> mouseX) / view -> pixels[0];
637 view -> anim -> last ->
img -> c_shift[1] += (double) (
y - view -> mouseY) / view -> pixels[1];
640 if (view -> camera_widg[i+5])
642 if (GTK_IS_WIDGET(view -> camera_widg[i+5]))
644 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+5], - view -> anim -> last ->
img -> c_shift[i]);
652 vec3_t pos_b = vec3(view -> mouseX, - view -> mouseY, 0.75);
653 vec3_t trans_a = v3_un_project (pos_a, view -> view_port, view -> projection_matrix);
654 vec3_t trans_b = v3_un_project (pos_b, view -> view_port, view -> projection_matrix);
656 trans.
x = (trans_a.
x - trans_b.
x);
657 trans.
y = (trans_b.
y - trans_a.
y);
660 trans.
x *= view -> anim -> last ->
img -> p_depth;
661 trans.
y *= view -> anim -> last ->
img -> p_depth;
691G_MODULE_EXPORT gboolean on_motion (GtkWidget * widg, GdkEvent * event, gpointer data)
694 if (view -> mouseStatus !=
RELEASED)
696 GdkEventMotion * mevent = (GdkEventMotion *)event;
698 GdkModifierType state;
699 if (mevent -> is_hint)
701 gdk_window_get_device_position (mevent -> window, mevent -> device, &
x, &
y, & state);
705 x = (gint) mevent ->
x;
706 y = (gint) mevent ->
y;
707 state = (GdkModifierType) mevent -> state;
727 if (view -> mouseStatus !=
RELEASED)
729 motion (view, (gint)
x, (gint)
y, gtk_event_controller_get_current_event_state((GtkEventController*)motc));
761 view -> pixels[0] = gtk_widget_get_allocated_width (GTK_WIDGET(area));
762 view -> pixels[1] = gtk_widget_get_allocated_height (GTK_WIDGET(area));
763 gtk_gl_area_make_current (area);
764 if (gtk_gl_area_get_error (area) == NULL)
766 view -> pixels[0] = gtk_widget_get_allocated_width (widg);
767 view -> pixels[1] = gtk_widget_get_allocated_height (widg);
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]);
777 view -> to_pick = FALSE;
778 reshape (view, view -> pixels[0], view -> pixels[1]);
784 glXSwapBuffers (GDK_WINDOW_XDISPLAY (win), GDK_WINDOW_XID (win));
805 case GDK_BUTTON_PRESS:
809 if (event_button == 1)
813 view -> to_pick = FALSE;
817 case GDK_BUTTON_RELEASE:
833G_MODULE_EXPORT gboolean on_lib_pressed (GtkWidget * widg, GdkEvent * event, gpointer data)
835 GdkEventButton * bevent = (GdkEventButton*)event;
853 glwin_lib_pressed (
x,
y, GDK_BUTTON_PRESS, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
869 glwin_lib_pressed (
x,
y, GDK_BUTTON_RELEASE, gtk_gesture_single_get_current_button ((GtkGestureSingle * )gesture), data);
887void glwin_button_event (
double event_x,
double event_y, guint event_button, guint event_type, guint32 event_time, gpointer data)
892 case GDK_BUTTON_PRESS:
894 view -> mouseX = event_x;
895 view -> mouseY = event_y;
896 clock_gettime (CLOCK_MONOTONIC, &
start_time);
897 if (event_button == 1 || event_button == 3)
901 view -> nth_copy = 0;
910 case GDK_BUTTON_RELEASE:
912 clock_gettime (CLOCK_MONOTONIC, &
stop_time);
915 view -> to_pick = TRUE;
922 if (view -> mode ==
EDITION && view -> mouseAction ==
MOTION)
927 if (event_button == 3)
954G_MODULE_EXPORT gboolean on_glwin_button_event (GtkWidget * widg, GdkEvent * event, gpointer data)
956 GdkEventButton * bevent = (GdkEventButton*)event;
957 glwin_button_event (bevent ->
x, bevent ->
y, bevent -> button, bevent -> type, bevent -> time, data);
974 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);
990 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);
1005 view -> anim -> last ->
img ->
zoom += delta * view -> zoom_factor;
1006 if (view -> camera_widg[0])
1008 if (GTK_IS_WIDGET(view -> camera_widg[0]))
1010 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[0], 1.0-0.5*view -> anim -> last ->
img ->
zoom);
1025G_MODULE_EXPORT gboolean on_scrolled (GtkWidget * widg, GdkEvent * event, gpointer data)
1028 GdkEventScroll * sevent = (GdkEventScroll *)event;
1029 if (sevent -> direction == GDK_SCROLL_UP)
1033 else if (sevent -> direction == GDK_SCROLL_DOWN && view -> anim -> last ->
img ->
zoom >
ZOOM_MAX)
1085 q_a = axis_to_quat (
axis, -
pi*angle_y/180.0);
1089 q_b = axis_to_quat (
axis, -
pi*angle_x/180.0);
1090 q_c = q4_mul (q_a, q_b);
1091 view -> anim -> last ->
img -> c_angle[0] -= angle_x;
1092 view -> anim -> last ->
img -> c_angle[1] -= angle_y;
1096 if (abs(view -> anim -> last ->
img -> c_angle[i]) > 180.0) view -> anim -> last ->
img -> c_angle[i] = 0.0;
1097 if (view -> camera_widg[i+3])
1099 if (GTK_IS_WIDGET(view -> camera_widg[i+3]))
1101 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+3], view -> anim -> last ->
img -> c_angle[i]);
1131 glwin * view = this_proj -> modelgl;
1132 if (get_depth) view -> anim -> last ->
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1133 if (view -> camera_widg[1])
1135 if (GTK_IS_WIDGET(view -> camera_widg[1]))
1137 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[1], view -> anim -> last ->
img -> p_depth);
1140 view -> anim -> last ->
img -> gnear = 6.0;
1141 if (view -> camera_widg[2])
1143 if (GTK_IS_WIDGET(view -> camera_widg[2]))
1145 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[2], view -> anim -> last ->
img -> gnear);
1148 view -> anim -> last ->
img -> gfar = view -> anim -> last ->
img -> p_depth*2.0;
1149 view -> anim -> last ->
img -> rotation_quaternion.w = 0.0;
1150 view -> anim -> last ->
img -> rotation_quaternion.x = 0.0;
1151 view -> anim -> last ->
img -> rotation_quaternion.y = 0.0;
1152 view -> anim -> last ->
img -> rotation_quaternion.z = 1.0;
1156 view -> anim -> last ->
img -> c_shift[i] = 0.0;
1157 view -> anim -> last ->
img -> c_angle[i] = 0.0;
1158 if (view -> camera_widg[i+5])
1160 if (GTK_IS_WIDGET(view -> camera_widg[i+5]))
1162 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[i+5], view -> anim -> last ->
img -> c_shift[i]);
1169 if (view -> camera_widg[0])
1171 if (GTK_IS_WIDGET(view -> camera_widg[0]))
1173 gtk_spin_button_set_value ((GtkSpinButton *)view -> camera_widg[0], 1.0 - 0.5*view -> anim -> last ->
img ->
zoom);
1191 for (i = 0; i<2; i++)
1195 for (j=0; j<nsp; j++)
img -> show_atom[i][j] = TRUE;
1197 img -> at_color = g_malloc0 (2*nsp*
sizeof*
img -> at_color);
1203 for (i = 0; i < nsp; i++)
1210 img -> bondrad[i][i] =
img -> bondrad[i+nsp][i+nsp] =
min(1.0,
img -> sphererad[i]/2.0);
1212 for (i=0; i < nsp-1; i++)
1214 for (j=i+1; j < nsp; j++)
1216 img -> linerad[i][j] =
img -> linerad[j][i]
1217 =
img -> linerad[i+nsp][j+nsp]
1219 img -> bondrad[i][j] =
min(1.0,
img -> sphererad[i]/2.0);
1220 img -> bondrad[i][j] =
min(
img -> bondrad[i][j],
img -> sphererad[j]/2.0);
1221 img -> bondrad[j][i] =
img -> bondrad[i+nsp][j+nsp]
1222 =
img -> bondrad[j+nsp][i+nsp]
1223 =
img -> bondrad[i][j];
1226 for (i=0; i<10; i++)
1228 img -> spcolor[i] = NULL;
1231 img -> spcolor[i] = g_malloc (nsp*
sizeof*
img -> spcolor[i]);
1235 img -> spcolor[i] = g_malloc (1*
sizeof*
img -> spcolor[i]);
1236 img -> spcolor[i][0] = NULL;
1252 if (
img -> l_ght) g_free (
img -> l_ght);
1253 img -> l_ght = g_malloc0 (3*
sizeof*
img -> l_ght);
1255 if (this_proj -> cell.box)
1257 val = (this_proj -> cell.box[0].param[0][0] == 0.0) ?
img -> p_depth : this_proj -> cell.box[0].param[0][0];
1263 float vbl =
img -> p_depth;
1279 this_proj -> modelgl -> anim -> last ->
img = g_malloc0(
sizeof*this_proj -> modelgl -> anim -> last ->
img);
1280 image *
img = this_proj -> modelgl -> anim -> last ->
img;
1281 img -> backcolor.red = 0.0;
1282 img -> backcolor.green = 0.0;
1283 img -> backcolor.blue = 0.0;
1284 img -> backcolor.alpha = 1.0;
1285 img -> box_color.red = 0.0;
1286 img -> box_color.green = 1.0;
1287 img -> box_color.blue = 0.0;
1288 img -> box_color.alpha = 1.0;
1289 img -> color_map[0] = 0;
1290 img -> color_map[1] = 0;
1291 img -> box_axis_rad[
BOX] = 0.05;
1294 img -> box_axis_rad[
AXIS] = 0.1;
1297 img -> axis_color = NULL;
1298 img -> axis_pos[0] = 50.0;
1299 img -> axis_pos[1] = 50.0;
1300 img -> axis_pos[2] = 0.0;
1301 img -> axis_labels = 1;
1310 if (this_proj -> cell.pbc)
1321 img -> labels_position[i] = 1;
1324 img -> labels_font[i] = g_strdup_printf (
"Sans Bold 12");
1326 img -> mtilt = TRUE;
1328 img -> mwidth = 1.0;
1331 img -> labels_font[3+i] = g_strdup_printf (
"Courier New Bold 18");
1332 img -> labels_color[3+i] = g_malloc (
sizeof*
img -> labels_color[3]);
1333 img -> labels_color[3+i][0].red = 1.0;
1334 img -> labels_color[3+i][0].green = 1.0;
1335 img -> labels_color[3+i][0].blue = 1.0;
1336 img -> labels_color[3+i][0].alpha = 1.0;
1337 img -> selected[i] = g_malloc0 (
sizeof*
img -> selected[i]);
1343 img -> radall[0] =
img -> radall[1] = 0.1;
1346 this_proj -> modelgl -> p_moy =
img -> p_depth = (this_proj -> natomes) ?
oglmax_ () : 50.0;
1348 img -> m_terial.predefine = 4;
1349 img -> m_terial.albedo = vec3(0.5, 0.5, 0.5);
1357 img -> f_g.density = 0.005;
1358 img -> f_g.depth[0] = 1.0;
1359 img -> f_g.depth[1] = 90.0;
1360 img -> f_g.color = vec3 (0.01f, 0.01f, 0.01f);
1374 glGetIntegerv (GL_NUM_EXTENSIONS, & i);
1377 if (g_strcmp0 (extension, (
const char*)glGetStringi(GL_EXTENSIONS, j)) == 0)
return TRUE;
1391 glEnable (GL_DEPTH_TEST);
1392 glDepthMask (GL_TRUE);
1393 glDepthFunc (GL_LEQUAL);
1394 glDepthRange (0.0f, 1.0f);
1395 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);
1445 for (l = 0; l < this_proj -> steps; l++)
1450 for (i = 0; i < this_proj -> natomes; i++)
1452 x += this_proj ->
atoms[l][i].x;
1453 y += this_proj ->
atoms[l][i].y;
1454 z += this_proj ->
atoms[l][i].z;
1456 x /= this_proj -> natomes;
1457 y /= this_proj -> natomes;
1458 z /= this_proj -> natomes;
1459 for (i = 0; i < this_proj -> natomes; i++)
1461 this_proj ->
atoms[l][i].x -=
x;
1462 this_proj ->
atoms[l][i].y -=
y;
1463 this_proj ->
atoms[l][i].z -=
z;
1468 if (this_proj -> modelgl -> volume_box[i])
1470 if (this_proj -> modelgl -> volume_box[i][l])
1472 this_proj -> modelgl -> volume_box[i][l][6] -=
x;
1473 this_proj -> modelgl -> volume_box[i][l][7] -=
y;
1474 this_proj -> modelgl -> volume_box[i][l][8] -=
z;
1475 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]);
1476 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]));
1480 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]);
1481 bend = m4_mul_coord (rot, bini);
1482 this_proj -> modelgl -> volume_box[i][l][6] = bend.
x;
1483 this_proj -> modelgl -> volume_box[i][l][7] = bend.
y;
1484 this_proj -> modelgl -> volume_box[i][l][8] = bend.
z;
1487 if (this_proj -> modelgl -> frag_box[i])
1489 if (this_proj -> modelgl -> frag_box[i][l])
1491 for (j=0; j<this_proj -> coord -> totcoord[2]; j++)
1493 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]);
1494 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]));
1498 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]);
1499 bend = m4_mul_coord (rot, bini);
1500 this_proj -> modelgl -> frag_box[i][l][j][6] = bend.
x;
1501 this_proj -> modelgl -> frag_box[i][l][j][7] = bend.
y;
1502 this_proj -> modelgl -> frag_box[i][l][j][8] = bend.
z;
1508 this_proj -> cell.crystal = FALSE;
1521 view -> insert_coords = vec3(0.0, 0.0, 0.0);
1524 view -> create_shaders[
PICKS] = TRUE;
1525 view -> create_shaders[
MDBOX] = TRUE;
1526 view -> create_shaders[
LABEL] = TRUE;
1527 view -> create_shaders[
MEASU] = TRUE;
1545 if (this_proj -> modelgl ->
colorp[i] != NULL)
1547 g_free (this_proj -> modelgl ->
colorp[i]);
1548 this_proj -> modelgl ->
colorp[i] = NULL;
1551 for (i=0; i<10; i++)
1553 k = (i > 2) ? 1 : spec;
1558 if (this_proj -> coord -> geolist[i][j] != NULL)
1560 g_free (this_proj -> coord -> geolist[i][j]);
1561 this_proj -> coord -> geolist[i][j] = NULL;
1564 this_proj -> coord -> geolist[i]=NULL;
1567 for (i=0; i<spec; i++)
1569 if (this_proj -> coord -> partial_geo[i] != NULL) g_free (this_proj -> coord -> partial_geo[i]);
1570 this_proj -> coord -> partial_geo[i] = NULL;
1572 g_free (this_proj -> coord -> partial_geo);
1573 this_proj -> coord -> partial_geo = NULL;
1589 this_proj -> modelgl ->
colorp[i] = NULL;
1590 this_proj -> modelgl ->
colorp[i] = g_malloc (nspec*2*
sizeof*this_proj -> modelgl ->
colorp[i]);
1591 for (j=0; j<nspec*2; j++)
1593 this_proj -> modelgl ->
colorp[i][j].a = this_proj -> id;
1594 this_proj -> modelgl ->
colorp[i][j].b = i;
1595 this_proj -> modelgl ->
colorp[i][j].c = j;
1602 for (i=0; i<10; i++)
1604 k = (i > 2) ? 1 : nspec;
1607 for (j = 0; j < 2; j++)
1609 this_proj -> modelgl -> oglmv[j][i] = NULL;
1610 this_proj -> modelgl -> oglmv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmv[j][i]);
1613 this_proj -> modelgl -> oglmc[j][i] = NULL;
1614 this_proj -> modelgl -> oglmc[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmc[j][i]);
1616 if (i < 2 || (i > 3 && i < 9))
1618 this_proj -> modelgl -> oglmpv[j][i] = NULL;
1619 this_proj -> modelgl -> oglmpv[j][i] = g_malloc0 (k*
sizeof*this_proj -> modelgl -> oglmpv[j][i]);
1623 this_proj -> modelgl -> oglmv[j][i][l] = NULL;
1624 if (i < 9) this_proj -> modelgl -> oglmc[j][i][l] = NULL;
1625 if (i < 2 || (i > 3 && i < 9)) this_proj -> modelgl -> oglmpv[j][i][l] = NULL;
1631 this_proj -> coord -> geolist[i] = g_malloc0 (k*
sizeof*this_proj -> coord -> geolist[i]);
1634 this_proj -> coord -> geolist[i][j] = NULL;
1638 this_proj -> coord -> partial_geo = g_malloc0 (nspec*
sizeof*this_proj -> coord -> partial_geo);
1639 for (i=0; i<nspec; i++) this_proj -> coord -> partial_geo[i] = NULL;
1652 view -> anim = g_malloc0 (
sizeof*view -> anim);
1653 snapshot * snap = g_malloc0 (
sizeof*snap);
1654 view -> anim -> first = snap;
1655 view -> anim -> last = snap;
1659 view -> mouseAction =
ANALYZE;
1664 view -> bondid = g_malloc0 (this_proj -> steps*
sizeof*view -> bondid);
1665 view -> clones = g_malloc0 (this_proj -> steps*
sizeof*view -> clones);
1667 for (i=0; i < this_proj -> steps; i++)
1669 view -> bondid[i] = g_malloc0 (2*
sizeof*view -> bondid[i]);
1670 view -> clones[i] = NULL;
1676 view -> stop = TRUE;
1677 view -> speed = 100;
1680 view -> selection_mode =
ATOMS;
1682 view -> rebuild[0][0] = view -> rebuild[1][0] = (this_proj -> steps > 1) ? FALSE : TRUE;
1683 view -> init = TRUE;
1686 this_proj -> initgl = TRUE;
1688 update_menu_bar (view);
1703 area = (GtkGLArea *)gtk_gl_area_new ();
1707 gtk_gl_area_make_current (area);
1709 gtk_gl_area_set_has_depth_buffer (area, TRUE);
1710 gtk_gl_area_set_has_stencil_buffer (area, TRUE);
1711 return gtk_gl_area_get_error (area);
1723G_MODULE_EXPORT
void on_realize (GtkGLArea * area, gpointer data)
1743 GdkWindow *
xwin = gtk_widget_get_window (view ->
plot);
1744 GLint attr_list[] = {GLX_DOUBLEBUFFER,
1751 XVisualInfo * visualinfo = glXChooseVisual (GDK_WINDOW_XDISPLAY (
xwin),
1752 gdk_screen_get_number (gdk_window_get_screen (
xwin)), attr_list);
1753 view ->
glcontext = glXCreateContext (GDK_WINDOW_XDISPLAY (
xwin), visualinfo, NULL, TRUE);
1754 g_free (visualinfo);
1755 if (glXMakeCurrent (GDK_WINDOW_XDISPLAY (
xwin), GDK_WINDOW_XID (
xwin), view ->
glcontext))
1773 gchar * errm = g_strdup_printf (
"Impossible to initialize the OpenGL 3D rendering ! \n %s\n", err -> message);
1794G_MODULE_EXPORT gboolean
on_expose (GtkGLArea * area, GdkGLContext * context, gpointer data)
1805G_MODULE_EXPORT gboolean
on_expose (GtkWidget * widg, cairo_t * cr, gpointer data)
1810 GdkEvent *
event = gtk_get_current_event ();
1811 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...
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 init_opengl(glwin *view)
initialize OpenGL rendering parameters for a glwin pointer
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 init_camera(project *this_proj, int get_depth)
intialize the OpenGL camera settings
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 reshape(glwin *view, int width, int height)
reshape (resize) the OpenGL window
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...