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

📄 psgraph.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
				*px2data++ = x2;			}		} else { /* pairs */			register int i;			register float *px1data=x1data[iplot];			register float *px2data=x2data[iplot];			float x1,x2;			if (pairs[iplot]) { /* x1,y1,x2,y2,...,xn,yn */				for (i=0; i<npoint; ++i) {					if (efread(&x1, FSIZE, 1, stdin)!=1)						err("Error reading input!\n");					if (efread(&x2, FSIZE, 1, stdin)!=1)						err("Error reading input!\n");					x1max = MAX(x1, x1max);					x1min = MIN(x1, x1min);					x2max = MAX(x2, x2max);					x2min = MIN(x2, x2min);					*px1data++ = x1;					*px2data++ = x2;				}			} else { /* x1,x2,...,xn,y1,y2,...,yn */				for (i=0; i<npoint; ++i) {					if (efread(&x1, FSIZE, 1, stdin)!=1)						err("Error reading input!\n");					x1max = MAX(x1, x1max);					x1min = MIN(x1, x1min);					*px1data++ = x1;				}				for (i=0; i<npoint; ++i) {					if (efread(&x2, FSIZE, 1, stdin)!=1)						err("Error reading input!\n");					x2max = MAX(x2, x2max);					x2min = MIN(x2, x2min);					*px2data++ = x2;				}			}		}	}	/* cope with special cases */	if (x1min==FLT_MAX) x1min = x1max = 0.0;	if (x2min==FLT_MAX) x2min = x2max = 0.0;	if (x1min == x1max) {		x1min -= 1.0;		x1max += 1.0;	}	if (x2min == x2max) {		x2min -= 1.0;		x2max += 1.0;	}	/* get plotting parameters */	getparstring("label1",&label1);	getparstring("label2",&label2);	getparstring("title",&title);	getparstring("style",&styles);	if (STREQ("normal",styles))		style = NORMAL;	else		style = SEISMIC;	getparstring("labelfont",&labelfont);	getparstring("titlefont",&titlefont);	labelsize = 18.0; getparfloat("labelsize",&labelsize);	titlesize = 24.0; getparfloat("titlesize",&titlesize);	getparstring("titlecolor",&titlecolor);	getparstring("axescolor",&axescolor);	getparstring("gridcolor",&gridcolor);	xbox = 1.5; getparfloat("xbox",&xbox);	ybox = 1.5; getparfloat("ybox",&ybox);	wbox = 6.0; getparfloat("wbox",&wbox);	hbox = 8.0; getparfloat("hbox",&hbox);	x1beg = x1min; getparfloat("x1beg",&x1beg);	x1end = x1max; getparfloat("x1end",&x1end);	x2beg = x2min; getparfloat("x2beg",&x2beg);	x2end = x2max; getparfloat("x2end",&x2end);	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;	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;	for (i=0; i<nplot; i++) {		mark[i] = i%9;		marksize[i] = 0.0;		linewidth[i] = 1.0;		lineon[i] = 1.0;		lineoff[i] = 0.0;		linegray[i] = 0.0;		linecolor[i] = scolor;	}	if ((npar=getparint("mark",mark)))		for (i=npar; i<nplot; ++i)  mark[i] = mark[npar-1];	if ((npar=getparfloat("marksize",marksize)))		for (i=npar; i<nplot; ++i)  marksize[i] = marksize[npar-1];	if ((npar=getparfloat("linewidth",linewidth)))		for (i=npar; i<nplot; ++i)  linewidth[i] = linewidth[npar-1];	if ((npar=getparfloat("lineon",lineon)))		for (i=npar; i<nplot; ++i)  lineon[i] = lineon[npar-1];	if ((npar=getparfloat("lineoff",lineoff)))		for (i=npar; i<nplot; ++i)  lineoff[i] = lineoff[npar-1];	if ((npar=getparfloat("linegray",linegray)))		for (i=npar; i<nplot; ++i)  linegray[i] = linegray[npar-1];	if (getparstring("linecolor",&scolor)) {		int i,j;  char *s;		for (i=0,s=strtok(scolor,","); s!=NULL; ++i,s=strtok(NULL,","))			linecolor[i] = s;		for (j=i-1; i<nplot; ++i)			linecolor[i] = linecolor[j];	}	if(!getparfloat("axeswidth",&axeswidth)) axeswidth=1;	if (!getparfloat("ticwidth",&ticwidth)) ticwidth=axeswidth;	if(!getparfloat("gridwidth",&gridwidth)) gridwidth =axeswidth;;	/* convert box parameters from inches to points */	xbox *= 72.0;	ybox *= 72.0;	wbox *= 72.0;	hbox *= 72.0;	/* set bounding box */	psAxesBBox(		xbox,ybox,wbox,hbox,		labelfont,labelsize,		titlefont,titlesize,		style,bbox);	boundingbox(bbox[0],bbox[1],bbox[2],bbox[3]);	/* begin PostScript */	begineps();	/* save graphics state */	gsave();	/* set clip */	rectclip(xbox,ybox,wbox,hbox);	/* determine axes sizes */	xsize = (style==NORMAL)?wbox:hbox;	ysize = (style==NORMAL)?hbox:wbox;	/* translate coordinate system by box offset */	translate(xbox,ybox);	/* if style is not normal, rotate coordinate system */	if (style!=NORMAL) {		rotate(-90.0);		translate(-hbox,0.0);	}		/* always use beveled joins of line segments */	setlinejoin(2);	/* determine x and y scale factors */	xscale = xsize/(x1end-x1beg);	yscale = ysize/(x2end-x2beg);	/* draw the plots */	/* Plot in fwd or reverse order. JGHACK ......here...........*/	if (plot_direction==1) {	  nplot_start=0;	  nplot_end=nplot-1;	} else {	  nplot_start=nplot-1;	  nplot_end=0;	}	for (iplot=nplot_start; (plot_direction==1) ? (iplot<=nplot_end) : (iplot>=nplot_end); 			   iplot+=plot_direction) {	        /* ......to here */	        register int j;		register int ni = n[iplot];		register float *px1data = x1data[iplot];		register float *px2data = x2data[iplot];		float *x1 = ealloc1float(ni);		float *x2 = ealloc1float(ni);		/* translate and scale */		for (j=0; j<ni; ++j) {			x1[j] = (*px1data++ - x1beg)*xscale;			x2[j] = (*px2data++ - x2beg)*yscale;		}		/* plot */		gsave();		if (linewidth[iplot]!=0.0) {			setlinewidth(linewidth[iplot]);			if (lineoff[iplot]!=0.0){				dash[0] = lineon[iplot];				dash[1] = lineoff[iplot];				setdash(dash,2,0.0);			} else {				setdash(dash,0,0.0);			}			if (strcmp(linecolor[iplot],"none"))				setcolor(linecolor[iplot]);			else				setgray(linegray[iplot]);			polyline(x1,x2,ni);		}		if (marksize[iplot]!=0.0) {			if (strcmp(linecolor[iplot],"none"))				setcolor(linecolor[iplot]);			else				setgray(linegray[iplot]);			for (j=0; j<ni; ++j)			    markto(x1[j],x2[j],mark[iplot],marksize[iplot]);		}		grestore();		free1float(x1);		free1float(x2);	}	/* restore graphics state */	grestore();	/* draw axes and title */	psAxesBox(		xbox,ybox,wbox,hbox,		x1beg,x1end,0.0,0.0,		d1num,f1num,n1tic,grid1,label1,		x2beg,x2end,0.0,0.0,		d2num,f2num,n2tic,grid2,label2,		labelfont,labelsize,		title,titlefont,titlesize,		titlecolor,axescolor,gridcolor,		ticwidth,axeswidth,gridwidth,		style);	/* end PostScript */	showpage();	endeps();	return 0;}

⌨️ 快捷键说明

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