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

📄 psaxesbox.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
		else	{			sprintf(sformat,"%%.%df",nformat);			sprintf(str,sformat,anumnorm);		}			if (style!=NORMAL) {			moveto(xas,numb);			rotate(90.0);			justshow(-1.0,str);			rotate(-90.0);		}		else   {			moveto(xa,numb);			justshow(-0.5,str);		}				}	/* draw exponential multiplier for axis1 */	if(nexplot1!=0)  {		if(style==NORMAL)   {			moveto(size1,labelb);			show("x10");			moveto(size1+1.5*labelCW,labelb+0.5*labelCA);			sprintf(str2,"%d",nexplot1);			show(str2);		}		else   {			moveto(size1+1.4*labelCH,-2.0*labelCW);			rotate(90.);			show("x10");			rotate(-90.);			moveto(size1+1.05*labelCH,-0.5*labelCW);			sprintf(str2,"%d",nexplot1);			rotate(90.);			show(str2);			rotate(-90.);		}	}	stroke();	/* draw axis1 tick marks */	if(style!=NORMAL)   labelb = numb-0.5*nplacesmax*labelCW;	dtic = dnum/ntic;	for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) {		if (atic<amin) continue;		xa = base+scale*atic;		moveto(xa,0.0);  lineto(xa,ticb/2);	}	stroke();		/* draw axis1 label */	moveto(size1/2.0,labelb);	if(style!=NORMAL)   {		rotate(180.);		justshow(-0.5,label1);		rotate(-180.);	}	else 	justshow(-0.5,label1);	/* draw axis1 grid */	setcolor(gridColor);	setlinewidth(gridwidth);	if (grid1==SOLID) {		grided = 1;		ndash = 0;	} else if (grid1==DASH) {		grided = 1;		ndash = 1;  dash[0] = 10;	} else if (grid1==DOT) {		grided = 1;		ndash = 2;  dash[0] = 1;  dash[1] = 5;	} else		grided = 0;	if (grided) {		for (anum=fnum; anum<=amax; anum+=dnum) {			if (anum<amin) continue;			xa = base+scale*anum;			moveto(xa,0.0);  lineto(xa,size2);		}		setdash(dash,ndash,0.0);		stroke();		setdash(dash,0,0.0);	} 	/* draw axis 2 */	setcolor(axesColor);	setlinewidth(ticwidth);	amin = (x2Beg<x2End)?x2Beg:x2End;	amax = (x2Beg>x2End)?x2Beg:x2End;	azero = 0.0001*(amax-amin);	dnum = d2Num;  fnum = f2Num;  ntic = n2Tic;	scale = size2/(x2End+p2End-x2Beg-p2Beg);	base = -scale*(x2Beg+p2Beg);	ticb = -ticsize;	numb = ticb+labelCD;	labelb = numb-labelCH;		/* determine axis2 exponent for scientific notation   */	ndigits = 0;	ndig    = 0;	fdexp   = log10(1.001*ABS(dnum));	if(fdexp<0.)   fdexp -=1.0;	for (anum=fnum; anum<=amax; anum+=dnum) {		if(anum==fnum && anum==0.)			nexpmax = 0;		nexp    = 0;		if(anum!=0.)   {			fnexp = log10(1.001*ABS(anum));			if(fnexp>0.)   nexp    = (int)fnexp;			else           nexp    = (int)fnexp-1;					if(anum==fnum)				nexpmax = nexp;			if(nexpmax<nexp || nexpmax==0)    				nexpmax = nexp;			ndig = 1+nexp-(int)fdexp;		}		if(ndigits<ndig)   ndigits = ndig;	}	nexplot2 = 0;	if(ABS(nexpmax)>3)   		nexplot2 = nexpmax;	if((nexpmax<0) && (ndigits+ABS(nexpmax))>4)   		nexplot2 = nexpmax;		/* loop for axis 2 numbering */	nplacesmax = 0;	pnorm      = pow(10.0,(double)nexplot2);	azeronorm  = azero/pnorm;	fdexp = log10(1.001*ABS(dnum/pnorm));	if(fdexp<0.)   fdexp -=1.0;	for (anum=fnum; anum<=amax; anum+=dnum) {		if (anum<amin) continue;		ya = base+scale*anum;		moveto(0.0,ya);  lineto(ticb,ya);		anumnorm = anum/pnorm;		yas = ya-0.25*labelCH;			/* find the number of places in axis2 numbers */		nplaces = 1;		nexp    = 1;		if (anumnorm<-azeronorm || anumnorm>azeronorm)   {			fnexp = log10(1.001*ABS(anumnorm));			if(fnexp>0.)   {				nexp    = (int)fnexp;				nplaces = nexp+2;			}			else   {				nexp    = (int)fnexp-1;				nplaces = -nexp+2;			}		}		/* numbers limited to four significant digits */		ndigits = 1+nexp-(int)fdexp;		if(ndigits>4)   ndigits = 4;		if((nexp>=0) && ((ndigits+1)>nplaces))    			nplaces = ndigits+1;		if(anum<0. )   			nplaces +=1;		if(nexp<0)   			nplaces = nplaces+ndigits-1;		if(nplacesmax<nplaces)   			nplacesmax = nplaces;		nformat = ndigits-(nexp+1);		if(nformat<0)   nformat = 0;			if (anumnorm>-azeronorm && anumnorm<azeronorm)			sprintf(str,"%.4g",0.0);		else	{			sprintf(sformat,"%%.%df",nformat);			sprintf(str,sformat,anumnorm);		}		if (style!=NORMAL) {			moveto(numb,ya);			rotate(90.0);			justshow(-0.5,str);			rotate(-90.0);		}		else   {			moveto(numb,yas); 			justshow(-1.,str);		}	}	/* draw exponential multiplier for axis2 */	if(nexplot2!=0)  {		if(style==NORMAL)   {			numb2 = size2+.5*labelCH;			moveto(labelb,numb2);			show("x10");			xb = labelb+1.5*labelCW;			numb2 = numb2+0.5*labelCA;			moveto(xb,numb2);			sprintf(str2,"%d",nexplot2);			show(str2);		}		else   {			moveto(labelb,size2-.5*labelCW);			rotate(90.);			show("x10");			rotate(-90.);			moveto(labelb-.35*labelCH,size2+1.0*labelCW);			sprintf(str2,"%d",nexplot2);			rotate(90.);			show(str2);			rotate(-90.);		}	}	stroke();	/* draw axis2 tick marks */	if(style==NORMAL)   labelb = numb-0.5*nplacesmax*labelCW;		dtic = dnum/ntic;	for (atic=fnum-ntic*dtic-dtic; atic<=amax; atic+=dtic) {		if (atic<amin) continue;		ya = base+scale*atic;		moveto(0.0,ya);  lineto(ticb/2,ya);	}	stroke();		/* draw axis2 label */	moveto(labelb,size2/2.0);	rotate(90.0);	justshow(-0.5,label2);	rotate(-90.0);	/* draw axis2 grid */	setcolor(gridColor);	setlinewidth(gridwidth);	if (grid2==SOLID) {		grided = 1;		ndash = 0;	} else if (grid2==DASH) {		grided = 1;		ndash = 1;  dash[0] = 10;	} else if (grid2==DOT) {		grided = 1;		ndash = 2;  dash[0] = 1;  dash[1] = 5;	} else		grided = 0;	if (grided) {		for (anum=fnum; anum<=amax; anum+=dnum) {			if (anum<amin) continue;			ya = base+scale*anum;			moveto(0.0,ya);  lineto(size1,ya);		}		setdash(dash,ndash,0.0);		stroke();		setdash(dash,0,0.0);	}	/* draw axes box */	setcolor(axesColor);	setlinewidth(axeswidth);	moveto(0.0,0.0);	lineto(size1,0.0);	lineto(size1,size2);	lineto(0.0,size2);	lineto(0.0,0.0);	stroke();	/* draw title */	setcolor(titleColor);	setfont(titleFont,titleSize);	if (style==NORMAL) {		numb2 = size2+0.5*titleCH-titleCD;		if(nexplot2!=0)	numb2 = numb2+.5*(labelCH+labelCA);		moveto(size1/2.0,numb2);		justshow(-0.5,title);	} else {		numb2 = size1+0.5*titleCH+titleCA;		if(nexplot1!=0)	numb2 = numb2+labelCH;		moveto(numb2,size2/2.0);		rotate(90.0);		justshow(-0.5,title);		rotate(-90.0);	}	/* restore graphics state */	grestore();}void psAxesBBox(	float x, float y, float width, float height,	char *labelFont, float labelSize,	char *titleFont, float titleSize,	int style, int bbox[])/*****************************************************************************psAxesBBox - estimate bounding box for an axes box drawn via psAxesBox*****************************************************************************Input:x		x coordinate of lower left corner of boxy		y coordinate of lower left corner of boxwidth		width of boxheight		height of boxlabelFont	name of font to use for axes labelslabelSize	size of font to use for axes labelstitleFont	name of font to use for titletitleSize	size of font to use for titlestyle		NORMAL (axis 1 on bottom, axis 2 on left) 			  SEISMIC (axis 1 on left, axis 2 on top)Output:bbox		bounding box (bbox[0:3] = llx, lly, ulx, uly)*****************************************************************************Notes:psAxesBBox uses font sizes to estimate the bounding box foran axes box drawn with psAxesBox.  To be on the safe side, psAxesBBox overestimates.psAxesBBox assumes that the axes labels and titles do not extendbeyond the corresponding edges of the axes box.*****************************************************************************Author:   Dave Hale,  Colorado School of Mines, 06/27/89Modified: Ken Larner, Colorado School of Mines, 07/24/90****************************************************************************/{	float labelCH,labelCW,titleCH;	/* determine font dimensions */	labelCH = fontheight(labelFont,labelSize);	labelCW = fontwidth(labelFont,labelSize);	titleCH = fontheight(titleFont,titleSize);	/* determine bounding box */	if (style==NORMAL) {		bbox[0] = x-3.5*labelCW-labelCH;		bbox[1] = y-3.0*labelCH;		bbox[2] = x+width+3.0*labelCW;		bbox[3] = y+height+2.0*titleCH+labelCH;	} else {		bbox[0] = x-3.5*labelCW-labelCH;		bbox[1] = y-2.0*titleCH-labelCH;		bbox[2] = x+width+3.0*labelCW;		bbox[3] = y+height+3.0*labelCH;	}}

⌨️ 快捷键说明

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