home *** CD-ROM | disk | FTP | other *** search
- From: hot@integow.uucp (Roland van Hout)
- Newsgroups: alt.sources
- Subject: PD plot(4) librarys (and hercules driver for interactive 386) part 4 of 9
- Message-ID: <1392@integow.uucp>
- Date: 28 Oct 90 03:55:33 GMT
-
-
-
- #!/bin/sh
- # This is part 04 of a multipart archive
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= libplot/lp/ib_map.c ==============
- echo "x - extracting libplot/lp/ib_map.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/ib_map.c &&
- X/*
- X * ib_map.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X */
- X
- X#include <stdio.h>
- X#include "const.h"
- X#include "fillcnst.h"
- X
- X#ifdef TESTVER
- X#include <signal.h>
- X#include "dbgvars.h"
- X#endif
- X
- X#define XLIM 94 /* 47 for 1/2 pg output, 94 for full page
- X * output */
- X#define YLIM 480 /* 240/480 for half/full pg output, mode K... */
- X /* ...480/960 for half/full pg output, mode L */
- X#define MODE 'Z' /* 'K' / 'L': 60 dots per in / 120 dots per
- X * in 'Z' quad density 240 dots per in */
- X
- X#define LEFT_CUTOFF 0
- X
- X/*
- X * Constants
- X * SCALEX and SCALEY have been changed to vars, set in init_map,
- X * to simplify quick changes of scale, depending on XLIM, YLIM
- X */
- X
- X#define ROUNDER 0.0
- X
- X#ifndef TESTVER
- X#define PUT_BIT(x,y) map[(x >> 3) + (XLIM * y)] |= BITS[x & 7]
- X#endif
- X
- X#define ABS(x) ((x) > 0.0 ? (x) : -(x))
- X
- Xlong MAP_MAX;
- Xdouble SCALEX,
- X SCALEY; /* <<<<<<<<<<<< */
- Xchar BITS[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
- Xextern char map[]; /* in maps.c */
- X
- X
- X/*******************************
- X * catch(), catchi() were here *
- X *******************************/
- X
- X#ifdef TESTVER
- XPUT_BIT(x, y)
- X int x,
- X y;
- X{
- X int offset;
- X
- X offset = ((x >> 3) + (XLIM * y));
- X if ((offset >= (MAP_MAX)) || (offset < 0)) {
- X fprintf(stderr,
- X "PUTBIT offset overflow: %d; x: %d; y: %d\n", offset, x, y);
- X fprintf(errfp,
- X "PUTBIT offset overflow: %d; x: %d; y: %d\n", offset, x, y);
- X fclose(errfp);
- X dump_map(TRUE);
- X exit(1);
- X }
- X map[offset] |= BITS[x & 7];
- X}
- X
- X#endif
- X
- X
- Xib_put_seg(p1, p2)
- X POINT p1,
- X p2;
- X{
- X double diffx,
- X diffy,
- X change_ratio;
- X register int x,
- X y;
- X register int inc;
- X
- X#if 0
- X signal(SIGSEGV, catch);
- X signal(SIGINT, catchi);
- X#endif
- X
- X#ifdef TESTVER
- X if (debug2 || debug2x) {
- X fprintf(errfp, "p1 ( %d, %d ); p2 ( %d, %d )\n",
- X p1.x, p1.y, p2.x, p2.y);
- X }
- X#endif
- X
- X p1.x = SCALEX * (double) p1.x + ROUNDER;
- X p2.x = SCALEX * (double) p2.x + ROUNDER;
- X p1.y = SCALEY * (double) p1.y + ROUNDER;
- X p2.y = SCALEY * (double) p2.y + ROUNDER;
- X
- X diffx = p2.x - p1.x;
- X diffy = p2.y - p1.y;
- X
- X if (diffx != 0.0 && diffy != 0.0) { /* neither horiz nor vert */
- X if (ABS(diffx) > ABS(diffy)) { /* closer to horizontal */
- X inc = (diffx < 0) ? -1 : 1;
- X change_ratio = diffy / diffx;
- X for (x = p1.x; x != p2.x; x += inc) {
- X y = (x - p1.x) * change_ratio + p1.y + ROUNDER;
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, p2.y);
- X } else { /* closer to vertical */
- X inc = (diffy < 0) ? -1 : 1;
- X change_ratio = diffx / diffy;
- X for (y = p1.y; y != p2.y; y += inc) {
- X x = (y - p1.y) * change_ratio + p1.x + ROUNDER;
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, p2.y);
- X }
- X } else {
- X if (diffx) { /* horizontal line */
- X y = p1.y;
- X inc = (diffx < 0) ? -1 : 1;
- X for (x = p1.x; x != p2.x; x += inc) {
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, y);
- X } else { /* vert. line */
- X x = p1.x;
- X inc = (diffy < 0) ? -1 : 1;
- X for (y = p1.y; y != p2.y; y += inc) {
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(x, p2.y);
- X }
- X }
- X}
- X
- X
- Xib_dump_map(to_printer)
- X int to_printer;
- X{
- X int i;
- X register int j;
- X char ch;
- X char hdr[5];
- X
- X if (to_printer) {
- X hdr[0] = ESC;
- X hdr[1] = '3';
- X hdr[2] = 24; /* Line spacing for graphics: 24/216 inch */
- X write(1, hdr, 3);
- X hdr[1] = MODE; /* 'K'/'L': 480/960 bit image graphics */
- X hdr[2] = (YLIM - LEFT_CUTOFF) & 0xff; /* n1 = YLIM mod 256 */
- X hdr[3] = ((YLIM - LEFT_CUTOFF) >> 8) & 0xff; /* n2 = YLIM / 256 */
- X
- X for (i = 0; i < XLIM; i++) {
- X write(1, hdr, 4);
- X for (j = LEFT_CUTOFF * XLIM; j < MAP_MAX; j += XLIM) {
- X ch = map[i + j];
- X if (ch == 26)
- X ch = 18; /* bug in proprinter graphics */
- X if (ch == '\n')
- X ch = 8; /* prevent add'n of \r to \n */
- X write(1, &ch, 1);
- X#ifdef TESTVER
- X if (debug5)
- X fprintf(errfp, "%4d", ch);
- X#endif
- X }
- X#ifdef TESTVER
- X if (debug5)
- X fprintf(errfp, "%3d*\n", i);
- X#endif
- X putchar('\n'); /* LF and CR to end line */
- X putchar('\r');
- X fflush(stdout);
- X }
- X
- X /* putchar( '\f' ); *//* form feed */
- X#ifdef TESTVER
- X fclose(errfp);
- X#endif
- X
- X } /* end if ( to_printer )... */
- X}
- X
- X
- Xib_init_map()
- X{
- X#ifdef TRUESOLID
- X extern double PUs_per_dot; /* declared in file filltype.c */
- X
- X#endif
- X register int k;
- X register char *mp;
- X
- X MAP_MAX = XLIM * YLIM;
- X SCALEX = (double) (XLIM * 8) / 10366;
- X SCALEY = (double) (YLIM) / 7963;
- X
- X#ifdef TRUESOLID
- X PUs_per_dot = 1.0 / SCALEX; /* used by fix_fill() in file filltype.c */
- X#endif
- X
- X mp = map;
- X for (k = 0; k < MAP_MAX; k++)
- X *mp++ = 0;
- X}
- SHAR_EOF
- $TOUCH -am 0214090289 libplot/lp/ib_map.c &&
- chmod 0644 libplot/lp/ib_map.c ||
- echo "restore of libplot/lp/ib_map.c failed"
- set `wc -c libplot/lp/ib_map.c`;Wc_c=$1
- if test "$Wc_c" != "4616"; then
- echo original size 4616, current size $Wc_c
- fi
- # ============= libplot/lp/itoa.h ==============
- echo "x - extracting libplot/lp/itoa.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/itoa.h &&
- X/********************************************************************
- X ***** itoa -- Konvertieren Zahlen in ASCII String *****
- X ********************************************************************/
- X/* Setzt Zahlen in ASCII String um. Die Umwandlung erfolgt
- X in umgekehrter Reihenfolge. Danach wird der String vertauscht.
- X
- X Beispiele:
- X int n;
- X char scrtext[100];
- X
- X itoa(n,scrtext);
- X printf("String: %s",&scrtext[0]);
- X*/
- X
- Xitoa(n,scrtext)
- Xint n;
- Xchar scrtext[];
- X{
- Xint i,sign,c,j;
- X/*
- X Vorzeichen merken
- X*/
- Xif ((sign = n) <0)
- X n= -n;
- X/*
- X Umwandeln
- X*/
- Xi=0;
- Xdo
- X {
- X scrtext[i++]= n % 10 +'0';
- X }
- Xwhile (( n/= 10)>0);
- X/*
- X Vorzeichen setzen
- X*/
- Xif (sign <0)
- X scrtext[i++]='-';
- Xscrtext[i]='\0';
- X/*
- X Nun Umdrehen
- X*/
- Xj= i-1;
- Xif (j>0);
- X {
- X for (i=0 ; i<j ; i++ , j--)
- X {
- X c=scrtext[i];
- X scrtext[i]=scrtext[j];
- X scrtext[j]=c;
- X }
- X }
- X}
- X
- X
- SHAR_EOF
- $TOUCH -am 1007125888 libplot/lp/itoa.h &&
- chmod 0644 libplot/lp/itoa.h ||
- echo "restore of libplot/lp/itoa.h failed"
- set `wc -c libplot/lp/itoa.h`;Wc_c=$1
- if test "$Wc_c" != "879"; then
- echo original size 879, current size $Wc_c
- fi
- # ============= libplot/lp/label.c ==============
- echo "x - extracting libplot/lp/label.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/label.c &&
- X/*
- X * do_lb.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X */
- X
- X#include <stdio.h>
- X#include "const.h"
- X#include "vars.h"
- X#include "dbgvars.h"
- X
- Xextern POINT plot_char();
- X
- Xlabel(s)
- Xchar *s;
- X{
- X char *sp;
- X POINT l_point;
- X sp=s;
- X#ifdef TESTVER
- X int was_on,
- X xwas_on; /* for debugging */
- X
- X /* turn debug2/2x off, if necessary, for the duration of labeling */
- X if (debug2) {
- X was_on = TRUE;
- X debug2 = FALSE;
- X } else {
- X was_on = FALSE;
- X }
- X if (debug2x) {
- X xwas_on = TRUE;
- X debug2x = FALSE;
- X } else {
- X xwas_on = FALSE;
- X }
- X#endif
- X
- X l_point = current;
- X if (stand_set_sel)
- X while ((c = *sp++) != NULL) {
- X l_point = plot_char(l_point, c, set_standard);
- X }
- X else
- X while ((c = *sp++) != NULL) {
- X l_point = plot_char(l_point, c, set_alternate);
- X }
- X pen_up = TRUE;
- X
- X#ifdef TESTVER
- X if (was_on) {
- X debug2 = TRUE;
- X }
- X if (xwas_on) {
- X debug2x = TRUE;
- X }
- X#endif
- X}
- X
- SHAR_EOF
- $TOUCH -am 1010115088 libplot/lp/label.c &&
- chmod 0644 libplot/lp/label.c ||
- echo "restore of libplot/lp/label.c failed"
- set `wc -c libplot/lp/label.c`;Wc_c=$1
- if test "$Wc_c" != "939"; then
- echo original size 939, current size $Wc_c
- fi
- # ============= libplot/lp/liblj.c ==============
- echo "x - extracting libplot/lp/liblj.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/liblj.c &&
- X/*
- X * main.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X *
- X * hpglplot v2.1
- X *
- X * Filter to read HPGL commands (Hewlett-Packard Graphics Language,
- X * used by HP7475A 6-pen plotter, among others) and produce bit map
- X * graphics commands for various printers.
- X *
- X * Usage: tplotlp -eismh
- X * Options: for the lpdriver.c program
- X * -e produce output for Epson LQ-1500
- X * -i produce output for IBM Proprinter
- X * -s produce output for HP LaserJet+ small
- X * -m produce output for HP LaserJet+ enlarged
- X * -h produce output for HP LaserJet+ extra large
- X *
- X *
- X * Authors:
- X * Mel Brooks
- X * Initial program design, command interpreter, Epson bit-map.
- X * Al Chase
- X * Fill routines, LaserJet and Proprinter bit-maps.
- X * David MacKenzie
- X * Rewrote option parser and makefile, cleaned up.
- X */
- X/* plot(4) graphics library for a regis terminal for VT240/VT300/GIGI */
- Xextern float deltx,delty;
- Xfloat pitograd;
- X
- X#include <math.h>
- X#include "plotlp.h"
- X
- Xclosepl()
- X{
- Xdump_map(printer);
- X}
- X
- Xspace(x0,y0,x1,y1)
- Xint x0,y0,x1,y1;
- X{
- Xint x,y;
- Xpitograd=(180.0/M_PI);
- X
- Xif (x1>0 && y1>0 && y0<y1 && x0<x1) {
- X x=x1-x0;y=y1-y0;
- X gxscrunch=(7850/(float) x);gyscrunch=(7850/(float) y);
- X offx = -(x0*gxscrunch);offy= -(y0*gyscrunch);
- X}
- X
- X}
- X
- Xerase()
- X{
- X/* printf("\014");*/
- X}
- X
- X
- Xarc(x,y,x0,y0,x1,y1)
- Xint x,y,x0,y0,x1,y1;
- X{
- X/*
- Xfloat a1,a2,r1,r2;
- Xint xo,yo,c1,c2,c;
- X move(x0,y0);
- X if ((x-x0) > 0) {
- X r1=(y-y0)/(x-x0);
- X a1=atan(r1);
- X c1=(a1*pitograd);
- X }
- X else {
- X c1=180;
- X }
- X if ((x-x1) > 0) {
- X r2=(y-y1)/(x-x1);
- X a2=atan(r2);
- X c2=(a2*pitograd);
- X }
- X else {
- X c2=180;
- X }
- X c=c1-c2;
- X xo=(x*gxscrunch);yo=(y*gyscrunch);
- X yo += offy ;xo += offx ;
- X printf("\033PpC(A%dC) [%d,%d]\033\\",c,xo,yo);
- X
- X*/
- X}
- X/*
- X * do_ew.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include "const.h"
- X#include "vars.h"
- X#ifdef TESTVER
- X# include "dbgvars.h"
- X#endif
- X
- X#define DEGREES_TO_RADIANS 3.1415926535898 / 180.0
- X
- Xdo_EW()
- X{
- X POINT t,
- X t1;
- X float radius;
- X int i_radius,
- X start_angle,
- X sweep_angle,
- X chordangle;
- X int i;
- X
- X#ifdef TESTVER
- X int xwas_on; /* for debugging
- X
- X /* turn debug2x off, if necessary, for the duration of do_EW()
- X if (debug2x) {
- X xwas_on = TRUE;
- X debug2x = FALSE;
- X } else {
- X xwas_on = FALSE;
- X }
- X#endif
- X
- X if (scanf("%f,%d,%d", &radius, &start_angle, &sweep_angle) != 3) {
- X fprintf(stderr, "Odd number of coordinate\n");
- X exit(4);
- X }
- X if ((c = getchar()) != ';') {
- X scanf("%d", &chordangle);
- X getchar();
- X } else {
- X chordangle = chord_angle;
- X }
- X
- X if (sweep_angle < 0)
- X chordangle = -1 * (abs(chordangle));
- X
- X start_angle %= 360;
- X if (sweep_angle > 360)
- X sweep_angle = 360;
- X else if (sweep_angle < -360)
- X sweep_angle = -360;
- X
- X if (scaling) {
- X i_radius = (int) (radius * x_scaler);
- X if (i_radius < 0)
- X i_radius -= 1;
- X } else
- X i_radius = (int) radius;
- X
- X /* plot starting radius
- X t.x = (int) ((double) radius * cos((double) start_angle *
- X DEGREES_TO_RADIANS) + 0.5) + current.x;
- X t.y = (int) ((double) radius * sin((double) start_angle *
- X DEGREES_TO_RADIANS) + 0.5) + current.y;
- X put_seg(current, t);
- X
- X /* plot chords up to (but not incl) sweep_angle
- X for (i = chordangle; abs(i) < abs(sweep_angle); i += chordangle) {
- X t1.x = (int) ((double) radius * cos((double) (start_angle + i)
- X * DEGREES_TO_RADIANS) + 0.5) + current.x;
- X t1.y = (int) ((double) radius * sin((double) (start_angle + i)
- X * DEGREES_TO_RADIANS) + 0.5) + current.y;
- X put_seg(t, t1);
- X t = t1;
- X }
- X
- X /* plot remaining (partial?) chord needed to make up the full sweep angle
- X t1.x = (int) ((double) radius * cos((double) (start_angle + sweep_angle)
- X * DEGREES_TO_RADIANS) + 0.5) + current.x;
- X t1.y = (int) ((double) radius * sin((double) (start_angle + sweep_angle)
- X * DEGREES_TO_RADIANS) + 0.5) + current.y;
- X put_seg(t, t1);
- X t = t1;
- X
- X /* plot ending radius
- X put_seg(t1, current);
- X
- X#ifdef TESTVER /* reset debug2x if necessary
- X if (xwas_on) {
- X debug2x = TRUE;
- X }
- X#endif
- X}
- X*/
- X
- Xdot(xi,yi,dx,n,pat)
- Xint xi,yi,dx,n,pat[256];
- X{
- X}
- X
- Xpoint(x,y)
- Xint x,y;
- X{
- X move(x,y);
- X cont(x,y);
- X}
- X
- X
- Xline (x1, y1, x2, y2)
- Xint x1,y1,x2,y2;
- X{
- X move(x1,y1);
- X cont(x2,y2);
- X}
- X
- X
- X
- X
- SHAR_EOF
- $TOUCH -am 1011095088 libplot/lp/liblj.c &&
- chmod 0644 libplot/lp/liblj.c ||
- echo "restore of libplot/lp/liblj.c failed"
- set `wc -c libplot/lp/liblj.c`;Wc_c=$1
- if test "$Wc_c" != "4267"; then
- echo original size 4267, current size $Wc_c
- fi
- # ============= libplot/lp/linemod.c ==============
- echo "x - extracting libplot/lp/linemod.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/linemod.c &&
- X#include "plotlp.h"
- X
- Xlinemod(s)
- Xchar *s;
- X{
- X line_type = SOLID;
- X if (strcmp(s,"dotted")==0) {
- X line_type=DOTS;
- X }
- X else if (strcmp(s,"solid")==0) {
- X line_type = SOLID;
- X }
- X else if (strcmp(s,"longdashed")==0) {
- X line_type=BROKN_2DASH;
- X }
- X else if (strcmp(s,"shortdashed")==0) {
- X line_type=SHORT_DASH;
- X }
- X else if (strcmp(s,"dotdashed")==0) {
- X line_type=BROKN_DASH;
- X }
- X}
- X
- SHAR_EOF
- $TOUCH -am 1010110488 libplot/lp/linemod.c &&
- chmod 0644 libplot/lp/linemod.c ||
- echo "restore of libplot/lp/linemod.c failed"
- set `wc -c libplot/lp/linemod.c`;Wc_c=$1
- if test "$Wc_c" != "399"; then
- echo original size 399, current size $Wc_c
- fi
- # ============= libplot/lp/lj_map.c ==============
- echo "x - extracting libplot/lp/lj_map.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/lj_map.c &&
- X/*
- X * lj_map.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X */
- X
- X#include <stdio.h>
- X#include "const.h"
- X#include "vars.h"
- X#include "fillcnst.h"
- X#include "itoa.h"
- X
- X#ifdef TESTVER
- X#include <signal.h>
- X#endif
- X
- X/*
- X * Origin is at lower left corner.
- X * Bytes of raster data are oriented along the x-axis, hi bit at left:
- X * (0,0) is bit 7 of byte 0;
- X * (7,0) is bit 0 of byte 0;
- X * (16,0) is bit 7 of byte 2;
- X * (16,3) is bit 7 of byte (2 + Xlim*3)
- X */
- X
- X/*
- X * Constants
- X * Ylim = 1440 dot rows, plus a couple extra for rounding error
- X#define Ylim 1442
- X#define Xlim 235
- X#define scaleX 0.180859
- X#define scaleY 0.180859
- X
- X#define Ylim 1841
- X#define Xlim 300
- X
- X/* scaleX = scaleY = number of dots per plotter unit
- X = 1440 dot rows in y-direction / 7962 PU's in y-dir
- X#define scaleX 0.231205
- X#define scaleY 0.231205
- X#define rounder 0.0
- X [hot@mh.nl] */
- X
- Xstatic int Ylim,Xlim,Ylim8;
- Xstatic double scaleX,scaleY,rounder;
- X
- X#define ABS(x) ((x) > 0.0 ? (x) : -(x))
- X
- X/* move bit map to maps.c for combined printer version --- */
- X#if 0
- Xchar map[Xlim * Ylim];
- X
- X#endif
- Xextern char map[];
- X
- Xstatic char BITS[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
- X#ifdef TESTVER
- X#define PUT_BIT(x, y) map[(tempindex = (tempx = (x >> 3)) + ((tempy = y) * Xlim))] |= BITS[x & 7];
- X#else
- X#define P_BIT(x, y) map[(x >> 3) + (y * Xlim)] |= BITS[x & 7];
- XPUT_BIT(x, y)
- Xint x,y;
- X{
- Xint saveit;
- Xif (printer == LASERHIGH || printer == LASERMED) {
- X saveit=x;x=y;y=Ylim-saveit;
- X}
- XP_BIT(x,y);
- X}
- X
- X#endif
- X
- X
- X#ifdef TESTVER
- Xstatic int tempindex,
- X tempx,
- X tempy;
- Xstatic POINT tempp1,
- X tempp2;
- X
- Xlj_catch()
- X{
- X fprintf(stderr, "Segmentation violation\n");
- X fprintf(stderr, "tempindex = %d x = %d y = %d p1 = %d,%d p2 = %d,%d\n",
- X tempindex, tempx, tempy, tempp1.x, tempp1.y, tempp2.x, tempp2.y);
- X lj_dump_map(FALSE);
- X exit(1);
- X}
- X
- Xljcatchi()
- X{
- X lj_dump_map(FALSE);
- X exit(1);
- X}
- X
- X#endif
- X
- Xlj_put_seg(p1, p2)
- X POINT p1,
- X p2;
- X{
- X double diffx,
- X diffy,
- X change_ratio;
- X register int x,
- X y;
- X register int inc;
- X
- X#ifdef TESTVER
- X#if 0
- X signal(SIGSEGV, lj_catch);
- X signal(SIGINT, ljcatchi);
- X#endif
- X tempp1 = p1;
- X tempp2 = p2;
- X#endif
- X
- X p1.x = scaleX * (double) p1.x + rounder;
- X p2.x = scaleX * (double) p2.x + rounder;
- X p1.y = scaleY * (double) p1.y + rounder;
- X p2.y = scaleY * (double) p2.y + rounder;
- X
- X diffx = p2.x - p1.x;
- X diffy = p2.y - p1.y;
- X
- X if (diffx != 0.0 && diffy != 0.0) {
- X if (ABS(diffx) > ABS(diffy)) {
- X inc = (diffx < 0) ? -1 : 1;
- X change_ratio = diffy / diffx;
- X for (x = p1.x; x != p2.x; x += inc) {
- X y = (x - p1.x) * change_ratio + p1.y + rounder;
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, p2.y);
- X } else {
- X inc = (diffy < 0) ? -1 : 1;
- X change_ratio = diffx / diffy;
- X for (y = p1.y; y != p2.y; y += inc) {
- X x = (y - p1.y) * change_ratio + p1.x + rounder;
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, p2.y);
- X }
- X } else {
- X if (diffx) { /* horizontal line */
- X y = p1.y;
- X inc = (diffx < 0) ? -1 : 1;
- X for (x = p1.x; x != p2.x; x += inc) {
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(p2.x, y);
- X } else {
- X x = p1.x;
- X inc = (diffy < 0) ? -1 : 1;
- X for (y = p1.y; y != p2.y; y += inc) {
- X PUT_BIT(x, y);
- X }
- X PUT_BIT(x, p2.y);
- X }
- X }
- X}
- X
- X
- Xlj_dump_map(to_printer)
- X int to_printer;
- X{
- X register int r;
- X char ccount[8];/* [hot@mh.nl] */
- X char hdr[80];/* [hot@mh.nl] */
- X char *mp = map;
- X char *p,leeg,
- X *maxp; /* for LF-char test */
- X short int schrijfspaar,hdr_length;
- X short int county,countx,countsx,countdif;/* [hot@mh.nl] */
- X
- X if (to_printer) {
- X hdr[0] = ESC;
- X
- X /* reset printer */
- X hdr_length = 1 + n_strcpy(&hdr[1], "E");
- X write(1, hdr, hdr_length);
- X
- X /* set printer to interpret a '\n' char to a '\r\n' pair */
- X hdr_length = 1 + n_strcpy(&hdr[1], "&k2G");
- X write(1, hdr, hdr_length);
- X
- X /* raster graphics resolution: 300 dots/in */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*t300R");
- X write(1, hdr, hdr_length);
- X
- X if (printer == LASERLOW) {
- X /* set cursor to col 11 */
- X hdr_length = 1 + n_strcpy(&hdr[1], "&a11C");
- X write(1, hdr, hdr_length);
- X
- X /* set cursor to row 10 */
- X hdr_length = 1 + n_strcpy(&hdr[1], "&a10R");
- X write(1, hdr, hdr_length);
- X /* [hot@mh.nl] */
- X }
- X
- X /* start graphics at current cursor posn */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*r1A");
- X write(1, hdr, hdr_length);
- X
- X if (printer==LASERLOW) {
- X /* transfer-line-of-graphics escape sequence -- 235 is Xlim */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*b");
- X itoa(Xlim,ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], "W");
- X }
- X
- X /*
- X * write Ylim rows, each row is Xlim bytes starting at offset r from
- X * map[0]
- X */
- X for (r = (Ylim - 1) * Xlim,county=1; r >= 0; r -= Xlim,county++) {
- X /* check this row for LF-chars; replace with byte value of 8 */
- X p = mp + r;
- X maxp = p + Xlim;
- X leeg=0; /* [hot@mh.nl] */
- X countx=0;
- X schrijfspaar=FALSE;
- X while (p < maxp) {
- X if (*p == '\n') *p = '\010';
- X if (printer != LASERLOW){
- X if (*p == '\000') {
- X if (schrijfspaar==TRUE) {
- X /* transfer-line-of-graphics escape sequence -- 235 is Xlim */
- X hdr_length += n_strcpy(&hdr[hdr_length], "\033*b");
- X itoa(countdif,ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], "W");
- X write(1, hdr, hdr_length);
- X write(1, mp + r + countsx, countdif);
- X /* end raster graphics */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*rB");
- X write(1, hdr, hdr_length);
- X schrijfspaar=FALSE;
- X fflush(stdout);
- X }
- X }
- X else { /* *p != 0 */
- X if (schrijfspaar==FALSE) {
- X /* make cursorposition header */
- X /* set cursor to current col */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*p");
- X itoa((countx*8),ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], "X");
- X /* set cursor to current row */
- X hdr_length += n_strcpy(&hdr[hdr_length], "\033*p");
- X itoa(county,ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], "Y");
- X /* start graphics at current cursor posn */
- X hdr_length += n_strcpy(&hdr[hdr_length], "\033*r1A");
- X countdif=1;countsx=countx;
- X schrijfspaar=TRUE;
- X }
- X else /* schrijfspaar==TRUE */
- X {
- X countdif++;
- X }
- X
- X } /* end of if (*p == 0) */
- X /* [hot@mh.nl] */
- X } /* end of if (printer != LASERLOW) */
- X p++;countx++;
- X } /* end of while (p < maxp) */
- X if (printer == LASERLOW) {
- X write(1, hdr, hdr_length);
- X write(1, mp + r, Xlim);
- X }
- X else {
- X if (schrijfspaar==TRUE) {
- X /* transfer-line-of-graphics escape sequence -- 235 is Xlim */
- X hdr_length += n_strcpy(&hdr[hdr_length], "\033*b");
- X itoa(countdif,ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], ccount);
- X hdr_length += n_strcpy(&hdr[hdr_length], "W");
- X write(1, hdr, hdr_length);
- X write(1, mp + r + countsx, countdif);
- X /* end raster graphics */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*rB");
- X write(1, hdr, hdr_length);
- X schrijfspaar=FALSE;
- X }
- X } /* end else van if (printer==LASERLOW) */
- X fflush(stdout);
- X } /* end van de grote for loop voor iedere regel */
- X if (printer==LASERLOW) {
- X /* end raster graphics */
- X hdr_length = 1 + n_strcpy(&hdr[1], "*rB");
- X write(1, hdr, hdr_length);
- X }
- X
- X /* reset printer and eject the page
- X hdr_length = 1 + n_strcpy(&hdr[1], "E");
- X write(1, hdr, hdr_length);
- X*/
- X /*
- X * set printer to interpret a '\n' char to a '\r\n' pair. this works
- X * in combo with the plot script, which also controls interpretation
- X * of \n's at the port
- X */
- X hdr_length = 1 + n_strcpy(&hdr[1], "&k2G");
- X write(1, hdr, hdr_length);
- X
- X fflush(stdout);
- X }
- X}
- X
- X
- X/*
- X * copy string from src to dst, including terminating \0.
- X * return number of chars copied, excluding terminating \0
- X */
- Xint
- Xn_strcpy(dst, src)
- X char *dst,
- X *src;
- X{
- X char *p;
- X
- X p = src;
- X while (*dst++ = *src++);
- X return ((--src) - p);
- X}
- X
- X
- Xlj_init_map()
- X{
- X register int k;
- X register char *mp;
- X int map_max ;
- X#ifdef TRUESOLID
- X extern double PUs_per_dot; /* declared in file filltype.c */
- X#endif
- X
- X switch(printer) {
- X case LASERLOW:
- X Ylim=1442;
- X Xlim=235;
- X scaleX=0.180859;
- X scaleY=0.180859;
- X rounder=0.0;
- X break;
- X case LASERMED:
- X Ylim=1841;
- X Xlim=300;
- X scaleX=0.231205;
- X scaleY=0.231205;
- X rounder=0.0;
- X break;
- X
- X/* scaleX = scaleY = number of dots per plotter unit
- X = 1440 dot rows in y-direction / 7962 PU's in y-dir */
- X case LASERHIGH:
- X Ylim=3000;
- X Ylim8=375;
- X Xlim=298;
- X scaleX=0.2995369;
- X scaleY=0.2995369;
- X rounder=0.0;
- X break;
- X }
- X map_max = Ylim * Xlim;
- X
- X#ifdef TRUESOLID
- X PUs_per_dot = 1.0 / scaleX; /* used by fix_fill() in file filltype.c */
- X#endif
- X
- X mp = map;
- X for (k = 0; k < map_max; k++) {
- X *mp++ = 0;
- X }
- X}
- SHAR_EOF
- $TOUCH -am 0216085089 libplot/lp/lj_map.c &&
- chmod 0644 libplot/lp/lj_map.c ||
- echo "restore of libplot/lp/lj_map.c failed"
- set `wc -c libplot/lp/lj_map.c`;Wc_c=$1
- if test "$Wc_c" != "9092"; then
- echo original size 9092, current size $Wc_c
- fi
- # ============= libplot/lp/maps.c ==============
- echo "x - extracting libplot/lp/maps.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > libplot/lp/maps.c &&
- X/*
- X * maps.c
- X *
- X * Copyright (c) 1988 Environmental Defense Fund, Inc.
- X *
- X * Uses the value of printer to dispatch map-related function
- X * calls to either ep_map.c or lj_map.c
- X */
- X
- X#include "const.h"
- X#include "vars.h"
- X
- X/*
- X * This is a single bit map, accessed by either the epson or laserjet
- X * map-related function calls, depending on which printer is being used.
- X * It has been declared to be somewhat larger than necessary.
- X */
- X
- Xchar map[BITMAPSIZE];
- X
- Xinit_map()
- X{
- X switch (printer) {
- X case EPSON:
- X ep_init_map();
- X break;
- X case LASERLOW:
- X case LASERMED:
- X case LASERHIGH:
- X lj_init_map();
- X break;
- X case IBM_PRO:
- X ib_init_map();
- X break;
- X }
- X}
- X
- Xdump_map(to_printer)
- X int to_printer;
- X{
- X switch (printer) {
- X case EPSON:
- X ep_dump_map(to_printer);
- X break;
- X case LASERLOW:
- X case LASERMED:
- X case LASERHIGH:
- X lj_dump_map(to_printer);
- X break;
- X case IBM_PRO:
- X ib_dump_map(to_printer);
- X break;
- X }
- X}
- X
- Xput_seg(p1, p2)
- X POINT p1,
- X p2;
- X{
- X switch (printer) {
- X case EPSON:
- X ep_put_seg(p1, p2);
- X break;
- X case LASERLOW:
- X case LASERMED:
- X case LASERHIGH:
- X lj_put_seg(p1, p2);
- X break;
- X case IBM_PRO:
- X ib_put_seg(p1, p2);
- X break;
- X }
- X}
- SHAR_EOF
- $TOUCH -am 1007125888 libplot/lp/maps.c &&
- chmod 0644 libplot/lp/maps.c ||
- echo "restore of libplot/lp/maps.c failed"
- set `wc -c libplot/lp/maps.c`;Wc_c=$1
- if test "$Wc_c" != "1200"; then
- echo original size 1200, current size $Wc_c
- fi
- echo "End of part 4, continue with part 5"
- exit 0
-
-
-
- --
- UUCP: ..!uunet!mcsun!hp4nl!integow!hot or hot@integow.UUCP or hot@hot.mug
- Roland van Hout, Sr. software engineer, Integrity software consultants,
- Pelmolenlaan 16, 3447 GW Woerden, Netherlands,
- tel +31 3480-30131, fax +31 3480-30182
-