[comp.sources.x] v06i017: xfig, Part09/15

argv%turnpike@Sun.COM (Dan Heller) (03/06/90)

Submitted-by: Brian Smith <bvsmith@lbl.gov>
Posting-number: Volume 6, Issue 17
Archive-name: xfig2/part09



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 9 (of 15)."
# Contents:  xfig/draw.c xfig/ellipse.c xfig/glue.c xfig/line.c
#   xfig/read1_3.c
# Wrapped by argv@turnpike on Wed Feb 28 10:53:21 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xfig/draw.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/draw.c'\"
else
echo shar: Extracting \"'xfig/draw.c'\" \(9838 characters\)
sed "s/^X//" >'xfig/draw.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	March 1988.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "object.h"
X#include "paintop.h"
X
Xextern int		pointmarker_shown, compoundbox_shown;
Xextern int		background_color, foreground_color;
Xextern int		radius;
Xextern PIXRECTREC	dot;
X
X/* COMMENTED OUT
Xerase_objects(objects)
XF_compound	*objects;
X{
X	erase_arcs(objects->arcs);
X	erase_ellipses(objects->ellipses);
X	erase_lines(objects->lines);
X	erase_texts(objects->texts);
X	erase_splines(objects->splines);
X	erase_compounds(objects->compounds);
X	}
X*/
X
Xerase_splines(splines)
XF_spline	*splines;
X{
X	F_spline	*s;
X
X	pw_batch_on(canvas_pixwin);
X	for (s = splines; s != NULL; s = s->next) {
X	    if (pointmarker_shown) toggle_splinepointmarker(s);
X	    draw_spline(s, ERASE);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xerase_ellipses(ellipses)
XF_ellipse	*ellipses;
X{
X	F_ellipse	*e;
X
X	pw_batch_on(canvas_pixwin);
X	for (e = ellipses; e != NULL; e = e->next) {
X	    if (pointmarker_shown) toggle_ellipsepointmarker(e);
X	    draw_ellipse(e, background_color);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xerase_arcs(arcs)
XF_arc	*arcs;
X{
X	F_arc	*a;
X
X	pw_batch_on(canvas_pixwin);
X	for (a = arcs; a != NULL; a = a->next) {
X	    if (pointmarker_shown) toggle_arcpointmarker(a);
X	    draw_arc(a, background_color);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xerase_compounds(compounds)
XF_compound	*compounds;
X{
X	F_compound	*c;
X
X	for (c = compounds; c != NULL; c = c->next) {
X	    if (compoundbox_shown) draw_compoundbox(c, INV_PAINT);
X	    erase_compound(c);
X	    };
X	}
X
Xerase_lines(lines)
XF_line	*lines;
X{
X	F_line	*l;
X
X	for (l = lines; l != NULL; l = l->next) {
X	    if (pointmarker_shown) toggle_linepointmarker(l);
X	    draw_line(l, ERASE);
X	    };
X	}
X
Xerase_texts(texts)
XF_text	*texts;
X{
X	F_text	*t;
X
X	for (t = texts; t != NULL; t = t->next) {
X	    draw_text(t, INV_PAINT);
X	    };
X	}
X
X/*
Xdraw_objects(objects)
XF_compound	*objects;
X{
X	draw_arcs(objects->arcs);
X	draw_ellipses(objects->ellipses);
X	draw_lines(objects->lines);
X	draw_texts(objects->texts);
X	draw_splines(objects->splines);
X	draw_compounds(objects->compounds);
X	}
X*/
X
Xdraw_ellipses(ellipses)
XF_ellipse	*ellipses;
X{
X	F_ellipse	*e;
X
X	pw_batch_on(canvas_pixwin);
X	for (e = ellipses; e != NULL; e = e->next) {
X	    draw_ellipse(e, foreground_color);
X	    if (pointmarker_shown) toggle_ellipsepointmarker(e);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xdraw_arcs(arcs)
XF_arc	*arcs;
X{
X	F_arc	*a;
X
X	pw_batch_on(canvas_pixwin);
X	for (a = arcs; a != NULL; a = a->next) {
X	    draw_arc(a, foreground_color);
X	    if (pointmarker_shown) toggle_arcpointmarker(a);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xdraw_lines(lines)
XF_line	*lines;
X{
X	F_line	*l;
X
X	pw_batch_on(canvas_pixwin);
X	for (l = lines; l != NULL; l = l->next) {
X	    draw_line(l, PAINT);
X	    if (pointmarker_shown) 
X		toggle_linepointmarker(l);
X	    }
X	pw_batch_off(canvas_pixwin);
X	}
X
Xdraw_splines(splines)
XF_spline	*splines;
X{
X	F_spline	*s;
X
X	pw_batch_on(canvas_pixwin);
X	for (s = splines; s != NULL; s = s->next) {
X	    draw_spline(s, PAINT);
X	    if (pointmarker_shown) toggle_splinepointmarker(s);
X	    };
X	pw_batch_off(canvas_pixwin);
X	}
X
Xdraw_texts(texts)
XF_text	*texts;
X{
X	F_text	*t;
X
X	for (t = texts; t != NULL; t = t->next) {
X	    draw_text(t, PAINT);
X	    };
X	}
X
Xdraw_compounds(compounds)
XF_compound	*compounds;
X{
X	F_compound	*c;
X
X	for (c = compounds; c != NULL; c = c->next) {
X	    draw_compound(c);
X	    if (compoundbox_shown) draw_compoundbox(c, INV_PAINT);
X	    };
X	}
X
X/*	draw arrow heading from (x1, y1) to (x2, y2)	*/
X
Xdraw_arrow(x1, y1, x2, y2, arrow, op)
Xint	x1, y1, x2, y2, op;
XF_arrow	*arrow;
X{
X	float	x, y, xb, yb, dx, dy, l, sina, cosa;
X	int	xc, yc, xd, yd;
X	float	wid = arrow->wid, ht = arrow->ht;
X
X	dx = x2 - x1;  dy = y1 - y2;
X	l = sqrt((double)(dx*dx + dy*dy));
X	sina = dy / l;  cosa = dx / l;
X	xb = x2*cosa - y2*sina;
X	yb = x2*sina + y2*cosa;
X	x = xb - ht;
X	y = yb - wid / 2;
X	xc = x*cosa + y*sina + .5;
X	yc = -x*sina + y*cosa + .5;
X	y = yb + wid / 2;
X	xd = x*cosa + y*sina + .5;
X	yd = -x*sina + y*cosa + .5;
X	pw_vector(canvas_pixwin, xc, yc, x2, y2, op, (int) arrow->thickness);
X	pw_vector(canvas_pixwin, xd, yd, x2, y2, op, (int) arrow->thickness);
X	}
X
Xdraw_spline(spline, op)
XF_spline	*spline;
Xint		op;
X{
X	if (int_spline(spline))
X	    draw_intspline(spline, op);
X	else if (spline->type == T_CLOSED_NORMAL)
X	    draw_closed_spline(spline, op);
X	else if (spline->type == T_OPEN_NORMAL)
X	    draw_open_spline(spline, op);
X	}
X
X#define		STACK_DEPTH		32
Xtypedef		struct stack {
X			float	x1, y1, x2, y2, x3, y3, x4, y4;
X			}
X		Stack;
Xstatic Stack	stack[20];
Xstatic Stack	*stack_top;
Xstatic int	stack_count;
X
Xclear_stack()
X{
X	stack_top = stack;
X	stack_count = 0;
X	}
X
Xpush(x1, y1, x2, y2, x3, y3, x4, y4)
Xfloat	x1, y1, x2, y2, x3, y3, x4, y4;
X{
X	stack_top->x1 = x1;
X	stack_top->y1 = y1;
X	stack_top->x2 = x2;
X	stack_top->y2 = y2;
X	stack_top->x3 = x3;
X	stack_top->y3 = y3;
X	stack_top->x4 = x4;
X	stack_top->y4 = y4;
X	stack_top++;
X	stack_count++;
X	}
X
Xint
Xpop(x1, y1, x2, y2, x3, y3, x4, y4)
Xfloat	*x1, *y1, *x2, *y2, *x3, *y3, *x4, *y4;
X{
X	if (stack_count == 0) return(0);
X	stack_top--;
X	stack_count--;
X	*x1 = stack_top->x1;
X	*y1 = stack_top->y1;
X	*x2 = stack_top->x2;
X	*y2 = stack_top->y2;
X	*x3 = stack_top->x3;
X	*y3 = stack_top->y3;
X	*x4 = stack_top->x4;
X	*y4 = stack_top->y4;
X	return(1);
X	}
X
Xdraw_line(line, op)
XF_line	*line;
Xint	op;
X{
X	F_point			*point;
X	int			xx, yy, x, y;
X
X	/* added 3/1/89 B.V.Smith */
X	fill_object(line,op);
X
X	if (line->type == T_ARC_BOX)	/* box with rounded corners */
X		{
X		draw_arc_box(line,op);
X		return;
X		}
X
X	point = line->points;
X	x = point->x;
X	y = point->y;
X	if (line->points->next == NULL) { /* A single point */
X		XDrawPoint(tool_d, canvas_pixwin, gccache[op], x, y);
X	    return;
X	    }
X	if (line->back_arrow) /* backward arrow  */
X	    draw_arrow(point->next->x, point->next->y, x, y, 
X		line->back_arrow, op);
X	for (point = point->next; point != NULL; point = point->next) {
X	    draw_line_segment(line->style, line->style_val, 
X				x, y, point->x, point->y, op, line->thickness);
X	    xx = x; yy = y;
X	    x = point->x;
X	    y = point->y;
X	    }
X	if (line->for_arrow) 
X	    draw_arrow(xx, yy, x, y, line->for_arrow, op);
X	}
X
X#define		round(x)	((int)((x) + .5))
X#define		dash_length	style_val
X#define		dot_gap		style_val
X
Xdraw_line_segment(line_style, style_val, x1, y1, x2, y2, op, thick)
Xint	line_style, x1, y1, x2, y2, op, thick;
Xfloat	style_val;
X{
X	switch (line_style) {
X	    case SOLID_LINE :
X		pw_vector(canvas_pixwin, x1, y1, x2, y2, op, thick);
X		break;
X	    case DASH_LINE : {
X		float	x, y, leng, dx, dy, dash_x, dash_y;
X		float	spacing_leng, space_x, space_y;
X		int	num_spacing;
X
X		dx = x2 - x1;
X		dy = y2 - y1;
X		leng = sqrt((double)(dx*dx + dy*dy));
X		if (leng <= dash_length) {
X		    pw_vector(canvas_pixwin, x1, y1, x2, y2, op, thick);
X		    break;
X		    }
X		dash_x = dash_length * dx / leng;
X		dash_y = dash_length * dy / leng;
X		num_spacing = (leng - dash_length) / (2 * dash_length);
X		if (num_spacing == 0)
X			spacing_leng = leng;
X		else
X			spacing_leng = (leng - dash_length * (num_spacing + 1)) /
X				((float)num_spacing);
X		space_x = spacing_leng * dx / leng;
X		space_y = spacing_leng * dy / leng;
X		dx = dash_x + space_x;  dy = dash_y + space_y;
X		for (x = x1, y = y1; leng > 0; 
X			x += dx, y += dy, leng -= dash_length + spacing_leng) {
X		    pw_vector(canvas_pixwin, round(x), round(y), 
X				round(x + dash_x), round(y + dash_y), op, thick);
X		    }
X		break;
X		}
X	    case DOTTED_LINE : {
X		float	x, y, leng, dx, dy, gap_x, gap_y;
X		int	n, color;
X
X		dot_gap += 1.0;
X		dx = x2 - x1;
X		dy = y2 - y1;
X		leng = sqrt((double)(dx*dx + dy*dy)) - 1;
X		n = round(leng/dot_gap);
X		if (op == PAINT)
X		    color = foreground_color;
X		else
X		    color = background_color;
X		if (n <= 1) {
X		    /*
X		    pw_vector(canvas_pixwin, x1, y1, x1, y1, op, thick);
X		    */
X		    pw_put(canvas_pixwin, x1, y1, color, thick);
X		    pw_put(canvas_pixwin, x2, y2, color, thick);
X		    break;
X		    }
X		dot_gap = leng / n;
X		gap_x = dot_gap * dx / leng;
X		gap_y = dot_gap * dy / leng;
X		for (x = x1, y = y1; n-- >= 0; x += gap_x, y += gap_y)
X		    /*
X		    pw_vector(canvas_pixwin,round(x),round(y),round(x),round(y),op,thick);
X		    */
X		    pw_put(canvas_pixwin, round(x), round(y), color, thick);
X		break;
X		}
X	    }
X	}
X
Xdraw_arc_box(line, op)
XF_line *line;
Xint op;
X	{
X	F_point		*point;
X	int		xmin,xmax,ymin,ymax;
X	int		pop, thick, style;
X	float		val;
X	int		radius;
X
X	point = line->points;
X	style = line->style;
X	val   = line->style_val;
X	thick = line->thickness;
X	radius = line->pen;		/* hopefully temporary */
X	pop = (op == ERASE)? background_color: foreground_color;
X
X	xmin = xmax = point->x;
X	ymin = ymax = point->y;
X	while (point->next)		/* find lower left (upper-left on screen) */
X		{			/* and upper right (lower right on screen) */
X		point = point->next;
X		if (point->x < xmin)
X			xmin = point->x;
X		else if (point->x > xmax)
X			xmax = point->x;
X		if (point->y < ymin)
X			ymin = point->y;
X		else if (point->y > ymax)
X			ymax = point->y;
X		}
X	curve(canvas_pixwin, 0, radius, -radius, 0, 1, 1, 1, 
X		xmin+radius, ymin+radius, pop, thick, 0);
X	draw_line_segment(style, val, xmin, ymin+radius, xmin, ymax-radius+1, op, thick);
X	curve(canvas_pixwin, -radius, 0, 0, -radius, 1, 1, 1, 
X		xmin+radius, ymax-radius, pop, thick, 0);
X	draw_line_segment(style, val, xmin+radius, ymax, xmax-radius+1, ymax,op, thick);
X	curve(canvas_pixwin, 0, -radius, radius, 0, 1, 1, 1, 
X		xmax-radius, ymax-radius, pop, thick, 0);
X	draw_line_segment(style, val, xmax, ymax-radius, xmax, ymin+radius-1, op, thick);
X	curve(canvas_pixwin, radius, 0, 0, radius, 1, 1, 1, 
X		xmax-radius, ymin+radius, pop, thick, 0);
X	draw_line_segment(style, val, xmax-radius, ymin, xmin+radius-1, ymin, op, thick);
X	}
END_OF_FILE
if test 9838 -ne `wc -c <'xfig/draw.c'`; then
    echo shar: \"'xfig/draw.c'\" unpacked with wrong size!
fi
# end of 'xfig/draw.c'
fi
if test -f 'xfig/ellipse.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/ellipse.c'\"
else
echo shar: Extracting \"'xfig/ellipse.c'\" \(9940 characters\)
sed "s/^X//" >'xfig/ellipse.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "alloc.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
Xextern int		cur_line_style, line_thickness;
Xextern float		cur_styleval;
Xextern float		cur_angle;
Xextern int		cur_color;
Xextern int		cur_areafill;
Xextern int		fill_mode;
Xextern int		fix_x, fix_y, cur_x, cur_y;
X
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
Xextern F_compound	objects;
X
X/*************************  local procedures  ********************/
X
X			init_ellipsebyradius_drawing();
X			init_ellipsebydiameter_drawing();
X			init_circlebyradius_drawing();
X			init_circlebydiameter_drawing();
X			move_ebrbox(), move_ebdbox();
X			move_cbrbox(), move_cbdbox();
Xint			create_ellipsebydia();
Xint			create_ellipsebyrad();
Xint			create_circlebyrad();
Xint			create_circlebydia();
X
X#define		round(z)	(int)((z)+.5)
X
Xcenter_marker(x, y)
Xint	x, y;
X{
X	pw_vector(canvas_pixwin, x, y-2, x, y+2, INV_PAINT, 1);
X	pw_vector(canvas_pixwin, x-2, y, x+2, y, INV_PAINT, 1);
X	}
X
Xellipsebyradius_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_ellipsebyradius_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_ellipsebyradius_drawing(x, y)
Xint	x, y;
X{
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	center_marker(fix_x, fix_y);
X	canvas_locmove_proc = move_ebrbox;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	canvas_middlebut_proc = create_ellipsebyrad;
X	set_temp_cursor(&null_cursor);
X	ellipsebyrad_box(INV_PAINT);
X	set_action_on();
X	}
X
Xmove_ebrbox(x, y)
Xint	x, y;
X{
X	ellipsebyrad_box(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	ellipsebyrad_box(INV_PAINT);
X	}
X
Xellipsebyrad_box(op)
Xint	op;
X{
X	register int	x1, y1, x2, y2;
X	int		rx, ry;
X
X	rx = cur_x - fix_x;
X	ry = cur_y - fix_y;
X	x1 = fix_x + rx;
X	x2 = fix_x - rx;
X	y1 = fix_y + ry;
X	y2 = fix_y - ry;
X	draw_rectbox(x1, y1, x2, y2, op, 1);
X	}
X
Xcreate_ellipsebyrad(x, y)
Xint	x, y;
X{
X	F_ellipse	*ellipse;
X
X	ellipsebyrad_box(INV_PAINT);
X	center_marker(fix_x, fix_y);
X	if (NULL == (Ellipse_malloc(ellipse))) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	ellipse->type = T_ELLIPSE_BY_RAD;
X	ellipse->style = cur_line_style;
X	ellipse->thickness = line_thickness;
X	ellipse->style_val = cur_styleval;
X	ellipse->angle = cur_angle;
X	ellipse->color = cur_color;
X	ellipse->depth = 0;
X	ellipse->pen = NULL;
X	/* added 3/1/89 B.V.Smith */
X	ellipse->area_fill = fill_mode? cur_areafill : 0;
X	ellipse->direction = 1;
X	ellipse->center.x = fix_x;
X	ellipse->center.y = fix_y;
X	ellipse->radiuses.x = abs(x - fix_x) +1;
X	ellipse->radiuses.y = abs(y - fix_y) +1;
X	ellipse->start.x = fix_x;
X	ellipse->start.y = fix_y;
X	ellipse->end.x = x;
X	ellipse->end.y = y;
X	ellipse->next = NULL;
X	pw_batch_on(canvas_pixwin);
X	draw_ellipse(ellipse, DRAW);
X	pw_batch_off(canvas_pixwin);
X	clean_up();
X	set_action_object(F_CREATE, O_ELLIPSE);
X	insert_ellipse(&objects.ellipses, ellipse);
X	set_latestellipse(ellipse);
X	set_modifiedflag();
X	ellipsebyradius_drawing_selected();
X	}
X
Xellipsebydiameter_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_ellipsebydiameter_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_ellipsebydiameter_drawing(x, y)
Xint	x, y;
X{
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	center_marker(fix_x, fix_y);
X	canvas_locmove_proc = move_ebdbox;
X	canvas_leftbut_proc = null_proc;
X	canvas_middlebut_proc = create_ellipsebydia;
X	set_temp_cursor(&null_cursor);
X	ellipsebydia_box(INV_PAINT);
X	set_action_on();
X	}
X
Xmove_ebdbox(x, y)
Xint	x, y;
X{
X	ellipsebydia_box(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	ellipsebydia_box(INV_PAINT);
X	}
X
Xellipsebydia_box(op)
Xint	op;
X{
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, op, 1);
X	}
X
Xcreate_ellipsebydia(x, y)
Xint	x, y;
X{
X	F_ellipse	*ellipse;
X
X	ellipsebydia_box(INV_PAINT);
X	center_marker(fix_x, fix_y);
X	if (NULL == (Ellipse_malloc(ellipse))) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	ellipse->type = T_ELLIPSE_BY_DIA;
X	ellipse->style = cur_line_style;
X	ellipse->thickness = line_thickness;
X	ellipse->style_val = cur_styleval;
X	ellipse->angle = cur_angle;
X	ellipse->color = cur_color;
X	ellipse->depth = 0;
X	ellipse->pen = NULL;
X	/* added 3/1/89 B.V.Smith */
X	ellipse->area_fill = fill_mode? cur_areafill : 0;
X	ellipse->direction = 1;
X	ellipse->center.x = (fix_x + x) / 2;
X	ellipse->center.y = (fix_y + y) / 2;
X	ellipse->radiuses.x = abs(ellipse->center.x - fix_x);
X	ellipse->radiuses.y = abs(ellipse->center.y - fix_y);
X	ellipse->start.x = fix_x;
X	ellipse->start.y = fix_y;
X	ellipse->end.x = x;
X	ellipse->end.y = y;
X	ellipse->next = NULL;
X	pw_batch_on(canvas_pixwin);
X	draw_ellipse(ellipse, DRAW);
X	pw_batch_off(canvas_pixwin);
X	clean_up();
X	set_action_object(F_CREATE, O_ELLIPSE);
X	insert_ellipse(&objects.ellipses, ellipse);
X	set_latestellipse(ellipse);
X	set_modifiedflag();
X	ellipsebydiameter_drawing_selected();
X	}
X
X/***************************  circle  section  ************************/
X
Xcirclebyradius_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_circlebyradius_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_circlebyradius_drawing(x, y)
Xint	x, y;
X{
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	center_marker(fix_x, fix_y);
X	canvas_locmove_proc = move_cbrbox;
X	canvas_leftbut_proc = null_proc;
X	canvas_middlebut_proc = create_circlebyrad;
X	set_temp_cursor(&null_cursor);
X	circlebyrad_box(INV_PAINT);
X	set_action_on();
X	}
X
Xmove_cbrbox(x, y)
Xint	x, y;
X{
X	circlebyrad_box(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	circlebyrad_box(INV_PAINT);
X	}
X
Xcirclebyrad_box(op)
Xint	op;
X{
X	register int	x1, y1, x2, y2;
X	int		radius, rx, ry;
X
X	rx = cur_x - fix_x;
X	ry = cur_y - fix_y;
X	radius = round(sqrt((double) (rx*rx + ry*ry)));
X	x1 = fix_x + radius;
X	x2 = fix_x - radius;
X	y1 = fix_y + radius;
X	y2 = fix_y - radius;
X	draw_rectbox(x1, y1, x2, y2, op, 1);
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, op, 1);
X	}
X
Xcreate_circlebyrad(x, y)
Xint	x, y;
X{
X	F_ellipse	*c;
X	int		rx, ry;
X
X	circlebyrad_box(INV_PAINT);
X	center_marker(fix_x, fix_y);
X	if (NULL == (Ellipse_malloc(c))) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	c->type = T_CIRCLE_BY_RAD;
X	c->style = cur_line_style;
X	c->thickness = line_thickness;
X	c->style_val = cur_styleval;
X	c->angle = 0.0;
X	c->color = cur_color;
X	c->depth = 0;
X	c->pen = NULL;
X	/* added 3/1/89 B.V.Smith */
X	c->area_fill = fill_mode? cur_areafill : 0;
X	c->direction = 1;
X	c->center.x = fix_x;
X	c->center.y = fix_y;
X	rx = fix_x - x;  ry = fix_y - y;
X	c->radiuses.x = c->radiuses.y = round(sqrt((double)(rx*rx + ry*ry)));
X	c->start.x = fix_x;
X	c->start.y = fix_y;
X	c->end.x = x;
X	c->end.y = y;
X	c->next = NULL;
X	pw_batch_on(canvas_pixwin);
X	draw_ellipse(c, DRAW);
X	pw_batch_off(canvas_pixwin);
X	clean_up();
X	set_action_object(F_CREATE, O_ELLIPSE);
X	insert_ellipse(&objects.ellipses, c);
X	set_latestellipse(c);
X	set_modifiedflag();
X	circlebyradius_drawing_selected();
X	}
X
Xcirclebydiameter_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_circlebydiameter_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_circlebydiameter_drawing(x, y)
Xint	x, y;
X{
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	center_marker(fix_x, fix_y);
X	canvas_locmove_proc = move_cbdbox;
X	canvas_leftbut_proc = null_proc;
X	canvas_middlebut_proc = create_circlebydia;
X	set_temp_cursor(&null_cursor);
X	circlebydia_box(INV_PAINT);
X	set_action_on();
X	}
X
Xmove_cbdbox(x, y)
Xint	x, y;
X{
X	circlebydia_box(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	circlebydia_box(INV_PAINT);
X	}
X
Xcirclebydia_box(op)
Xint	op;
X{
X	register int	x1, y1, x2, y2;
X	int		radius, rx, ry;
X
X	rx = (cur_x - fix_x) / 2;
X	ry = (cur_y - fix_y) / 2;
X	radius = round(sqrt((double) (rx*rx + ry*ry)));
X	x1 = fix_x + rx + radius;
X	x2 = fix_x + rx - radius;
X	y1 = fix_y + ry + radius;
X	y2 = fix_y + ry - radius;
X	draw_rectbox(x1, y1, x2, y2, op, 1);
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, op, 1);
X	}
X
Xcreate_circlebydia(x, y)
Xint	x, y;
X{
X	F_ellipse	*c;
X	int		rx, ry;
X
X	circlebydia_box(INV_PAINT);
X	center_marker(fix_x, fix_y);
X	if (NULL == (Ellipse_malloc(c))) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	c->type = T_CIRCLE_BY_DIA;
X	c->style = cur_line_style;
X	c->thickness = line_thickness;
X	c->style_val = cur_styleval;
X	c->angle = 0.0;
X	c->color = cur_color;
X	c->depth = 0;
X	c->pen = NULL;
X	/* added 3/1/89 B.V.Smith */
X	c->area_fill = fill_mode? cur_areafill : 0;
X	c->direction = 1;
X	c->center.x = (fix_x + x) / 2 + .5;
X	c->center.y = (fix_y + y) / 2 + .5;
X	rx = x - c->center.x;  ry = y - c->center.y;
X	c->radiuses.x = c->radiuses.y = round(sqrt((double)(rx*rx + ry*ry)));
X	c->start.x = fix_x;
X	c->start.y = fix_y;
X	c->end.x = x;
X	c->end.y = y;
X	c->next = NULL;
X	pw_batch_on(canvas_pixwin);
X	draw_ellipse(c, DRAW);
X	pw_batch_off(canvas_pixwin);
X	clean_up();
X	set_action_object(F_CREATE, O_ELLIPSE);
X	insert_ellipse(&objects.ellipses, c);
X	set_latestellipse(c);
X	set_modifiedflag();
X	circlebydiameter_drawing_selected();
X	}
X
Xdraw_ellipse(e, op)
XF_ellipse	*e;
Xint		op;
X{
X	int	a, b;
X
X	a = e->radiuses.x;
X	b = e->radiuses.y;
X	curve(canvas_pixwin, a, 0, a, 0, e->direction, (b*b), (a*a), 
X		e->center.x, e->center.y, op, e->thickness, e->area_fill);
X	}
END_OF_FILE
if test 9940 -ne `wc -c <'xfig/ellipse.c'`; then
    echo shar: \"'xfig/ellipse.c'\" unpacked with wrong size!
fi
# end of 'xfig/ellipse.c'
fi
if test -f 'xfig/glue.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/glue.c'\"
else
echo shar: Extracting \"'xfig/glue.c'\" \(11029 characters\)
sed "s/^X//" >'xfig/glue.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "alloc.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
X#define			TOLERANCE	7
X#define			min(a, b)	(((a) < (b)) ? (a) : (b))
X#define			max(a, b)	(((a) > (b)) ? (a) : (b))
X
Xextern F_pos		last_position, new_position;  /* undo.c   */
Xextern int		fix_x, fix_y, cur_x, cur_y;
X
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
Xextern F_compound	objects;
Xextern int		compoundbox_shown;
Xextern int		pointmarker_shown;
Xextern int		foreground_color, background_color;
X
X			create_compound();
XF_compound		*compound_point_search();
X
X			init_create_compound();
X
Xcompound_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_create_compound;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_create_compound(x, y)
Xint	x, y;
X{
X	init_box_drawing(x, y);
X	canvas_middlebut_proc = create_compound;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	}
X
Xcreate_compound(x, y)
Xint	x, y;
X{
X	F_compound	*c;
X
X	if (NULL == (Compound_malloc(c))) {
X	    put_msg(Err_mem);
X	    return;
X	    }
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X	c->nwcorner.x = min(fix_x, x);
X	c->nwcorner.y = min(fix_y, y);
X	c->secorner.x = max(fix_x, x);
X	c->secorner.y = max(fix_y, y);
X	if (compose_compound(c) == 0) {
X	    free((char*)c);
X	    compound_selected();
X	    put_msg("Empty compound, ignore");
X	    return;
X	    }
X	draw_compoundbox(c, INV_PAINT);
X	c->next = NULL;
X	clean_up();
X	set_action(F_GLUE);
X	insert_compound(&objects.compounds, c);
X	set_latestcompound(c);
X	compound_selected();
X	}
X
Xcompose_compound(c)
XF_compound	*c;
X{
X	c->ellipses = NULL;
X	c->lines = NULL;
X	c->texts = NULL;
X	c->splines = NULL;
X	c->arcs = NULL;
X	c->compounds = NULL;
X	get_ellipse(&c->ellipses, c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y);
X	get_lineobj(&c->lines, c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y);
X	get_spline(&c->splines, c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y);
X	get_text(&c->texts, c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y);
X	get_arc(&c->arcs, c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y);
X	get_compound(&c->compounds, c->nwcorner.x, c->nwcorner.y,
X		     c->secorner.x, c->secorner.y);
X	/*  get rid of point-marker  */
X	if (pointmarker_shown) toggle_compoundpointmarker(c);
X	if (c->ellipses != NULL) return(1);
X	if (c->splines != NULL) return(1);
X	if (c->lines != NULL) return(1);
X	if (c->texts != NULL) return(1);
X	if (c->arcs != NULL) return(1);
X	if (c->compounds != NULL) return(1);
X	return(0);
X	}
X
Xdraw_compoundbox(c, op)
XF_compound	*c;
Xint		op;
X{
X	draw_rectbox( c->nwcorner.x-1, c->nwcorner.y-1,
X		c->secorner.x+1, c->secorner.y+1, op, 1);
X	draw_rectbox( c->nwcorner.x, c->nwcorner.y,
X		c->secorner.x, c->secorner.y, op, 1);
X	draw_rectbox( c->nwcorner.x+1, c->nwcorner.y+1,
X		c->secorner.x-1, c->secorner.y-1, op, 1);
X	}
X
Xget_ellipse(list, xmin, ymin, xmax, ymax)
XF_ellipse	**list;
Xint		xmin, ymin, xmax, ymax;
X{
X	F_ellipse	*e, *ee, *ellipse;
X
X	for (e = objects.ellipses; e != NULL;) {
X	    if (xmin > e->center.x - e->radiuses.x) { 
X		ee = e; e = e->next; continue;
X		}
X	    if (xmax < e->center.x + e->radiuses.x) {
X		ee = e; e = e->next; continue;
X		}
X	    if (ymin > e->center.y - e->radiuses.y) {
X		ee = e; e = e->next; continue;
X		}
X	    if (ymax < e->center.y + e->radiuses.y) {
X		ee = e; e = e->next; continue;
X		}
X	    ellipse = e;
X	    if (e == objects.ellipses) 
X		e = objects.ellipses = objects.ellipses->next;
X	    else {
X		e = ee->next = e->next;
X		}
X	    ellipse->next = *list;
X	    *list = ellipse;
X	    }
X	}
X
Xget_arc(list, xmin, ymin, xmax, ymax)
XF_arc	**list;
Xint		xmin, ymin, xmax, ymax;
X{
X	F_arc	*a, *arc, *aa;
X	int	urx, ury, llx, lly;
X
X	for (a = objects.arcs; a != NULL;) {
X	    arc_bound(a, &llx, &lly, &urx, &ury);
X	    if (xmin > llx) goto out;
X	    if (xmax < urx) goto out;
X	    if (ymin > lly) goto out;
X	    if (ymax < ury) goto out;
X	    arc = a;
X	    if (a == objects.arcs) 
X		a = objects.arcs = objects.arcs->next;
X	    else
X		a = aa->next = a->next;
X	    arc->next = *list;
X	    *list = arc;
X	    continue;
X	out:
X	    aa = a; a = a->next;
X	    }
X	}
X
Xget_lineobj(list, xmin, ymin, xmax, ymax)
XF_line	**list;
Xint	xmin, ymin, xmax, ymax;
X{
X	F_line	*line, *l, *ll;
X	F_point	*p;
X	int	inbound;
X
X	for (l = objects.lines; l != NULL;) {
X	    for (inbound = 1, p = l->points; p!= NULL && inbound; 
X			p = p->next) {
X		inbound = 0;
X		if (xmin > p->x) continue;
X		if (xmax < p->x) continue;
X		if (ymin > p->y) continue;
X		if (ymax < p->y) continue;
X		inbound = 1;
X		}
X	    if (! inbound) {
X		ll = l; l = l->next; continue;
X		}
X	    line = l;
X	    if (l == objects.lines) 
X		l = objects.lines = objects.lines->next;
X	    else
X		l = ll->next = l->next;
X	    line->next = *list;
X	    *list = line;
X	    }
X	}
X
Xget_spline(list, xmin, ymin, xmax, ymax)
XF_spline	**list;
Xint		xmin, ymin, xmax, ymax;
X{
X	F_spline	*spline, *s, *ss;
X	int		urx, ury, llx, lly;
X
X	for (s = objects.splines; s != NULL;) {
X	    spline_bound(s, &llx, &lly, &urx, &ury);
X	    if (xmin > llx) goto out;
X	    if (xmax < urx) goto out;
X	    if (ymin > lly) goto out;
X	    if (ymax < ury) goto out;
X	    spline = s;
X	    if (s == objects.splines) 
X		s = objects.splines = objects.splines->next;
X	    else
X		s = ss->next = s->next;
X	    spline->next = *list;
X	    *list = spline;
X	    continue;
X	out:
X	    ss = s; s = s->next;
X	    }
X	}
X
Xget_text(list, xmin, ymin, xmax, ymax)
XF_text	**list;
Xint	xmin, ymin, xmax, ymax;
X{
X	int halflen;
X	F_text	*text, *t, *tt;
X
X	for (t = objects.texts; t != NULL;) {
X	    halflen = t->length/2;
X	    if ( ((t->type == T_LEFT_JUSTIFIED) && xmin > t->base_x) ||
X	        ((t->type == T_CENTER_JUSTIFIED) && xmin > t->base_x - halflen) ||
X	        ((t->type == T_RIGHT_JUSTIFIED) && xmin > t->base_x - t->length) )
X			{
X			tt = t; t = t->next ; continue;
X			}
X	    if ( ((t->type == T_LEFT_JUSTIFIED) && xmax < t->base_x + t->length) ||
X	        ((t->type == T_CENTER_JUSTIFIED) && xmax < t->base_x + halflen) ||
X	        ((t->type == T_RIGHT_JUSTIFIED) && xmax < t->base_x) )
X			{
X			tt = t; t = t->next ; continue;
X			}
X	    if (ymin > t->base_y - t->height) {
X		tt = t; t = t->next; continue;
X		}
X	    if (ymax < t->base_y) {
X		tt = t; t = t->next; continue;
X		}
X	    text = t;
X	    if (t == objects.texts) 
X		t = objects.texts = objects.texts->next;
X	    else
X		t = tt->next = t->next;
X	    text->next = *list;
X	    *list = text;
X	    }
X	}
X
Xget_compound(list, xmin, ymin, xmax, ymax)
XF_compound	**list;
Xint	xmin, ymin, xmax, ymax;
X{
X	F_compound	*compd, *c, *cc;
X	for (c = objects.compounds; c != NULL;)
X	{
X		if (xmin > c->nwcorner.x)
X		{
X			cc = c;
X			c = c->next;
X			continue;
X		}
X		if (xmax < c->secorner.x)
X		{
X			cc = c;
X			c = c->next;
X			continue;
X		}
X		if (ymin > c->nwcorner.y)
X		{
X			cc = c;
X			c = c->next;
X			continue;
X		}
X		if (ymax < c->secorner.y)
X		{
X			cc = c;
X			c = c->next;
X			continue;
X		}
X		compd = c;
X		if (c == objects.compounds) 
X			c = objects.compounds = objects.compounds->next;
X		else
X			c = cc->next = c->next;
X		compd->next = *list;
X		*list = compd;
X	}
X}
X
XF_compound *
Xcompound_point_search(x, y, tol, px, py)
Xint	x, y, tol, *px, *py;
X{
X	F_compound	*c;
X
X	for (c = objects.compounds; c != NULL; c = c->next) {
X	    if (abs(c->nwcorner.x - x) <= tol && 
X		abs(c->nwcorner.y - y) <= tol) {
X		*px = c->nwcorner.x;
X		*py = c->nwcorner.y;
X		return(c);
X		}
X	    if (abs(c->nwcorner.x - x) <= tol && 
X		abs(c->secorner.y - y) <= tol) {
X		*px = c->nwcorner.x;
X		*py = c->secorner.y;
X		return(c);
X		}
X	    if (abs(c->secorner.x - x) <= tol && 
X		abs(c->nwcorner.y - y) <= tol) {
X		*px = c->secorner.x;
X		*py = c->nwcorner.y;
X		return(c);
X		}
X	    if (abs(c->secorner.x - x) <= tol && 
X		abs(c->secorner.y - y) <= tol) {
X		*px = c->secorner.x;
X		*py = c->secorner.y;
X		return(c);
X		}
X	    }
X	return(NULL);
X	}
X
Xdraw_compound(c)
XF_compound	*c;
X{
X	draw_compoundelements(c, foreground_color, foreground_color,
X				PAINT, PAINT, PAINT, PAINT);
X	}
X
Xerase_compound(c)
XF_compound	*c;
X{
X	draw_compoundelements(c, background_color, background_color,
X				ERASE, ERASE, INV_PAINT, ERASE);
X	}
X
Xdraw_compoundelements(c, arcop, ellipseop, lineop, splineop, textop, compop)
XF_compound	*c;
Xint		arcop, ellipseop, lineop, splineop, textop, compop;
X{
X	F_line		*l;
X	F_spline	*s;
X	F_ellipse	*e;
X	F_text		*t;
X	F_arc		*a;
X	F_compound	*c1;
X	
X	pw_batch_on(canvas_pixwin);
X	for (l = c->lines; l != NULL; l = l->next) {
X	    draw_line(l, lineop);
X	    }
X	for (s = c->splines; s != NULL; s = s->next) {
X	    draw_spline(s, splineop);
X	   } 
X	for (a = c->arcs; a != NULL; a = a->next) {
X	    draw_arc(a, arcop);
X	   } 
X	for (e = c->ellipses; e != NULL; e = e->next) {
X	    draw_ellipse(e, ellipseop);
X	    }
X	for (t = c->texts; t != NULL; t = t->next) {
X	    draw_text(t, textop);
X	    }
X	for (c1 = c->compounds; c1 != NULL; c1 = c1->next) {
X	    draw_compoundbox(c1, INV_PAINT);
X	    compop == ERASE ? erase_compound(c1) : draw_compound(c1);
X	    }
X	pw_batch_off(canvas_pixwin);
X	}
X
XF_compound *
Xcompound_search(x, y, tolerance, px, py)
Xint	x, y, tolerance, *px, *py;
X{
X	F_compound	*c;
X	float		tol2;
X
X	tol2 = tolerance * tolerance;
X	
X	for (c = objects.compounds; c != NULL; c = c->next) {
X	    if (close_to_vector(c->nwcorner.x, c->nwcorner.y, c->nwcorner.x,
X			c->secorner.y, x, y, tolerance, tol2, px, py)) 
X		return(c);
X	    if (close_to_vector(c->secorner.x, c->secorner.y, c->nwcorner.x,
X			c->secorner.y, x, y, tolerance, tol2, px, py)) 
X		return(c);
X	    if (close_to_vector(c->secorner.x, c->secorner.y, c->secorner.x,
X			c->nwcorner.y, x, y, tolerance, tol2, px, py)) 
X		return(c);
X	    if (close_to_vector(c->nwcorner.x, c->nwcorner.y, c->secorner.x,
X			c->nwcorner.y, x, y, tolerance, tol2, px, py)) 
X		return(c);
X	    }
X	return(NULL);
X	}
X
Xtoggle_compoundpointmarker(c)
XF_compound	*c;
X{
X	F_line		*l;
X	F_spline	*s;
X	F_ellipse	*e;
X	F_arc		*a;
X
X	for (l = c->lines; l != NULL; l = l->next) {
X	    toggle_linepointmarker(l);
X	    }
X	for (s = c->splines; s != NULL; s = s->next) {
X	    toggle_splinepointmarker(s);
X	   } 
X	for (a = c->arcs; a != NULL; a = a->next) {
X	    toggle_arcpointmarker(a);
X	   } 
X	for (e = c->ellipses; e != NULL; e = e->next) {
X	    toggle_ellipsepointmarker(e);
X	    }
X	}
X
Xshow_compoundbox()
X{
X	F_compound	*c;
X
X	if (compoundbox_shown) return;
X	compoundbox_shown = 1;
X	for (c = objects.compounds; c != NULL; c = c->next) 
X	    draw_compoundbox(c, INV_PAINT);
X	}
X
Xerase_compoundbox()
X{
X	F_compound	*c;
X
X	if (! compoundbox_shown) return;
X	compoundbox_shown = 0;
X	for (c = objects.compounds; c != NULL; c = c->next) 
X	    draw_compoundbox(c, INV_PAINT);
X	}
X
X
X
END_OF_FILE
if test 11029 -ne `wc -c <'xfig/glue.c'`; then
    echo shar: \"'xfig/glue.c'\" unpacked with wrong size!
fi
# end of 'xfig/glue.c'
fi
if test -f 'xfig/line.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/line.c'\"
else
echo shar: Extracting \"'xfig/line.c'\" \(10243 characters\)
sed "s/^X//" >'xfig/line.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "alloc.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
Xextern int		fix_x, fix_y, cur_x, cur_y;
Xextern int		fill_mode,cur_areafill;
X
Xextern int		cur_command;
Xextern int		manhattan_mode, mountain_mode;
Xextern int		latexline_mode, latexarrow_mode;
Xextern int		magnet_mode, latexarrow_mode;
Xextern int		autoforwardarrow_mode, autobackwardarrow_mode;
Xextern int		cur_line_style, line_thickness;
Xextern float		cur_styleval;
Xextern int		cur_color;
Xextern F_compound	objects;
Xextern int		num_point;
Xextern int		latex_endpoint();
X
Xextern F_point		*first_point, *cur_point; 
X
X/*************************** locally global variables *********************/
X
Xstatic int		firstx, firsty;
X			init_line_drawing();
X
Xint			create_lineobject();
X			create_latexobject();
X			determine_angle();
X			freehand_elasticline();
X			latex_elasticline();
X			angle0_elasticline(), angle90_elasticline(); 
X			angle45_elasticline(), angle135_elasticline(); 
X			get_direction(), get_intermediatepoint(),
X			get_latexpoint();
X
X/**********************  polyline and polygon section  **********************/
X
Xline_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_line_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_line_drawing(x, y)
Xint	x, y;
X{
X	first_point = Point_malloc(cur_point);
X	if (cur_point == NULL) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	canvas_rightbut_proc = null_proc;
X	set_action_on();
X	cur_point->x = firstx = fix_x = cur_x = x;
X	cur_point->y = firsty = fix_y = cur_y = y;
X	cur_point->next = NULL;
X	num_point = 1;
X	if (latexline_mode || latexarrow_mode) {
X	    canvas_locmove_proc = latex_elasticline;
X	    canvas_leftbut_proc = get_latexpoint;
X	    canvas_middlebut_proc = create_latexobject;
X	    }
X	else if (manhattan_mode || mountain_mode) {
X	    canvas_locmove_proc = determine_angle;
X	    canvas_leftbut_proc = get_direction;
X	    canvas_middlebut_proc = create_lineobject;
X	    }
X	else {
X	    canvas_locmove_proc = freehand_elasticline;
X	    canvas_leftbut_proc = get_intermediatepoint;
X	    canvas_middlebut_proc = create_lineobject;
X	    }
X	set_temp_cursor(&null_cursor);
X	cur_cursor = &null_cursor;
X	draw_elasticline();
X	}
X
Xdraw_elasticline()
X{
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	}
X
Xfreehand_elasticline(x, y)
Xint	x, y;
X{
X	draw_elasticline();
X	cur_x = x;  
X	cur_y = y;
X	draw_elasticline();
X	}
X
Xdraw_latexline()
X{
X	int  x, y;
X	CURSOR c;
X
X	latex_endpoint(fix_x, fix_y, cur_x, cur_y, &x, &y, latexarrow_mode, (magnet_mode)? 5: 1);
X	pw_vector(canvas_pixwin, fix_x, fix_y, x, y, INV_PAINT,1);
X	c = (x == cur_x  &&  y == cur_y)? &null_cursor: &crosshair_cursor;
X	if (c != cur_cursor) {
X	    set_temp_cursor(c);
X	    cur_cursor = c;
X	    }
X	}
X
Xlatex_elasticline(x, y)
Xint	x, y;
X{
X	draw_latexline();
X	cur_x = x;  
X	cur_y = y;
X	draw_latexline();
X	}
X
Xangle0_elasticline(x, y)
Xint	x, y;
X{
X	if (x == cur_x && y == cur_y) return;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	cur_x = x;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	}
X
Xangle90_elasticline(x, y)
Xint	x, y;
X{
X	if (x == cur_x && y == cur_y) return;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	cur_y = y;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	}
X
Xangle45_elasticline(x, y)
Xint	x, y;
X{
X	if (x == cur_x && y == cur_y) return;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	if (abs(x - cur_x) < abs(y - cur_y)) {
X	    cur_x += cur_y - y;
X	    cur_y = y;
X	    }
X	else {
X	    cur_y -= x - cur_x;
X	    cur_x = x;
X	    }
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	}
X
Xangle135_elasticline(x, y)
Xint	x, y;
X{
X	if (x == cur_x && y == cur_y) return;
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	if (abs(x - cur_x) < abs(y - cur_y)) {
X	    cur_x += y - cur_y;
X	    cur_y = y;
X	    }
X	else {
X	    cur_y += x - cur_x;
X	    cur_x = x;
X	    }
X	pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, INV_PAINT,1);
X	win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	}
X
Xget_direction(x, y)
Xint	x, y;
X{
X	(*canvas_locmove_proc) (x, y);
X	canvas_locmove_proc = determine_angle;
X	get_intermediatepoint(cur_x, cur_y);
X	}
X
Xdetermine_angle(x, y)
Xint	x, y;
X{
X	float	angle, dx, dy;
X
X	dx = x - fix_x;  dy = fix_y - y;
X	if (sqrt((double)(dx*dx + dy*dy)) < 7) return;
X	if (dx == 0)
X	    angle = -90;
X	else
X	    angle = 180 * atan((double)(dy / dx)) / 3.1416;
X
X	if (manhattan_mode) {
X	    if (mountain_mode) {
X		if (angle < -67.5) canvas_locmove_proc = angle90_elasticline;
X		else if (angle < -22.5) canvas_locmove_proc = angle135_elasticline;
X		else if (angle <  22.5) canvas_locmove_proc = angle0_elasticline;
X		else if (angle <  67.5) canvas_locmove_proc = angle45_elasticline;
X		else canvas_locmove_proc = angle90_elasticline;
X		}
X	    else {
X		if (angle < -45) canvas_locmove_proc = angle90_elasticline;
X		else if (angle < 45) canvas_locmove_proc = angle0_elasticline;
X		else canvas_locmove_proc = angle90_elasticline;
X		}
X	    }
X	else {
X	    if (angle < 0) canvas_locmove_proc = angle135_elasticline;
X	    else canvas_locmove_proc = angle45_elasticline;
X	    }
X	    
X	(*canvas_locmove_proc)(x, y);
X	}
X
Xget_latexpoint(x, y)
Xint	x, y;
X{
X	draw_latexline();
X	latex_endpoint(fix_x, fix_y, x, y, &cur_x, &cur_y, latexarrow_mode, (magnet_mode)? 5: 1);
X	if (cur_cursor != &null_cursor) {
X	    set_temp_cursor(&null_cursor);
X	    cur_cursor = &null_cursor;
X	    }
X	win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	get_intermediatepoint(cur_x, cur_y);
X	}
X
Xget_intermediatepoint(x, y)
Xint	x, y;
X{
X	draw_elasticline();  /* erase elastic line */
X	cur_x = x;
X	cur_y = y;
X	if (cur_command == F_POLYLINE || cur_command == F_POLYGON)
X	    draw_line_segment(cur_line_style, cur_styleval, fix_x, fix_y, x, y, 
X				PAINT, line_thickness);
X	else
X	    draw_elasticline();
X	num_point++;
X	fix_x = x;
X	fix_y = y;
X	draw_elasticline();
X	append_point(fix_x, fix_y, &cur_point);
X	}
X
Xcreate_latexobject(x, y)
Xint	x, y;
X{
X	if (x != fix_x || y != fix_y || num_point == 1) {
X	    draw_latexline();
X	    latex_endpoint(fix_x, fix_y, x, y, &cur_x, &cur_y, latexarrow_mode, (magnet_mode)? 5: 1);
X	    if (cur_cursor != &null_cursor) {
X		set_temp_cursor(&null_cursor);
X		cur_cursor = &null_cursor;
X		}
X	    win_setmouseposition(canvas_swfd, cur_x, cur_y);
X	    }
X	create_lineobject(cur_x, cur_y);
X	}
X
X/* come here upon pressing middle button (last point of lineobject) */
X
Xcreate_lineobject(x, y)
Xint	x, y;
X{
X	extern F_arrow	*forward_arrow(), *backward_arrow();
X	F_point		*p, *q;
X	F_line		*line;
X	int		dot;
X
X	dot = 0;
X	if (x != fix_x || y != fix_y) {
X	    if( manhattan_mode || mountain_mode )
X		    get_direction(x, y);
X	    else if( latexline_mode || latexarrow_mode )
X		    get_latexpoint(x, y);
X	    else
X		    get_intermediatepoint(x, y);
X	    draw_elasticline();
X	    }
X	else if (num_point == 1) {
X	    dot = 1;
X	    if( manhattan_mode || mountain_mode )
X		    get_direction(x, y);
X	    else if( latexline_mode || latexarrow_mode )
X		    get_latexpoint(x, y);
X	    else
X		    get_intermediatepoint(x, y);
X	    draw_elasticline();
X	    }
X	if (NULL == (Line_malloc(line))) {
X	    put_msg(Err_mem);
X	    line_drawing_selected();
X	    return;
X	    }
X	line->type = T_POLYLINE;
X	line->style = cur_line_style;
X	line->thickness = line_thickness;
X	line->style_val = cur_styleval;
X	line->color = cur_color;
X	line->depth = 0;
X	line->area_fill = 0;
X	line->pen = NULL;
X	line->points = first_point;
X	line->next = NULL;
X	line->for_arrow = NULL;
X	line->back_arrow = NULL;
X	if (cur_command == F_POLYGON) {
X	    if (num_point >= 3) {
X		line->type = T_POLYGON;
X		num_point++;
X		append_point(firstx, firsty, &cur_point);
X		/* added 3/1/89 B.V.Smith */
X		line->area_fill = fill_mode? cur_areafill : 0;
X		fill_object(line,PAINT);
X		draw_line_segment(cur_line_style, cur_styleval, 
X			firstx, firsty, fix_x, fix_y, PAINT, line_thickness);
X		}
X	    }
X	else if (dot) {
X	    pw_vector(canvas_pixwin, fix_x, fix_y, cur_x, cur_y, PAINT, 1);
X	    line->style = SOLID_LINE;
X	    }
X	else if (num_point > 1) {
X	    if (autoforwardarrow_mode) {
X		line->for_arrow = forward_arrow();
X		for (p = line->points; p != cur_point; q = p, p = p->next);
X		draw_arrow(q->x, q->y, p->x, p->y, line->for_arrow, PAINT);
X		}
X	    if (autobackwardarrow_mode) {
X		line->back_arrow = backward_arrow();
X		p = line->points->next;
X		draw_arrow(p->x, p->y, firstx, firsty, line->back_arrow, PAINT);
X		}
X	    }
X	clean_up();
X	set_action_object(F_CREATE, O_POLYLINE);
X	insert_line(&objects.lines, line);
X	set_latestline(line);
X	set_modifiedflag();
X	line_drawing_selected();
X	}
X
Xappend_point(x, y, point)
Xint	x, y;
XF_point	**point;
X{
X	F_point	*p;
X
X	if (NULL == (Point_malloc(p))) {
X	    put_msg(Err_mem);
X	    return;
X	    }
X	p->x = x;
X	p->y = y;
X	p->next = NULL;
X	(*point)->next = p;
X	*point = p;
X	}
X
X
Xfill_object(line, op)
XF_line *line;
Xint op;
X	{
X	int npts,i;
X	struct f_point *pnt;
X	XPoint *points;
X	GC gc;
X
X	if (line->area_fill == 0)
X		return;
X
X	if (op == PAINT)		/* fill */
X		gc = fill_gc[line->area_fill-1];
X	else				/* un-fill */
X		gc = un_fill_gc[line->area_fill-1];
X
X	npts=0;
X	/* count number of points in this object */
X	for (pnt=line->points; pnt != NULL; pnt = pnt->next)
X		npts++;
X	if ((points = (XPoint *) malloc(npts*sizeof(XPoint)))==0)
X		{
X		put_msg(Err_mem);
X		return;
X		}
X	for (pnt=line->points, i=0; i<npts; i++, pnt=pnt->next)
X		{
X		points[i].x = pnt->x;
X		points[i].y = pnt->y;
X		}
X	XFillPolygon(tool_d,canvas_pixwin,gc,points, npts,
X			Complex, CoordModeOrigin);
X	free(points);
X	}
END_OF_FILE
if test 10243 -ne `wc -c <'xfig/line.c'`; then
    echo shar: \"'xfig/line.c'\" unpacked with wrong size!
fi
# end of 'xfig/line.c'
fi
if test -f 'xfig/read1_3.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/read1_3.c'\"
else
echo shar: Extracting \"'xfig/read1_3.c'\" \(9960 characters\)
sed "s/^X//" >'xfig/read1_3.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985, 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : March 1988.
X *
X *	%W%	%G%
X*/
X
X/*******************************************************************/
X/***************       Read version 1.3 format       ***************/
X/*******************************************************************/
X#include "fig.h"
X#include "alloc.h"
X#include "object.h"
X
X/*******    Fig 1.3 subtype of objects    *******/
X#define			DRAW_ELLIPSE_BY_RAD 	1
X#define			DRAW_ELLIPSE_BY_DIA 	2
X#define			DRAW_CIRCLE_BY_RAD 	3
X#define			DRAW_CIRCLE_BY_DIA 	4
X#define			DRAW_CIRCULAR_ARC	5
X#define			DRAW_POLYLINE		6
X#define			DRAW_BOX		7
X#define			DRAW_POLYGON		8
X#define			DRAW_TEXT		9
X#define			DRAW_SPLINE		10
X#define			DRAW_CLOSEDSPLINE	11
X#define			DRAW_COMPOUND		13
X
Xextern F_arrow		*forward_arrow(), *backward_arrow();
Xextern int		figure_modified;
Xextern int		errno;
Xextern char		*sys_errlist[];
Xextern int		sys_nerr, errno;
X
Xstatic F_ellipse	*read_ellipseobject();
Xstatic F_line		*read_lineobject();
Xstatic F_text		*read_textobject();
Xstatic F_spline		*read_splineobject();
Xstatic F_arc		*read_arcobject();
Xstatic F_compound	*read_compoundobject();
X
Xextern int		line_no;
Xextern int		num_object;
X
Xint
Xread_1_3_objects(fp, obj)
XFILE		*fp;
XF_compound	*obj;
X{
X	F_ellipse	*e, *le = NULL;
X	F_line		*l, *ll = NULL;
X	F_text		*t, *lt = NULL;
X	F_spline	*s, *ls = NULL;
X	F_arc		*a, *la = NULL;
X	F_compound	*c, *lc = NULL;
X	int		 n;
X	int		 object, pixperinch, canvaswid, canvasht, coord_sys;
X
X	n = fscanf(fp,"%d%d%d%d\n", &pixperinch, &coord_sys, &canvaswid, &canvasht);
X	if (n != 4) {
X	    put_msg("Incorrect format in the first line in input file");
X	    return(-1);
X	    }
X	obj->nwcorner.x = pixperinch;
X	obj->nwcorner.y = coord_sys;
X	while (fscanf(fp, "%d", &object) == 1) {
X	    switch (object) {
X		case O_POLYLINE :
X		    if ((l = read_lineobject(fp)) == NULL) return(-1);
X		    if (ll)
X			ll = (ll->next = l);
X		    else
X			ll = obj->lines = l;
X		    num_object++;
X		    break;
X		case O_SPLINE :
X		    if ((s = read_splineobject(fp)) == NULL) return(-1);
X		    if (ls)
X			ls = (ls->next = s);
X		    else
X			ls = obj->splines = s;
X		    num_object++;
X		    break;
X		case O_ELLIPSE :
X		    if ((e = read_ellipseobject(fp)) == NULL) return(-1);
X		    if (le)
X			le = (le->next = e);
X		    else
X			le = obj->ellipses = e;
X		    num_object++;
X		    break;
X		case O_ARC :
X		    if ((a = read_arcobject(fp)) == NULL) return(-1);
X		    if (la)
X			la = (la->next = a);
X		    else
X			la = obj->arcs = a;
X		    num_object++;
X		    break;
X		case O_TEXT :
X		    if ((t = read_textobject(fp)) == NULL) return(-1);
X		    if (lt)
X			lt = (lt->next = t);
X		    else
X			lt = obj->texts = t;
X		    num_object++;
X		    break;
X		case O_COMPOUND :
X		    if ((c = read_compoundobject(fp)) == NULL) return(-1);
X		    if (lc)
X			lc = (lc->next = c);
X		    else
X			lc = obj->compounds = c;
X		    num_object++;
X		    break;
X		default:
X		    put_msg("Incorrect object code %d", object);
X		    return(-1);
X		} /*  switch */
X	    } /*  while */
X	if (feof(fp))
X	    return(0);
X	else
X	    return(errno);
X	}
X
Xstatic F_arc *
Xread_arcobject(fp)
XFILE	*fp;
X{
X	F_arc	*a;
X	int	f, b, h, w, n;
X
X	Arc_malloc(a);
X	a->type = T_3_POINTS_ARC;
X	a->color = BLACK;
X	a->depth = 0;
X	a->pen = NULL;
X	a->for_arrow = NULL;
X	a->back_arrow = NULL;
X	a->next = NULL;
X	n = fscanf(fp, " %d %d %d %f %d %d %d %d %d %f %f %d %d %d %d %d %d\n",
X		&a->type, &a->style, &a->thickness, 
X		&a->style_val, &a->direction, &f, &b,
X		&h, &w, &a->center.x, &a->center.y, 
X		&a->point[0].x, &a->point[0].y, 
X		&a->point[1].x, &a->point[1].y, 
X		&a->point[2].x, &a->point[2].y);
X	if (n != 17) {
X	    put_msg("incomplete arc data");
X	    free((char*)a);
X	    return(NULL);
X	    }
X	if (f) {
X	    a->for_arrow = forward_arrow();
X	    a->for_arrow->wid = w;
X	    a->for_arrow->ht = h;
X	    }
X	if (b) {
X	    a->back_arrow = backward_arrow();
X	    a->back_arrow->wid = w;
X	    a->back_arrow->ht = h;
X	    }
X	return(a);
X	}
X
Xstatic F_compound *
Xread_compoundobject(fp)
XFILE	*fp;
X{
X	F_arc		*a, *la = NULL;
X	F_ellipse	*e, *le = NULL;
X	F_line		*l, *ll = NULL;
X	F_spline	*s, *ls = NULL;
X	F_text		*t, *lt = NULL;
X	F_compound	*com, *c, *lc = NULL;
X	int		 n, object;
X
X	Compound_malloc(com);
X	com->arcs = NULL;
X	com->ellipses = NULL;
X	com->lines = NULL;
X	com->splines = NULL;
X	com->texts = NULL;
X	com->compounds = NULL;
X	com->next = NULL;
X	n = fscanf(fp, " %d %d %d %d\n", &com->nwcorner.x, &com->nwcorner.y,
X		&com->secorner.x, &com->secorner.y);
X	if (n != 4) {
X	    put_msg("Incorrect compound object format");
X	    return(NULL);
X	    }
X	while (fscanf(fp, "%d", &object) == 1) {
X	    switch (object) {
X		case O_POLYLINE :
X		    if ((l = read_lineobject(fp)) == NULL) { 
X			free_line(&l);
X			return(NULL);
X			}
X		    if (ll)
X			ll = (ll->next = l);
X		    else
X			ll = com->lines = l;
X		    break;
X		case O_SPLINE :
X		    if ((s = read_splineobject(fp)) == NULL) { 
X			free_spline(&s);
X			return(NULL);
X			}
X		    if (ls)
X			ls = (ls->next = s);
X		    else
X			ls = com->splines = s;
X		    break;
X		case O_ELLIPSE :
X		    if ((e = read_ellipseobject(fp)) == NULL) { 
X			free_ellipse(&e);
X			return(NULL);
X			}
X		    if (le)
X			le = (le->next = e);
X		    else
X			le = com->ellipses = e;
X		    break;
X		case O_ARC :
X		    if ((a = read_arcobject(fp)) == NULL) { 
X			free_arc(&a);
X			return(NULL);
X			}
X		    if (la)
X			la = (la->next = a);
X		    else
X			la = com->arcs = a;
X		    break;
X		case O_TEXT :
X		    if ((t = read_textobject(fp)) == NULL) { 
X			free_text(&t);
X			return(NULL);
X			}
X		    if (lt)
X			lt = (lt->next = t);
X		    else
X			lt = com->texts = t;
X		    break;
X		case O_COMPOUND :
X		    if ((c = read_compoundobject(fp)) == NULL) { 
X			free_compound(&c);
X			return(NULL);
X			}
X		    if (lc)
X			lc = (lc->next = c);
X		    else
X			lc = com->compounds = c;
X		    break;
X		case O_END_COMPOUND :
X		    return(com);
X		} /*  switch */
X	    }
X	if (feof(fp))
X	    return(com);
X	else {
X	    put_msg("Format error: %s", sys_errlist[errno]);
X	    return(NULL);
X	    }
X	}
X
Xstatic F_ellipse *
Xread_ellipseobject(fp)
XFILE	*fp;
X{
X	F_ellipse	*e;
X	int		n, t;
X
X	Ellipse_malloc(e);
X	e->color = BLACK;
X	e->angle = 0.0;
X	e->depth = 0;
X	e->pen = NULL;
X	e->area_fill = NULL;
X	e->next = NULL;
X	n = fscanf(fp," %d %d %d %f %d %d %d %d %d %d %d %d %d\n", 
X		&t, &e->style,
X		&e->thickness, &e->style_val, &e->direction, 
X		&e->center.x, &e->center.y, 
X		&e->radiuses.x, &e->radiuses.y, 
X		&e->start.x, &e->start.y, 
X		&e->end.x, &e->end.y);
X	if (n != 13) {
X	    put_msg("incomplete ellipse data");
X	    free((char*)e);
X	    return(NULL);
X	    }
X	if (t == DRAW_ELLIPSE_BY_RAD)
X	    e->type = T_ELLIPSE_BY_RAD;
X	else if (t == DRAW_ELLIPSE_BY_DIA)
X	    e->type = T_ELLIPSE_BY_DIA;
X	else if (t == DRAW_CIRCLE_BY_RAD)
X	    e->type = T_CIRCLE_BY_RAD;
X	else
X	    e->type = T_CIRCLE_BY_DIA;
X	return(e);
X	}
X
Xstatic F_line *
Xread_lineobject(fp)
XFILE			*fp;
X{
X	F_line	*l;
X	F_point	*p, *q;
X	int	f, b, h, w, n, t, x, y;
X
X	Line_malloc(l);
X	l->color = BLACK;
X	l->depth = 0;
X	l->pen = NULL;
X	l->area_fill = NULL;
X	l->for_arrow = NULL;
X	l->back_arrow = NULL;
X	l->next = NULL;
X	l->points = Point_malloc(p);
X	n = fscanf(fp, " %d %d %d %f %d %d %d %d %d %d", &t, 
X		&l->style, &l->thickness, &l->style_val,
X		&f, &b, &h, &w, &p->x, &p->y);
X	if (n != 10) {
X	    put_msg("incomplete line data");
X	    free((char*)l);
X	    return(NULL);
X	    }
X	if (t == DRAW_POLYLINE)
X	    l->type = T_POLYLINE;
X	else if (t == DRAW_POLYGON)
X	    l->type = T_POLYGON;
X	else
X	    l->type = T_BOX;
X	if (f) {
X	    l->for_arrow = forward_arrow();
X	    l->for_arrow->wid = w;
X	    l->for_arrow->ht = h;
X	    }
X	if (b) {
X	    l->back_arrow = backward_arrow();
X	    l->back_arrow->wid = w;
X	    l->back_arrow->ht = h;
X	    }
X	for (;;) {
X	    if (fscanf(fp, " %d %d", &x, &y) != 2) {
X		put_msg("incomplete line object");
X		free_linestorage(l);
X		return(NULL);
X		}
X	    if (x == 9999) break;
X	    Point_malloc(q);
X	    q->x = x;
X	    q->y = y;
X	    q->next = NULL;
X	    p->next = q;
X	    p = q;
X	    }
X	return(l);
X	}
X
Xstatic F_spline *
Xread_splineobject(fp)
XFILE	*fp;
X{
X	F_spline	*s;
X	F_point		*p, *q;
X	int		f, b, h, w, n, t, x, y;
X
X	Spline_malloc(s);
X	s->color = BLACK;
X	s->depth = 0;
X	s->pen = NULL;
X	s->area_fill = NULL;
X	s->for_arrow = NULL;
X	s->back_arrow = NULL;
X	s->controls = NULL;
X	s->next = NULL;
X	s->points = Point_malloc(p);
X	n = fscanf(fp, " %d %d %d %f %d %d %d %d %d %d", 
X	    	&t, &s->style, &s->thickness, &s->style_val,
X	    	&f, &b,
X	    	&h, &w, &p->x, &p->y);
X	if (n != 10) {
X	    put_msg("incomplete spline data");
X	    free((char*)s);
X	    return(NULL);
X	    }
X	if (t == DRAW_CLOSEDSPLINE)
X	    s->type = T_CLOSED_NORMAL;
X	else
X	    s->type = T_OPEN_NORMAL;
X	if (f) {
X	    s->for_arrow = forward_arrow();
X	    s->for_arrow->wid = w;
X	    s->for_arrow->ht = h;
X	    }
X	if (b) {
X	    s->back_arrow = backward_arrow();
X	    s->back_arrow->wid = w;
X	    s->back_arrow->ht = h;
X	    }
X	for (;;) {
X	    if (fscanf(fp, " %d %d", &x, &y) != 2) {
X		put_msg("incomplete spline object");
X		free_splinestorage(s);
X		return(NULL);
X		};
X	    if (x == 9999) break;
X	    Point_malloc(q);
X	    q->x = x;
X	    q->y = y;
X	    q->next = NULL;
X	    p->next = q;
X	    p = q;
X	    }
X	return(s);
X	}
X
Xstatic F_text *
Xread_textobject(fp)
XFILE	*fp;
X{
X	F_text	*t;
X	int	n;
X	char	buf[128];
X
X	Text_malloc(t);
X	t->type = T_LEFT_JUSTIFIED;
X	t->style = PLAIN;
X	t->color = BLACK;
X	t->depth = 0;
X	t->pen = NULL;
X	t->angle = 0.0;
X	t->next = NULL;
X	n = fscanf(fp," %d %d %d %d %d %d %d %[^\n]", &t->font, 
X		&t->size, &t->style, &t->height, &t->length, 
X		&t->base_x, &t->base_y, buf);
X	if (n != 8) {
X	    put_msg("incomplete text data");
X	    free((char*)t);
X	    return(NULL);
X	    }
X	t->cstring = (char *) calloc((unsigned)(strlen(buf)+1), sizeof(char));
X	if (t->cstring == NULL) {
X	    put_msg(Err_mem);
X	    free((char*) t);
X	    return(NULL);
X	    }
X	strcpy(t->cstring, buf);
X	if (t->size == 0) t->size == 18;
X	return(t);
X	}
END_OF_FILE
if test 9960 -ne `wc -c <'xfig/read1_3.c'`; then
    echo shar: \"'xfig/read1_3.c'\" unpacked with wrong size!
fi
# end of 'xfig/read1_3.c'
fi
echo shar: End of archive 9 \(of 15\).
cp /dev/null ark9isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv@sun.com / argv@ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.