Ejemplo n.º 1
0
void
newbaseline (
    char *buf			/* whatever followed "x X NewBaseline" */
)


{


    char	*p;			/* for eliminating white space etc. */


/*
 *
 * Called from devcntrl() whenever an "x X NewBaseline" command is recognized. We
 * assume whatever is in *buf is a set of parametric equations that describe the
 * new baseline. Equations for x(t), y(t), dx/dt, and dy/dt must be written in
 * PostScript, bracketed by { and } characters, and supplied in exactly that order.
 * In particular the equation for x must come first in *buf and it ends up as the
 * last one on the stack, while the equation for dy/dt comes last (in *buf) and
 * ends up on the top of the PostScript stack. For example if *buf is given by,
 *
 *	{} {180 mul 3.1416 div cos} {pop 1} {180 mul 3.1416 div sin neg}
 *
 * text will be printed along the curve y = cos(x).
 *
 * Angles given in radians must be converted to degrees for the PostScript trig
 * functions, and things are scaled so that 1 unit maps into 1 inch. In the last
 * example the cosine curve that describes the baseline has an amplitude of 1 inch.
 * As another example of this rather confusing syntax if *buf is,
 *
 *	{} {} {pop 1} {pop 1}
 *
 * the baseline will be the 45 degree line y = x.
 *
 * When any of the four functions is used they're called with a single number on
 * the stack that's equal to the current value of the parameter t. The coordinate
 * system axes run parallel to the PostScript coordinate system that's currently
 * being used.
 *
 */


    for ( p = buf; *p; p++ )		/* eliminate trailing '\n' */
	if ( *p == '\n' )  {
	    *p = '\0';
	    break;
	}   /* End if */

    for ( p = buf; *p && (*p == ' ' || *p == ':'); p++ ) ;

    if ( *p != '\0' )  {		/* something's there */
	endtext();
	getbaseline();
	fprintf(tf, "mark resolution %s newbaseline\n", p);
	t_sf(1);
	resetpos();
    }	/* End if */

}   /* End of newbaseline */
Ejemplo n.º 2
0
void
drawellip (
    int a,
    int b,			/* axes lengths for the ellipse */
    int c
)


{


/*
 *
 * Draws an ellipse having axes lengths horizontally and vertically of a and
 * b. The left side of the ellipse is at the current point. After we're done
 * drawing the path we move the current position to the right side.
 *
 */


    if ( a == 0 && b == 0 )
	return;

    fprintf(tf, "%d %d %d %d D%c\n", hpos, vpos, a, b, c);

    hgoto(hpos + a);			/* where troff expects to be */
    vgoto(vpos);

    resetpos();				/* not sure where the printer is */

}   /* End of drawellip */
Ejemplo n.º 3
0
void
drawline (
    int dx,
    int dy			/* endpoint is (hpos+dx, vpos+dy) */
)


{


/*
 *
 * Draws a line from (hpos, vpos) to (hpos+dx, vpos+dy), and leaves the current
 * position at the endpoint.
 *
 */


    if ( dx == 0 && dy == 0 )
	drawcirc(1, 'c');
    else fprintf(tf, "%d %d %d %d Dl\n", hpos + dx, vpos + dy, hpos, vpos);

    hgoto(hpos+dx);			/* where troff expects to be */
    vgoto(vpos+dy);

    resetpos();				/* not sure where the printer is */

}   /* End of drawline */
Ejemplo n.º 4
0
/******************************************************************************
 函数名称:Get_Passwd
 功能描述:验证密码进入设置POS号状态
 参数描述:
 参数名称:	输入/输出?	类型		描述

 返  回  值:ok(0)-验证成功
				 notok(0xFF)-验证失败

 作      者	:刘及华
 日      期:2005-05-20
 修改历史:
		日期		修改人		修改描述
		------		---------	-------------
******************************************************************************/
INT8U Get_Passwd(void)
{
	INT8U i;
	INT8U key_seq[20];
	INT8S *password = (INT8S *)"22995757";
	INT8U buf[20];

	ToggleWD();

	Lcd_Cls();
	lcddisp(1, 1, "请输入密码: ");

	Beep(50);
	SleepMs(50);
	Beep(50);
	SleepMs(50);
	Beep(50);
	SleepMs(1000);

	for ( i=0; i<8; i++ )			   //取得8个按键输入
	{
		do				   //only accept 0-9, '+', '-'
		{
			key_seq[i] = get_key();
		}while ( !( (key_seq[i]>='0' && key_seq[i]<='9') ) );

		buf[strlen((void *)buf) - 1] = '\0';
		strcat((void *)buf, (void *)"*_");
// 		LCD_Display_Str(2, 0, buf, NORMAL);
		lcddisp(2, 1, buf);

//      OSTimeDlyHMSM(0, 0, 0, 150);
		OSTimeDlyHMSM(0, 0, 0, 100);
	}

	key_seq[i] = '\0';

	if ( strcmp((void *)key_seq, (void *)password) != 0 )	//密码错误
	{
		lcddisp(2, 2, "密码错误");
		OSTimeDlyHMSM(0, 0, 1, 0);
		return notok;
	}

	lcddisp(2, 2, "密码正确");
	lcddisp(3, 0, "执行格式化操作..");

	OS_ENTER_CRITICAL();

	InitImportantParameter();

	OS_EXIT_CRITICAL();

	OSTimeDlyHMSM(0, 0, 1, 0);		//为了显示能看清

	resetpos();

	return ok;
}
Ejemplo n.º 5
0
void
settext(char *buf)


{


    char	*p;


/*
 *
 * Does whatever is needed to ensure any text that follows will be set along the
 * curve described by the PostScript procedures listed in *buf. If *buf doesn't
 * contain anything useful (eg. just a newline) things are restored to whatever
 * they originally were. Doesn't work well if we try to start in the middle of a
 * line of text.
 *
 * The parametric equations needed are,
 *
 *	x = f(t)
 *	y = g(t)
 *	dx/dt = f'(t)
 *	dy/dt = g'(t)
 *
 * and must be given as proper PostScript procedures. The equation for x must come
 * first (ie. it ends up on the bottom of the stack) and the equation for dy/dt
 * must be given last (ie. it ends up on top of the stack). For example if *buf
 * is given by,
 *
 *	{} {180 mul 3.1416 div cos} {pop 1} {180 mul 3.1416 div sin neg}
 *
 * text will be set along the curve y=cos(x).
 *
 */


    endtext();
    getbaseline();

    for ( p = buf; *p && *p == ' '; p++ ) ;

    if ( *p && *p != '\n' )  {
	encoding = maxencoding + 2;
	fprintf(tf, "mark resolution %s newbaseline\n", buf);
    } else encoding = realencoding;

    fprintf(tf, "%d setdecoding\n", encoding);
    resetpos();

}   /* End of settext */
Ejemplo n.º 6
0
void
drawtext (
    char *buf			/* whatever followed "x X DrawText */
)


{


    char	*p;			/* for eliminating white space etc. */


/*
 *
 * Called from devcntrl() whenever an "x X DrawText command is recognized. *buf
 * should contain three arguments in the following order. First comes the text we
 * want to print along the current baseline. Right now the string should be given
 * as a PostScript string using characters '(' and ')' as the delimiters. Next in
 * *buf comes a justification mode that can be the words left, right, or center.
 * Last comes a number that represents the starting value of the parameter t that's
 * given as the argument to the parametric equations that describe the current
 * baseline. For example if *buf is given by,
 *
 *	(hello world) left .5
 *
 * hello world will be printed along the path described by the current baseline
 * and left justified at whatever (x(.5), y(.5)) happens to be. Usually will be
 * preceeded by an "x X NewBaseline" call that defines the current baseline. The
 * origin of the coordinate system used by the parametric equations will be the
 * current point.
 *
 */


    for ( p = buf; *p; p++ )		/* eliminate trailing '\n' */
	if ( *p == '\n' )  {
	    *p = '\0';
	    break;
	}   /* End if */

    for ( p = buf; *p && (*p == ' ' || *p == ':'); p++ ) ;

    if ( *p != '\0' )  {		/* something's there */
	endtext();
	getbaseline();
	xymove(hpos, vpos);
	fprintf(tf, "mark %s drawfunnytext\n", p);
	resetpos();
    }	/* End if */

}   /* End of drawtext */
Ejemplo n.º 7
0
void
drawarc (
    int dx1,
    int dy1,		/* vector from current pos to center */
    int dx2,
    int dy2,		/* from center to end of the arc */
    int c			/* clockwise if c is A */
)


{


/*
 *
 * If c isn't set to 'A' a counter-clockwise arc is drawn from the current point
 * (hpos, vpos) to (hpos+dx1+dx2, vpos+dy1+dy2). The center of the circle is the
 * point (hpos+dx1, vpos+dy1). If c is 'A' the arc goes clockwise from the point
 * (hpos+dx1+dx2, vpos+dy1+dy2) to (hpos, vpos). Clockwise arcs are only needed
 * if we're building a larger path out of pieces that include arcs, and want to
 * have PostScript manage the path for us. Arguments (for a clockwise arc) are
 * what would have been supplied if the arc was drawn in a counter-clockwise
 * direction, and are converted to values suitable for use with PostScript's arcn
 * operator.
 *
 */


    if ( (dx1 != 0 || dy1 != 0) && (dx2 != 0 || dy2 != 0) )
    {
        fprintf(tf, "%d %d %d %d %d %d D%c\n", hpos, vpos, dx1, dy1, dx2, dy2, c);
    }

    hgoto(hpos + dx1 + dx2);		/* where troff expects to be */
    vgoto(vpos + dy1 + dy2);

    resetpos();				/* not sure where the printer is */

}   /* End of drawarc */
Ejemplo n.º 8
0
void
drawspline(


    FILE	*fp,			/* input for point list */
    int		flag			/* flag!=1 connect end points */
)


{


    int		x[100], y[100];
    size_t	i, N;


/*
 *
 * Spline drawing routine for Postscript printers. The complicated stuff is
 * handled by procedure Ds, which should be defined in the library file. I've
 * seen wrong implementations of troff's spline drawing, so fo the record I'll
 * write down the parametric equations and the necessary conversions to Bezier
 * cubic splines (as used in Postscript).
 *
 *
 * Parametric equation (x coordinate only):
 *
 *
 *	    (x2 - 2 * x1 + x0)    2                    (x0 + x1)
 *	x = ------------------ * t   + (x1 - x0) * t + ---------
 *		    2					   2
 *
 *
 * The coefficients in the Bezier cubic are,
 *
 *
 *	A = 0
 *	B = (x2 - 2 * x1 + x0) / 2
 *	C = x1 - x0
 *
 *
 * while the current point is,
 *
 *	current-point = (x0 + x1) / 2
 *
 * Using the relationships given in the Postscript manual (page 121) it's easy to
 * see that the control points are given by,
 *
 *
 *	x0' = (x0 + 5 * x1) / 6
 *	x1' = (x2 + 5 * x1) / 6
 *	x2' = (x1 + x2) / 2
 *
 *
 * where the primed variables are the ones used by curveto. The calculations
 * shown above are done in procedure Ds using the coordinates set up in both
 * the x[] and y[] arrays.
 *
 * A simple test of whether your spline drawing is correct would be to use cip
 * to draw a spline and some tangent lines at appropriate points and then print
 * the file.
 *
 */


    for ( N = 2; N < sizeof(x)/sizeof(x[0]); N++ )
	if (fscanf(fp, "%d %d", &x[N], &y[N]) != 2)
		break;

    x[0] = x[1] = hpos;
    y[0] = y[1] = vpos;

    for (i = 1; i < N; i++)  {
	x[i+1] += x[i];
	y[i+1] += y[i];
    }	/* End for */

    x[N] = x[N-1];
    y[N] = y[N-1];

    for (i = ((flag!=1)?0:1); i < ((flag!=1)?N-1:N-2); i++)
	fprintf(tf, "%d %d %d %d %d %d Ds\n", x[i], y[i], x[i+1], y[i+1], x[i+2], y[i+2]);

    hgoto(x[N]);			/* where troff expects to be */
    vgoto(y[N]);

    resetpos();				/* not sure where the printer is */

}   /* End of drawspline */