📄 gsegyviewscaling.c
字号:
/* * GTKSEISVIEWUI - Library of interface elements for GSEGYView * * Copyright (C) 2006 Vladimir Bashkardin * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more av. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Vladimir Bashkardin <vovizmus@users.sourceforge.net> */#include "gsegyfileaux.h"#include "gsegyviewscaling.h"G_DEFINE_TYPE (GSEGYViewScaling, g_segy_view_scaling, G_TYPE_OBJECT)#define G_SEGY_VIEW_SCALING_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), G_SEGY_TYPE_VIEW_SCALING, GSEGYViewScalingPrivate))typedef struct _GSEGYViewScalingPrivate GSEGYViewScalingPrivate;struct _GSEGYViewScalingPrivate { GtkWidget *window; GtkWidget *vbox; GtkWidget *frame; GtkWidget *hbox; GtkWidget *vbox1; GtkWidget *amp_frame; GtkWidget *amp_vbox; GtkWidget *amp_scale; GtkWidget *horiz_frame; GtkWidget *horiz_vbox; GtkWidget *horiz_scale; GtkWidget *vert_frame; GtkWidget *vert_hbox; GtkWidget *vert_scale; GtkWidget *viewport_frame; GtkWidget *viewport_vbox; GtkWidget *viewport_area; GtkWidget *button_box; GtkWidget *close_button; GtkWidget *active_widget; GdkPixmap *viewport_pixmap; GdkCursor *fleur_cursor; guint32 trace_num; guint32 sample_num; gdouble horiz_size; gdouble vert_size; gfloat traces_scale; gdouble vert_start; gdouble horiz_start; gdouble slow_pointer_screen; gdouble fast_pointer_screen; gboolean inside_viewport; gboolean dragging_viewport; gboolean block_expose; gboolean block_selection; gboolean viewport_draw_queued; gboolean enable_viewport_change; gint property_change; gulong notify_slow_start_id; gulong notify_fast_start_id; gulong notify_slow_size_id; gulong notify_fast_size_id; gulong notify_traces_scale_id; GtkSeisViewGl *seis_view; gboolean seis_view_is_threaded;};static void g_segy_view_scaling_init (GSEGYViewScaling *self) { GSEGYViewScalingPrivate *private = G_SEGY_VIEW_SCALING_GET_PRIVATE (self); private->window = NULL; private->vbox = NULL; private->frame = NULL; private->hbox = NULL; private->vbox1 = NULL; private->amp_frame = NULL; private->amp_vbox = NULL; private->amp_scale = NULL; private->horiz_frame = NULL; private->horiz_vbox = NULL; private->horiz_scale = NULL; private->vert_frame = NULL; private->vert_hbox = NULL; private->vert_scale = NULL; private->viewport_frame = NULL; private->viewport_vbox = NULL; private->viewport_area = NULL; private->button_box = NULL; private->close_button = NULL; private->seis_view = NULL; private->seis_view_is_threaded = FALSE; private->notify_slow_start_id = 0; private->notify_fast_start_id = 0; private->notify_slow_size_id = 0; private->notify_fast_size_id = 0; private->notify_traces_scale_id = 0; private->trace_num = 10; private->sample_num = 10; private->horiz_size = 1; private->vert_size = 1; private->traces_scale = 1; private->horiz_start = 0; private->vert_start = 0; private->inside_viewport = FALSE; private->dragging_viewport = FALSE; private->block_expose = FALSE; private->block_selection = FALSE; private->viewport_draw_queued = FALSE; private->property_change = 0; private->active_widget = NULL; private->viewport_pixmap = NULL; private->fleur_cursor = NULL; private->enable_viewport_change = TRUE;#ifdef DEBUG g_print ("<GSEGYViewScaling is inited>\n");#endif}static void g_segy_view_scaling_finalize (GObject *object) { GSEGYViewScaling *self = G_SEGY_VIEW_SCALING (object); GSEGYViewScalingPrivate *private = G_SEGY_VIEW_SCALING_GET_PRIVATE (self); g_signal_handler_disconnect (G_OBJECT (private->seis_view), private->notify_slow_size_id); g_signal_handler_disconnect (G_OBJECT (private->seis_view), private->notify_fast_size_id); g_signal_handler_disconnect (G_OBJECT (private->seis_view), private->notify_slow_start_id); g_signal_handler_disconnect (G_OBJECT (private->seis_view), private->notify_fast_start_id); g_signal_handler_disconnect (G_OBJECT (private->seis_view), private->notify_traces_scale_id); if (private->window) gtk_widget_destroy (private->window); if (private->seis_view) g_object_unref (G_OBJECT (private->seis_view)); if (private->viewport_pixmap) g_object_unref (G_OBJECT (private->viewport_pixmap)); if (private->fleur_cursor) gdk_cursor_unref (private->fleur_cursor);#ifdef DEBUG g_print ("<GSEGYViewScaling is finalized>\n");#endif if (G_OBJECT_CLASS (g_segy_view_scaling_parent_class)->finalize) G_OBJECT_CLASS (g_segy_view_scaling_parent_class)->finalize (object);}static void g_segy_view_scaling_class_init (GSEGYViewScalingClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = g_segy_view_scaling_finalize; g_type_class_add_private (klass, sizeof (GSEGYViewScalingPrivate));#ifdef DEBUG g_print ("<GSEGYViewScaling class is inited>\n");#endif}void g_segy_view_scaling_change_ensemble (GSEGYViewScaling *self, guint32 trace_num, guint32 sample_num) { GSEGYViewScalingPrivate *private = G_SEGY_VIEW_SCALING_GET_PRIVATE (self); private->trace_num = trace_num; private->sample_num = sample_num; if (trace_num) { gdouble slow_data_size; g_object_get (G_OBJECT (private->seis_view), "slow-size-data", &slow_data_size, NULL); if (private->horiz_scale) { gtk_range_set_range (GTK_RANGE (private->horiz_scale), 1.0 / (gfloat)trace_num, 1.0); if (trace_num > 50) gtk_range_set_increments (GTK_RANGE (private->horiz_scale), 50.0 / (gfloat)trace_num, 50.0 / (gfloat)trace_num); else gtk_range_set_increments (GTK_RANGE (private->horiz_scale), 1.0 / (gfloat)trace_num, 1.0 / (gfloat)trace_num); if (slow_data_size < 1.0 / (gfloat)trace_num) gtk_range_set_value (GTK_RANGE (private->horiz_scale), 1.0 / (gfloat)trace_num); else gtk_range_set_value (GTK_RANGE (private->horiz_scale), slow_data_size); } private->horiz_size = slow_data_size; } if (sample_num) { gdouble fast_data_size; g_object_get (G_OBJECT (private->seis_view), "fast-size-data", &fast_data_size, NULL); if (private->vert_scale) { gtk_range_set_range (GTK_RANGE (private->vert_scale), 1.0 / (gfloat)sample_num, 1.0); if (sample_num > 100) gtk_range_set_increments (GTK_RANGE (private->vert_scale), 100.0 / (gfloat)sample_num, 100.0 / (gfloat)sample_num); else gtk_range_set_increments (GTK_RANGE (private->vert_scale), 1.0 / (gfloat)sample_num, 1.0 / (gfloat)sample_num); if (fast_data_size < 1.0 / (gfloat)sample_num) gtk_range_set_value (GTK_RANGE (private->vert_scale), 1.0 / (gfloat)sample_num); else gtk_range_set_value (GTK_RANGE (private->vert_scale), fast_data_size); } private->vert_size = fast_data_size; }}static void g_segy_view_scaling_draw_viewport (GSEGYViewScaling *self) { GSEGYViewScalingPrivate *private = G_SEGY_VIEW_SCALING_GET_PRIVATE (self); if (NULL == private->viewport_pixmap) return; GdkRectangle update_rect; update_rect.x = 0; update_rect.y = 0; update_rect.width = private->viewport_area->allocation.width; update_rect.height = private->viewport_area->allocation.height; gtk_paint_box (private->viewport_area->style, private->viewport_pixmap, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, NULL, private->viewport_area, NULL, 0, 0, private->viewport_area->allocation.width, private->viewport_area->allocation.height); gdouble x, y, width, height; x = 1 + (private->viewport_area->allocation.width - 1) * private->horiz_start; y = 1 + (private->viewport_area->allocation.height - 1) * private->vert_start; width = (private->viewport_area->allocation.width - 1) * private->horiz_size; height = (private->viewport_area->allocation.height - 1) * private->vert_size; if (width < 1.0) width = 1.0; if (height < 1.0) height = 1.0; gtk_paint_box (private->viewport_area->style, private->viewport_pixmap, GTK_STATE_ACTIVE, GTK_SHADOW_OUT, NULL, private->viewport_area, NULL, x, y, width, height); if (private->block_expose) { gdk_draw_drawable (private->viewport_area->window, private->viewport_area->style->fg_gc[GTK_WIDGET_STATE (private->viewport_area)], private->viewport_pixmap, 0, 0, 0, 0, private->viewport_area->allocation.width, private->viewport_area->allocation.height); } else { private->block_expose = TRUE; gdk_window_invalidate_rect (private->viewport_area->window, &update_rect, FALSE); private->block_expose = FALSE; } private->viewport_draw_queued = FALSE; gdk_flush ();}static void g_segy_view_scaling_amp_scale_handler (GtkWidget *widget, gpointer data) { GSEGYViewScalingPrivate *private = G_SEGY_VIEW_SCALING_GET_PRIVATE (G_SEGY_VIEW_SCALING (data)); if (private->block_selection) return; private->property_change++; private->traces_scale = gtk_range_get_value (GTK_RANGE (private->amp_scale)); gtk_seis_view_gl_set_traces_scale (private->seis_view, private->traces_scale); gtk_seis_view_gl_redraw (private->seis_view);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -