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

📄 axesbox.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       *//* AXESBOX: $Revision: 1.11 $ ; $Date: 1997/07/29 15:42:23 $	*//*********************** self documentation **********************//*****************************************************************************AXESBOX - Functions to draw axes in X-windows graphicsxDrawAxesBox	draw a labeled axes boxxSizeAxesBox	determine optimal origin and size for a labeled axes box*****************************************************************************Function Prototypes:void xDrawAxesBox (Display *dpy, Window win,	int x, int y, int width, int height,	float x1beg, float x1end, float p1beg, float p1end,	float d1num, float f1num, int n1tic, int grid1, char *label1,	float x2beg, float x2end, float p2beg, float p2end,	float d2num, float f2num, int n2tic, int grid2, char *label2,	char *labelfont, char *title, char *titlefont, 	char *axescolor, char *titlecolor, char *gridcolor,	int style);void xSizeAxesBox (Display *dpy, Window win, 	char *labelfont, char *titlefont, int style,	int *x, int *y, int *width, int *height);*****************************************************************************xDrawAxesBox:Input:dpy		display pointerwin		windowx		x coordinate of upper left corner of boxy		y coordinate of upper left corner of boxwidth		width of boxheight		height of boxx1beg		axis value at beginning of axis 1x1end		axis value at end of axis 1p1beg		pad value at beginning of axis 1p1end		pad value at end of axis 1d1num		numbered tic increment for axis 1 (0.0 for automatic)f1num		first numbered tic for axis 1n1tic		number of tics per numbered tic for axis 1grid1		grid code for axis 1:  NONE, DOT, DASH, or SOLIDlabel1		label for axis 1x2beg		axis value at beginning of axis 2x2end		axis value at end of axis 2p2beg		pad value at beginning of axis 2p2end		pad value at end of axis 2d2num		numbered tic increment for axis 2 (0.0 for automatic)f2num		first numbered tic for axis 2n2tic		number of tics per numbered tic for axis 2grid2		grid code for axis 2:  NONE, DOT, DASH, or SOLIDlabel2		label for axis 2labelfont	name of font to use for axes labelstitle		axes box titletitlefont	name of font to use for titleaxescolor	name of color to use for axestitlecolor	name of color to use for titlegridcolor	name of color to use for gridint style	NORMAL (axis 1 on bottom, axis 2 on left)		SEISMIC (axis 1 on left, axis 2 on top)******************************************************************************xSizeAxesBox:Input:dpy		display pointerwin		windowlabelfont	name of font to use for axes labelstitlefont	name of font to use for titleint style	NORMAL (axis 1 on bottom, axis 2 on left)		SEISMIC (axis 1 on left, axis 2 on top)Output:x		x coordinate of upper left corner of boxy		y coordinate of upper left corner of boxwidth		width of boxheight		height of box******************************************************************************{	XFontStruct *fa,*ft;******************************************************************************Notes:xDrawAxesBox:will determine the numbered tic incremenet and firstnumbered tic automatically, if the specified increment is zero.Pad values must be specified in the same units as the correspondingaxes values.  These pads are useful when the contents of the axes boxrequires more space than implied by the axes values.  For example,the first and last seismic wiggle traces plotted inside an axes boxwill typically extend beyond the axes values corresponding to thefirst and last traces.  However, all tics will lie within the limitsspecified in the axes values (x1beg, x1end, x2beg, x2end).xSizeAxesBox:is intended to be used prior to xDrawAxesBox.An "optimal" axes box is one that more or less fills the window, with little wasted space around the edges of the window.******************************************************************************Author:		Dave Hale, Colorado School of Mines, 01/27/90*****************************************************************************//**************** end self doc ********************************/#include "xplot.h"voidxDrawAxesBox (Display *dpy, Window win,	int x, int y, int width, int height,	float x1beg, float x1end, float p1beg, float p1end,	float d1num, float f1num, int n1tic, int grid1, char *label1,	float x2beg, float x2end, float p2beg, float p2end,	float d2num, float f2num, int n2tic, int grid2, char *label2,	char *labelfont, char *title, char *titlefont, 	char *axescolor, char *titlecolor, char *gridcolor,	int style)/*****************************************************************************draw a labeled axes box******************************************************************************Input:dpy		display pointerwin		windowx		x coordinate of upper left corner of boxy		y coordinate of upper left corner of boxwidth		width of boxheight		height of boxx1beg		axis value at beginning of axis 1x1end		axis value at end of axis 1p1beg		pad value at beginning of axis 1p1end		pad value at end of axis 1d1num		numbered tic increment for axis 1 (0.0 for automatic)f1num		first numbered tic for axis 1n1tic		number of tics per numbered tic for axis 1grid1		grid code for axis 1:  NONE, DOT, DASH, or SOLIDlabel1		label for axis 1x2beg		axis value at beginning of axis 2x2end		axis value at end of axis 2p2beg		pad value at beginning of axis 2p2end		pad value at end of axis 2d2num		numbered tic increment for axis 2 (0.0 for automatic)f2num		first numbered tic for axis 2n2tic		number of tics per numbered tic for axis 2grid2		grid code for axis 2:  NONE, DOT, DASH, or SOLIDlabel2		label for axis 2labelfont	name of font to use for axes labelstitle		axes box titletitlefont	name of font to use for titleaxescolor	name of color to use for axestitlecolor	name of color to use for titlegridcolor	name of color to use for gridint style	NORMAL (axis 1 on bottom, axis 2 on left)		SEISMIC (axis 1 on left, axis 2 on top)******************************************************************************Notes:xDrawAxesBox will determine the numbered tic incremenet and firstnumbered tic automatically, if the specified increment is zero.Pad values must be specified in the same units as the correspondingaxes values.  These pads are useful when the contents of the axes boxrequires more space than implied by the axes values.  For example,the first and last seismic wiggle traces plotted inside an axes boxwill typically extend beyond the axes values corresponding to thefirst and last traces.  However, all tics will lie within the limitsspecified in the axes values (x1beg, x1end, x2beg, x2end).******************************************************************************Author:		Dave Hale, Colorado School of Mines, 01/27/90*****************************************************************************/{	GC gca,gct,gcg;	XGCValues *values=NULL;	XColor scolor,ecolor;	XFontStruct *fa,*ft;	XWindowAttributes wa;	Colormap cmap;	int labelca,labelcd,labelch,labelcw,titleca,		ntic,xa,ya,tw,ticsize,ticb,numb,labelb,lstr,grided,grid,		n1num,n2num;	float dnum,fnum,dtic,amin,amax,base,scale,anum,atic,azero;	char str[256],dash[2],*label;	/* create graphics contexts */	gca = XCreateGC(dpy,win,0,values);	gct = XCreateGC(dpy,win,0,values);	gcg = XCreateGC(dpy,win,0,values);	/* get and set fonts and determine character dimensions */	fa = XLoadQueryFont(dpy,labelfont);	if (fa==NULL) fa = XLoadQueryFont(dpy,"fixed");	if (fa==NULL) {		fprintf(stderr,"Cannot load/query labelfont=%s\n",labelfont);		exit(-1);	}	XSetFont(dpy,gca,fa->fid);	labelca = fa->max_bounds.ascent;	labelcd = fa->max_bounds.descent;	labelch = fa->max_bounds.ascent+fa->max_bounds.descent;	labelcw = fa->max_bounds.lbearing+fa->max_bounds.rbearing;	ft = XLoadQueryFont(dpy,titlefont);	if (ft==NULL) ft = XLoadQueryFont(dpy,"fixed");	if (ft==NULL) {		fprintf(stderr,"Cannot load/query titlefont=%s\n",titlefont);		exit(-1);	}	XSetFont(dpy,gct,ft->fid);	titleca = ft->max_bounds.ascent;	/* determine window's current colormap */	XGetWindowAttributes(dpy,win,&wa);	cmap = wa.colormap;	/* get and set colors */	if (XAllocNamedColor(dpy,cmap,axescolor,&scolor,&ecolor))		XSetForeground(dpy,gca,ecolor.pixel);	else		XSetForeground(dpy,gca,1L);	if (XAllocNamedColor(dpy,cmap,titlecolor,&scolor,&ecolor))		XSetForeground(dpy,gct,ecolor.pixel);	else		XSetForeground(dpy,gct,1L);	if (XAllocNamedColor(dpy,cmap,gridcolor,&scolor,&ecolor))		XSetForeground(dpy,gcg,ecolor.pixel);	else		XSetForeground(dpy,gcg,1L);	/* determine tic size */	ticsize = labelcw;	/* determine numbered tic intervals */	if (d1num==0.0) {		n1num = (style==NORMAL ? width : height)/(8*labelcw);		scaxis(x1beg,x1end,&n1num,&d1num,&f1num);	}	if (d2num==0.0) {		n2num = (style==NORMAL ? height : width)/(8*labelcw);		scaxis(x2beg,x2end,&n2num,&d2num,&f2num);	}

⌨️ 快捷键说明

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