📄 gtkseisviewgl.c
字号:
g_idle_add ((GSourceFunc)gtk_seis_view_gl_property_notify_idle, (gpointer)&private->notify_data[property_num]); else g_object_notify (G_OBJECT (self), seis_view_properties[property_num]);}gboolean gtk_seis_view_gl_can_render_offscreen (GtkSeisViewGl *self) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->dataccess_mutex) g_mutex_lock (private->dataccess_mutex); gboolean return_val = private->offscreen_rendering; if (private->dataccess_mutex) g_mutex_unlock (private->dataccess_mutex); return return_val;}gboolean gtk_seis_view_gl_can_change_palette_fast (GtkSeisViewGl *self) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->dataccess_mutex) g_mutex_lock (private->dataccess_mutex); gboolean return_val = private->fast_palette_change; if (private->dataccess_mutex) g_mutex_unlock (private->dataccess_mutex); return return_val;}gboolean gtk_seis_view_gl_has_real_amplitudes (GtkSeisViewGl *self) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->dataccess_mutex) g_mutex_lock (private->dataccess_mutex); gboolean return_val = FALSE == private->use_agc && GTK_SEIS_VIEW_MINMAX_PER_ENSEMBLE == private->minmax_mode; if (private->dataccess_mutex) g_mutex_unlock (private->dataccess_mutex); return return_val;}gboolean gtk_seis_view_gl_is_threaded (GtkSeisViewGl *self) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->dataccess_mutex) g_mutex_lock (private->dataccess_mutex); gboolean return_val = private->is_threaded; if (private->dataccess_mutex) g_mutex_unlock (private->dataccess_mutex); return return_val;}static gboolean gtk_seis_view_gl_calc_data_pos (GtkWidget *widget, GtkSeisViewGlPrivate *private, gint screen_x, gint screen_y) { if (private->is_threaded) gdk_threads_enter (); GdkGLContext *gl_context = gtk_widget_get_gl_context (widget); GdkGLDrawable *gl_drawable = gtk_widget_get_gl_drawable (widget); GLdouble win_x, win_y, win_z; GLdouble obj_x, obj_y, obj_z; /* Stick to the area of seismic data visibility */ if (screen_x < private->left_margin_pixels) screen_x = private->left_margin_pixels; if (screen_y <= private->top_margin_pixels) screen_y = private->top_margin_pixels + 1; if (screen_x >= widget->allocation.width - private->right_margin_pixels) screen_x = widget->allocation.width - private->right_margin_pixels - 1; if (screen_y > widget->allocation.height - private->bottom_margin_pixels) screen_y = widget->allocation.height - private->bottom_margin_pixels; if (!gdk_gl_drawable_gl_begin (gl_drawable, gl_context)) { if (private->is_threaded) gdk_threads_leave (); return FALSE; } win_z = 0; win_x = screen_x; win_y = widget->allocation.height - screen_y; 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); /* Mouse pointer location in the screen space */ private->data_vis.slow_pointer_pos_screen = screen_x; private->data_vis.fast_pointer_pos_screen = screen_y; /* Mouse pointer location in the object space */ private->data_vis.slow_pointer_pos_object = obj_x; private->data_vis.fast_pointer_pos_object = obj_y; /* Mouse pointer location in the data space */ private->data_vis.slow_pointer_pos_data = (obj_x - private->data_vis.slow_start_object) * private->data_vis.slow_size_data / private->data_vis.slow_size_object + private->data_vis.slow_start_data; private->data_vis.fast_pointer_pos_data = (obj_y - private->data_vis.fast_start_object) * private->data_vis.fast_size_data / private->data_vis.fast_size_object + private->data_vis.fast_start_data; gdk_gl_drawable_gl_end (gl_drawable); if (private->is_threaded) gdk_threads_leave (); return TRUE;}static void gtk_seis_view_gl_draw_cross (GtkSeisViewGl *self, gboolean had_cross, gboolean has_cross, gdouble old_slow_pos_object, gdouble old_fast_pos_object, gdouble new_slow_pos_object, gdouble new_fast_pos_object) { GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if ((had_cross || has_cross) && (private->show_cross || private->cross_is_drawn)) { GdkGLContext *gl_context = gtk_widget_get_gl_context (GTK_WIDGET (self)); GdkGLDrawable *gl_drawable = gtk_widget_get_gl_drawable (GTK_WIDGET (self)); if (gdk_gl_drawable_gl_begin (gl_drawable, gl_context)) { glDrawBuffer (GL_FRONT); glEnable (GL_COLOR_LOGIC_OP); glLogicOp (GL_XOR); glColor3f (1, 1, 1); glBegin (GL_LINES); if (had_cross && private->cross_is_drawn) { glVertex2f (old_slow_pos_object, private->data_vis.fast_start_object); glVertex2f (old_slow_pos_object, private->data_vis.fast_start_object + private->data_vis.fast_size_object); glVertex2f (private->data_vis.slow_start_object, old_fast_pos_object); glVertex2f (private->data_vis.slow_start_object + private->data_vis.slow_size_object, old_fast_pos_object); } private->cross_is_drawn = FALSE; if (has_cross) { glVertex2f (new_slow_pos_object, private->data_vis.fast_start_object); glVertex2f (new_slow_pos_object, private->data_vis.fast_start_object + private->data_vis.fast_size_object); glVertex2f (private->data_vis.slow_start_object, new_fast_pos_object); glVertex2f (private->data_vis.slow_start_object + private->data_vis.slow_size_object, new_fast_pos_object); private->cross_is_drawn = TRUE; } glEnd (); glLogicOp (GL_SET); glDisable (GL_COLOR_LOGIC_OP); glDrawBuffer (GL_BACK); glFlush (); gdk_gl_drawable_gl_end (gl_drawable); } }}static gboolean gtk_seis_view_gl_button_event_thread (GtkWidget *widget, GdkEventButton *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; gtk_seis_view_gl_calc_data_pos (widget, private, event->x, event->y); if (private->active_tool) { g_seis_view_tool_button_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 (); } return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_button_event * * */typedef struct _GtkSeisViewGlButtonEventData GtkSeisViewGlButtonEventData;struct _GtkSeisViewGlButtonEventData { GtkSeisViewGlMessageType type; GtkSeisViewGl *seis_view; GdkEvent *event; guint8 data[MAX_MESSAGE_DATA];};static gboolean gtk_seis_view_gl_button_event (GtkWidget *widget, GdkEventButton *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)) { GtkSeisViewGlButtonEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_BUTTON_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_button_event_thread (widget, event);}static gboolean gtk_seis_view_gl_scroll_event_thread (GtkWidget *widget, GdkEventScroll *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; gtk_seis_view_gl_calc_data_pos (widget, private, event->x, event->y); if (private->active_tool) { g_seis_view_tool_scroll_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 (); } return FALSE;}/* * * Thread launcher wrapper for gtk_seis_view_gl_scroll_event * * */typedef struct _GtkSeisViewGlScrollEventData GtkSeisViewGlScrollEventData;struct _GtkSeisViewGlScrollEventData { GtkSeisViewGlMessageType type; GtkSeisViewGl *seis_view; GdkEvent *event; guint8 data[MAX_MESSAGE_DATA];};static gboolean gtk_seis_view_gl_scroll_event (GtkWidget *widget, GdkEventScroll *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)) { GtkSeisViewGlScrollEventData message_data; message_data.type = GTK_SEIS_VIEW_MSG_SCROLL_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_scroll_event_thread (widget, event);}static gboolean gtk_seis_view_gl_key_event_thread (GtkWidget *widget, GdkEventKey *event) { GtkSeisViewGl *self = GTK_SEIS_VIEW_GL (widget); GtkSeisViewGlPrivate *private = GTK_SEIS_VIEW_GL_GET_PRIVATE (self); if (private->active_tool) { 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; g_seis_view_tool_key_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,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -