Ejemplo n.º 1
0
static void
getdata(void)
{
	char *p, buf[1000], buf1[100];
	int ln;

	curfile->lineno = 0;
	printlf(1, curfile->fname);
	while (fgets(buf, sizeof buf, curfile->fin) != NULL) {
		curfile->lineno++;
		if (*buf == '.' && *(buf+1) == 'P' && *(buf+2) == 'S') {
			for (p = &buf[3]; *p == ' '; p++)
				;
			if (*p++ == '<') {
				Infile svfile;
				svfile = *curfile;
				sscanf(p, "%s", buf1);
				if ((curfile->fin=fopen(buf1, "r")) == NULL)
					ERROR "can't open %s", buf1 FATAL;
				curfile->fname = tostring(buf1);
				getdata();
				fclose(curfile->fin);
				free(curfile->fname);
				*curfile = svfile;
				printlf(curfile->lineno, curfile->fname);
				continue;
			}
			reset();
			yyparse();
			anyerr += synerr;
			/* yylval.i now contains 'E' or 'F' from .PE or .PF */

			deltx = (xmax - xmin) / getfval("scale");
			delty = (ymax - ymin) / getfval("scale");
			if (buf[3] == ' ') {	/* next things are wid & ht */
				if (sscanf(&buf[4],"%lf %lf", &deltx, &delty) < 2)
					delty = deltx * (ymax-ymin) / (xmax-xmin);
#if 0
				/* else {
				 *	double xfac, yfac; */
				 *	xfac = deltx / (xmax-xmin);
				 *	yfac = delty / (ymax-ymin);
				 *	if (xfac <= yfac)
				 *		delty = xfac * (ymax-ymin);
				 *	else
				 *		deltx = yfac * (xmax-xmin);
				 *}
				 */
#endif
			}
			dprintf("deltx = %g, delty = %g\n", deltx, delty);
			if (codegen && !synerr) {
				openpl(&buf[3]);	/* puts out .PS, with ht & wid stuck in */
				printlf(curfile->lineno+1, NULL);
				print();	/* assumes \n at end */
				closepl(yylval.i);	/* does the .PE/F */
			}
			printlf(curfile->lineno+1, NULL);
			fflush(stdout);
		} else if (buf[0] == '.' && buf[1] == 'l' && buf[2] == 'f') {
Ejemplo n.º 2
0
void VoronoiDiagramGenerator::plotinit()
{
	float dx,dy,d;
	
	dy = ymax - ymin;
	dx = xmax - xmin;
	d = (float)(( dx > dy ? dx : dy) * 1.1);
	pxmin = (float)(xmin - (d-dx)/2.0);
	pxmax = (float)(xmax + (d-dx)/2.0);
	pymin = (float)(ymin - (d-dy)/2.0);
	pymax = (float)(ymax + (d-dy)/2.0);
	cradius = (float)((pxmax - pxmin)/350.0);
	openpl();
	range(pxmin, pymin, pxmax, pymax);
}
Ejemplo n.º 3
0
void
plotinit(void)
    {
    float dx, dy, d ;

    dy = ymax - ymin ;
    dx = xmax - xmin ;
    d = ( dx > dy ? dx : dy) * 1.1 ;
    pxmin = xmin - (d-dx) / 2.0 ;
    pxmax = xmax + (d-dx) / 2.0 ;
    pymin = ymin - (d-dy) / 2.0 ;
    pymax = ymax + (d-dy) / 2.0 ;
    cradius = (pxmax - pxmin) / 350.0 ;
    openpl() ;
    range(pxmin, pymin, pxmax, pymax) ;
    }
Ejemplo n.º 4
0
openvt(){
openpl();
}
Ejemplo n.º 5
0
obj *
print_obj(int layer, obj *p) {
	double	r, ox, oy, x0, y0, x1, y1;
	obj	*op, *q;
	int	n;

	op = p;
#if 0
/*  4/23/91 -- trying to understand BoundingBox problems */
	if (redo_gbox) {
		float	bnd[4];
		Gbox[2] = Gbox[3] = -(Gbox[0] = Gbox[1] = 32767);
		for (q = objhead->o_next; q != objtail; q = q->o_next) {
			if (q->o_type > TEXT)
				continue;
			get_tot_bounds(q, bnd, 1);
/*			get_bounds(q, bnd, 1);		*/
			track_bounds (bnd[0], bnd[1], bnd[2], bnd[3]);
			if (q->o_type == BLOCK)
				q = q->o_val[N_VAL].o;
		}
		redo_gbox = 0;
	}
#endif
	openpl("");
	if (p->o_type != BLOCK && p->o_layer != layer)
		return p;
	if (p->o_type <= TEXT && (p->o_mxx!=1 || p->o_myy!=1 || p->o_mxy!=0 ||
				  p->o_myx!=0 || p->o_mxt!=0 || p->o_myt!=0))
		return print_xform(layer,p);

	ox = p->o_x;
	oy = p->o_y;
	if (p->o_type < TEXT && (p->o_attr & (FILLED | EDGED)))
		chk_attrs (p);
	switch (p->o_type) {

	case TROFF:
		n = p->o_nt1;
		if (text[n].t_type & EQNTXT)
			puteqn(ox, oy, text[n].t_type, atoi(text[n].t_val));
		else
			troff(text[n].t_val);
		return p;
	case BLOCK:
		for (q = p->o_next; q != p->o_val[N_VAL].o; q = q->o_next)
			if (q->o_type <= TEXT || q->o_nt2 > q->o_nt1)
				q = print_obj(layer,q);
		p = q;
		break;
	case PSFILE:
		puteps(p);
		/* CAREFUL!! THIS FLOWS THROUGH INTO BOX!! */
	case BOX:
		if (p->o_attr & (FILLED|EDGED)) {
			x0 = ox - p->o_wid/2;	x1 = ox + p->o_wid/2;
			y0 = oy - p->o_ht/2;	y1 = oy + p->o_ht/2;
			r  = p->o_val[N_VAL].f;
			box(x0, y0, x1, y1, r);
		}
		break;
	case CIRCLE:
	case ELLIPSE:
		if (p->o_attr & (FILLED|EDGED))
			ellipse(ox,oy,p->o_wid/2,0.,0.,p->o_ht/2,0.,2*M_PI,0);
		break;
	case SECTOR:
	case ARC:
		if (p->o_attr & (FILLED|EDGED)) {
			register double ang1, ang2;

			if (p->o_attr & HEAD12) {
				print_xform(layer, p);
				break;
			}
			r  = p->o_val[N_VAL+0].f;
			x0 = p->o_val[N_VAL+2].f;	/* starting point */
			y0 = p->o_val[N_VAL+3].f;
			x1 = p->o_val[N_VAL+4].f;	/* ending point   */
			y1 = p->o_val[N_VAL+5].f;
			ang1 = atan2(y0-oy, x0-ox);
			ang2 = atan2(y1-oy, x1-ox);
			ellipse(ox, oy, r, 0., 0., r, ang1, ang2, p->o_type);
		}
		break;
	case LINE:
	case ARROW:
	case SPLINE:
		if (p->o_attr & (FILLED|EDGED)) {
			int	c, nxy;

			if (p->o_attr & HEAD12) {
				print_xform(layer, p);
				break;
			}
			r   = p->o_val[N_VAL+0].f;
			nxy = p->o_val[N_VAL+3].f;	    /* segment count */
			x0  = p->o_val[N_VAL+4].f;	    /* first point   */
			y0  = p->o_val[N_VAL+5].f;
			x1  = p->o_val[N_VAL+4+2*nxy].f;    /* last point    */
			y1  = p->o_val[N_VAL+5+2*nxy].f;
			c = (x0 == x1 && y0 == y1);	    /* flags closure */
			if (nxy == 1)
				line(x0, y0, x1, y1);
			else if (p->o_type == SPLINE)
				spline(nxy, c, &p->o_val[N_VAL+4]);
			else
				pline (nxy, c, &p->o_val[N_VAL+4], r);
		}
		break;
	}
	if (op->o_nt1 < op->o_nt2)
		objtext(ox, oy, op);
	return p;
}
Ejemplo n.º 6
0
openpl_()
{
	openpl();
}
Ejemplo n.º 7
0
static void
fplt(FILE *fin)
{
	int c;
	char s[256];
	int xi,yi,x0,y0,x1,y1,r/*,dx,n,i*/;
	/*int pat[256];*/

	openpl();
	while((c=getc(fin)) != EOF){
		switch(c){
		case 'm':
			xi = getsi(fin);
			yi = getsi(fin);
			plot_move(xi,yi);
			break;
		case 'l':
			x0 = getsi(fin);
			y0 = getsi(fin);
			x1 = getsi(fin);
			y1 = getsi(fin);
			line(x0,y0,x1,y1);
			break;
		case 't':
			getstr(s,fin);
			label(s);
			break;
		case 'e':
			plot_erase();
			break;
		case 'p':
			xi = getsi(fin);
			yi = getsi(fin);
			point(xi,yi);
			break;
		case 'n':
			xi = getsi(fin);
			yi = getsi(fin);
			cont(xi,yi);
			break;
		case 's':
			x0 = getsi(fin);
			y0 = getsi(fin);
			x1 = getsi(fin);
			y1 = getsi(fin);
			space(x0,y0,x1,y1);
			break;
		case 'a':
			xi = getsi(fin);
			yi = getsi(fin);
			x0 = getsi(fin);
			y0 = getsi(fin);
			x1 = getsi(fin);
			y1 = getsi(fin);
			arc(xi,yi,x0,y0,x1,y1);
			break;
		case 'c':
			xi = getsi(fin);
			yi = getsi(fin);
			r = getsi(fin);
			circle(xi,yi,r);
			break;
		case 'f':
			getstr(s,fin);
			linemod(s);
			break;
		default:
			fprintf(stderr, "Unknown command %c (%o)\n", c, c);
			break;
			}
		}
	closepl();
}
Ejemplo n.º 8
0
void
openvt(void)
{
	openpl();
}