envbvs@epb2.lbl.gov (Brian V. Smith) (07/04/90)
Submitted-by: envbvs@epb2.lbl.gov (Brian V. Smith) Posting-number: Volume 8, Issue 21 Archive-name: xfig2.8/part12 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 12 (of 21)." # Contents: f2p.c ruler.c undo.c # Wrapped by envbvs@epb2.lbl.gov on Thu Jun 28 08:52:38 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'f2p.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'f2p.c'\" else echo shar: Extracting \"'f2p.c'\" \(13361 characters\) sed "s/^X//" >'f2p.c' <<'END_OF_FILE' X/* X * F2p : Fig-to-pic translator X * X * Copyright (c) 1985, 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU) X * January 1985. X * 1st revision : October 1985. X * 2nd revision : March 1988 - read fig 1.4 X * Support for fonts and point sizes added by daved@physiol.su.oz.au X * March 1990 X * X * %W% %G% X*/ X#include "fig.h" X#include "object.h" X#include "troff_fonts.h" X#include "psfonts.h" X Xchar Usage[] = "Usage: f2p [ -f font_file ] [ input_file [ output_file ] ]\n"; Xchar *from = NULL, X *to = NULL; XFILE *tfp = NULL; Xchar Err_incomp[] = "Incomplete %s object at line %d."; Xchar Err_mem[] = "Running out of memory."; X Xint line_thickness; /* not for f2ps - arrow.c needs it for fig */ Xextern struct _fstruct fontnames[]; /* printer font names */ Xint dotps, /* most recent size passed to .ps */ X dotft; /* one more than num of font passed to .ft */ X X/*VARARGS1*/ Xput_msg(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) Xchar *format, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8; X{ X fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); X fputc('\n',stderr); X} X Xget_args(argc, argv) Xint argc; Xchar *argv[]; X{ X char *a; X int first = 1; X X while (--argc) X { X a = *++argv; X if (*a == '-') X { X if (*++a == 'f') X { X if (--argc) X font_file = *++argv; X else X { X fprintf(stderr, Usage); X exit(1); X } X } X else X { X fprintf(stderr, Usage); X exit(1); X } X } X else if (first) X { X from = a; /* from file */ X first = 0; X } X else if (first == 0) X { X to = a; /* to file */ X first = -1; X } X else X { X fprintf(stderr, Usage); X exit(1); X } X } X} X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X F_compound objects; X int status; X X get_args(argc, argv); X troff_init(); X if (to == NULL) X tfp = stdout; X else if ((tfp = fopen(to, "w")) == NULL) X { X fprintf(stderr, "Couldn't open %s\n", to); X fprintf(stderr, Usage); X exit(1); X } X X if (from) X status = read_fig(from, &objects); X else /* read from stdin */ X status = readfp_fig(stdin, &objects); X X if (status != 0) X { X if (from) read_fail_message(from, status); X exit(1); X } X genpic_objects(&objects); X if (tfp != stdout) fclose(tfp); X exit(0); X} X X#define TOP 10.5 /* top of page is 10.5 inch */ Xstatic double ppi; Xstatic int CONV = 0; X Xdouble Xconvy(a) Xdouble a; X{ X return((double)(CONV ? TOP-a : a)); X} X Xgenpic_objects(objects) XF_compound *objects; X{ X int coord_system; X F_arc *a; X F_compound *c; X F_ellipse *e; X F_line *l; X F_spline *s; X F_text *t; X X if (0 == (ppi = (double)objects->nwcorner.x)) X { X fprintf(stderr, "Resolution is zero!! default to 80 ppi\n"); X ppi = 80.0; X } X coord_system = objects->nwcorner.y; X if (coord_system != 1 && coord_system != 2) X { X fprintf(stderr, "Wrong coordinate system; cannot continue\n"); X return; X } X if (coord_system == 2) CONV = 1; X X fprintf(tfp, ".PS\n"); /* start of pic macro */ X X for (a = objects->arcs; a != NULL; a = a->next) genpic_arc(a); X for (c = objects->compounds; c != NULL; c = c->next) genpic_compound(c); X for (e = objects->ellipses; e != NULL; e = e->next) genpic_ellipse(e); X for (l = objects->lines; l != NULL; l = l->next) genpic_line(l); X for (s = objects->splines; s != NULL; s = s->next) genpic_spline(s); X for (t = objects->texts; t != NULL; t = t->next) genpic_text(t); X if(dotps) X fprintf(tfp, ".ps\n"); /* back to initial point size */ X if(dotft) X fprintf(tfp, ".ft\n"); /* back to initial font */ X fprintf(tfp, ".PE\n"); X} X X/* X** linewidth can be controlled with pointsize, but this means we have X** to be rigorous about using a .ps (null) every time, so a real point size X** request can revert to previous size X*/ Xset_linewidth(w) Xint w; X{ X if (w == 0 || w*10 == dotps) return; X fprintf(tfp,".ps\n.ps %d\n",dotps = 10*w); X} X Xset_style(s, v) Xint s; Xfloat v; X{ X static float style_val = -1; X X if (s == DASH_LINE || s == DOTTED_LINE) X { X if (v == style_val) return; X if (v == 0.0) return; X style_val = v; X fprintf(tfp, "dashwid = %.3fi\n", style_val/ppi); X } X} X Xgenpic_compound(com) XF_compound *com; X{ X F_arc *a; X F_compound *c; X F_ellipse *e; X F_line *l; X F_spline *s; X F_text *t; X X for (a = com->arcs; a != NULL; a = a->next) genpic_arc(a); X for (c = com->compounds; c != NULL; c = c->next) genpic_compound(c); X for (e = com->ellipses; e != NULL; e = e->next) genpic_ellipse(e); X for (l = com->lines; l != NULL; l = l->next) genpic_line(l); X for (s = com->splines; s != NULL; s = s->next) genpic_spline(s); X for (t = com->texts; t != NULL; t = t->next) genpic_text(t); X} X Xgenpic_line(l) XF_line *l; X{ X F_point *p, *q; X X set_linewidth(l->thickness); X set_style(l->style, l->style_val); X p = l->points; X q = p->next; X if (q == NULL) X { /* A single point line */ X fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f\n", X p->x/ppi, convy(p->y/ppi), p->x/ppi, convy(p->y/ppi)); X return; X } X if (l->back_arrow) X draw_arrow_head(q->x/ppi, convy(q->y/ppi), p->x/ppi, X convy(p->y/ppi), l->back_arrow->ht/ppi, l->back_arrow->wid/ppi); X if (l->style == DASH_LINE && l->style_val > 0.0) X fprintf(tfp, "line dashed from"); X else if (l->style == DOTTED_LINE && l->style_val > 0.0) X fprintf(tfp, "line dotted from"); X else X fprintf(tfp, "line from"); X fprintf(tfp, " %.3f,%.3f to", p->x/ppi, convy(p->y/ppi)); X while (q->next != NULL) X { X p = q; X q = q->next; X fprintf(tfp, " %.3f,%.3f to", p->x/ppi, convy(p->y/ppi)); X } X fprintf(tfp, " %.3f,%.3f\n", q->x/ppi, convy(q->y/ppi)); X if (l->for_arrow) X draw_arrow_head(p->x/ppi, convy(p->y/ppi), q->x/ppi, X convy(q->y/ppi), l->for_arrow->ht/ppi, l->for_arrow->wid/ppi); X} X Xgenpic_spline(s) XF_spline *s; X{ X set_linewidth(s->thickness); X if (int_spline(s)) X genpic_itp_spline(s); X else X genpic_ctl_spline(s); X} X Xgenpic_ctl_spline(s) XF_spline *s; X{ X if (closed_spline(s)) X genpic_closed_spline(s); X else X genpic_open_spline(s); X} X Xgenpic_open_spline(s) XF_spline *s; X{ X double x1, y1, x2, y2; X F_point *p, *q; X X p = s->points; X x1 = p->x/ppi; X y1 = convy(p->y/ppi); X p = p->next; X x2 = p->x/ppi; X y2 = convy(p->y/ppi); X X if (s->back_arrow) X draw_arrow_head(x2, y2, x1, y1, X s->back_arrow->ht/ppi, s->back_arrow->wid/ppi); X X /* Pic's spline supports only solid line style */ X X if (p->next == NULL) X { X fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f\n", x1, y1, x2, y2); X if (s->for_arrow) X draw_arrow_head(x1, y1, x2, y2, s->for_arrow->ht/ppi, X s->for_arrow->wid/ppi); X return; X } X X fprintf(tfp, "spline from %.3f,%.3f to %.3f,%.3f", x1, y1, x2, y2); X X for (q = p->next; q->next != NULL; p = q, q = q->next) X fprintf(tfp, " to %.3f,%.3f", q->x/ppi, convy(q->y/ppi)); X fprintf(tfp, " to %.3f,%.3f\n", (x2=q->x/ppi), (y2=convy(q->y/ppi))); X X if (s->for_arrow) X draw_arrow_head(p->x/ppi, convy(p->y/ppi), x2, y2, X s->for_arrow->ht/ppi, s->for_arrow->wid/ppi); X} X Xgenpic_ellipse(e) XF_ellipse *e; X{ X set_linewidth(e->thickness); X fprintf(tfp, "ellipse at %.3f,%.3f wid %.3f ht %.3f\n", X e->center.x/ppi, convy(e->center.y/ppi), X 2 * e->radiuses.x/ppi, 2 * e->radiuses.y/ppi); X} X X/* XText is display on the screen with the base line starting at X(base_x, base_y); some characters extend below this line. XPic displays the center of the height of text at the given Xcoordinate. HT_OFFSET is use to compensate all the above factors Xso text position in fig 1.4 should be at the same position on Xthe screen as on the hard copy. X*/ X#define HT_OFFSET (0.2 / 72.0) X Xgenpic_text(t) XF_text *t; X{ X float y; X static char fontcode[NUMFONTS][3]; X int i; X X if(fontcode[t->font][0] == '\0') X for(i=0; *troff_fonts[i].lwname != '\0'; i++) X { X if(strcmp(troff_fonts[i].lwname,fontnames[t->font].psfont)==0) X { X strncpy(&fontcode[t->font][0],troff_fonts[i].trname,2); X break; X } X } X if(fontcode[t->font][0] == '\0') X fontcode[t->font][0] = 'R'; /* default */ X X if(t->size != dotps) X fprintf(tfp, ".ps\n.ps %d\n", dotps = t->size); X if(t->font != dotft - 1) X { X fprintf(tfp, ".ft\n.ft %s\n", &fontcode[t->font][0]); X dotft = t->font + 1; X } X X y = convy(t->base_y/ppi) + t->size * HT_OFFSET; X fprintf(tfp, "\"%s\" at %.3f,%.3f", X t->cstring, t->base_x/ppi, y); X X switch(t->type) X { X case T_RIGHT_JUSTIFIED: X fprintf(tfp, " rjust\n"); X break; X case T_LEFT_JUSTIFIED: X fprintf(tfp, " ljust\n"); X break; X default: X putc('\n',tfp); X } X} X Xgenpic_arc(a) XF_arc *a; X{ X double x, y; X double cx, cy, sx, sy, ex, ey; X X cx = a->center.x/ppi; X cy = convy(a->center.y/ppi); X sx = a->point[0].x/ppi; X sy = convy(a->point[0].y/ppi); X ex = a->point[2].x/ppi; X ey = convy(a->point[2].y/ppi); X X set_linewidth(a->thickness); X X if (a->for_arrow) X { X arc_tangent(cx, cy, ex, ey, a->direction, &x, &y); X draw_arrow_head(x, y, ex, ey, X a->for_arrow->ht/ppi, a->for_arrow->wid/ppi); X } X if (a->back_arrow) X { X arc_tangent(cx, cy, sx, sy, !a->direction, &x, &y); X draw_arrow_head(x, y, sx, sy, X a->back_arrow->ht/ppi, a->back_arrow->wid/ppi); X } X X if (a->direction) X fprintf(tfp, "arc at %.3f,%.3f from %.3f,%.3f to %.3f,%.3f\n", X cx, cy, sx, sy, ex, ey); X else X fprintf(tfp, "arc at %.3f,%.3f from %.3f,%.3f to %.3f,%.3f cw\n", X cx, cy, sx, sy, ex, ey); X X} X Xarc_tangent(x1, y1, x2, y2, direction, x, y) Xdouble x1, y1, x2, y2, *x, *y; Xint direction; X{ X if (direction) X { /* counter clockwise */ X *x = x2 + (y2 - y1); X *y = y2 - (x2 - x1); X } X else X { X *x = x2 - (y2 - y1); X *y = y2 + (x2 - x1); X } X} X X/* draw arrow heading from (x1, y1) to (x2, y2) */ X Xdraw_arrow_head(x1, y1, x2, y2, arrowht, arrowwid) Xdouble x1, y1, x2, y2, arrowht, arrowwid; X{ X double x, y, xb, yb, dx, dy, l, sina, cosa; X double xc, yc, xd, yd; X X dx = x2 - x1; X dy = y1 - y2; X l = sqrt((dx*dx + dy*dy)); X sina = dy / l; X cosa = dx / l; X xb = x2*cosa - y2*sina; X yb = x2*sina + y2*cosa; X x = xb - arrowht; X y = yb - arrowwid / 2; X xc = x*cosa + y*sina; X yc = -x*sina + y*cosa; X y = yb + arrowwid / 2; X xd = x*cosa + y*sina; X yd = -x*sina + y*cosa; X fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f to %.3f,%.3f\n", X xc, yc, x2, y2, xd, yd); X} X X#define THRESHOLD .05 /* inch */ X Xquadratic_spline(a1, b1, a2, b2, a3, b3, a4, b4) Xdouble a1, b1, a2, b2, a3, b3, a4, b4; X{ X double x1, y1, x4, y4; X double xmid, ymid; X X x1 = a1; X y1 = b1; X x4 = a4; X y4 = b4; X X xmid = (a2 + a3) / 2; X ymid = (b2 + b3) / 2; X if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD) X { X fprintf(tfp, "\tto %.3f,%.3f\\\n", xmid, ymid); X } X else X { X quadratic_spline(x1, y1, ((x1+a2)/2), ((y1+b2)/2), X ((3*a2+a3)/4), ((3*b2+b3)/4), xmid, ymid); X } X X if (fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) X { X fprintf(tfp, "\tto %.3f,%.3f\\\n", x4, y4); X } X else X { X quadratic_spline(xmid, ymid, ((a2+3*a3)/4), ((b2+3*b3)/4), X ((a3+x4)/2), ((b3+y4)/2), x4, y4); X } X} X Xgenpic_closed_spline(s) XF_spline *s; X{ X F_point *p; X double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; X double x1, y1, x2, y2; X X set_linewidth(s->thickness); X p = s->points; X x1 = p->x/ppi; X y1 = convy(p->y/ppi); X p = p->next; X x2 = p->x/ppi; X y2 = convy(p->y/ppi); X cx1 = (x1 + x2) / 2; X cy1 = (y1 + y2) / 2; X cx2 = (x1 + 3 * x2) / 4; X cy2 = (y1 + 3 * y2) / 4; X X for (p = p->next; p != NULL; p = p->next) X { X fprintf(tfp, "line from %.3f,%.3f ", cx1, cy1); X x1 = x2; X y1 = y2; X x2 = p->x/ppi; X y2 = convy(p->y/ppi); X cx3 = (3 * x1 + x2) / 4; X cy3 = (3 * y1 + y2) / 4; X cx4 = (x1 + x2) / 2; X cy4 = (y1 + y2) / 2; X quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); X fprintf(tfp, "\n"); X cx1 = cx4; X cy1 = cy4; X cx2 = (x1 + 3 * x2) / 4; X cy2 = (y1 + 3 * y2) / 4; X } X x1 = x2; X y1 = y2; X p = s->points->next; X x2 = p->x/ppi; X y2 = convy(p->y/ppi); X cx3 = (3 * x1 + x2) / 4; X cy3 = (3 * y1 + y2) / 4; X cx4 = (x1 + x2) / 2; X cy4 = (y1 + y2) / 2; X fprintf(tfp, "line from %.3f,%.3f ", cx1, cy1); X quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); X fprintf(tfp, "\n"); X} X Xgenpic_itp_spline(s) XF_spline *s; X{ X F_point *p1, *p2; X F_control *cp1, *cp2; X double x1, x2, y1, y2; X X p1 = s->points; X cp1 = s->controls; X cp2 = cp1->next; X x2 = p1->x/ppi; X y2 = convy(p1->y/ppi); X X if (s->back_arrow) X draw_arrow_head(cp2->lx/ppi, convy(cp2->ly/ppi), x2, y2, X s->back_arrow->ht/ppi, s->back_arrow->wid/ppi); X X for (p2 = p1->next, cp2 = cp1->next; p2 != NULL; X cp1 = cp2, p2 = p2->next, cp2 = cp2->next) X { X fprintf(tfp, "line from %.3f,%.3f ", x2, y2); X x1 = x2; X y1 = y2; X x2 = p2->x/ppi; X y2 = convy(p2->y/ppi); X bezier_spline(x1, y1, (double)cp1->rx/ppi, convy(cp1->ry/ppi), X (double)cp2->lx/ppi, convy(cp2->ly/ppi), x2, y2); X fprintf(tfp, "\n"); X } X X if (s->for_arrow) X draw_arrow_head((double)cp1->lx/ppi, convy(cp1->ly/ppi), x1, y1, X (double)s->for_arrow->ht/ppi, (double)s->for_arrow->wid/ppi); X} X Xbezier_spline(a0, b0, a1, b1, a2, b2, a3, b3) Xdouble a0, b0, a1, b1, a2, b2, a3, b3; X{ X double x0, y0, x3, y3; X double sx1, sy1, sx2, sy2, tx, ty, tx1, ty1, tx2, ty2, xmid, ymid; X X x0 = a0; X y0 = b0; X x3 = a3; X y3 = b3; X if (fabs(x0 - x3) < THRESHOLD && fabs(y0 - y3) < THRESHOLD) X { X fprintf(tfp, "\tto %.3f,%.3f\\\n", x3, y3); X } X else X { X tx = (a1 + a2) / 2; X ty = (b1 + b2) / 2; X sx1 = (x0 + a1) / 2; X sy1 = (y0 + b1) / 2; X sx2 = (sx1 + tx) / 2; X sy2 = (sy1 + ty) / 2; X tx2 = (a2 + x3) / 2; X ty2 = (b2 + y3) / 2; X tx1 = (tx2 + tx) / 2; X ty1 = (ty2 + ty) / 2; X xmid = (sx2 + tx1) / 2; X ymid = (sy2 + ty1) / 2; X X bezier_spline(x0, y0, sx1, sy1, sx2, sy2, xmid, ymid); X bezier_spline(xmid, ymid, tx1, ty1, tx2, ty2, x3, y3); X } X} X END_OF_FILE if test 13361 -ne `wc -c <'f2p.c'`; then echo shar: \"'f2p.c'\" unpacked with wrong size! fi # end of 'f2p.c' fi if test -f 'ruler.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ruler.c'\" else echo shar: Extracting \"'ruler.c'\" \(12537 characters\) sed "s/^X//" >'ruler.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 "font.h" X#include "paintop.h" X X#define INCH_MARK 8 X#define HALF_MARK 8 X#define QUARTER_MARK 6 X#define SIXTEENTH_MARK 4 X X#define TRM_WID 16 X#define TRM_HT 8 X#define SRM_WID 8 X#define SRM_HT 16 X Xextern int CANVAS_HEIGHT, CANVAS_WIDTH; Xextern int SIDERULER_WIDTH, SIDERULER_HEIGHT; Xextern int TOPRULER_WIDTH, TOPRULER_HEIGHT; Xextern int SIDERULER_HEIGHT, SIDERULER_START; Xextern int TOPRULER_LEFT, TOPRULER_TOP; Xextern null_proc(); Xextern appresStruct appres; X Xstatic lasty = -100; Xstatic lastx = -100; Xstatic int troffx = -7, troffy = -10; Xstatic char tr_marker_image[16] = { X 0xFE, 0xFF, /* *************** */ X 0xFC, 0x7F, /* ************* */ X 0xF8, 0x3F, /* *********** */ X 0xF0, 0x1F, /* ********* */ X 0xE0, 0x0F, /* ******* */ X 0xC0, 0x07, /* ***** */ X 0x80, 0x03, /* *** */ X 0x00, 0x01, /* * */ X }; Xstatic mpr_static(trm_pr, TRM_WID, TRM_HT, 1, tr_marker_image); Xstatic int srroffx = 2, srroffy = -7; Xstatic char srr_marker_image[16] = { X 0x80, /* * */ X 0xC0, /* ** */ X 0xE0, /* *** */ X 0xF0, /* **** */ X 0xF8, /* ***** */ X 0xFC, /* ****** */ X 0xFE, /* ******* */ X 0xFF, /* ******** */ X 0xFE, /* ******* */ X 0xFC, /* ****** */ X 0xF8, /* ***** */ X 0xF0, /* **** */ X 0xE0, /* *** */ X 0xC0, /* ** */ X 0x80, /* * */ X 0x00 X }; Xstatic mpr_static(srrm_pr, SRM_WID, SRM_HT, 1, srr_marker_image); X Xstatic int srloffx = -10, srloffy = -7; Xstatic char srl_marker_image[16] = { X 0x01, /* * */ X 0x03, /* ** */ X 0x07, /* *** */ X 0x0F, /* **** */ X 0x1F, /* ***** */ X 0x3F, /* ****** */ X 0x7F, /* ******* */ X 0xFF, /* ******** */ X 0x7F, /* ******* */ X 0x3F, /* ****** */ X 0x1F, /* ***** */ X 0x0F, /* **** */ X 0x07, /* *** */ X 0x03, /* ** */ X 0x01, /* * */ X 0x00 X }; Xstatic mpr_static(srlm_pr, SRM_WID, SRM_HT, 1, srl_marker_image); X Xstatic Pixmap toparrow_pm, sidearrow_pm; X Xset_toprulermark(x) Xint x; X{ X XClearArea(tool_d, topruler_win,lastx + troffx, X TOPRULER_HEIGHT + troffy,trm_pr.width, X trm_pr.height, False); X XCopyArea(tool_d, toparrow_pm, topruler_win, topgc, X 0, 0, trm_pr.width, trm_pr.height, X x + troffx, TOPRULER_HEIGHT + troffy); X lastx = x; X } X Xstatic Arg ruler_args[] = X{ X /* 0 */ { XtNwidth, (XtArgVal) 0 }, X /* 1 */ { XtNheight, (XtArgVal) 0 }, X /* 2 */ { XtNlabel, (XtArgVal) "" }, X /* 3 */ { XtNfromHoriz, (XtArgVal) NULL }, X /* 4 */ { XtNhorizDistance, (XtArgVal) 0 }, X /* 5 */ { XtNfromVert, (XtArgVal) NULL }, X /* 6 */ { XtNvertDistance, (XtArgVal) 0 }, X /* 7 */ { XtNresizable, (XtArgVal) False }, X /* 8 */ { XtNtop, (XtArgVal) XtRubber }, /* these will be changed */ X /* 9 */ { XtNbottom, (XtArgVal) XtRubber }, X /* 10 */ { XtNleft, (XtArgVal) XtRubber }, X /* 11 */ { XtNright, (XtArgVal) XtRubber }, X}; X Xextern int SIDERULER_WIDTH, SIDERULER_HEIGHT; Xextern int TOPRULER_WIDTH, TOPRULER_HEIGHT; X Xint Xinit_sideruler(tool) X TOOL tool; X{ X ruler_args[0].value = SIDERULER_WIDTH = RULER_WIDTH; X ruler_args[1].value = SIDERULER_HEIGHT = CANVAS_HEIGHT; X ruler_args[3].value = (XtArgVal) canvas_sw; /* from right edge of canvas */ X ruler_args[5].value = (XtArgVal) topruler_sw; /* down from top ruler */ X /* Place the sideruler below the topruler, next to the canvas, X but fixed offset from the top of the form */ X ruler_args[8].value = (XtArgVal) XtChainTop; X ruler_args[9].value = (XtArgVal) XtRubber; X ruler_args[10].value = (XtArgVal) XtChainRight; X ruler_args[11].value = (XtArgVal) XtChainRight; X X sideruler_sw = XtCreateWidget("sruler", labelWidgetClass, tool, X ruler_args, XtNumber(ruler_args)); X return(1); X} X Xredisplay_sideruler() X{ X XClearWindow(tool_d, sideruler_win); X} X Xint Xinit_topruler(tool) X TOOL tool; X{ X ruler_args[0].value = TOPRULER_WIDTH = CANVAS_WIDTH;; /* width */ X ruler_args[1].value = TOPRULER_HEIGHT = RULER_WIDTH; /* height */ X ruler_args[3].value = (XtArgVal) panel_sw; X ruler_args[5].value = (XtArgVal) NULL; X /* fix the top & bottom to the top of the form, X the left to the panel, and the right is rubber */ X ruler_args[8].value = (XtArgVal) XtChainTop; X ruler_args[9].value = (XtArgVal) XtChainTop; X ruler_args[10].value = (XtArgVal) XtChainLeft; X ruler_args[11].value = (XtArgVal) XtRubber; X X topruler_sw = XtCreateWidget("truler", labelWidgetClass, tool, X ruler_args, XtNumber(ruler_args)); X return(1); X} X Xredisplay_topruler() X{ X XClearWindow(tool_d, topruler_win); X} X Xsetup_rulers() X{ X register int i, j; X register Pixmap p; X#define HINCH (PIX_PER_INCH / 2) X#define QINCH (PIX_PER_INCH / 4) X#define SINCH (PIX_PER_INCH / 16) X#define TWOMM (PIX_PER_CM / 5) X char number[3]; X Arg tmp_arg[3]; X unsigned long bg, fg; X static Arg ruler_args[] = X { X { XtNbackgroundPixmap, (XtArgVal)NULL }, X }; X X topruler_win = XtWindow(topruler_sw); X sideruler_win = XtWindow(sideruler_sw); X XDefineCursor(tool_d, topruler_win, (Cursor)bull_cursor.bitmap); X XDefineCursor(tool_d, sideruler_win, (Cursor)bull_cursor.bitmap); X X /* top ruler, adjustments for digits are kludges based on 6x13 char */ X p = XCreatePixmap(tool_d, topruler_win, X TOPRULER_WIDTH, TOPRULER_HEIGHT, X DefaultDepthOfScreen(tool_s)); X X XtSetArg(tmp_arg[0], XtNbackground, &bg); X XtSetArg(tmp_arg[1], XtNforeground, &fg); X XtGetValues(topruler_sw, tmp_arg, 2); X X XSetBackground(tool_d, gc, bg); X XSetForeground(tool_d, gc, bg); X XFillRectangle(tool_d, p, gc, 0, 0, TOPRULER_WIDTH, X TOPRULER_HEIGHT); X XSetForeground(tool_d, gc, fg); X X XDrawString(tool_d, p, gc, 2, TOPRULER_HEIGHT - INCH_MARK - 3, X appres.INCHES ? "in" : "cm", 2); X if(appres.INCHES) X for (i = SINCH - 1; i <= TOPRULER_WIDTH; i += SINCH) X { X j = i + 1; X if (j % PIX_PER_INCH == 0) X { X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - INCH_MARK - 1); X sprintf(number, "%d", j / PIX_PER_INCH); X XDrawString(tool_d, p, gc, i - 3, X TOPRULER_HEIGHT - INCH_MARK - 3, number, X j < PIX_PER_INCH * 10 ? 1 : 2); X } X else if (j % HINCH == 0) X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - HALF_MARK - 1); X else if (j % QINCH == 0) X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - QUARTER_MARK - 1); X else if (j % SINCH == 0) X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - SIXTEENTH_MARK - 1); X } X else X for (i = TWOMM - 1; i <= TOPRULER_WIDTH; i++) X { X j = i + 1; X if (j % PIX_PER_CM == 0) X { X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - INCH_MARK - 1); X sprintf(number, "%d", j / PIX_PER_CM); X XDrawString(tool_d, p, gc, i - 3, X TOPRULER_HEIGHT - INCH_MARK - 3, number, X j < PIX_PER_CM * 10 ? 1 : 2); X } X else if (j % TWOMM == 0) X XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i, X TOPRULER_HEIGHT - QUARTER_MARK - 1); X } X ruler_args[0].value = (XtArgVal) p; X XtSetValues(topruler_sw, ruler_args, 1); X X /* The arrows will be XORed into the rulers. X We want the foreground color in the arrow to result in X the foreground or background color in the display. X so if the source pixel is fg^bg, it produces fg when XOR'ed X with bg, and bg when XOR'ed with bg. X X If the source pixel is zero, it produces fg when XOR'ed with X fg, and bg when XOR'ed with bg. X */ X XSetForeground(tool_d, gc, fg ^ bg); X XSetBackground(tool_d, gc, 0); X X /* make pixmaps for top ruler arrow */ X toparrow_pm = XCreatePixmap(tool_d, topruler_win, trm_pr.width, X trm_pr.height, X DefaultDepthOfScreen(tool_s)); X XPutImage(tool_d, toparrow_pm, gc, &trm_pr, 0, 0, 0, 0, X trm_pr.width, trm_pr.height); X X /* side ruler, adjustments for digits are kludges based on 6x13 char */ X p = XCreatePixmap(tool_d, sideruler_win, X SIDERULER_WIDTH, SIDERULER_HEIGHT, X DefaultDepthOfScreen(tool_s)); X XtSetArg(tmp_arg[0], XtNbackground, &bg); X XtSetArg(tmp_arg[1], XtNforeground, &fg); X XtGetValues(sideruler_sw, tmp_arg, 2); X X XSetBackground(tool_d, gc, bg); X XSetForeground(tool_d, gc, bg); X XFillRectangle(tool_d, p, gc, 0, 0, SIDERULER_WIDTH, X SIDERULER_HEIGHT); X XSetForeground(tool_d, gc, fg); X X if( appres.INCHES ) X { X if( appres.RHS_PANEL ) X { X for (i = SINCH - 1; i <= SIDERULER_HEIGHT; i += SINCH) X { X j = i + 1; X if (j % PIX_PER_INCH == 0) X { X XDrawLine(tool_d, p, gc, RULER_WIDTH-INCH_MARK, X i, RULER_WIDTH, i); X sprintf(number, "%d", j / PIX_PER_INCH); X XDrawString(tool_d, p, gc, X RULER_WIDTH-INCH_MARK - 8, i + 3, X number, j < PIX_PER_INCH * 10 ? 1 : 2); X } X else if (j % QINCH == 0) X XDrawLine(tool_d, p, gc, X RULER_WIDTH-QUARTER_MARK, i, X RULER_WIDTH, i); X else if (j % SINCH == 0) X XDrawLine(tool_d, p, gc, X RULER_WIDTH-SIXTEENTH_MARK, i, X RULER_WIDTH, i); X } X } X else X { X for (i = SINCH - 1; i <= SIDERULER_HEIGHT; i += SINCH) X { X j = i + 1; X if (j % PIX_PER_INCH == 0) X { X XDrawLine(tool_d, p, gc, 0, i, X INCH_MARK - 1, i); X sprintf(number, "%d", j / PIX_PER_INCH); X XDrawString(tool_d, p, gc, INCH_MARK + 3, X i + 3, number, X j < PIX_PER_INCH * 10 ? 1 : 2); X } X else if (j % QINCH == 0) X XDrawLine(tool_d, p, gc, 0, i, X QUARTER_MARK - 1, i); X else if (j % SINCH == 0) X XDrawLine(tool_d, p, gc, 0, i, X SIXTEENTH_MARK - 1, i); X } X } X } X else X { X if( appres.RHS_PANEL ) X { X for (i = TWOMM - 1; i <= SIDERULER_HEIGHT; i++) X { X j = i + 1; X if (j % PIX_PER_CM == 0) X { X XDrawLine(tool_d, p, gc, RULER_WIDTH-INCH_MARK, X i, RULER_WIDTH, i); X sprintf(number, "%d", j / PIX_PER_CM); X XDrawString(tool_d, p, gc, X RULER_WIDTH-INCH_MARK - 8, i + 3, X number, j < PIX_PER_CM * 10 ? 1 : 2); X } X else if (j % TWOMM == 0) X XDrawLine(tool_d, p, gc, X RULER_WIDTH-QUARTER_MARK, i, X RULER_WIDTH, i); X } X } X else X { X for (i = TWOMM - 1; i <= SIDERULER_HEIGHT; i++) X { X j = i + 1; X if (j % PIX_PER_CM == 0) X { X XDrawLine(tool_d, p, gc, 0, i, X INCH_MARK - 1, i); X sprintf(number, "%d", j / PIX_PER_CM); X XDrawString(tool_d, p, gc, INCH_MARK + 3, X i + 3, number, X j < PIX_PER_CM * 10 ? 1 : 2); X } X else if (j % TWOMM == 0) X XDrawLine(tool_d, p, gc, 0, i, X QUARTER_MARK - 1, i); X } X } X } X ruler_args[0].value = (XtArgVal) p; X XtSetValues(sideruler_sw, ruler_args, 1); X X /* Colors set as above */ X XSetForeground(tool_d, gc, fg ^ bg); X XSetBackground(tool_d, gc, 0); X X /* make pixmaps for side ruler arrow */ X if( appres.RHS_PANEL ) X { X sidearrow_pm = XCreatePixmap(tool_d, sideruler_win, X srlm_pr.width, srlm_pr.height, X DefaultDepthOfScreen(tool_s)); X XPutImage(tool_d, sidearrow_pm, gc, &srlm_pr, 0, 0, 0, 0, X srlm_pr.width, srlm_pr.height); X } X else X { X sidearrow_pm = XCreatePixmap(tool_d, sideruler_win, X srrm_pr.width, srrm_pr.height, X DefaultDepthOfScreen(tool_s)); X XPutImage(tool_d, sidearrow_pm, gc, &srrm_pr, 0, 0, 0, 0, X srrm_pr.width, srrm_pr.height); X } X} X Xset_rulermark(x, y) Xint x, y; X{ X if( appres.TRACKING ) X { X set_siderulermark(y); X set_toprulermark(x); X } X} X Xredisplay_rulers() X{ X redisplay_topruler(); X redisplay_sideruler(); X} X Xset_siderulermark(y) Xint y; X{ X if( appres.RHS_PANEL ) { X /* Because the ruler uses a background pixmap, we can win X here by using XClearArea to erase the old thing. */ X XClearArea(tool_d, sideruler_win, X RULER_WIDTH+srloffx, lasty + srloffy, X srlm_pr.width, srlm_pr.height, False); X XCopyArea(tool_d, sidearrow_pm, sideruler_win, X sidegc, 0, 0, srlm_pr.width, X srlm_pr.height, RULER_WIDTH+srloffx, y + srloffy); X } X else X { X /* Because the ruler uses a background pixmap, we can win X here by using XClearArea to erase the old thing. */ X XClearArea(tool_d, sideruler_win, X srroffx, lasty + srroffy, X srlm_pr.width, srlm_pr.height, False); X XCopyArea(tool_d, sidearrow_pm, sideruler_win, X sidegc, 0, 0, srrm_pr.width, X srrm_pr.height, srroffx, y + srroffy); X } X lasty = y; X} END_OF_FILE if test 12537 -ne `wc -c <'ruler.c'`; then echo shar: \"'ruler.c'\" unpacked with wrong size! fi # end of 'ruler.c' fi if test -f 'undo.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'undo.c'\" else echo shar: Extracting \"'undo.c'\" \(13353 characters\) sed "s/^X//" >'undo.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 : August 1985. X * 2nd revision : March 1988. 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 Xextern int pointmarker_shown, compoundbox_shown; X Xextern int foreground_color, background_color; Xextern int last_action, last_object; Xextern int last_axis, last_rotateangle; Xextern int movedpoint_num; Xextern int fix_x, fix_y; Xextern F_pos last_position, new_position; X Xextern F_compound objects; Xextern F_compound saved_objects; Xextern F_compound object_tails; X Xextern F_point *left_point; Xextern F_point *moved_point; Xextern F_point *deleted_point; Xextern F_point *added_point; X Xundo() X{ X switch(last_action) { X case F_CREATE : X undo_create(); X break; X case F_REMOVE : X undo_remove(); X break; X case F_MOVE : X undo_move(); X break; X case F_MOVE_POINT : X undo_movepoint(); X break; X case F_FLIP : X undo_flip(); X break; X case F_ROTATE : X undo_rotate(); X break; X case F_GLUE : X undo_glue(); X break; X case F_BREAK : X undo_break(); X break; X case F_SCALE : X undo_scale(); X break; X case F_ADD_POINT : X undo_addpoint(); X break; X case F_DELETE_POINT : X undo_deletepoint(); X break; X case F_CHANGE : X undo_change(); X default : X return; X } X } X Xundo_addpoint() X{ X if (last_object == O_POLYLINE) X linepoint_deleting(saved_objects.lines); X else X splinepoint_deleting(saved_objects.splines); X last_action = F_DELETE_POINT; X deleted_point = added_point; X } X Xundo_deletepoint() X{ X if (last_object == O_POLYLINE) X linepoint_adding(saved_objects.lines, deleted_point); X else X splinepoint_adding(saved_objects.splines, deleted_point); X last_action = F_ADD_POINT; X added_point = deleted_point; X } X Xundo_break() X{ X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X cut_objects(&objects, &object_tails); X insert_compound(&objects.compounds, saved_objects.compounds); X last_action = F_GLUE; X } X Xundo_glue() X{ X put_msg("UNDO for GLUE not working"); X return; X X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X delete_compound(&objects.compounds, saved_objects.compounds); X append_objects(&objects, saved_objects.compounds, &object_tails); X last_action = F_BREAK; X } X Xundo_change() X{ X switch (last_object) { X case O_POLYLINE : X change_line(saved_objects.lines->next,saved_objects.lines); X break; X case O_ELLIPSE: X change_ellipse(saved_objects.ellipses->next,saved_objects.ellipses); X break; X case O_TEXT : X change_text(saved_objects.texts->next,saved_objects.texts); X break; X case O_SPLINE : X change_spline(saved_objects.splines->next,saved_objects.splines); X break; X case O_ARC : X change_arc(saved_objects.arcs->next,saved_objects.arcs); X break; X } X last_action = F_CHANGE; X} X X/* XWhen a single object is created, it is inserted as the first object in Xthe appropriate list in objects. It is also placed in the appropriate Xlist in saved_objects. X XHowever when a number of objects are created (usually by reading them Xin from a file or undoing a remove-all action), they are appended to Xthe lists in objects and also saved in saved_objects. The pointers Xin object_tails will be set to point to the last members of the lists Xin objects prior to the appending. X XNote: The read operation will set the pointers in object_tails Xwhile the remove-all operation will zero pointers in objects. X*/ X Xundo_create() X{ X switch(last_object) { X case O_POLYLINE : X objects.lines = saved_objects.lines->next; X saved_objects.lines->next = NULL; X erase_lines(saved_objects.lines); X break; X case O_ELLIPSE : X objects.ellipses = saved_objects.ellipses->next; X saved_objects.ellipses->next = NULL; X erase_ellipses(saved_objects.ellipses); X break; X case O_TEXT : X objects.texts = saved_objects.texts->next; X saved_objects.texts->next = NULL; X erase_texts(saved_objects.texts); X break; X case O_SPLINE : X objects.splines = saved_objects.splines->next; X saved_objects.splines->next = NULL; X erase_splines(saved_objects.splines); X break; X case O_ARC : X objects.arcs = saved_objects.arcs->next; X saved_objects.arcs->next = NULL; X erase_arcs(saved_objects.arcs); X break; X case O_COMPOUND : X objects.compounds = saved_objects.compounds->next; X saved_objects.compounds->next = NULL; X erase_compounds(saved_objects.compounds); X break; X case O_ALL_OBJECT : X cut_objects(&objects, &object_tails); X redisplay_canvas(); X break; X } X last_action = F_REMOVE; X } X Xundo_remove() X{ X switch (last_object) { X case O_POLYLINE : X draw_lines(saved_objects.lines); X insert_line(&objects.lines, saved_objects.lines); X break; X case O_ELLIPSE : X draw_ellipses(saved_objects.ellipses); X insert_ellipse(&objects.ellipses, saved_objects.ellipses); X break; X case O_TEXT : X draw_texts(saved_objects.texts); X insert_text(&objects.texts, saved_objects.texts); X break; X case O_SPLINE : X draw_splines(saved_objects.splines); X insert_spline(&objects.splines, saved_objects.splines); X break; X case O_ARC : X draw_arcs(saved_objects.arcs); X insert_arc(&objects.arcs, saved_objects.arcs); X break; X case O_COMPOUND : X draw_compounds(saved_objects.compounds); X insert_compound(&objects.compounds, saved_objects.compounds); X break; X case O_ALL_OBJECT : X append_objects(&objects, &saved_objects, &object_tails); X redisplay_canvas(); X break; X } X last_action = F_CREATE; X } X Xundo_flip() X{ X switch (last_object) { X case O_POLYLINE : X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X draw_line(saved_objects.lines, ERASE); X flip_line(saved_objects.lines, X last_position.x, last_position.y, X last_axis); X draw_line(saved_objects.lines, PAINT); X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X break; X case O_ELLIPSE : X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X draw_ellipse(saved_objects.ellipses, background_color); X flip_ellipse(saved_objects.ellipses, X last_position.x, last_position.y, X last_axis); X draw_ellipse(saved_objects.ellipses, foreground_color); X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X break; X case O_SPLINE : X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X draw_spline(saved_objects.splines, ERASE); X flip_spline(saved_objects.splines, X last_position.x, last_position.y, X last_axis); X draw_spline(saved_objects.splines, PAINT); X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X break; X case O_ARC : X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X draw_arc(saved_objects.arcs, background_color); X flip_arc(saved_objects.arcs, X last_position.x, last_position.y, X last_axis); X draw_arc(saved_objects.arcs, foreground_color); X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X break; X case O_COMPOUND : X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X erase_compound(saved_objects.compounds); X flip_compound(saved_objects.compounds, X last_position.x, last_position.y, X last_axis); X draw_compound(saved_objects.compounds); X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X break; X } X } X Xundo_move() X{ X int dx, dy; X X dx = last_position.x - new_position.x; X dy = last_position.y - new_position.y; X switch (last_object) { X case O_POLYLINE : X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X draw_line(saved_objects.lines, ERASE); X translate_line(saved_objects.lines, dx, dy); X draw_line(saved_objects.lines, PAINT); X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X break; X case O_ELLIPSE : X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X draw_ellipse(saved_objects.ellipses, background_color); X translate_ellipse(saved_objects.ellipses, dx, dy); X draw_ellipse(saved_objects.ellipses, foreground_color); X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X break; X case O_TEXT : X draw_text(saved_objects.texts, INV_PAINT); X translate_text(saved_objects.texts, dx, dy); X draw_text(saved_objects.texts, PAINT); X break; X case O_SPLINE : X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X draw_spline(saved_objects.splines, ERASE); X translate_spline(saved_objects.splines, dx, dy); X draw_spline(saved_objects.splines, PAINT); X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X break; X case O_ARC : X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X draw_arc(saved_objects.arcs, background_color); X translate_arc(saved_objects.arcs, dx, dy); X draw_arc(saved_objects.arcs, foreground_color); X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X break; X case O_COMPOUND : X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X erase_compound(saved_objects.compounds); X translate_compound(saved_objects.compounds, dx, dy); X draw_compound(saved_objects.compounds); X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X break; X } X swap_newp_lastp(); X } X Xundo_movepoint() X{ X switch (last_object) { X case O_POLYLINE : X relocate_linepoint(saved_objects.lines, X last_position.x, last_position.y, X saved_objects.lines->points->x, X saved_objects.lines->points->y, X moved_point, left_point); X break; X case O_SPLINE : X relocate_splinepoint(saved_objects.splines, last_position.x, X last_position.y, moved_point); X break; X case O_ARC : X relocate_arcpoint(saved_objects.arcs, last_position.x, X last_position.y, movedpoint_num); X break; X case O_ELLIPSE : X relocate_ellipsepoint(saved_objects.ellipses, last_position.x, X last_position.y, movedpoint_num); X break; X } X swap_newp_lastp(); X } X Xundo_rotate() X{ X switch (last_object) { X case O_POLYLINE : X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X draw_line(saved_objects.lines, ERASE); X if (last_rotateangle == 90) last_rotateangle = 270; X else last_rotateangle = 90; X rotate_line(saved_objects.lines, X last_position.x, last_position.y, X last_rotateangle); X draw_line(saved_objects.lines, PAINT); X if (pointmarker_shown) X toggle_linepointmarker(saved_objects.lines); X break; X case O_ELLIPSE : X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X draw_ellipse(saved_objects.ellipses, background_color); X if (last_rotateangle == 90) last_rotateangle = 270; X else last_rotateangle = 90; X rotate_ellipse(saved_objects.ellipses, X last_position.x, last_position.y, X last_rotateangle); X draw_ellipse(saved_objects.ellipses, foreground_color); X if (pointmarker_shown) X toggle_ellipsepointmarker(saved_objects.ellipses); X break; X case O_SPLINE : X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X draw_spline(saved_objects.splines, ERASE); X if (last_rotateangle == 90) last_rotateangle = 270; X else last_rotateangle = 90; X rotate_spline(saved_objects.splines, X last_position.x, last_position.y, X last_rotateangle); X draw_spline(saved_objects.splines, PAINT); X if (pointmarker_shown) X toggle_splinepointmarker(saved_objects.splines); X break; X case O_ARC : X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X draw_arc(saved_objects.arcs, background_color); X if (last_rotateangle == 90) last_rotateangle = 270; X else last_rotateangle = 90; X rotate_arc(saved_objects.arcs, X last_position.x, last_position.y, X last_rotateangle); X draw_arc(saved_objects.arcs, foreground_color); X if (pointmarker_shown) X toggle_arcpointmarker(saved_objects.arcs); X break; X case O_COMPOUND : X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X erase_compound(saved_objects.compounds); X if (last_rotateangle == 90) last_rotateangle = 270; X else last_rotateangle = 90; X rotate_compound(saved_objects.compounds, X last_position.x, last_position.y, X last_rotateangle); X draw_compound(saved_objects.compounds); X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X break; X } X } X Xundo_scale() X{ X float scalex, scaley; X X if (compoundbox_shown) X draw_compoundbox(saved_objects.compounds, INV_PAINT); X erase_compound(saved_objects.compounds); X scalex = ((float)(last_position.x-fix_x)) / (new_position.x-fix_x); X scaley = ((float)(last_position.y-fix_y)) / (new_position.y-fix_y); X scale_compound(saved_objects.compounds, scalex, scaley, fix_x, fix_y); X draw_compound(saved_objects.compounds); X if (compoundbox_shown) draw_compoundbox(saved_objects.compounds, INV_PAINT); X swap_newp_lastp(); X } X Xswap_newp_lastp() X{ X int t; /* swap new_position and last_position */ X X t = new_position.x; X new_position.x = last_position.x; X last_position.x = t; X t = new_position.y; X new_position.y = last_position.y; X last_position.y = t; X } END_OF_FILE if test 13353 -ne `wc -c <'undo.c'`; then echo shar: \"'undo.c'\" unpacked with wrong size! fi # end of 'undo.c' fi echo shar: End of archive 12 \(of 21\). cp /dev/null ark12isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 21 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 Opinions expressed reflect those of the author only.