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

📄 pslegendbox.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
			if(nexpmax<nexp || nexpmax==0)    				nexpmax = nexp;			ndig = 1+nexp-(int)fdexp;		}		if(ndigits<ndig)   ndigits = ndig;	}	nexplot1 = 0;	if(ABS(nexpmax)>3)   		nexplot1 = nexpmax;	if((nexpmax<0) && (ndigits+ABS(nexpmax))>4)   		nexplot1 = nexpmax;		/* loop for axis1 numbering */	nplacesmax = 0;	pnorm      = pow(10.0,(double)nexplot1);	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;		xa = base+scale*anum;		anumnorm = anum/pnorm;		/* find the number of places in axis1 numbers */		nplaces = 1;		nexp    = 1;		nexp    = 0;		if (anumnorm<-azeronorm || anumnorm>azeronorm)   {			fnexp = log10(1.001*ABS(anumnorm));			if(fnexp>0.)   {				nexp    = (int)fnexp;				nplaces = nexp+1;			}			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==VERTLEFT) || (style==VERTRIGHT)) {		  if (ticsside==LEFT) {		    moveto(numb,xa-(labelCA/2.));		    justshow(-1.0,str);		  } else {		    moveto(width-numb,xa-(labelCA/2.));		    justshow(0.0,str);		  }		}		else   {		  moveto(xa,numb);		  justshow(-0.5,str);		}				}	/* draw exponential multiplier for axis1 */	if(nexplot1!=0)  {	  if((style!=VERTLEFT) && (style!=VERTRIGHT))   {	    moveto(width-numb,0);	    show("x10");	    moveto(width-numb+1.5*labelCW,0.5*labelCA);	    sprintf(str2,"%d",nexplot1);	    show(str2);	  }	  else   {	    if (ticsside==LEFT) {	      moveto(-1.5*labelCW,labelb);	      show("x10");	      moveto(0.0,labelb+0.5*labelCA);	      sprintf(str2,"%d",nexplot1);	      show(str2);	    } else {	      moveto(width,labelb);	      show("x10");	      moveto(width+1.5*labelCW,labelb+0.5*labelCA);	      sprintf(str2,"%d",nexplot1);	      show(str2);	    }	  }	}	stroke();	/* draw axis1 tick marks */	if((style==VERTLEFT) || (style==VERTRIGHT)) 	  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;		if ((style==VERTLEFT) || (style==VERTRIGHT)) { /* vertical */		  if (ticsside==LEFT) {		    moveto(0.0,xa); lineto(ticb/2,xa);		  }		  else {		    moveto(width,xa); lineto(width-ticb/2,xa);		  }		} else { /* horizontal */		  moveto(xa,0.0); lineto(xa,ticb/2);		}	}	stroke();	/* draw axis1 label */	if((style!=VERTLEFT) && (style!=VERTRIGHT)) {	  moveto(width/2.0,labelb);   /* TS: 02/10/99: 1.5 -> 2.0 */	  justshow(-0.5,label1);	}	else {	  if (ticsside==LEFT) {	    moveto(labelb+labelCD,height/2.0);	    rotate(90.);	    justshow(-0.5,label1);	    rotate(-90.);	  } else {	    moveto(width-labelb+labelCH,height/2.0);	    rotate(90.);	    justshow(-0.5,label1);	    rotate(-90.);	  }	}	/* draw axis1 grid */	setcolor(gridColor);	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;			if ((style==VERTLEFT) || (style==VERTRIGHT)) { /* vertical */			  moveto(0.0,xa);  lineto(width,xa);			} else { /* horizontal */			  moveto(xa,0.0);  lineto(xa,height);			}		}		setdash(dash,ndash,0.0);		stroke();		setdash(dash,0,0.0);	}		/* draw axes box */	setcolor(axesColor);	moveto(0.0,0.0);	lineto(width,0.0);	lineto(width,height);	lineto(0.0,height);	lineto(0.0,0.0);	stroke();	/* restore graphics state */	grestore();}void psLegendBBox(float x, float y, float width, float height,	char *labelFont, float labelSize,	int style, int bbox[])/*****************************************************************************psLegendBBox - estimate bounding box for an axes box drawn via psLegendBox*****************************************************************************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 labelsstyle		VERTLEFT (Vertical, axis label on left side) 		VERTRIGHT (Vertical, axis label on right side) 		HORIBOTTOM (Horizontal, axis label on bottom)Output:bbox		bounding box (bbox[0:3] = llx, lly, ulx, uly)*****************************************************************************Notes:psLegendBBox uses font sizes to estimate the bounding box fora legend box drawn with psLegendBox.  To be on the safe side, psLegendBBox overestimates.psLegendBBox assumes same calculations like the psLegendBox.*****************************************************************************Author:   Dave Hale,  Colorado School of Mines, 06/27/89Modified: Ken Larner, Colorado School of Mines, 07/24/90Modified: Torsten Schoenfelder, Koeln, Germany, 06/16/97****************************************************************************/{	float labelCH,labelCW,labelCA,labelCD;	/* determine font dimensions */	labelCH = fontheight(labelFont,labelSize);	labelCW = fontwidth(labelFont,labelSize);	labelCA = fontascender(labelFont,labelSize);	labelCD = fontdescender(labelFont,labelSize);	/* determine bounding box */	if ((style==VERTLEFT) || (style==VERTRIGHT)) { /* Vertical */	  bbox[1] = IROUND(y-3.0*labelCH)-1;	  bbox[3] = IROUND(y+height+labelCH)+1;	  if (style==VERTRIGHT) {	    bbox[0] = x-2;	    bbox[2] = IROUND(x+width+4.0*labelCW-labelCD)+1;	  } else {	    /* TS: 02/10/99: 2.36 -> 3.36 */	    bbox[0] = IROUND(x-3.36*labelCW+2.*labelCD-labelCH)-1;	    bbox[2] = x+width+3; /* +1 should be OK, if really needed */	  }	} else { /* Horizontal */	  bbox[0] = IROUND(x-3.5*labelCW-labelCH)-1;	  bbox[1] = IROUND(y-1.36*labelCH-labelCA+labelCD)-1;	  bbox[2] = IROUND(x+width+4.0*labelCW)+1;	  bbox[3] = IROUND(y+height)+2;	}}

⌨️ 快捷键说明

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