📄 gtkseisviewgl.c
字号:
private->data_vis.fast_pointer_pos_object); if (private->is_threaded) gdk_threads_leave (); } return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_key_event * * */typedef struct _GtkSeisViewGlKeyEventData GtkSeisViewGlKeyEventData;struct _GtkSeisViewGlKeyEventData { GtkSeisViewGlMessageType type; GtkSeisViewGl *seis_view; GdkEvent *event; guint8 data[MAX_MESSAGE_DATA];};static gboolean gtk_seis_view_gl_key_event (GtkWidget *widget, GdkEventKey *event) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (GTK_SEIS_VIEW_GL (widget)); if (private->message_queue && NULL == g_private_get (private->message_key)) { GtkSeisViewGlKeyEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_KEY_EVENT; message_data.seis_view = GTK_SEIS_VIEW_GL (widget); message_data.event = gdk_event_copy ((GdkEvent*)event); g_mutex_lock (private->message_mutex); g_array_prepend_vals (private->messages, &message_data, 1); g_mutex_unlock (private->message_mutex); g_async_queue_push (private->message_queue, (gpointer)message_data.type); return FALSE; } else return gtk_seis_view_gl_key_event_thread (widget, event);}static gboolean gtk_seis_view_gl_pointer_enter_signal (GtkSeisViewGl *self) { g_signal_emit (self, GTK_SEIS_VIEW_GL_GET_CLASS (self)->pointer_enter_id, 0); return FALSE;}static gboolean gtk_seis_view_gl_enter_event_thread (GtkWidget *widget, GdkEventCrossing *event) { GtkSeisViewGl *self = GTK_SEIS_VIEW_GL (widget); GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->active_tool) g_seis_view_tool_enter_event (private->active_tool, widget, event, &private->data_vis); if (private->message_queue) g_idle_add ((GSourceFunc)gtk_seis_view_gl_pointer_enter_signal, (gpointer)self); else gtk_seis_view_gl_pointer_enter_signal (self); return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_enter_event * * */typedef struct _GtkSeisViewGlCrossingEventData GtkSeisViewGlCrossingEventData;struct _GtkSeisViewGlCrossingEventData { GtkSeisViewGlMessageType type; GtkSeisViewGl *seis_view; GdkEvent *event; guint8 data[MAX_MESSAGE_DATA];};static gboolean gtk_seis_view_gl_enter_event (GtkWidget *widget, GdkEventCrossing *event) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (GTK_SEIS_VIEW_GL (widget)); gtk_widget_grab_focus (widget); if (private->message_queue && NULL == g_private_get (private->message_key)) { GtkSeisViewGlCrossingEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_ENTER_EVENT; message_data.seis_view = GTK_SEIS_VIEW_GL (widget); message_data.event = gdk_event_copy ((GdkEvent*)event); g_mutex_lock (private->message_mutex); g_array_prepend_vals (private->messages, &message_data, 1); g_mutex_unlock (private->message_mutex); g_async_queue_push (private->message_queue, (gpointer)message_data.type); return FALSE; } else return gtk_seis_view_gl_enter_event_thread (widget, event);}static gboolean gtk_seis_view_gl_pointer_leave_signal (GtkSeisViewGl *self) { g_signal_emit (self, GTK_SEIS_VIEW_GL_GET_CLASS (self)->pointer_leave_id, 0); return FALSE;}static gboolean gtk_seis_view_gl_leave_event_thread (GtkWidget *widget, GdkEventCrossing *event) { GtkSeisViewGl *self = GTK_SEIS_VIEW_GL (widget); GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); gdouble old_slow_pointer_pos_object = private->data_vis.slow_pointer_pos_object; gdouble old_fast_pointer_pos_object = private->data_vis.fast_pointer_pos_object; gboolean had_cross = private->active_tool ? private->active_tool->show_cross : TRUE; if (private->active_tool) g_seis_view_tool_leave_event (private->active_tool, widget, event, &private->data_vis); gboolean has_cross = FALSE; if (private->is_threaded) gdk_threads_enter (); gtk_seis_view_gl_draw_cross (self, had_cross, has_cross, old_slow_pointer_pos_object, old_fast_pointer_pos_object, private->data_vis.slow_pointer_pos_object, private->data_vis.fast_pointer_pos_object); if (private->is_threaded) gdk_threads_leave (); if (private->message_queue) g_idle_add ((GSourceFunc)gtk_seis_view_gl_pointer_leave_signal, (gpointer)self); else gtk_seis_view_gl_pointer_leave_signal (self); return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_leave_event * * */static gboolean gtk_seis_view_gl_leave_event (GtkWidget *widget, GdkEventCrossing *event) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (GTK_SEIS_VIEW_GL (widget)); if (private->message_queue && NULL == g_private_get (private->message_key)) { GtkSeisViewGlCrossingEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_LEAVE_EVENT; message_data.seis_view = GTK_SEIS_VIEW_GL (widget); message_data.event = gdk_event_copy ((GdkEvent*)event); g_mutex_lock (private->message_mutex); g_array_prepend_vals (private->messages, &message_data, 1); g_mutex_unlock (private->message_mutex); g_async_queue_push (private->message_queue, (gpointer)message_data.type); return FALSE; } else return gtk_seis_view_gl_leave_event_thread (widget, event);}static gboolean gtk_seis_view_gl_pointer_position_signal (GtkSeisViewGl *self) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); g_signal_emit (self, GTK_SEIS_VIEW_GL_GET_CLASS (self)->pointer_position_id, 0, private->data_vis.slow_pointer_pos_data, private->data_vis.fast_pointer_pos_data); return FALSE;}static gboolean gtk_seis_view_gl_motion_event_thread (GtkWidget *widget, GdkEventMotion *event) { GtkSeisViewGl *self = GTK_SEIS_VIEW_GL (widget); GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); gdouble old_slow_pointer_pos_object = private->data_vis.slow_pointer_pos_object; gdouble old_fast_pointer_pos_object = private->data_vis.fast_pointer_pos_object; gboolean had_cross = private->active_tool ? private->active_tool->show_cross : TRUE; if (gtk_seis_view_gl_calc_data_pos (widget, private, event->x, event->y)) { if (private->active_tool) g_seis_view_tool_motion_event (private->active_tool, widget, event, &private->data_vis); gboolean has_cross = private->active_tool ? private->active_tool->show_cross : TRUE; if (private->is_threaded) gdk_threads_enter (); gtk_seis_view_gl_draw_cross (self, had_cross, has_cross, old_slow_pointer_pos_object, old_fast_pointer_pos_object, private->data_vis.slow_pointer_pos_object, private->data_vis.fast_pointer_pos_object); if (private->is_threaded) gdk_threads_leave (); if (private->message_queue) g_idle_add ((GSourceFunc)gtk_seis_view_gl_pointer_position_signal, (gpointer)self); else gtk_seis_view_gl_pointer_position_signal (self); } return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_motion_event * * */typedef struct _GtkSeisViewGlMotionEventData GtkSeisViewGlMotionEventData;struct _GtkSeisViewGlMotionEventData { GtkSeisViewGlMessageType type; GtkSeisViewGl *seis_view; GdkEvent *event; guint8 data[MAX_MESSAGE_DATA];};static gboolean gtk_seis_view_gl_motion_event (GtkWidget *widget, GdkEventMotion *event) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (GTK_SEIS_VIEW_GL (widget)); gint x, y; GdkModifierType state; /* Magic call which will send us the next motion event */ if (event->is_hint) gdk_window_get_pointer (event->window, &x, &y, &state); if (private->message_queue && NULL == g_private_get (private->message_key)) { GtkSeisViewGlMotionEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_MOTION_EVENT; message_data.seis_view = GTK_SEIS_VIEW_GL (widget); message_data.event = gdk_event_copy ((GdkEvent*)event); g_mutex_lock (private->message_mutex); g_array_prepend_vals (private->messages, &message_data, 1); g_mutex_unlock (private->message_mutex); g_async_queue_push (private->message_queue, (gpointer)message_data.type); return FALSE; } else return gtk_seis_view_gl_motion_event_thread (widget, event);}static void gtk_seis_view_calc_data_visibility_thread (GtkSeisViewGl *self, guint width, guint height) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); GLdouble win_x, win_y, win_z; GLdouble obj_x, obj_y, obj_z; win_z = 0; win_x = private->left_margin_pixels; win_y = 0; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x, &obj_y, &obj_z); private->left_margin_size = obj_x - private->ortho_left_x; win_x = width - private->right_margin_pixels; win_y = 0; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x, &obj_y, &obj_z); private->right_margin_size = (private->ortho_left_x + private->ortho_width) - obj_x; win_x = 0; win_y = private->top_margin_pixels; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x, &obj_y, &obj_z); private->top_margin_size = (private->ortho_top_y + private->ortho_height) - obj_y; win_x = 0; win_y = height - private->bottom_margin_pixels; gluUnProject (win_x, win_y, win_z, private->data_vis.model_view, private->data_vis.projection, private->data_vis.viewport, &obj_x, &obj_y, &obj_z); private->bottom_margin_size = obj_y; /* Area of the seismic data visibility in the object space */ private->data_vis.slow_start_object = private->ortho_left_x + private->left_margin_size; private->data_vis.fast_start_object = private->ortho_top_y + private->top_margin_size; private->data_vis.slow_size_object = private->ortho_width - private->left_margin_size - private->right_margin_size; private->data_vis.fast_size_object = private->ortho_height - private->bottom_margin_size - private->top_margin_size; /* Area of the seismic data visibility in the screen space */ private->data_vis.slow_start_screen = private->left_margin_pixels; private->data_vis.slow_size_screen = width - private->left_margin_pixels - private->right_margin_pixels; private->data_vis.fast_start_screen = private->top_margin_pixels; private->data_vis.fast_size_screen = height - private->top_margin_pixels - private->bottom_margin_pixels; private->recalc_data_vis = FALSE;}static void gtk_seis_view_gl_calc_configure_thread (GtkSeisViewGl *self, guint width, guint height) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); GLfloat wh; guint i; if (width <= height) { wh = (GLfloat)height / (GLfloat)width; private->ortho_left_x = 0; private->ortho_top_y = 0; private->ortho_width = 2.0; private->ortho_height = wh * 2.0; } else { wh = (GLfloat)width / (GLfloat)height; private->ortho_left_x = 0; private->ortho_top_y = 0; private->ortho_width = wh * 2.0; private->ortho_height = 2.0; } /* Dimensions of the object coordinate system */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -