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

📄 xwigb.c

📁 seismic software,very useful
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright (c) Colorado School of Mines, 1990./* All rights reserved.                       */char *sdoc = "XWIGB - X WIGgle-trace plot of f(x1,x2) via Bitmap\n""\n""xwigb n1= [optional parameters] <binaryfile\n""\n""X Functionality:\n""Button 1	Zoom with rubberband box\n""Button 2	Show mouse (x1,x2) coordinates while pressed\n""Q key		Quit (can also use Motif Action button)\n""s key		Save current mouse (x1,x2) location to stdout\n""\n""Required Parameters:\n""n1                     number of samples in 1st (fast) dimension\n""\n""Optional Parameters:\n""d1=1.0                 sampling interval in 1st dimension\n""f1=d1                  first sample in 1st dimension\n""n2=all                 number of samples in 2nd (slow) dimension\n""d2=1.0                 sampling interval in 2nd dimension\n""f2=d2                  first sample in 2nd dimension\n""x2=f2,f2+d2,...        array of sampled values in 2nd dimension\n""bias=0.0               data value corresponding to location along axis 2\n""perc=100.0             percentile for determining clip\n""clip=(perc percentile) data values < bias+clip and > bias-clip are clipped\n""xcur=1.0               wiggle excursion in traces corresponding to clip\n""wt=1                   =0 for no wiggle-trace; =1 for wiggle-trace\n""va=1                   =0 for no variable-area; =1 for variable-area fill\n""nbpi=72                number of bits per inch at which to rasterize\n""verbose=1              =1 for info printed on stderr (0 for no info)\n""xbox=50                x in pixels of upper left corner of window\n""ybox=50                y in pixels of upper left corner of window\n""wbox=550               width in pixels of window\n""hbox=700               height in pixels of window\n""x1beg=x1min            value at which axis 1 begins\n""x1end=x1max            value at which axis 1 ends\n""d1num=0.0              numbered tic interval on axis 1 (0.0 for automatic)\n""f1num=x1min            first numbered tic on axis 1 (used if d1num not 0.0)\n""n1tic=1                number of tics per numbered tic on axis 1\n""grid1=none             grid lines on axis 1 - none, dot, dash, or solid\n""label1=                label on axis 1\n""x2beg=x2min            value at which axis 2 begins\n""x2end=x2max            value at which axis 2 ends\n""d2num=0.0              numbered tic interval on axis 2 (0.0 for automatic)\n""f2num=x2min            first numbered tic on axis 2 (used if d2num not 0.0)\n""n2tic=1                number of tics per numbered tic on axis 2\n""grid2=none             grid lines on axis 2 - none, dot, dash, or solid\n""label2=                label on axis 2\n""labelfont=Erg14        font name for axes labels\n""title=                 title of plot\n""titlefont=Rom22        font name for title\n""labelcolor=blue        color for axes labels\n""titlecolor=red         color for title\n""gridcolor=blue         color for grid lines\n""style=seismic          normal (axis 1 horizontal, axis 2 vertical) or\n""                       seismic (axis 1 vertical, axis 2 horizontal)\n""\n""AUTHOR:  Dave Hale, Colorado School of Mines, 08/09/90\n""\n";#include "par.h"#include "xplot.h"#include <X11/Xatom.h>#include <X11/keysym.h>/* 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);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(Display *dpy, Window win, XEvent event, int style,	FILE *mpicksfp, int x, int y, int width, int height,	float x1begb, float x1endb, float x2begb, float x2endb);main (argc,argv)int argc; char **argv;{	int n1,n2,n1tic,n2tic,nfloats,wt,va,		i1,i2,grid1,grid2,style,		nz,iz,verbose,		xbox,ybox,wbox,hbox,		xb,yb,wb,hb,		x,y,width,height,		i,j,nx,ny,		imageOutOfDate,winwidth=-1,winheight=-1,		showloc=0;	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;	int scr;	unsigned long black,white;	/* initialize getpar */	initargs(argc,argv);	askdoc(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 (fseek(infp,0L,2)!=0)				err("must specify n2 if in a pipe!\n");			nfloats = eftell(infp)/sizeof(float);			efseek(infp,0L,0);			n2 = 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;	}/* modified by z.li to allow negative d2 *//*	for (i2=1,x2min=x2max=x2[0]; i2<n2; i2++) {		x2min = MIN(x2min,x2[i2]);		x2max = MAX(x2max,x2[i2]);	}*/	x2min=x2[0];	x2max=x2[n2-1];/* modified by z.li to allow negative d2 */	/* set up file to save mouse picks */	if (!getparstring("mpicks", &mpicks)) mpicks = "/dev/tty";		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++)			temp[iz] = fabs(z[iz]);		iz = (nz*perc/100.0);		if (iz<0) iz = 0;		if (iz>nz-1) iz = nz-1;		qkfind(iz,nz,temp);		clip = temp[iz];		free1float(temp);	}	verbose = 1;  getparint("verbose",&verbose);	if (verbose) warn("clip=%g\n",clip);	/* get wiggle-trace-variable-area parameters */	wt = 1;  getparint("wt",&wt);	va = 1;  getparint("va",&va);	xcur = 1.0;  getparfloat("xcur",&xcur);	/* get axes parameters */	xbox = 50; getparint("xbox",&xbox);	ybox = 50; getparint("ybox",&ybox);	wbox = 550; getparint("wbox",&wbox);	hbox = 700; getparint("hbox",&hbox);	x1beg = x1min; getparfloat("x1beg",&x1beg);	x1end = x1max; getparfloat("x1end",&x1end);	d1num = 0.0; getparfloat("d1num",&d1num);	f1num = x1min; getparfloat("f1num",&f1num);	n1tic = 1; getparint("n1tic",&n1tic);	getparstring("grid1",&grid1s);	if (STREQ("dot",grid1s)) grid1 = DOT;	else if (STREQ("dash",grid1s)) grid1 = DASH;	else if (STREQ("solid",grid1s)) grid1 = SOLID;	else grid1 = NONE;	getparstring("label1",&label1);	x2beg = x2min; getparfloat("x2beg",&x2beg);	x2end = x2max; getparfloat("x2end",&x2end);	d2num = 0.0; getparfloat("d2num",&d2num);	f2num = 0.0; getparfloat("f2num",&f2num);	n2tic = 1; getparint("n2tic",&n2tic);	getparstring("grid2",&grid2s);	if (STREQ("dot",grid2s)) grid2 = DOT;	else if (STREQ("dash",grid2s)) grid2 = DASH;	else if (STREQ("solid",grid2s)) grid2 = SOLID;	else grid2 = NONE;	getparstring("label2",&label2);	getparstring("labelfont",&labelfont);	labelsize = 18.0; getparfloat("labelsize",&labelsize);	getparstring("title",&title);	getparstring("titlefont",&titlefont);	titlesize = 24.0; getparfloat("titlesize",&titlesize);	getparstring("style",&styles);	if (STREQ("seismic",styles)) style = SEISMIC;	else err("Sorry, only style=seismic is currently available!");	getparstring("titlecolor",&titlecolor);	getparstring("labelcolor",&labelcolor);	getparstring("gridcolor",&gridcolor);		/* initialize zoom box parameters */	x1begb = x1beg;  x1endb = x1end;	x2begb = x2beg;  x2endb = x2end;	/* connect to X server */	if ((dpy=XOpenDisplay(NULL))==NULL)		err("Cannot connect to display %s!\n",XDisplayName(NULL));	scr = DefaultScreen(dpy);	black = BlackPixel(dpy,scr);	white = WhitePixel(dpy,scr);		/* create window */	win = xNewWindow(dpy,xbox,ybox,wbox,hbox,black,white,"xwigb");			/* make GC for image */	gci = XCreateGC(dpy,win,0,NULL);	/* set normal event mask */	XSelectInput(dpy,win,		StructureNotifyMask |		ExposureMask |		KeyPressMask |		PointerMotionMask |		ButtonPressMask |		ButtonReleaseMask |		Button1MotionMask |		Button2MotionMask);		/* map window */	XMapWindow(dpy,win);		/* clear the window */	XClearWindow(dpy,win);						/* determine good size for axes box */	xSizeAxesBox(dpy,win,		labelfont,titlefont,style,		&x,&y,&width,&height);		/* note that image is out of date */	imageOutOfDate = 1;	/* main event loop */	while(True) {		XNextEvent(dpy,&event);		/* if window was resized */		if (event.type==ConfigureNotify &&			(event.xconfigure.width!=winwidth ||			 event.xconfigure.height!=winheight)) {			winwidth = event.xconfigure.width;			winheight = event.xconfigure.height;										/* determine good size for axes box */			xSizeAxesBox(dpy,win,				labelfont,titlefont,style,				&x,&y,&width,&height);						/* clear the window */			XClearWindow(dpy,win);						/* note that image is out of date */			imageOutOfDate = 1;

⌨️ 快捷键说明

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