[comp.sources.x] v06i021: xfig, Part13/15

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

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



#! /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 13 (of 15)."
# Contents:  xfig/README.X11 xfig/box.c xfig/changestyle.c xfig/char.c
#   xfig/corner.c xfig/fig.h xfig/fig.icon.X xfig/font.c xfig/grid.c
#   xfig/latex_line.c xfig/list.c xfig/remove.c xfig/search.c
#   xfig/testgc.c xfig/turn.c
# Wrapped by argv@turnpike on Wed Feb 28 10:53:25 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xfig/README.X11' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/README.X11'\"
else
echo shar: Extracting \"'xfig/README.X11'\" \(4436 characters\)
sed "s/^X//" >'xfig/README.X11' <<'END_OF_FILE'
XNOTE: This is version 2.0 of xfig using file protocol (format) 1.4X.
X      It no longer supports SunView!  If you wish to retain compatibility 
X      with SunView, use version 1.4.3.
X
XThis the famous fig program, ported to X11. I have ported version 1.4
Xwith patches for LaTeX line drawing by Frank Schmuck of Cornell.
X
X
XI only added code to it, which means this is a derivative work, so you
Xhave to stick to the terms of redistribution of the SunView version.
XThe copyright belongs to Supoj Sutanthavibul, but the source code for
Xfig (the SunView only version) has been freely available to everyone
Xfor a long time. In particular, it has been available for ftp from
Xsally.utexas.edu and is also stored in the Sun-Spots archive.
XTherefore, I presume that you may also freely redistribute xfig source
Xcode and you should *at least* not remove the copyright notice and not
Xtry to make money selling it. Naturally, everything is provided as is
Xand the user bears all risks of using this software.  Disclaimer:  I am
Xnot a lawyer so none of what I say may have any legal weight.
X
Xxfig 1.4:
X
X> I have chosen to retain compatibility with the SunView version, mainly
X> for sanity; so that I know I haven't changed the modus operandi of the
X> program.  You can compile for SunView simply by editing two lines in
X> the Makefile. You may have to change the paths a little.
X
X* See below under v2.0
X
XUpdating the ruler arrows slows down xfig noticeably. You might want to
Xoptimize the code or make this feature an command line option.
X
XI know there are things that aren't quite right with the program, I
Xdon't have time to fix them properly now.  There are some quirks with
Xthe behaviour of xfig.  Lots of error returns that should be checked
Xare not.
X
XI will gratefully receive bug reports and tune ups but I'm not
Xinterested in taking up maintenance in the long run. (I have to finish
Xa thesis.) In particular reports of little-endian machine versions and
Xweird machines (not Sun or Vax) are interesting to me.
X
XIf you send me bug reports they will probably sit in my mailbox until I
Xhave the time to install them locally. Then it may be some time before
XI post a new version. So it will be best if you also posted your fixes
Xto some public place. As for coordinating and merging fixes, well that
Xwill have to happen by anarchy unless somebody volunteers to be the
Xgrundge.
X
XPlease keep the history and version numbers up to date.
X
XThe fig2latex translator and friends are part of the transfig package
Xfrom Cornell and at the time of writing, were available by ftp from
Xsvax.cs.cornell.edu.
X
X	Ken Yap (ken@cs.rochester.edu)
X	July 1988
X
XHistory:
X
Xxfig 1.4.1:
X
X14 Jul 88	Ken Yap (University of Rochester)
X		Ported to X11. Alpha release.
X
X31 Jul 88	Ken Yap (University of Rochester)
X		Works practically like SunView version now. Beta release.
X
X8 Aug 88	Ken Yap (University of Rochester)
X		Dana Chee of Bellcore contributed lots of cleanups
X		and put right some features I didn't know how
X		to do properly. (Thanks, Dana.) Released to world.
X
Xxfig 1.4.2:
X
X23 Aug 88 	Dana Chee (Bellcore)
X	  	Fixed color, added mouse tracking option.
X
Xxfig 1.4.3:
X
X26 Aug 88 	Dana Chee (Bellcore)
X	  	Added John Kohl's changes to fix color and make
X	  	inverse video work on a monochrome display.
X	  	Allow scaling of compound objects on a side as well as
X	  	a corner.
X	  	Allow compound objects within a compound.
X
Xxfig 2.0:
X
X16 Feb 90	Brian Smith (Lawrence Berkeley Laboratory)
X		Separate program version (2.0) from file format (protocol 
X		  is now 1.4X)
X		Area fill for circles, boxes, etc. with 20 different 
X		  gray shades for Postscript output.
X		35 different fonts - the 35 fonts normally included with
X		  the Laserwriters can be used in figures at any point size.
X		  If there is a corresponding font in X, then the text is shown 
X		  in that font on the screen.
X		Text can be virtually any point size.
X		Left, center and right justification of text.
X		Rounded-corner boxes with any radius of the corners. The "pen"
X		  component of the object is used for the radius (in pixels)
X		Different line thicknesses.
X		Lower button panel for quick access to "save", "chdir", 
X		  etc. functions.
X		Button to change the line thickness of an existing object.
X		Button to change the line type of an existing object.
X		Portrait or landscape print mode.
X
X		Deleted Features:
X
X		f2p (fig to pic) support not updated for above features.
X		Sunview code has been removed.
END_OF_FILE
if test 4436 -ne `wc -c <'xfig/README.X11'`; then
    echo shar: \"'xfig/README.X11'\" unpacked with wrong size!
fi
# end of 'xfig/README.X11'
fi
if test -f 'xfig/box.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/box.c'\"
else
echo shar: Extracting \"'xfig/box.c'\" \(2912 characters\)
sed "s/^X//" >'xfig/box.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 int		cur_color;
Xextern int		cur_areafill;
Xextern int		fill_mode;
Xextern int		fix_x, fix_y, cur_x, cur_y;
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/*************************** locally global procedures *********************/
X
X			elastic_box();
Xint			create_boxobject();
X			init_box_drawing();
X
Xbox_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_box_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_box_drawing(x, y)
Xint	x, y;
X{
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	canvas_locmove_proc = elastic_box;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	canvas_middlebut_proc = create_boxobject;
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X	set_temp_cursor(&null_cursor);
X	set_action_on();
X	}
X
Xdraw_rectbox(x1, y1, x2, y2, op, thick)
Xint	x1, y1, x2, y2, op, thick;
X{
X	pw_vector(canvas_pixwin, x1, y1, x1, y2, op, thick);
X	pw_vector(canvas_pixwin, x1, y2, x2, y2, op, thick);
X	pw_vector(canvas_pixwin, x2, y2, x2, y1, op, thick);
X	pw_vector(canvas_pixwin, x2, y1, x1, y1, op, thick);
X	}
X
Xelastic_box(x, y)
Xint	x, y;
X{
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X	cur_x = x;  
X	cur_y = y;
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X	}
X
Xcreate_boxobject(x, y)
Xint	x, y;
X{
X	F_line	*box;
X	F_point	*point;
X
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X
X	
X	if ((Point_malloc(point)) == NULL) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	point->x = fix_x;
X	point->y = fix_y;
X	point->next = NULL;
X
X	Line_malloc(box);
X	box->type = T_BOX;
X	box->style = cur_line_style;
X	box->thickness = line_thickness;
X	box->color = cur_color;
X	box->depth = NULL;
X	box->pen = NULL;
X	/* added 3/1/89 B.V.Smith */
X	box->area_fill = fill_mode? cur_areafill : 0;
X	box->style_val = cur_styleval;
X	box->for_arrow = NULL;
X	box->back_arrow = NULL;
X	box->points = point;
X	box->next  = NULL;
X	append_point(x, fix_y, &point);
X	append_point(x, y, &point);
X	append_point(fix_x, y, &point);
X	append_point(fix_x, fix_y, &point);
X	draw_line(box, PAINT);
X	clean_up();
X	set_action_object(F_CREATE, O_POLYLINE);
X	insert_line(&objects.lines, box);
X	set_latestline(box);
X	set_modifiedflag();
X	box_drawing_selected();
X	}
END_OF_FILE
if test 2912 -ne `wc -c <'xfig/box.c'`; then
    echo shar: \"'xfig/box.c'\" unpacked with wrong size!
fi
# end of 'xfig/box.c'
fi
if test -f 'xfig/changestyle.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/changestyle.c'\"
else
echo shar: Extracting \"'xfig/changestyle.c'\" \(3025 characters\)
sed "s/^X//" >'xfig/changestyle.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 "font.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
X#define			TOLERANCE	3
X
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			(*return_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
Xextern F_line		*line_search();
Xextern F_arc		*arc_search();
Xextern F_ellipse	*ellipse_search();
Xextern F_spline		*spline_search();
Xextern F_compound	*compound_search();
X
Xextern int		foreground_color, background_color;
Xextern int		compoundbox_shown;
Xextern int		cur_line_style;
Xextern float		cur_styleval;
X
Xextern 			change_style();
X
Xchange_style_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = change_style;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	return_proc = change_style_selected;
X	set_cursor(&pick9_cursor);
X	reset_action_on();
X	}
X
Xchange_style(x, y)
Xint	x, y;
X{
X	F_line		*l;
X	F_arc		*a;
X	F_ellipse	*e;
X	F_spline	*s;
X	F_compound	*c;
X	int		px, py;
X
X	if ((l = line_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    win_setmouseposition(canvas_swfd, px, py);
X	    draw_line(l, ERASE);
X	    l->style = cur_line_style;
X	    l->style_val = cur_styleval;
X	    draw_line(l, PAINT);
X	    clean_up();
X	    set_action_object(F_CHANGE_STYLE, O_POLYLINE);
X	    set_latestline(l);
X	    set_modifiedflag();
X	    }
X	else if ((e = ellipse_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    win_setmouseposition(canvas_swfd, px, py);
X	    pw_batch_on(canvas_pixwin);
X	    draw_ellipse(e, background_color);
X	    e->style = cur_line_style;
X	    e->style_val = cur_styleval;
X	    draw_ellipse(e, foreground_color);
X	    pw_batch_off(canvas_pixwin);
X	    clean_up();
X	    set_action_object(F_CHANGE_STYLE, O_ELLIPSE);
X	    set_latestellipse(e);
X	    set_modifiedflag();
X	    }
X	else if ((a = arc_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    win_setmouseposition(canvas_swfd, px, py);
X	    pw_batch_on(canvas_pixwin);
X	    draw_arc(a, background_color);
X	    a->style = cur_line_style;
X	    a->style_val = cur_styleval;
X	    draw_arc(a, foreground_color);
X	    pw_batch_off(canvas_pixwin);
X	    clean_up();
X	    set_action_object(F_CHANGE_STYLE, O_ARC);
X	    set_latestarc(a);
X	    set_modifiedflag();
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    win_setmouseposition(canvas_swfd, px, py);
X	    pw_batch_on(canvas_pixwin);
X	    draw_spline(s, ERASE);
X	    s->style = cur_line_style;
X	    s->style_val = cur_styleval;
X	    draw_spline(s, PAINT);
X	    pw_batch_off(canvas_pixwin);
X	    clean_up();
X	    set_action_object(F_CHANGE_STYLE, O_SPLINE);
X	    set_latestspline(s);
X	    set_modifiedflag();
X	    }
X	else
X	    return;
X	}
END_OF_FILE
if test 3025 -ne `wc -c <'xfig/changestyle.c'`; then
    echo shar: \"'xfig/changestyle.c'\" unpacked with wrong size!
fi
# end of 'xfig/changestyle.c'
fi
if test -f 'xfig/char.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/char.c'\"
else
echo shar: Extracting \"'xfig/char.c'\" \(3837 characters\)
sed "s/^X//" >'xfig/char.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 *	Febuary 1988.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "font.h"
X#include "paintop.h"
X#include "object.h"
X
Xextern int		cur_x, cur_y;
Xextern int		cur_font, cur_fontsize;
Xextern int		cur_texttype;
X
X#define			BUF_SIZE	400
X	
Xchar			prefix[BUF_SIZE],	/* part of string left of mouse click */
X			suffix[BUF_SIZE];	/* part to right of click */
Xint			leng_prefix, leng_suffix;
X
Xstatic PIXWIN		pw;
Xstatic int		char_ht;
Xstatic int		char_received;
Xstatic int		cbase_x, cbase_y;
Xstatic float		rbase_x, rcur_x;
Xstatic int		obase_x;
X
Xstatic			(*cr_proc)();
X
Xstatic
Xdraw_cursor(x, y)
Xint	x, y;
X{
X	pw_vector(pw, x, y, x, y-char_ht, INV_PAINT, 1);
X	}
X
Xinitialize_char_handler(p, cr, bx, by)
XPIXWIN		p;
Xint		(*cr)();
Xint		bx, by;
X{
Xchar c;
X	pw = p;
X	cr_proc = cr;
X	rbase_x = obase_x = cbase_x = bx;	/* keep real base so dont have roundoff */
X	rcur_x = cur_x;
X	cbase_y = by;
X
X	char_ht = char_height(canvas_font);
X	char_received = 0;
X	turn_on_blinking_cursor(draw_cursor, draw_cursor,
X				cur_x, cur_y, (long)0, (long)700000);
X	}
X
Xterminate_char_handler()
X{
X	turn_off_blinking_cursor();
X	cr_proc = NULL;
X	return(char_received);
X	}
X
Xerase_char_string()
X{
X	pw_text(pw, cbase_x, cbase_y, INV_PAINT, 
X		cur_font, cur_fontsize, prefix);
X	if (leng_suffix) 
X		pw_text(pw, cur_x, cbase_y, INV_PAINT, 
X			cur_font, cur_fontsize, suffix);
X	}
X
Xdraw_char_string()
X{
X	pw_text(pw, cbase_x, cbase_y, INV_PAINT, 
X		cur_font, cur_fontsize, prefix);
X	if (leng_suffix) 
X		pw_text(pw, cur_x, cbase_y, INV_PAINT, 
X			cur_font, cur_fontsize, suffix);
X	move_blinking_cursor(cur_x, cur_y);
X	}
X
Xchar_handler(c)
Xchar	c;
X{
X	int cwidth; 
X
X	if (c == CR) {
X	    erase_char_string();
X	    cr_proc();
X	    }
X	else if (c == DEL || c == CTRL_H) {
X	    if (leng_prefix > 0) {
X		erase_char_string();
X		char_received = 1;
X		cwidth = char_advance(canvas_font,prefix[leng_prefix-1]);
X		if (cur_texttype == T_LEFT_JUSTIFIED)
X		    rcur_x -= cwidth;	/* move the suffix to the left */
X		else if (cur_texttype == T_CENTER_JUSTIFIED)
X		    {
X		    rbase_x += cwidth/2.0;	/* advance right by half cwidth */
X		    rcur_x -= cwidth/2.0;	/* move suffix left half cwidth */
X		    }
X		if (cur_texttype == T_RIGHT_JUSTIFIED)
X		    rbase_x += (float) cwidth;	/* move the prefix to the right */
X		prefix[--leng_prefix] = '\0';
X		cbase_x = rbase_x;		/* fix */
X		cur_x = rcur_x;
X		draw_char_string();
X		}
X	    }
X	else if (c == CTRL_U || c == CTRL_X) {
X	    if (leng_prefix > 0) {
X		erase_char_string();
X		char_received = 1;
X		if (cur_texttype == T_CENTER_JUSTIFIED)
X		    {
X		    while (leng_prefix--) /* subtract half of the character widths */
X			rcur_x -= char_advance(canvas_font,prefix[leng_prefix])/2.0;
X		    cur_x = cbase_x = rbase_x = rcur_x ;
X		    }
X		else if (cur_texttype == T_RIGHT_JUSTIFIED)
X		    cbase_x = rbase_x = cur_x = rcur_x;
X		else
X		    cur_x = rcur_x = cbase_x = rbase_x;
X		leng_prefix = 0;
X		*prefix = '\0';
X		draw_char_string();
X		}
X	    }
X	else if (c < SP) {
X	    }
X	else if (leng_prefix+leng_suffix == BUF_SIZE) {
X	    put_msg("Text buffer is full, character is ignored");
X	    }
X	else {
X	    erase_char_string();
X	    cwidth = char_advance(canvas_font,c);
X	    if (cur_texttype == T_LEFT_JUSTIFIED)
X	    	rcur_x += cwidth;	/* move the suffix to the right */
X	    else if (cur_texttype == T_CENTER_JUSTIFIED)
X		{
X		rbase_x -= cwidth/2.0;		/* advance left by half cwidth */
X		rcur_x += cwidth/2.0;		/* move suffix right half cwidth */
X		}
X	    if (cur_texttype == T_RIGHT_JUSTIFIED)
X		    rbase_x -= cwidth;	/* move the prefix to the left */
X	    char_received = 1;
X	    prefix[leng_prefix++] = c;
X	    prefix[leng_prefix] = '\0';
X	    cbase_x = rbase_x;			/* fix */
X	    cur_x = rcur_x;
X	    draw_char_string();
X	    }
X	}
END_OF_FILE
if test 3837 -ne `wc -c <'xfig/char.c'`; then
    echo shar: \"'xfig/char.c'\" unpacked with wrong size!
fi
# end of 'xfig/char.c'
fi
if test -f 'xfig/corner.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/corner.c'\"
else
echo shar: Extracting \"'xfig/corner.c'\" \(2921 characters\)
sed "s/^X//" >'xfig/corner.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	This module corner.c Copyright (c) 1989 by Brian V. Smith (bvsmith@lbl.gov)
X *	Original xfig Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	December 1989.
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 int		cur_color;
Xextern int		fix_x, fix_y, cur_x, cur_y;
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/*************************** locally global procedures *********************/
X
X			elastic_box();
Xint			create_arc_cornerobject();
X			init_arc_corner_drawing();
X
Xarc_corner_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_arc_corner_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_arc_corner_drawing(x, y)
Xint	x, y;
X{
X	fprintf(stderr,"init_arc..  x=%d, y=%d\n",x,y);
X	cur_x = fix_x = x; 
X	cur_y = fix_y = y;
X	canvas_locmove_proc = elastic_box;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	canvas_middlebut_proc = create_arc_cornerobject;
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X	set_temp_cursor(&null_cursor);
X	set_action_on();
X	}
X
Xcreate_arc_cornerobject(x, y)
Xint	x, y;
X{
X	F_line	*corner;
X	F_point	*point;
X	int tmp;
X
X	draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT, 1);
X
X	
X	if ((Point_malloc(point)) == NULL) {
X	    blink_msg();
X	    put_msg(Err_mem);
X	    return;
X	    }
X	fprintf(stderr,"x=%d, y=%d,  fix_x=%d, fix_y=%d,  cur_x=%d, cur_y=%d\n",
X			x,y,fix_x,fix_y,cur_x,cur_y);
X	/* sort x and y so that the upper left is first */
X	/*
X	if (x > fix_x)
X		{ 
X		tmp = x; x = fix_x ; fix_x = tmp;
X		}
X
X	if (y > fix_y)
X		{
X		tmp = y; y = fix_y ; fix_y = tmp;
X		}
X	*/
X	point->x = x;
X	point->y = y;
X	point->next = NULL;
X
X	Line_malloc(corner);
X	corner->type = T_ARC_CORNER;
X	corner->style = cur_line_style;
X	corner->thickness = line_thickness;
X	corner->color = cur_color;
X	corner->depth = NULL;
X	corner->pen = 1234;			/* use the pen slot for the radius */
X	corner->area_fill = 0;			/* no area fill */
X	corner->style_val = cur_styleval;
X	corner->for_arrow = NULL;
X	corner->back_arrow = NULL;
X	corner->points = point;
X	corner->next  = NULL;
X	append_point(x, fix_y, &point);
X	append_point(fix_x, fix_y, &point);
X	append_point(fix_x, y, &point);
X	append_point(x, y, &point);
X	draw_line(corner, PAINT);
X	clean_up();
X	set_action_object(F_CREATE, O_POLYLINE);
X	insert_line(&objects.lines, corner);
X	set_latestline(corner);
X	set_modifiedflag();
X	arc_corner_drawing_selected();
X	}
END_OF_FILE
if test 2921 -ne `wc -c <'xfig/corner.c'`; then
    echo shar: \"'xfig/corner.c'\" unpacked with wrong size!
fi
# end of 'xfig/corner.c'
fi
if test -f 'xfig/fig.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/fig.h'\"
else
echo shar: Extracting \"'xfig/fig.h'\" \(817 characters\)
sed "s/^X//" >'xfig/fig.h' <<'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 <X11/Xos.h>
X
X#include <sys/stat.h>
X#include <fcntl.h>
X#include <pwd.h>
X#include <signal.h>
X
X#include <stdio.h>
X#include <ctype.h>
X#include <errno.h>
X#include <math.h>
X
X#ifndef M_PI
X#define M_PI    3.14159265358979323846
X#define M_PI_2  1.57079632679489661923
X#endif
X
X#include <X11/Xlib.h>
X#include <X11/cursorfont.h>
X#include <X11/Intrinsic.h>
X#include <X11/Scroll.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X#include <X11/Command.h>
X#include <X11/Label.h>
X#include <X11/Dialog.h>
X#include <X11/Box.h>
X#include <X11/Form.h>
X
X#ifdef sparc
X
X#define free(x) FREE(x)
X#define cfree(x) CFREE(x)
X
X#endif sparc
END_OF_FILE
if test 817 -ne `wc -c <'xfig/fig.h'`; then
    echo shar: \"'xfig/fig.h'\" unpacked with wrong size!
fi
# end of 'xfig/fig.h'
fi
if test -f 'xfig/fig.icon.X' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/fig.icon.X'\"
else
echo shar: Extracting \"'xfig/fig.icon.X'\" \(3314 characters\)
sed "s/^X//" >'xfig/fig.icon.X' <<'END_OF_FILE'
X#define fig_width 64
X#define fig_height 64
X#define fig_x_hot -1
X#define fig_y_hot -1
Xstatic char fig_bits[] = {
X   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x80,
X   0x01, 0x7f, 0x8e, 0x0f, 0x00, 0x60, 0x03, 0x80, 0x01, 0x42, 0x44, 0x08,
X   0x00, 0x10, 0x04, 0x80, 0x01, 0x12, 0x44, 0x00, 0x00, 0x18, 0x08, 0x80,
X   0x01, 0x1e, 0x44, 0x1e, 0x00, 0x04, 0x08, 0x80, 0x01, 0x12, 0x44, 0x08,
X   0x00, 0x04, 0x10, 0x80, 0x01, 0x02, 0x44, 0x08, 0x00, 0x03, 0x10, 0x80,
X   0x01, 0x02, 0x44, 0x0c, 0x00, 0x01, 0x10, 0x80, 0x01, 0x07, 0x8e, 0x0b,
X   0x80, 0x00, 0x10, 0x80, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x08, 0x83,
X   0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x88, 0x8c, 0x61, 0x00, 0x00, 0x00,
X   0x40, 0x00, 0x48, 0xf0, 0x81, 0x07, 0x00, 0x00, 0x40, 0x40, 0x38, 0xc0,
X   0x01, 0x78, 0x00, 0x00, 0x38, 0x20, 0x00, 0x80, 0x01, 0x80, 0x07, 0xfc,
X   0x47, 0x20, 0x00, 0x80, 0xe1, 0x00, 0xf8, 0x03, 0x40, 0x10, 0x00, 0x81,
X   0x01, 0x0f, 0x00, 0x00, 0x0e, 0x0c, 0xd0, 0x80, 0x01, 0xf0, 0xe0, 0xe0,
X   0x87, 0x00, 0x06, 0x80, 0x01, 0x00, 0xbf, 0xff, 0x40, 0xf1, 0x00, 0x80,
X   0x01, 0x00, 0x90, 0x38, 0xa0, 0x06, 0x00, 0x80, 0x01, 0x00, 0x58, 0x08,
X   0x80, 0x08, 0x00, 0x80, 0x01, 0x00, 0x48, 0x08, 0x18, 0x11, 0x00, 0x80,
X   0x01, 0x00, 0x4c, 0x08, 0x04, 0x21, 0xe0, 0x83, 0x01, 0x00, 0x22, 0x04,
X   0x03, 0x41, 0x10, 0x82, 0x01, 0x00, 0x21, 0x02, 0x00, 0x01, 0x10, 0x84,
X   0x01, 0x00, 0x11, 0x01, 0x00, 0x81, 0xe1, 0xe4, 0x01, 0x80, 0x90, 0x00,
X   0x1c, 0x00, 0x01, 0x99, 0x01, 0x80, 0x90, 0x80, 0x23, 0x01, 0x02, 0x82,
X   0x01, 0x40, 0x90, 0x81, 0x38, 0x01, 0x02, 0x82, 0x01, 0x20, 0x10, 0x7f,
X   0x04, 0x01, 0x04, 0x84, 0x01, 0x10, 0x20, 0x00, 0x82, 0x00, 0x04, 0x84,
X   0x01, 0x08, 0x20, 0x80, 0x81, 0x00, 0x00, 0x88, 0x01, 0x08, 0x40, 0x40,
X   0x80, 0x00, 0x08, 0x90, 0x01, 0x04, 0x40, 0x40, 0x40, 0x00, 0x00, 0x90,
X   0x01, 0x02, 0x80, 0x40, 0x20, 0x0c, 0x10, 0x90, 0x01, 0x01, 0x80, 0x20,
X   0x10, 0x12, 0x10, 0xa0, 0x01, 0x01, 0x00, 0x21, 0x00, 0x11, 0x10, 0xa0,
X   0x81, 0x20, 0x00, 0x31, 0x00, 0x09, 0x10, 0xa0, 0x81, 0x10, 0x00, 0x12,
X   0x00, 0x09, 0x00, 0xa0, 0x41, 0x00, 0x00, 0x12, 0x00, 0x05, 0x20, 0xa0,
X   0x41, 0x08, 0x00, 0x12, 0x80, 0x04, 0x00, 0xa0, 0x21, 0x00, 0x00, 0x12,
X   0x40, 0x04, 0x20, 0xa0, 0x21, 0x04, 0x00, 0x14, 0x20, 0x04, 0x20, 0xa0,
X   0x11, 0x00, 0x00, 0x24, 0x18, 0x04, 0x00, 0xa0, 0x11, 0x04, 0x00, 0xc4,
X   0x07, 0x04, 0x00, 0xa0, 0x11, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x90,
X   0x09, 0x04, 0x00, 0x08, 0x00, 0x04, 0x00, 0x90, 0x09, 0x00, 0x00, 0x08,
X   0x00, 0x04, 0x00, 0x98, 0x09, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x88,
X   0x11, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x88, 0x11, 0x00, 0x00, 0x08,
X   0x00, 0x10, 0x00, 0x84, 0x11, 0x00, 0x00, 0x04, 0x00, 0x20, 0x00, 0x86,
X   0x11, 0xe0, 0x00, 0x04, 0x00, 0x60, 0x00, 0x81, 0x21, 0x20, 0x01, 0x02,
X   0x00, 0x80, 0x81, 0x80, 0x21, 0xc0, 0x00, 0x01, 0x00, 0x00, 0xc1, 0x80,
X   0x41, 0x00, 0x80, 0x00, 0x00, 0x00, 0x62, 0x80, 0x81, 0x00, 0xc0, 0x00,
X   0x00, 0x00, 0x1c, 0x80, 0x01, 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x80,
X   0x01, 0x0e, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xf8, 0x01, 0x00,
X   0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
X   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
END_OF_FILE
if test 3314 -ne `wc -c <'xfig/fig.icon.X'`; then
    echo shar: \"'xfig/fig.icon.X'\" unpacked with wrong size!
fi
# end of 'xfig/fig.icon.X'
fi
if test -f 'xfig/font.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/font.c'\"
else
echo shar: Extracting \"'xfig/font.c'\" \(3531 characters\)
sed "s/^X//" >'xfig/font.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 "font.h"
X#include "psfonts.h"
X
XPIX_FONT		bold_font;
XPIX_FONT		roman_font;
XPIX_FONT		button_font;
X
Xextern	struct _fstruct fontnames[NUMFONTS];
X
XXFontStruct *XLoadQueryFont();
X#define MAXNAMES 30
X
Xstatic struct {
X	char *fn;
X	int s;
X	} flist[MAXNAMES];
X
Xchar	*boldFont = NULL;
Xchar	*normalFont = NULL;
X
Xinit_font()
X	{
X	struct	xfont *newfont, *nf;
X	int	f,count,i,p,ss;
X	char	**fontlist,**fname,*np;
X
X	if( boldFont == NULL || *boldFont == NULL)
X		boldFont = BOLD_FONT;
X	if( normalFont == NULL || *normalFont == NULL)
X		normalFont = NORMAL_FONT;
X	
X	roman_font = XLoadQueryFont(tool_d, normalFont);
X	if ((bold_font = XLoadQueryFont(tool_d, boldFont)) ==0)
X		{
X		fprintf(stderr,"Can't load font: %s, using %s\n",boldFont,normalFont);
X		bold_font = XLoadQueryFont(tool_d, normalFont);
X		}
X	button_font = XLoadQueryFont(tool_d, NORMAL_FONT);
X
X	for (i=0; i<0x10; i++)
X		{
X		cur_gcfont[i] = -1;
X		cur_gcfontsize[i] = 0;
X		}
X
X	/* Now initialize the font structure for the X fonts corresponding
X	   to the Postscript fonts for the canvas */
X
X	for (f=0; f < NUMFONTS; f++)
X		{
X		nf = NULL;
X		if (fontlist = XListFonts(tool_d, fontnames[f].template, MAXNAMES, &count))
X			{
X			fname = fontlist;	/* go through the list finding point sizes */
X			p=0;
X			while (count--)
X				{
X				ss = parsesize(*fname);
X				flist[p].fn = *fname++;
X				flist[p++].s = ss;
X				}
X			for (ss=4; ss<=40; ss++)
X			    {
X			    for (i=0; i<p; i++)
X				if (flist[i].s == ss)
X					break;
X			    if (i<p && flist[i].s == ss)
X				{
X				newfont = (struct xfont *) malloc(sizeof(struct xfont));
X				if (nf==NULL)
X					fontnames[f].xfontlist = newfont;
X				else
X					nf-> next = newfont;
X				nf = newfont;		/* keep current ptr */
X				nf->size = ss;		/* store the size here */
X				nf->fid = NULL;		/* haven't loaded the font yet */
X				nf->fstruct = NULL;	/* ditto */
X				nf->fname = flist[i].fn;	/* keep actual name */
X				nf->next = NULL;
X				fname++;		/* point to next name (if any) */
X				}
X			    }
X			}
X		} /* next font, f */
X	}
X
Xparsesize(name)
Xchar *name;
X	{
X	int s;
X	char *np;
X
X	for (np = name; *(np+1); np++)
X		if (*np=='-' && *(np+1)=='-')
X			break;
X	s=0;
X	if (*(np+1))
X		{
X		np += 2;	/* point past the -- */
X		s = atoi(np);	/* get the point size */
X		}
X	else 
X		fprintf(stderr,"Can't parse '%s'\n",name);
X	return s;
X	}
X
X/* Lookup an X font corresponding to a Postscript font style that is close in size */
X
XPIX_FONT
Xlookfont(f,s)
Xint f,s;
X	{
X	int	found = FALSE;
X	struct	xfont *xf;
X	Font	font;
X	XFontStruct *fontst;
X
X	xf = fontnames[f].xfontlist;	/* go through the linked list looking for match */
X	if (xf == NULL)
X		return roman_font;	/* use a default font */
X	while (!found)
X		{
X		if (s <= xf->size)	/* exact or larger point size */
X			{
X			found = TRUE;
X			break;
X			}
X		if (xf->next != NULL)	/* keep ptr to last if not found */
X			xf = xf->next;
X		else
X			break;		/* not found, use largest point size in the list */
X		}
X	if (xf->fid == NULL)		/* if the font is not yet loaded, load it */
X		{
X		/* fprintf(stderr,"Loading font %s\n",xf->fname); */
X		if (fontst = XLoadQueryFont(tool_d, xf->fname))	/* load it */
X			{
X			xf->fid = fontst->fid;		/* save the id */
X			xf->fstruct = fontst;		/* and the XFontStruct ptr */
X			}
X		else
X			fprintf(stderr,"What!!?!?! Can't find font %s\n",xf->fname);
X		}
X	return xf->fstruct;
X	}
END_OF_FILE
if test 3531 -ne `wc -c <'xfig/font.c'`; then
    echo shar: \"'xfig/font.c'\" unpacked with wrong size!
fi
# end of 'xfig/font.c'
fi
if test -f 'xfig/grid.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/grid.c'\"
else
echo shar: Extracting \"'xfig/grid.c'\" \(3974 characters\)
sed "s/^X//" >'xfig/grid.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 "const.h"
X#include "func.h"
X#include "paintop.h"
X
Xstatic int	cur_grid = -1;
Xextern int	CANVAS_WIDTH, CANVAS_HEIGHT;
Xextern int	INCHES;
X
X#define null_width 32
X#define null_height 32
Xstatic char null_bits[null_width * null_height / 8] = { 0 };
X
X#define quarter_width 20
X#define quarter_height 20
Xstatic char quarter_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x42, 0x08};
X
X#define half_width 40
X#define half_height 40
Xstatic char half_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x10, 0x42, 0x08, 0x21, 0x84};
X
X#define half_cm_width 15
X#define half_cm_height 15
Xstatic char half_cm_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x10, 0x42, 0x00, 0x00};
X
Xstatic Pixmap	null_pm, quarter_pm, half_pm, half_cm_pm;
X
Xinit_grid()
X{
X	long	bg, fg;
X	Arg	tmp_arg[3];
X
X	XtSetArg(tmp_arg[0], XtNbackground, &bg);
X	XtSetArg(tmp_arg[1], XtNforeground, &fg);
X	XtGetValues(canvas_sw, tmp_arg, 2);
X	
X	null_pm = XCreatePixmapFromBitmapData(tool_d, canvas_pixwin,
X		null_bits, null_width, null_height,
X		fg, bg,	DefaultDepthOfScreen(tool_s));
X	quarter_pm = XCreatePixmapFromBitmapData(tool_d, canvas_pixwin,
X		quarter_bits, quarter_width, quarter_height,
X		fg, bg,	DefaultDepthOfScreen(tool_s));
X	half_pm = XCreatePixmapFromBitmapData(tool_d, canvas_pixwin,
X		half_bits, half_width, half_height,
X		fg, bg,	DefaultDepthOfScreen(tool_s));
X	half_cm_pm = XCreatePixmapFromBitmapData(tool_d, canvas_pixwin,
X		half_cm_bits, half_cm_width, half_cm_height,
X		fg, bg, DefaultDepthOfScreen(tool_s));
X}
X
X/* grid in X11 is simply the background of the canvas */
X
Xsetup_grid(grid)
X	int		grid;
X{
X	static Arg	grid_args[] =
X	{
X		{ XtNbackgroundPixmap, (XtArgVal)NULL },
X	};
X
X	if (grid == cur_grid)
X	{
X		grid_args[0].value = (XtArgVal)null_pm;
X		grid = -1;
X	}
X	if( INCHES )
X	{
X		if (grid == F_GRID1)
X			grid_args[0].value = (XtArgVal)quarter_pm;
X		else if (grid == F_GRID2)
X			grid_args[0].value = (XtArgVal)half_pm;
X	}else if (grid == F_GRID1 || grid == F_GRID2)
X		grid_args[0].value = (XtArgVal)half_cm_pm;
X	cur_grid = grid;
X	XtSetValues(canvas_sw, grid_args, XtNumber(grid_args));
X}
X
Xredisplay_grid()
X{
X}
END_OF_FILE
if test 3974 -ne `wc -c <'xfig/grid.c'`; then
    echo shar: \"'xfig/grid.c'\" unpacked with wrong size!
fi
# end of 'xfig/grid.c'
fi
if test -f 'xfig/latex_line.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/latex_line.c'\"
else
echo shar: Extracting \"'xfig/latex_line.c'\" \(3275 characters\)
sed "s/^X//" >'xfig/latex_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 "math.h"
X
Xint  pgcd(a,b)
X    int a, b;
X/*
X *  compute greatest common divisor, assuming 0 < a <= b
X */
X{
X    b = b % a;
X    return (b)? gcd(b, a): a;
X}
X
Xint  gcd(a, b)
X    int a, b;
X/*
X *  compute greatest common divisor
X */
X{
X    if (a < 0) a = -a;
X    if (b < 0) b = -b;
X    return (a <= b)? pgcd(a, b): pgcd(b, a);
X}
X
X
Xint  lcm(a, b)
X    int a, b;
X/*
X *  compute least common multiple
X */
X{
X    return abs(a*b)/gcd(a,b);
X}
X
X
Xdouble rad2deg = 57.295779513082320877;
X
Xstruct angle_table {
X    int    x, y;
X    double angle;
X};
X
Xstruct angle_table line_angles[25] =
X  { {0, 1, 90.0}, 
X    {1, 0,  0.0},
X    {1, 1, 45.0}, 
X    {1, 2, 63.434948822922010648},
X    {1, 3, 71.565051177077989351},
X    {1, 4, 75.963756532073521417},
X    {1, 5, 78.690067525979786913},
X    {1, 6, 80.537677791974382609},
X    {2, 1, 26.565051177077989351},
X    {2, 3, 56.309932474020213086},
X    {2, 5, 68.198590513648188229}, 
X    {3, 1, 18.434948822922010648},
X    {3, 2, 33.690067525979786913},
X    {3, 4, 53.130102354155978703},
X    {3, 5, 59.036243467926478582},
X    {4, 1, 14.036243467926478588},
X    {4, 3, 36.869897645844021297},
X    {4, 5, 51.340191745909909396},
X    {5, 1, 11.309932474020213086},
X    {5, 2, 21.801409486351811770},
X    {5, 3, 30.963756532073521417},
X    {5, 4, 38.659808254090090604},
X    {5, 6, 50.194428907734805993},
X    {6, 1, 9.4623222080256173906},
X    {6, 5, 39.805571092265194006}
X  };
X
Xstruct angle_table arrow_angles[13] =
X  { {0, 1, 90.0}, 
X    {1, 0,  0.0},
X    {1, 1, 45.0}, 
X    {1, 2, 63.434948822922010648},
X    {1, 3, 71.565051177077989351},
X    {1, 4, 75.963756532073521417},
X    {2, 1, 26.565051177077989351},
X    {2, 3, 56.309932474020213086},
X    {3, 1, 18.434948822922010648},
X    {3, 2, 33.690067525979786913},
X    {3, 4, 53.130102354155978703},
X    {4, 1, 14.036243467926478588},
X    {4, 3, 36.869897645844021297},
X  };
X
Xget_slope(dx, dy, sxp, syp, arrow)
X    int  dx, dy, *sxp, *syp, arrow;
X{
X    double angle;
X    int    i, s, max;
X    double d, d1;
X    struct angle_table *st;
X
X    if (dx == 0) {
X	*sxp = 0;
X	*syp = (dy < 0)? -1: 1;
X	return;
X    }
X    angle = atan((double)abs(dy) / (double)abs(dx)) * rad2deg;
X    if (arrow) {
X	st = arrow_angles;
X	max = 13;
X    } else {
X	st = line_angles;
X	max = 25;
X    }
X    s = 0;
X    d = 9.9e9;
X    for (i = 0; i < max; i++) {
X	d1 = fabs(angle - st[i].angle);
X	if (d1 < d) {
X	    s = i;
X	    d = d1;
X	} 
X    }
X    *sxp = st[s].x;
X    if (dx < 0) *sxp = -*sxp;
X    *syp = st[s].y;
X    if (dy < 0) *syp = -*syp;
X}
X
Xlatex_endpoint(x1, y1, x2, y2, xout, yout, arrow, magnet)
X    int  x1, y1, x2, y2;
X    int  *xout, *yout;
X    int  arrow, magnet;
X{
X    int    dx, dy, sx, sy, ds, dsx, dsy;
X
X    dx = x2-x1;
X    dy = y2-y1;
X    get_slope(dx, dy, &sx, &sy, arrow);
X    if (abs(sx) >= abs(sy)) {
X	ds = lcm(sx, magnet*gcd(sx,magnet));
X	dsx = (2*abs(dx)/ds + 1)/2;
X	dsx = (dx >= 0)? dsx*ds: -dsx*ds;
X	*xout = x1 + dsx;
X	*yout = y1 + dsx*sy/sx;
X    } else {
X	ds = lcm(sy, magnet*gcd(sy,magnet));
X	dsy = (2*abs(dy)/ds + 1)/2;
X	dsy = (dy >= 0)? dsy*ds: -dsy*ds;
X	*yout = y1 + dsy;
X	*xout = x1 + dsy*sx/sy;
X    }
X}
END_OF_FILE
if test 3275 -ne `wc -c <'xfig/latex_line.c'`; then
    echo shar: \"'xfig/latex_line.c'\" unpacked with wrong size!
fi
# end of 'xfig/latex_line.c'
fi
if test -f 'xfig/list.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/list.c'\"
else
echo shar: Extracting \"'xfig/list.c'\" \(2980 characters\)
sed "s/^X//" >'xfig/list.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 *	Febuary 1988.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "object.h"
X
Xdelete_arc(arc_list, arc)
XF_arc	**arc_list, *arc;
X{
X	F_arc	*a, *aa;
X
X	if (*arc_list == NULL) return;
X	if (arc == NULL) return;
X
X	for (a = aa = *arc_list; aa != NULL; a = aa, aa = aa->next) {
X	    if (aa == arc) {
X		if (aa == *arc_list)
X		    *arc_list = (*arc_list)->next;
X		else
X		    a->next = aa->next;
X		break;
X		}
X	    }
X	arc->next = NULL;
X	}
X
Xdelete_ellipse(ellipse_list, ellipse)
XF_ellipse	**ellipse_list, *ellipse;
X{
X	F_ellipse	*q, *r;
X
X	if (*ellipse_list == NULL) return;
X	if (ellipse == NULL) return;
X
X	for (q = r = *ellipse_list; r != NULL; q = r, r = r->next) {
X	    if (r == ellipse) {
X		if (r == *ellipse_list)
X		    *ellipse_list = (*ellipse_list)->next;
X		else
X		    q->next = r->next;
X		break;
X		}
X	    }
X	ellipse->next = NULL;
X	}
X
Xdelete_line(line_list, line)
XF_line	*line, **line_list;
X{
X	F_line	*q, *r;
X
X	if (*line_list == NULL) return;
X	if (line == NULL) return;
X
X	for (q = r = *line_list; r != NULL; q = r, r = r->next) {
X	    if (r == line) {
X		if (r == *line_list)
X		    *line_list = (*line_list)->next;
X		else
X		    q->next = r->next;
X		break;
X		}
X	    }
X	line->next = NULL;
X	}
X
Xdelete_spline(spline_list, spline)
XF_spline	**spline_list, *spline;
X{
X	F_spline	*q, *r;
X
X	if (*spline_list == NULL) return;
X	if (spline == NULL) return;
X
X	for (q = r = *spline_list; r != NULL; q = r, r = r->next) {
X	    if (r == spline) {
X		if (r == *spline_list)
X		    *spline_list = (*spline_list)->next;
X		else
X		    q->next = r->next;
X		break;
X		}
X	    }
X	spline->next = NULL;
X	}
X
Xdelete_text(text_list, text)
XF_text	**text_list, *text;
X{
X	F_text	*q, *r;
X
X	if (*text_list == NULL) return;
X	if (text == NULL) return;
X
X	for (q = r = *text_list; r != NULL; q = r, r = r->next) 
X	    if (r == text) {
X		if (r == *text_list)
X		    *text_list = text->next;
X		else
X		    q->next = text->next;
X		break;
X		}
X	text->next = NULL;
X	}
X
Xdelete_compound(list, compound)
XF_compound	**list, *compound;
X{
X	F_compound	*c, *cc;
X
X	if (*list == NULL) return;
X	if (compound == NULL) return;
X
X	for (cc = c = *list; c != NULL; cc = c, c = c->next) {
X	    if (c == compound) {
X		if (c == *list)
X		    *list = (*list)->next;
X		else
X		    cc->next = c->next;
X		break;
X		}
X	    }
X	compound->next = NULL;
X	}
X
Xinsert_arc(arc_list, a)
XF_arc	**arc_list, *a;
X{
X	a->next = *arc_list;
X	*arc_list = a;
X	}
X
Xinsert_ellipse(ellipse_list, e)
XF_ellipse	**ellipse_list, *e;
X{
X	e->next = *ellipse_list;
X	*ellipse_list = e;
X	}
X
Xinsert_line(line_list, l)
XF_line	**line_list, *l;
X{
X	l->next = *line_list;
X	*line_list = l;
X	}
X
Xinsert_spline(spline_list, s)
XF_spline	**spline_list, *s;
X{
X	s->next = *spline_list;
X	*spline_list = s;
X	}
X
Xinsert_text(text_list, t)
XF_text	**text_list, *t;
X{
X	t->next = *text_list;
X	*text_list = t;
X	}
X
X
Xinsert_compound(list, c)
XF_compound	**list, *c;
X{
X	c->next = *list;
X	*list = c;
X	}
END_OF_FILE
if test 2980 -ne `wc -c <'xfig/list.c'`; then
    echo shar: \"'xfig/list.c'\" unpacked with wrong size!
fi
# end of 'xfig/list.c'
fi
if test -f 'xfig/remove.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/remove.c'\"
else
echo shar: Extracting \"'xfig/remove.c'\" \(3561 characters\)
sed "s/^X//" >'xfig/remove.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 "func.h"
X#include "object.h"
X#include "paintop.h"
X
X#define			TOLERANCE	7
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
X
Xextern int		foreground_color, background_color;
X
X			init_remove();
X
Xremove_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_remove;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&buster_cursor);
X	}
X
Xinit_remove(x, y)
Xint	x, y;
X{
X	extern F_line		*line_search();
X	extern F_arc		*arc_search();
X	extern F_ellipse	*ellipse_search();
X	extern F_text		*text_search();
X	extern F_spline		*spline_search();
X	extern F_compound	*compound_search();
X	extern F_compound	objects;
X	F_line		*l;
X	F_arc		*a;
X	F_ellipse	*e;
X	F_text		*t;
X	F_spline	*s;
X	F_compound	*c;
X	int		dummy;
X
X	if ((c = compound_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
X	    draw_compoundbox(c, INV_PAINT);
X	    erase_compound(c);
X	    delete_compound(&objects.compounds, c);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_COMPOUND);
X	    set_latestcompound(c);
X	    set_modifiedflag();
X	    }
X	else if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
X	    toggle_linepointmarker(l);
X	    draw_line(l, ERASE);
X	    delete_line(&objects.lines, l);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_POLYLINE);
X	    set_latestline(l);
X	    set_modifiedflag();
X	    }
X	else if ((t = text_search(x, y)) != NULL) {
X	    draw_text(t, INV_PAINT);
X	    delete_text(&objects.texts, t);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_TEXT);
X	    set_latesttext(t);
X	    set_modifiedflag();
X	    }
X	else if ((e = ellipse_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
X	    toggle_ellipsepointmarker(e);
X	    pw_batch_on(canvas_pixwin);
X	    draw_ellipse(e, background_color);
X	    pw_batch_off(canvas_pixwin);
X	    delete_ellipse(&objects.ellipses, e);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_ELLIPSE);
X	    set_latestellipse(e);
X	    set_modifiedflag();
X	    }
X	else if ((a = arc_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
X	    toggle_arcpointmarker(a);
X	    pw_batch_on(canvas_pixwin);
X	    draw_arc(a, background_color);
X	    pw_batch_off(canvas_pixwin);
X	    delete_arc(&objects.arcs, a);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_ARC);
X	    set_latestarc(a);
X	    set_modifiedflag();
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
X	    toggle_splinepointmarker(s);
X	    pw_batch_on(canvas_pixwin);
X	    draw_spline(s, ERASE);
X	    pw_batch_off(canvas_pixwin);
X	    delete_spline(&objects.splines, s);
X	    clean_up();
X	    set_action_object(F_REMOVE, O_SPLINE);
X	    set_latestspline(s);
X	    set_modifiedflag();
X	    }
X	remove_selected();
X	}
X
Xremove_all()
X{
X	extern F_compound	objects;
X	extern F_compound	saved_objects;
X	extern int		last_action;
X
X	clean_up();
X	set_action_object(F_REMOVE, O_ALL_OBJECT);
X
X	/* Aggregate assignment between variables is allowed,
X	but not from constant (weird!?) */
X
X	saved_objects = objects;
X
X	objects.arcs = NULL;
X	objects.compounds = NULL;
X	objects.ellipses = NULL;
X	objects.lines = NULL;
X	objects.splines = NULL;
X	objects.texts = NULL;
X	}
END_OF_FILE
if test 3561 -ne `wc -c <'xfig/remove.c'`; then
    echo shar: \"'xfig/remove.c'\" unpacked with wrong size!
fi
# end of 'xfig/remove.c'
fi
if test -f 'xfig/search.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/search.c'\"
else
echo shar: Extracting \"'xfig/search.c'\" \(3895 characters\)
sed "s/^X//" >'xfig/search.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 "object.h"
X
Xextern F_compound	objects;
X
XF_arc *
Xarc_search(x, y, tolerance, px, py)
Xint	x, y, tolerance, *px, *py;
X{	/*	(px, py) is the control point on the circumference of an arc
X		which is the closest to (x, y)				*/
X
X	F_arc	*a;
X	int	i;
X
X	for (a = objects.arcs; a != NULL; a = a->next) {
X	    for (i = 0; i < 3; i++) 
X		if ((abs(a->point[i].x - x) <= tolerance) && 
X		    (abs(a->point[i].y - y) <= tolerance)) {
X		    *px = a->point[i].x;
X		    *py = a->point[i].y;
X		    return(a);
X		    }
X	    }
X	return(NULL);
X	}
X
X
X#define min(a,b) ((a) < (b) ? (a) : (b))
X
XF_ellipse *
Xellipse_search(x, y, tolerance, px, py)
Xint	x, y, tolerance, *px, *py;
X{	/*	(px, py) is the point on the circumference of an ellipse
X		which is the closest to (x, y)				*/
X
X	F_ellipse	*e;
X	int		a, b, dx, dy;
X	float		dis, r, tol;
X
X	tol = (float) tolerance;
X	for (e = objects.ellipses; e != NULL; e = e->next) {
X	    dx = x - e->center.x;
X	    dy = y - e->center.y;
X	    a = e->radiuses.x;
X	    b = e->radiuses.y;
X	    dis = sqrt((double)(dx*dx + dy*dy));
X 	    if (dis == 0) {
X 		*px = e->center.x;
X 		*py = e->center.y;
X 		return(e);
X 	    }
X	    r = a * b * dis / sqrt((double) (1.0*b*b*dx*dx + 1.0*a*a*dy*dy));
X	    if (fabs(dis - r) <= tol) {
X		*px = (int)(r*dx/dis + ((dx < 0) ? -.5 : .5)) + e->center.x;
X		*py = (int)(r*dy/dis + ((dy < 0) ? -.5 : .5)) + e->center.y;
X		return(e);
X		}
X	    }
X	return(NULL);
X	}
X
XF_line *
Xline_search(x, y, tolerance, px, py)
Xint	x, y, tolerance, *px, *py;
X{	/*	return the pointer to lines object if the search is successful
X		otherwise return NULL.  
X		The value returned via (px, py) is the closest point on the 
X		vector to point (x, y) 					*/
X 
X	F_line	*lines;
X	F_point	*point;
X	int	x1, y1, x2, y2;
X	float	tol2;
X
X	tol2 = (float) tolerance * tolerance;
X	for (lines = objects.lines; lines != NULL; lines = lines->next) {
X	    point = lines->points;
X	    x1 = point->x;
X	    y1 = point->y;
X	    if (abs(x - x1) <= tolerance && abs(y - y1) <= tolerance) {
X		*px = x1;  *py = y1;
X		return(lines);
X		}
X	    for (point = point->next; point != NULL; point = point->next) {
X		x2 = point->x;
X		y2 = point->y;
X		if (close_to_vector(x1, y1, x2, y2, x, y, tolerance, tol2, 
X					px, py)) 
X		    return(lines);
X		x1 = x2;
X		y1 = y2;
X		}
X	    }
X	return(NULL);
X	}
X
XF_spline *
Xspline_search(x, y, tolerance, px, py)
Xint	x, y, tolerance, *px, *py;
X{	/*	return the pointer to lines object if the search is successful
X		otherwise return NULL.  */
X 
X	F_spline	*splines;
X	F_point		*point;
X	int		x1, y1, x2, y2;
X	float		tol2;
X
X	tol2 = (float) tolerance * tolerance;
X	for (splines = objects.splines; splines != NULL; splines = splines->next) {
X	    point = splines->points;
X	    x1 = point->x;
X	    y1 = point->y;
X	    for (point = point->next; point != NULL; point = point->next) {
X		x2 = point->x;
X		y2 = point->y;
X		if (close_to_vector(x1, y1, x2, y2, x, y, tolerance, tol2,
X					px, py)) 
X		    return(splines);
X		x1 = x2;
X		y1 = y2;
X		}
X	    }
X	return(NULL);
X	}
X
XF_text *
Xtext_search(x, y)
Xint	x, y;
X{
X	F_text	*t;
X	int	halflen;
X
X	for (t = objects.texts; t != NULL; t = t->next) {
X	    halflen = t->length/2;
X	    if (t->base_y - t->height > y) 
X		continue;
X	    if (t->base_y < y) 
X		continue;
X	    if ( ((t->type == T_LEFT_JUSTIFIED) && t->base_x > x) ||
X	        ((t->type == T_CENTER_JUSTIFIED) && t->base_x - halflen > x) ||
X	        ((t->type == T_RIGHT_JUSTIFIED) && t->base_x - t->length > x) )
X			continue;
X	    if ( ((t->type == T_LEFT_JUSTIFIED) && t->base_x + t->length < x) ||
X	        ((t->type == T_CENTER_JUSTIFIED) && t->base_x + halflen < x) ||
X	        ((t->type == T_RIGHT_JUSTIFIED) && t->base_x < x) )
X			continue;
X	    return(t);
X	    }
X	return(NULL);
X	}
END_OF_FILE
if test 3895 -ne `wc -c <'xfig/search.c'`; then
    echo shar: \"'xfig/search.c'\" unpacked with wrong size!
fi
# end of 'xfig/search.c'
fi
if test -f 'xfig/testgc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/testgc.c'\"
else
echo shar: Extracting \"'xfig/testgc.c'\" \(2959 characters\)
sed "s/^X//" >'xfig/testgc.c' <<'END_OF_FILE'
X#include <X11/Xlib.h>
X#include <stdio.h>
X
XWindow window;
XDisplay *dpy;
XGC gc;
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X	{
X	XGCValues gcv;
X
X	if ((dpy=XOpenDisplay(""))==0)
X		{
X		fprintf(stderr,"can't open display\n");
X		exit(1);
X		}
X	window = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,500,500,1,0,
X			XWhitePixel(dpy,0));
X	XMapRaised(dpy,window);
X	XFlush(dpy);
X	fprintf(stderr,"press return for line thickness 1...");
X	getchar();
X	gc = XDefaultGC(dpy,0);
X	gcv.line_width = 0;
X	gcv.foreground = XBlackPixel(dpy,0);
X	XChangeGC(dpy,gc,GCForeground|GCLineWidth,&gcv);
X	drawstuff();
X	gcv.line_width = 3;
X	XChangeGC(dpy,gc,GCForeground|GCLineWidth,&gcv);
X	drawstuff();
X	gcv.line_width = 0;
X	XChangeGC(dpy,gc,GCForeground|GCLineWidth,&gcv);
X	drawstuff();
X	exit(0);
X	}
X
Xdrawstuff()
X	{
X	int radius;
X	XClearWindow(dpy,window);
X	for (radius=2; radius<200; radius+=10)
X		curve(radius, 0, radius, 0, 1, 1, 1, 200, 200);
X	XFlush(dpy);
X	fprintf(stderr,"press return...");
X	getchar();
X	}
X
X#define		round(a)	((int)((a) + .5))
X
X#define MAXPTS 4000
Xstatic	XPoint	*points=NULL;
X
Xcurve(xstart, ystart, xend, yend, direction, 
X		a, b, xoff, yoff)
Xint	xstart, ystart, xend, yend, a, b, xoff, yoff;
Xint	direction;
X{
X	int	dfx, dfy, dfxx, dfyy;
X	int	falpha, fx, fy, fxy, absfx, absfy, absfxy;
X	int	margin, test_succeed, x, y, deltax, deltay, inc, dec;
X	int	npoints;
X	
X	if (a == 0 || b == 0) 
X		return;
X
X	if (points==NULL)
X		if ((points = (XPoint *) malloc(MAXPTS*sizeof(XPoint))) == 0)
X			{
X			fprintf(stderr,"curve(): No memory\n");
X			return;
X			}
X
X	x    = xstart;
X	y    = ystart;
X	dfx  = 2 * a * xstart;
X	dfy  = 2 * b * ystart;
X	dfxx = 2 * a;
X	dfyy = 2 * b;
X
X	falpha = 0;
X	if (direction) {
X	    inc = 1;  dec = -1;
X	    }
X	else {
X	    inc = -1;  dec = 1;
X	    }
X	if (xstart == xend && ystart == yend) {
X	    test_succeed = margin = 1;
X	    }
X	else {
X	    test_succeed = margin = 3; 
X	    }
X
X	npoints = 0;
X	do {
X	    if (dfy < 0) 
X		deltax = inc; 
X	    else 
X		deltax = dec;
X	    if (dfx < 0) 
X		deltay = dec; 
X	    else 
X		deltay = inc;
X	    fx  = falpha + dfx * deltax + a;
X	    fy  = falpha + dfy * deltay + b;
X	    fxy = fx + fy - falpha;
X	    absfx  = abs(fx); absfy  = abs(fy); absfxy = abs(fxy);
X
X	    if ((absfxy <= absfx) && (absfxy <= absfy))
X		falpha = fxy;
X	    else if (absfy <= absfx) {
X		deltax = 0; falpha = fy;
X		}
X	    else {
X		deltay = 0; falpha = fx;
X		}
X	    x = x + deltax;  y = y + deltay;
X	    points[npoints].x = (short) xoff+x;
X	    points[npoints].y = (short) yoff-y;
X	    if (npoints < MAXPTS)
X		    npoints++;
X	    dfx = dfx + dfxx * deltax;
X	    dfy = dfy + dfyy * deltay;
X	    if (abs(x - xend) < margin && abs(y - yend) < margin) 
X		test_succeed--;
X	    } while (test_succeed);
X
X	if (margin == 1)	/* end points should touch */
X		{
X		points[npoints].x = (short) xoff+xstart;
X		points[npoints].y = (short) yoff-ystart;
X		if (npoints < MAXPTS)
X		    npoints++;
X		}
X	XDrawLines(dpy, window, gc, points, npoints, CoordModeOrigin);
X	free(points);
X	}
END_OF_FILE
if test 2959 -ne `wc -c <'xfig/testgc.c'`; then
    echo shar: \"'xfig/testgc.c'\" unpacked with wrong size!
fi
# end of 'xfig/testgc.c'
fi
if test -f 'xfig/turn.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/turn.c'\"
else
echo shar: Extracting \"'xfig/turn.c'\" \(3473 characters\)
sed "s/^X//" >'xfig/turn.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
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		pointmarker_shown;
X
Xextern F_compound	objects;
Xextern F_line		*line_search();
Xextern F_spline		*spline_search();
X
X			init_turn();
X
Xturn_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_turn;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&pick15_cursor);
X	}
X
Xinit_turn(x, y)
Xint	x, y;
X{
X	F_line		*l;
X	F_spline	*s;
X	int		dummy;
X
X	if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
X	    if (l->type == T_BOX || l->type == T_ARC_BOX) return;
X	    line_2_spline(l);
X	    turn_selected();
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
X	    spline_2_line(s);
X	    turn_selected();
X	    }
X	}
X
Xline_2_spline(l)
XF_line	*l;
X{
X	F_spline	*s;
X
X	if (num_points(l->points) < 3) {
X	    put_msg("Can't turn this line into spline");
X	    return(-1);
X	    }
X	if (pointmarker_shown) toggle_linepointmarker(l);
X	draw_line(l, ERASE);
X	delete_line(&objects.lines, l);
X
X	if (NULL == (Spline_malloc(s))) {
X	    put_msg(Err_mem);
X	    return(-1);
X	    }
X
X	if (l->type == T_POLYGON)
X	    s->type = T_CLOSED_INTERPOLATED;
X	else
X	    s->type = T_OPEN_INTERPOLATED;
X	s->style = l->style;
X	s->thickness = l->thickness;
X	s->color = l->color;
X	s->depth = l->depth;
X	s->style_val = l->style_val;
X	s->pen = l->pen;
X	s->area_fill = l->area_fill;
X	s->for_arrow = l->for_arrow;
X	s->back_arrow = l->back_arrow;
X	s->points = l->points;
X	s->controls = NULL;
X	s->next = NULL;
X
X	l->for_arrow = l->back_arrow = NULL;
X	/* l->area_fill = 0; */
X	l->pen = NULL;
X	l->points = NULL;
X
X	if (-1 == create_control_list(s)) {
X	    free(s);
X	    return(-1);
X	    }
X
X	remake_control_points(s);
X	draw_spline(s, PAINT);
X	if (pointmarker_shown) toggle_splinepointmarker(s);
X	clean_up();
X	set_action_object(F_TURN, O_POLYLINE);
X	insert_spline(&objects.splines, s);
X	set_latestspline(s);
X	set_latestline(l);
X	return(1);
X	}
X
Xspline_2_line(s)
XF_spline	*s;
X{
X	F_line	*l;
X
X	if (pointmarker_shown) toggle_splinepointmarker(s);
X	draw_spline(s, ERASE);
X	delete_spline(&objects.splines, s);
X
X	/* Now we turn s into a line */
X	if (NULL == (Line_malloc(l))) {
X	    put_msg(Err_mem);
X	    return(-1);
X	    }
X
X	if (s->type == T_OPEN_INTERPOLATED)
X	    l->type = T_POLYLINE;
X	else if (s->type == T_CLOSED_INTERPOLATED)
X	    l->type = T_POLYGON;
X	l->style = s->style;
X	l->thickness = s->thickness;
X	l->color = s->color;
X	l->depth = s->depth;
X	l->style_val = s->style_val;
X	l->pen = s->pen;
X	l->area_fill = s->area_fill;
X	l->for_arrow = s->for_arrow;
X	l->back_arrow = s->back_arrow;
X	l->points = s->points;
X	l->next = NULL;
X
X	s->for_arrow = s->back_arrow = NULL;
X	s->area_fill = 0;
X	s->pen = NULL;
X	s->points = NULL;
X
X	draw_line(l, PAINT);
X	if (pointmarker_shown) toggle_linepointmarker(l);
X	clean_up();
X	set_action_object(F_TURN, O_SPLINE);
X	insert_line(&objects.lines, l);
X	set_latestspline(s);
X	set_latestline(l);
X	return(1);
X	}
END_OF_FILE
if test 3473 -ne `wc -c <'xfig/turn.c'`; then
    echo shar: \"'xfig/turn.c'\" unpacked with wrong size!
fi
# end of 'xfig/turn.c'
fi
echo shar: End of archive 13 \(of 15\).
cp /dev/null ark13isdone
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.