⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpicker.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 4 页
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       *//* Copyright (c) Colorado School of Mines, 2003.*//* All rights reserved.                       *//* XPICKER: $Revision: 1.19 $ ; $Date: 2004/07/21 17:48:13 $  */#include "par.h"#include "xplot.h"#include <X11/Xatom.h>#include <X11/keysym.h>#define EGSTERN#include "xwindow.h"#include "garnish.h"#include "picking.h"/*********************** self documentation **********************/char *sdoc[] = {"									"," XPICKER - X wiggle-trace plot of f(x1,x2) via Bitmap with PICKing	","									"," xpicker n1= [optional parameters] <binaryfile				","									"," X Menu functionality:							","    Pick Filename Window	default is pick_file			","    Load		load an existing Pick Filename			","    Save		save to Pick Filename				","    View only/Pick	default is View, click to enable Picking	","    Add/Delete		default is Add, click to delete picks		","    Cross off/on	default is Cross off, click to enable Crosshairs","									"," In View mode:								","    a or page up keys          enhance clipping by 10%                 ","    c or page down keys        reduce clipping by 10%                  ","    up,down,left,right keys    move zoom window by half width/height   ","    i or +(keypad)             zoom in by factor 2                     ","    o or -(keypad)             zoom out by factor 2                    ","    l 				lock the zoom while moving the coursor	","    u 				unlock the zoom 			","									"," Notes:								","	Menu selections and toggles (\"clicks\") are made with button 1	","	Pick selections are made with button 3				","	Edit a pick selection by dragging it with button 3 down	or	","	by making a new pick on that trace				","	Reaching the window limits while moving within changes the zoom	","	factor in this direction. The use of zoom locking(l) disables it","									"," Other X Mouse functionality:						"," Mouse Button 1	Zoom with rubberbox				"," Mouse Button 2	Show mouse (x1,x2) coordinates while pressed	","									"," The following keys are active in View Only mode:			","									"," Required Parameters:							"," n1=		number of samples in 1st (fast) dimension		","									"," Optional Parameters:							"," mpicks=pick_file	name of output (input) pick file		"," d1=1.0		sampling interval in 1st dimension		"," f1=d1		  first sample in 1st dimension				"," n2=all		 number of samples in 2nd (slow) dimension	"," d2=1.0		 sampling interval in 2nd dimension		"," f2=d2		  first sample in 2nd dimension				"," x2=f2,f2+d2,...	array of sampled values in 2nd dimension	"," bias=0.0	       data value corresponding to location along axis 2"," perc=100.0	     percentile for determining clip			"," clip=(perc percentile) data values < bias+clip and > bias-clip are clipped"," xcur=1.0	       wiggle excursion in traces corresponding to clip	"," wt=1		   =0 for no wiggle-trace; =1 for wiggle-trace		"," va=1		   =0 for no variable-area; =1 for variable-area fill	","                        =2 for variable area, solid/grey fill          ","                        SHADING: 2<=va<=5  va=2 light grey, va=5 black "," verbose=1	      =1 for info printed on stderr (0 for no info)	"," xbox=50		x in pixels of upper left corner of window	"," ybox=50		y in pixels of upper left corner of window	"," wbox=550	      	width in pixels of window			"," hbox=700		height in pixels of window			"," x1beg=x1min		value at which axis 1 begins			"," x1end=x1max		value at which axis 1 ends			"," d1num=0.0		 numbered tic interval on axis 1 (0.0 for automatic)"," f1num=x1min		first numbered tic on axis 1 (used if d1num not 0.0)"," n1tic=1		number of tics per numbered tic on axis 1	"," grid1=none		grid lines on axis 1 - none, dot, dash, or solid"," label1=		label on axis 1					"," x2beg=x2min		value at which axis 2 begins			"," x2end=x2max		value at which axis 2 ends			"," d2num=0.0		 numbered tic interval on axis 2 (0.0 for automatic)"," f2num=x2min		first numbered tic on axis 2 (used if d2num not 0.0)"," n2tic=1		number of tics per numbered tic on axis 2	"," grid2=none		grid lines on axis 2 - none, dot, dash, or solid "," label2=		label on axis 2					"," labelfont=Erg14	font name for axes labels			"," title=		title of plot					"," titlefont=Rom22	font name for title				"," labelcolor=blue	color for axes labels				"," titlecolor=red	color for title					"," gridcolor=blue	color for grid lines				"," style=seismic		normal (axis 1 horizontal, axis 2 vertical) or	"," 		    	seismic (axis 1 vertical, axis 2 horizontal)	"," endian=		=0 little endian, =1 big endian			"," interp=0		no sinc interpolation				","			=1 perform sinc interpolation			"," x2file=		file of \"acceptable\" x2 values		"," x1x2=1		save picks in the order (x1,x2) 		"," 			=0 save picks in the order (x2,x1) 		","									"," Notes:								"," Xpicker will try to detect the endian value of the X-display and will	"," set it to the right value. If it gets obviously wrong information the "," endian value will be set to the endian value of the machine that is	"," given at compile time as the value of CWPENDIAN defined in cwp.h	"," and set via the compile time flag ENDIANFLAG in Makefile.config.	","								       "," The only time that you might want to change the value of the endian   "," variable is if you are viewing traces on a machine with a different   "," byte order than the machine you are creating the traces on AND if for "," some reason the automaic detection of the display byte order fails.   "," Set endian to that of the machine you	are viewing the traces on.	"," 									"," The interp flag is useful for making better quality wiggle trace for	"," making plots from screen dumps. However, this flag assumes that the	"," data are purely oscillatory. This option may not be appropriate for all"," data sets.								"," 									"," If the x2file=  option is set, then the values from the specified file"," will define the set of \"acceptable\" values of x2 for xpicker to	"," output. The format is a single column of ASCII values. The number of  "," specified values is arbitrary.					"," 									"," Such a file can be built from an SU data set via:			","     sugethw < sudata key=offset output=geom > x2example 		"," 									"," If the value of x2file= is not set, then				"," xpicker will use the values specified via: x2=.,.,.,. or those that are", " computed from the values of f2=  and d2= as being the \"acceptible\" "," values.								"," 									"," See the selfdoc of  suxpicker  for information on using key fields from"," the SU trace headers directly. 					"," 									",NULL};/* * AUTHOR:  Dave Hale, Colorado School of Mines, 08/09/90 * with picking by Wenying Cai of University of Utah. * Endian stuff by Morten Pedersen and John Stockwell of CWP. * Interp stuff by Tony Kocurko of Memorial University of Newfoundland * Modified to include acceptable values by Bill Lutter of the *     Department of Geology, University of Wisconsin 10/96 * MODIFIED:  P. Michaels, Boise State Univeristy  29 December 2000 *            Added solid/grey color scheme for peaks/troughs *  * G.Klein, IFG Kiel University, 2003-09-29, added cursor scrolling and *            interactive change of zoom and clipping. * * NOTES: * Interactive picker improved to allow x-axis of picks to be * coordinated with "key=header" parameter set in driver routine * suxpicker. Multiple picks per trace are now allowed. * *  Input: *  The command line of suxpicker is unchanged.  The parameter"key=header" *  set in  suxpicker controls a) trace x-axis  displayed via xpicker and *  b) the header values in the first column of a pick file either read in *     or written out from xpicker c) header values expected in optional file *      or written out from xpicker c) header values expected in optional file *     x2file= which reads into xpicker allowable trace x-axis values. * *   a) example command line:  suxpicker key=offset < shot10.plotpik * *   b) pick file format: *	x-axis_value_1 time_1 *	x-axis_value_2 time_2   *	x-axis_value_3 time_3 *	etc. *	x-axis_value_n time_n * *	pick file example: *         1000.000000 0.500000 *         2000.000000 1.000000 *         3000.000000 1.500000 *         4000.000000 2.000000 *         5000.000000 2.500000 * *  c)  format of optional file x2file=: *    	   header_value_1 * 	   header_value_2 *	   etc. *	   header_val_m * *       If file "x2file=" exists in directory from which suxpicker is *      invoked, then these trace header x-axis values are the only allowable *      x-axis pick values used in the pick "add" or "delete" menu operation. *      Header values do not need to be sorted or 1 to 1 with input traces. *      Further, pick file x-axis values can be read into xpicker via load *      operation without having to match key_pickx1_val x-axis values and *      can also be rewritten out an output pickfile.  As indicated, only *      the "add" and "delete" pick operations are influenced by existence *       of this file. * *      Offset header values for "x2file=" can be generated by the *      command line: * *      sugethw < su_segyfile key=offset output=geom >  x2examplefile= * *      Output: Only change is in format of pick_file (format described above). *      If x2file= file exists then x-axis value of added picks *      will be forced to nearest allowable trace x-axis value (input values *      of x2file= file). If x2file= is not set, then the values of x2  *      that are either assigned uniformly to the traces via f2 and d2, *      or by the vector of values of x2=.,.,.,.    will be the "acceptable" *      values. * *    Strategy: *   a) malloc() and realloc() used to dynamically allocate memory *	  for array of x-axis value read in from optional file *	  x2file=.  This is done in function read_keyval(). * *	  b) The pick file dimensions are set in main program via malloc() *	  and then initialized (*apick)[i].picked = FALSE) in function *	  init_picks().  The pick file is declared as pick_t **apick, in *	  order to use realloc() as needed in functions load_picks where the *	  pick file is read in and edit_picks where picks are added.  The *	  call to realloc() and further initializing is performed in *	  function realloc_picks(). * *	  c) If x2file= file exists the mouse derived x-axis value *	  for a pick to be added is checked against allowable x-axis values *	  to find the closest match via function add_pick called from *	  edit_picks.  If the pick is to be deleted, first a search is done *	  to find the closest x-axis value, then the existing pick values *	  are searched to find the closest radial value (x**2 + t**2) via *	  function del_pick() invoked from edit_picks. * *	  d) Code modifications are limited to above mentioned functions, *	  except for additional parameters passed to functions edit_picks, *	  load_picks, save_picks, and check_buttons. */ /**************** end self doc ********************************//* Prototypes of functions defined and used internally */static void zoomBox (int x, int y, int w, int h, 	int xb, int yb, int wb, int hb,	float x1, float x2,	float y1, float y2,	float *x1b, float *x2b,	float *y1b, float *y2b);static XImage *newBitmap (Display *dpy, int width, int height,	int n1, float d1, float f1, int n2, float *x2, float *z,	float x1beg, float x1end, float x2beg, float x2end,	float xcur, float clip, int wt, int va,	float *p2begp, float *p2endp, int endian, int interp);void xMouseLoc(Display *dpy, Window win, XEvent event, int style, Bool show,	int x, int y, int width, int height,	float x1begb, float x1endb, float x2begb, float x2endb,	float p2beg, float p2end);void xMousePrint(XEvent event, int style,	FILE *mpicksfp, int x, int y, int width, int height,	float x1begb, float x1endb, float x2begb, float x2endb);static void draw_cross(Display *dpy, Window win, GC gc, int x, int y,			int w, int h, int mx, int my, int cross_mode,			int draw_f);void init_stuff(int winwidth, int num_wiggles,		TextSet **filename_input, char *pick_fname,		int *control_mode,int *edit_mode, int *cross_mode);void save_picks(pick_t **apick, int num_wiggles, char *fnam,	       int *pickdimax, int *pickdimend, int verbose, int x1x2);void load_picks(pick_t **apick, int num_wiggles, char *fname,	       int *pickdimax, int *pickdimend, int verbose, int x1x2);/** added by Bill Lutter - Oct 96     */void realloc_picks(pick_t **apick, int more,	int *pickdimax, int *pickdimend, int verbose);float *read_keyval(char *x2file,int *ioff, int verbose);void init_picks(pick_t **apick, int *pickdimax, int *pickdimend);void add_pick(pick_t **apick, int *pickdimax, int *pickdimend,	     float *off, int ioff,	     float fy, int *pick_num, int *ihead,int verbose);void del_pick(pick_t **apick, int *pickdimax, int *pickdimend,	     float *off, int ioff,	     float fy, int *pick_num, int *ihead, int verbose); void edit_pick(Display *dpy, Window win, GC gc, XEvent event,	       int style, int x, int y,	       int width, int height,	       pick_t **apick, int num_wiggles,	       float x1begb, float x1endb,	       float x2begb, float x2endb,	       float p2beg, float p2end,	       int control_mode,	       int edit_mode,	       int cross_mode,	       int *pickdimax,	       int *pickdimend,	       int ioff, float *off, int verbose);/** 			*/void draw_pick(Display *dpy, Window win, GC gc, pick_t *pick, int i,	       int xmargin, int ymargin,	       int width, int height,	       float x1begb, float x1endb,	       float x2begb, float x2endb,	       float p2beg, float p2end);void draw_command_bar(int winwidth, TextSet *filename_input,		      char *pick_fname, int control_mode, int edit_mode,		      int cross_mode);void draw_seg(Display *dpy, Window win, GC gc, int x, int y);void check_buttons(Display *dpy, Window win, GC gc,XEvent event,pick_t **apick,		   int num_wiggles,		   int x, int y,		   int winwidth, int height,		   float x1begb, float x1endb,		   float x2begb, float x2endb,		   float p2beg, float p2end,		   TextSet *filename_input,		   char *pick_fname,		   int *control_mode,		   int *edit_mode,		   int *cross_mode,		   int *pickdimax,		   int *pickdimend,		   int verbose,		   int x1x2);intmain (int argc, char **argv){	/* begin picking related variables */	int num_wiggles;	/* number of total wiggles in plot */	int control_mode;	/* specifies pick mode or regular mode */	int edit_mode;		/* specifies pick add mode or pick delete */	int cross_mode;		/* draw crosshair if TRUE */	char pick_fname[50];	/* pick file name */		TextSet *filename_input;	/* end picking related variables */  	int n1,n2,n1tic,n2tic,wt,va,		i2,grid1,grid2,style=0,		nz,iz,verbose=0,		xbox,ybox,wbox,hbox,		xb,yb,wb,hb,		x,y,width,height,		i,		imageOutOfDate,winwidth=-1,winheight=-1,		showloc=0,endian,interp;	unsigned long nfloats;	float labelsize,titlesize,perc,clip,xcur,bias,		d1,f1,d2,f2,*z,*temp,*x2,		x1beg,x1end,x2beg,x2end,		x1min,x1max,x2min,x2max,		d1num,f1num,d2num,f2num,		x1begb,x1endb,x2begb,x2endb,p2beg,p2end;	char *label1="",*label2="",*title="",		*labelfont="Erg14",*titlefont="Rom22",		*styles="seismic",*grid1s="none",*grid2s="none",		*labelcolor="blue",*titlecolor="red",		*gridcolor="blue",keybuf[256],*mpicks;	FILE *infp=stdin, *mpicksfp;	Display *dpy;	Window win;	XEvent event;	KeySym keysym;	XComposeStatus keystat;	XImage *image=NULL;	GC gci,rgc;	int scr;	unsigned long mask;	unsigned long black,white;	/** Added by Bill Lutter 10/96    */	float *off;     /* pointer for 1-d float array */	int ioff;	/* number of header value entries in off */	int pickdimax=10; /* current dimension of pick array apick */	int pickdimend=0; /* number of pick entries in apick  */	pick_t **apick,*cpick; 	/* added by John Stockwell */	char *x2file="";	/* x2file name	*/		/* added by John Stockwell */	int x1x2;		/* flag to specfy (x1,x2) output */ 	/* added by Gerald Klein */	int lock=0;		/* lock/unlock zoom while scrolling */	float mve;		/* distance for scrolling */	char  *msg="";		/* message on screen */		/* initialize getpar */	initargs(argc,argv);	requestdoc(1);	/* get parameters describing 1st dimension sampling */	if (!getparint("n1",&n1))		err("Must specify number of samples in 1st dimension!\n");	d1 = 1.0;  getparfloat("d1",&d1);	f1 = d1;  getparfloat("f1",&f1);	x1min = (d1>0.0)?f1:f1+(n1-1)*d1;	x1max = (d1<0.0)?f1:f1+(n1-1)*d1;	/* get parameters describing 2nd dimension sampling */	if ((n2=countparval("x2"))==0 && !getparint("n2",&n2)) {			if (efseeko(infp,(off_t) 0,SEEK_END)!=0)				err("must specify n2 if in a pipe!\n");			nfloats = (int)(eftello(infp)/((off_t) sizeof(float)));			efseeko(infp,(off_t) 0,SEEK_SET);			n2 = (int) nfloats/n1;	}	x2 = ealloc1float(n2);	if (!getparfloat("x2",x2)) {		d2 = 1.0;  getparfloat("d2",&d2);		f2 = d2;  getparfloat("f2",&f2);		for (i2=0; i2<n2; i2++)			x2[i2] = f2+i2*d2;	}	for (i2=1,x2min=x2max=x2[0]; i2<n2; i2++) {		x2min = MIN(x2min,x2[i2]);		x2max = MAX(x2max,x2[i2]);	}	getparstring("x2file",&x2file);		if (*x2file!='\0') { 			/**  added by Bill Lutter 10/96   */		/* Read in header values (allowable pick.x2 values and also */		/* allowable values (for these traces) in pick file  */		off = read_keyval(x2file,&ioff,verbose);		if (verbose) warn("x-axis value 0:   %f\n",off[0]);		if (verbose) warn("x-axis value ioff:  %d %f\n",ioff,off[ioff]);	} else { /* use n2 and x2 for the "ioff" and "off" values */		ioff = n2;		off = ealloc1float(ioff);		memcpy( (void *) off, (const void *) x2, n2*FSIZE);	}	if (!getparint("x1x2",&x1x2))		x1x2 = 1;			/* dynamically allocate memory for picks  - Bill Lutter    */	cpick = (pick_t *) malloc(pickdimax*sizeof(struct pick_tag ));	apick = &cpick;	init_picks(apick,&pickdimax,&pickdimend);	/* set up file to save mouse picks */	if (!getparstring("mpicks", &mpicks)) mpicks = "pick_file";		mpicksfp = efopen(mpicks, "w");	/* read binary data to be plotted */	nz = n1*n2;	z = ealloc1float(nz);	if (fread(z,sizeof(float),nz,infp)!=nz)		err("error reading input file");	/* if necessary, subtract bias */	if (getparfloat("bias",&bias) && bias!=0.0)		for (iz=0; iz<nz; iz++)			z[iz] -= bias;		/* if necessary, determine clip from percentile */	if (!getparfloat("clip",&clip)) {		perc = 100.0;  getparfloat("perc",&perc);		temp = ealloc1float(nz);		for (iz=0; iz<nz; iz++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -