Patch 2 to Reldb - Relational database and graphing tools
Gunnar Stefansson
gunnar at hafro.is
Tue Sep 26 22:08:29 AEST 1989
This is patch 2 to Reldb.
These patches include some corrections to problems that occurred during
distribution (in particular, a newline was missing in one of the
doc-files, causing strange things). Also included are changes
to the plot(1)-filters, xplot, hpglplot and plot itself. Xplot in now
much better than before, and several new extensions have been added to
the standard plot(5)-commands.
Remember to apply patch 1 before this.
cd to where you keep the Reldb programs and run this through 'patch -p'.
Please let me know asap of any problems.
*** patchlevel.h Tue Sep 26 11:26:00 1989
--- patchlevel.h Tue Sep 26 11:40:23 1989
Prereq: 1
***************
*** 1 ****
! #define PATCHLEVEL 1
--- 1 ----
! #define PATCHLEVEL 2
*** doc/scat.1 Tue Sep 26 11:25:08 1989
--- doc/scat.1 Mon Sep 25 22:31:12 1989
***************
*** 59,60 ****
--- 59,76 ----
[
+ .B \-T
+ "x number"
+ ]
+ [
+ .B \-T
+ "y number"
+ ]
+ [
+ .B \-t
+ "x number"
+ ]
+ [
+ .B \-t
+ "y number"
+ ]
+ [
.B \-d
***************
*** 187,188 ****
--- 203,217 ----
.I name.
+ .TP
+ .BI \-T\ xnumber
+ Number of large tick marks on x-axis.
+ .TP
+ .BI \-T\ ynumber
+ Number of large tick marks on y-axis.
+ .TP
+ .BI \-t\ xnumber
+ Number of small tick marks between large tick marks on x-axis.
+ .TP
+ .BI \-t\ xnumber
+ Number of small tick marks between large tick marks on y-axis.
+ .B
.TP
*** doc/subtotal.1 Tue Sep 26 11:25:09 1989
--- doc/subtotal.1 Mon Sep 25 21:01:49 1989
***************
*** 56,117 ****
.I addcol
! to do the work. This is inefficient but the inefficiency is rarely noticable.\Rogue\Monster\
! else
! echo "will not over write ./doc/subtotal.1"
! fi
! if `test ! -s ./doc/union.1`
! then
! echo "writting ./doc/union.1"
! cat > ./doc/union.1 << '\Rogue\Monster\'
! .\" Man page for union(1)
! .TH UNION 1 "1. April 1989"
! .SH NAME
! union - appends one table to another
! .SH SYNOPSIS
! .B union
! .I file1\ file2
! [
! .I >\ outputfile
! ]
! .SH DESCRIPTION
! .LP
! The
! .I union
! command simply concatenates two files, appending the second to the
! first, but using only the header of the first file.
! .LP
! With the two files,
! .I data1:
! .nf
! first second third
! ----- ------ -----
! 1 3 0
! 1 2 3
! .fi
! and
! .I data2:
! .nf
! first second third
! ----- ------ -----
! 2 3 4
! 3 4 5
! 4 5 6
! .fi
! the
! command
! .BI union\ data1\ data2
! yields:
! .nf
! first second third
! ----- ------ -----
! 1 3 0
! 1 2 3
! 2 3 4
! 3 4 5
! 4 5 6
! .fi
! on the standard output.
! .LP
! Note that the two input files must have the same columns,
! in the same order.
! .SH "SEE ALSO"
! .BR reldb(1)\ cat(1).
--- 56,57 ----
.I addcol
! to do the work. This is inefficient but the inefficiency is rarely noticable.
*** /dev/null Tue Sep 26 10:45:31 1989
--- doc/union.1 Wed Apr 19 10:58:05 1989
***************
*** 0 ****
--- 1,53 ----
+ .\" Man page for union(1)
+ .TH UNION 1 "1. April 1989"
+ .SH NAME
+ union - appends one table to another
+ .SH SYNOPSIS
+ .B union
+ .I file1\ file2
+ [
+ .I >\ outputfile
+ ]
+ .SH DESCRIPTION
+ .LP
+ The
+ .I union
+ command simply concatenates two files, appending the second to the
+ first, but using only the header of the first file.
+ .LP
+ With the two files,
+ .I data1:
+ .nf
+ first second third
+ ----- ------ -----
+ 1 3 0
+ 1 2 3
+ .fi
+ and
+ .I data2:
+ .nf
+ first second third
+ ----- ------ -----
+ 2 3 4
+ 3 4 5
+ 4 5 6
+ .fi
+ the
+ command
+ .BI union\ data1\ data2
+ yields:
+ .nf
+ first second third
+ ----- ------ -----
+ 1 3 0
+ 1 2 3
+ 2 3 4
+ 3 4 5
+ 4 5 6
+ .fi
+ on the standard output.
+ .LP
+ Note that the two input files must have the same columns,
+ in the same order.
+ .SH "SEE ALSO"
+ .BR reldb(1)\ cat(1).
*** plot1.src/README Tue Sep 26 11:25:12 1989
--- plot1.src/README Thu Sep 21 21:27:48 1989
***************
*** 21,25 ****
Graplot will take plot(5)-data and write output for the grap-program.
! This is extremely handy for putting into a troff-style paper.
! I (gunnar at hafro) apologize for not having gotten formal permission from
previous authors (notable Jim Constantine and Scott Sutherland)
--- 21,25 ----
Graplot will take plot(5)-data and write output for the grap-program.
! This is extremely handy for putting graphics into a troff-style paper.
! I (gunnar at hafro.is) apologize for not having gotten formal permission from
previous authors (notable Jim Constantine and Scott Sutherland)
*** plot1.src/hpglplot.c Tue Sep 26 11:25:12 1989
--- plot1.src/hpglplot.c Mon Sep 25 21:33:03 1989
***************
*** 1,2 ****
--- 1,20 ----
+ /* This is hpgl.c -- a collection of plot(3) routines */
+ /* which are called upon by the plotfilter.c-program */
+ /* */
+ /* These routines output HPGL plotting commands */
+ /* Some routines have been added to the standard */
+ /* plot(3)-library -- see below */
+ /* */
+ /* Contributors: */
+ /* */
+ /* Modified July 1989 by Jon von Tetzchner Stephenson */
+ /* Several mods added by asta at hafro.is, early 1989 */
+ /* See also comments in xplot.c */
+ /* HP-GL plot(5) library */
+ /* - does NOT do line locking */
+ /* - aspect ratio is not maintained */
+ /* Originally by: Jim Constantine */
+ /* Copyright 1985 Sun Microsystems Inc. */
+
#include <sgtty.h>
***************
*** 5,19 ****
! /* HP-GL plot(5) library */
! /* - does NOT do line locking */
! /* - aspect ratio is not maintained */
! /* Jim Constantine */
! /* Copyright 1985 Sun Microsystems Inc. */
! /* Extensions by asta at hafro.is (March, 1989) */
! /* Prepared for redistribution by gunnar at hafro.is */
! /* Notable features, which are really bugs: This
! program assumes it is writing to a device. That
! causes problems when writing to e.g. hpgl2ps filters.
! Use of some special HPGL escape sequences may also cause
! problems */
openpl()
--- 23,29 ----
! int loX=-999999,loY=-999999,hiX=999999,hiY=999999;
! int OUT=0;
! int saveX=-100,saveY=-100;
+
openpl()
***************
*** 32,35 ****
! /*printf("IN;\033.P1:"); /* out - gs */
! printf("IN;");
fflush(stdout);
--- 42,44 ----
! printf("IN;\033.P1:");
fflush(stdout);
***************
*** 42,44 ****
{
! printf("PU %d,%d;\n", x, y);
}
--- 51,57 ----
{
! OUT=check(&x,&y);
! saveX=x;
! saveY=y;
! if(! OUT)
! printf("PU %d,%d;\n", x, y);
}
***************
*** 47,49 ****
{
! printf("PU %d,%d PD %d,%d;\n", x1, y1, x2, y2);
}
--- 60,68 ----
{
! int out1,out2;
! out1=check(&x1,&y1);
! out2=check(&x2,&y2);
! if (! (out1 && out2))
! printf("PU %d,%d PD %d,%d;\n", x1, y1, x2, y2);
! saveX=x2;
! saveY=y2;
}
***************
*** 53,54 ****
--- 72,74 ----
{
+ printf("PU %d,%d;\n", saveX, saveY);
printf("LB%s\03;\n", s);
***************
*** 58,60 ****
{
! printf("PG;AF;\n"); /* feed page if paper has been writen on */
}
--- 78,80 ----
{
! printf("PG;AF;\n"); /* feed page if paper has been written on */
}
***************
*** 63,65 ****
{
! printf("PU %d,%d PD PU;\n", x, y);
}
--- 83,87 ----
{
! OUT=check(&x,&y);
! if (! OUT)
! printf("PU %d,%d PD PU;\n", x, y);
}
***************
*** 68,70 ****
{
! printf("PD %d,%d;\n", x, y);
}
--- 90,101 ----
{
! int outside;
! outside=check(&x,&y);
! if (! (outside && OUT))
! {
! OUT=outside;
! printf("PU %d,%d;\n", saveX, saveY);
! printf("PD %d,%d;\n", x, y);
! }
! saveX=x;
! saveY=y;
}
***************
*** 122,124 ****
labelrotation(s)
! char *s;
{
--- 153,155 ----
labelrotation(s)
! char *s;
{
***************
*** 171,173 ****
selectcolor(s)
! char *s;
{
--- 202,204 ----
selectcolor(s)
! int s;
{
***************
*** 174,178 ****
! switch(s[1]) {
! case '1': /* select pen 1 */
printf("SP 1;\n");
--- 205,209 ----
! switch(s) {
! case 1: /* select pen 1 */
printf("SP 1;\n");
***************
*** 180,182 ****
! case '2': /* select pen 2 */
printf("SP 2;\n");
--- 211,213 ----
! case 2: /* select pen 2 */
printf("SP 2;\n");
***************
*** 184,186 ****
! case '3': /* select pen 3 */
printf("SP 3;\n");
--- 215,217 ----
! case 3: /* select pen 3 */
printf("SP 3;\n");
***************
*** 188,190 ****
! case '4': /* select pen 4 */
printf("SP 4;\n");
--- 219,221 ----
! case 4: /* select pen 4 */
printf("SP 4;\n");
***************
*** 192,194 ****
! case '5': /* select pen 5 */
printf("SP 5;\n");
--- 223,225 ----
! case 5: /* select pen 5 */
printf("SP 5;\n");
***************
*** 196,198 ****
! case '6': /* select pen 6 */
printf("SP 6;\n");
--- 227,229 ----
! case 6: /* select pen 6 */
printf("SP 6;\n");
***************
*** 200,202 ****
! case '7': /* select pen 7 */
printf("SP 7;\n");
--- 231,233 ----
! case 7: /* select pen 7 */
printf("SP 7;\n");
***************
*** 204,206 ****
! case '8': /* select pen 8 */
printf("SP 8;\n");
--- 235,237 ----
! case 8: /* select pen 8 */
printf("SP 8;\n");
***************
*** 219 ****
--- 250,314 ----
+
+ /***********************************************************************
+ * check by jvts *
+ ***********************************************************************/
+
+ check(x,y)
+ int *x,*y;
+ {
+ int outside=0;
+ if (*x>hiX) {*x=hiX;outside=1;}
+ else if (*x<loX) {*x=loX;outside=1;}
+ if (*y>hiY) {*y=hiY;outside=1;}
+ else if (*y<loY) {*y=loY;outside=1;}
+ return outside;
+ }
+
+
+ /************************************************************************
+ * homemade: window by jon v. tetzchner stephenson *
+ ************************************************************************/
+ window(x0,y0,x1,y1)
+ int x0,y0,x1,y1;
+ {
+
+ loX=x0;
+ loY=y0;
+ hiX=x1;
+ hiY=y1;
+
+ /*printf("IW %d %d %d %d",x0,y0,x1,y1);*/
+ }
+
+ /************************************************************************
+ * linewid *
+ ************************************************************************/
+
+ linewid(wi)
+ int wi;
+ {
+ if (wi==1) printf("LT;\n");
+ else if (wi==2 || wi==3 || wi==4) printf("LT 3;\n");
+ else if (wi==5) printf("LT 1;\n");
+ else if (wi==6) printf("LT;\n");
+ else
+ {
+ printf("LT;\n");
+ }
+ }
+
+
+
+ /************************************************************************
+ * box by jvts *
+ ************************************************************************/
+
+ box(x1,y1,x2,y2)
+ int x1,y1,x2,y2;
+ {
+ move(x1,y1);
+ cont(x2,y1);
+ cont(x2,y2);
+ cont(x1,y2);
+ cont(x1,y1);
+ }
*** plot1.src/plotfilter.c Tue Sep 26 11:25:13 1989
--- plot1.src/plotfilter.c Mon Sep 11 08:54:39 1989
***************
*** 49,50 ****
--- 49,58 ----
+ case 'b':
+ x1 = getint();
+ y1 = getint();
+ x2 = getint();
+ y2 = getint();
+ box(x1,y1,x2,y2);
+ break;
+
case 't': /* text */
***************
*** 66,67 ****
--- 74,84 ----
+ case 'w': /* window */
+ x1 = getint();
+ y1 = getint();
+ x2 = getint();
+ y2 = getint();
+ window(x1,y1,x2,y2);
+ break;
+
+
case 'a': /* arc */
***************
*** 99,102 ****
case 'z': /* homemade colorfunction*/
! string(buf);
! selectcolor(buf);
break;
--- 116,119 ----
case 'z': /* homemade colorfunction*/
! x1=getint();
! selectcolor(x1);
break;
***************
*** 103,104 ****
--- 120,126 ----
+ case 'v': /* linewid */
+ x1=getint();
+ linewid(x1);
+ break;
+
default:
***************
*** 139 ****
--- 161,163 ----
}
+
+
*** plot1.src/xplot.c Tue Sep 26 11:25:13 1989
--- plot1.src/xplot.c Thu Sep 14 15:40:01 1989
***************
*** 1 ****
--- 1,4 ----
+ /* Modified July 1989 by Jon von Tetzchner Stephenson, hafransoknarstofnun Islands */
+
+
/************************************************************************
***************
*** 4,6 ****
* Asta G. March 1989 *
! * Adapted from a code for suntools by: *
* *
--- 7,9 ----
* Asta G. March 1989 *
! * Adapted from a code by: *
* *
***************
*** 9,11 ****
* *
! * This was adapted from a code by: *
* Jim Constantine, Janurary 1986 *
--- 12,14 ----
* *
! * Adapted from a code by: *
* Jim Constantine, Janurary 1986 *
***************
*** 20,21 ****
--- 23,25 ----
#include <strings.h>
+ #include <X11/Xos.h>
***************
*** 25,26 ****
--- 29,46 ----
+ #define NUMLINES 5 /* for linemod */
+ #define DOTTED_LIST_LENGTH 2
+ #define DOT_DASHED_LIST_LENGTH 4
+ #define SHORT_DASHED_LIST_LENGTH 2
+ #define LONG_DASHED_LIST_LENGTH 2
+
+
+ /* When the window command is not called, these values are used . */
+ /* I hope they are large(small) enaugh. */
+
+ int loX=-999999,loY=-999999,hiX=999999,hiY=999999,oldX,oldY;
+
+ int OUT=0; /* was last drawing outside of window ? */
+
+ int gcnum=4; /* to chose linemod (4=linesolid) */
+
/* plot stuff */
***************
*** 31,33 ****
char *label_pl;
! int xheight, yheight, width;
int winX, winY, winW, winH;
--- 51,53 ----
char *label_pl;
! int xheight, yheight, width,xxwidth,xxheight;
int winX, winY, winW, winH;
***************
*** 65,67 ****
Window win; /* Window ID */
! GC gc; /* GC to draw with */
char *fontName; /* Name of the font to use */
--- 85,87 ----
Window win; /* Window ID */
! GC gc[NUMLINES]; /* GCs to draw with */
char *fontName; /* Name of the font to use */
***************
*** 75,78 ****
char *geomSpec; /* Window geometry string */
! XSetWindowAttributes xswa; /* Temporary Set Window Attribute struct
Window win;
--- 95,164 ----
char *geomSpec; /* Window geometry string */
! XSetWindowAttributes xswa; /* Temporary Set Window Attribute struct */
Window win;
+ int COLOR=0; /* Are we using a color displaay ?? */
+
+ #define MAX_COLORS 9 /* I use 9 colors, no problem to use more */
+ int colors[MAX_COLORS]; /* definitions of colors */
+ int VERTICAL=0;
+
+
+ /*************************************************************************
+ * get_colors is a routine that is called from openpl. It checks if the *
+ * display uses color and if so sets the COLOR variable to 1 (TRUE) *
+ *************************************************************************/
+
+ get_colors()
+ {
+ int depth;
+ Visual *visual;
+ static char *name[]={"Black","Blue","Red","Green","Yellow","Cyan","Pink","Orange","Gold"};
+ XColor exact_def;
+ Colormap cmap;
+ int ncolors=MAX_COLORS;
+
+ int i;
+
+ /* printf("in get colors\n"); */
+
+ depth=DisplayPlanes(dpy,DefaultScreen(dpy));
+ visual=DefaultVisual(dpy,DefaultScreen(dpy));
+ cmap=DefaultColormap(dpy,DefaultScreen(dpy));
+
+ if (depth==1)
+ {
+ /* printf("monocrome\n"); */
+ bd=BlackPixel(dpy,DefaultScreen(dpy));
+ bg=WhitePixel(dpy,DefaultScreen(dpy));
+ fg=BlackPixel(dpy,DefaultScreen(dpy));
+ }
+ else
+ {
+ for (i=0;i<MAX_COLORS; i++)
+ {
+ /* printf("allocating %s \n",name[i]); */
+ if (! XParseColor(dpy,cmap,name[i],&exact_def))
+ {
+ fprintf(stderr,"XXplot: color name %s not in database\n",name[i]);
+ exit(0);
+ }
+ /* printf("The RGB values from the database are %d %d %d\n",
+ exact_def.red,exact_def.green,exact_def.blue); */
+ if (! XAllocColor(dpy,cmap,&exact_def))
+ {
+ fprintf(stderr,"XXplot: all colorcells allocated and read/write\n");
+ exit(0);
+ }
+ /* printf("The RGB values actually allocated are %d %d %d\n",
+ exact_def.red,exact_def.green,exact_def.blue); */
+ colors[i]=exact_def.pixel;
+ }
+ /* printf("allocated %d read/write colorcells\n",ncolors); */
+
+ bg = WhitePixel(dpy, DefaultScreen(dpy));
+ bd = BlackPixel(dpy, DefaultScreen(dpy));
+ fg=colors[0];
+ COLOR=1;
+ }
+ }
+
***************
*** 81,84 ****
/************************************************************************/
! openpl() {
!
/* Process arguments: */
--- 167,172 ----
/************************************************************************/
! openpl()
! {
! int done1=0;
! char *fontname2="6x13";
/* Process arguments: */
***************
*** 105,113 ****
if ((fontName = XGetDefault(dpy, argv_copy[0], ARG_FONT)) == NULL) {
! fontName = FONT;
! }
if ((fontstruct = XLoadQueryFont(dpy, fontName)) == NULL) {
! fprintf(stderr, "%s: display %s doesn't know font %s\n",
! argv_copy[0], DisplayString(dpy), fontName);
! exit(1);
! }
fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
--- 193,206 ----
if ((fontName = XGetDefault(dpy, argv_copy[0], ARG_FONT)) == NULL) {
! fontName = FONT;
! }
!
if ((fontstruct = XLoadQueryFont(dpy, fontName)) == NULL) {
! if ((fontstruct = XLoadQueryFont(dpy,fontname2))==NULL)
! {
! fprintf(stderr, "%s: display %s doesn't know font %s\n",
! argv_copy[0], DisplayString(dpy), fontname2);
! exit(1);
! }
! }
!
fth = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent;
***************
*** 116,118 ****
! /*
* Select colors for the border, the window background, and the
--- 209,211 ----
! /*
* Select colors for the border, the window background, and the
***************
*** 120,124 ****
*/
! bd = BlackPixel(dpy, DefaultScreen(dpy));
! bg = WhitePixel(dpy, DefaultScreen(dpy));
! fg = BlackPixel(dpy, DefaultScreen(dpy));
--- 213,216 ----
*/
!
! get_colors();
***************
*** 144,146 ****
}
!
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
--- 236,241 ----
}
!
! xxwidth=xsh.width;
! xxheight=xsh.height;
!
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
***************
*** 171,184 ****
! /*
! * Create the GC for plotting. See Section 5.3.
! */
!
! gcv.font = fontstruct->fid;
! gcv.foreground = fg;
! gcv.background = bg;
! /* gcv.function=GXand;
! gcv.plane_mask=BlackPixel(dpy,DefaultScreen(dpy)) ^
! WhitePixel(dpy,DefaultScreen(dpy)); */
! gc = XCreateGC(dpy, win, (GCFont | GCForeground | GCBackground ), &gcv);
!
/*
--- 266,269 ----
! set_dashes();
!
/*
***************
*** 187,189 ****
*/
! XSelectInput(dpy, win, ExposureMask);
--- 272,274 ----
*/
! XSelectInput(dpy, win, ExposureMask| StructureNotifyMask);
***************
*** 193,197 ****
XMapWindow(dpy, win);
! XNextEvent(dpy, &event);
!
}
/************************************************************************/
--- 278,358 ----
XMapWindow(dpy, win);
!
! while(! done1)
! {
!
! XNextEvent(dpy,&event);
! switch(event.type)
! {
! case Expose:
!
! while (XCheckTypedEvent(dpy,Expose,&event)) ;
!
!
! done1=1;
!
! break;
!
! case ConfigureNotify:
!
! xxwidth=event.xconfigure.width;
! xxheight=event.xconfigure.height;
! break;
!
!
! default: /* all events selected by StructureNotifyMask except ConfigureNotify are */
! /* thrown away here, since nothing is done with them */
!
! done1=1; /* because of some problems with hafro */
! break;
! }
! }
!
!
}
+
+ /**********************************************************************/
+ /* set_dashes sets 5 diffrent gcs to be able to alter linemod quickly */
+ /* called by openpl */
+ /**********************************************************************/
+ set_dashes()
+ /*
+ * Create the GC for plotting. See Section 5.3.
+ */
+ {
+ int i;
+ static int dash_list_length[]=
+ {
+ DOTTED_LIST_LENGTH,
+ DOT_DASHED_LIST_LENGTH,
+ SHORT_DASHED_LIST_LENGTH,
+ LONG_DASHED_LIST_LENGTH
+ };
+
+ static unsigned char dotted[DOTTED_LIST_LENGTH]={3,1};
+ static unsigned char dot_dashed[DOT_DASHED_LIST_LENGTH]={3,4,3,1};
+ static unsigned char short_dashed[SHORT_DASHED_LIST_LENGTH]={4,4};
+ static unsigned char long_dashed[LONG_DASHED_LIST_LENGTH]={4,7};
+
+ static unsigned char *dash_list[]=
+ {
+ dotted,dot_dashed,short_dashed,long_dashed
+ };
+ int dash_offset=0;
+ gcv.font = fontstruct->fid;
+ gcv.foreground = fg;
+ gcv.background = bg;
+ /* gcv.function=GXand;
+ gcv.plane_mask=BlackPixel(dpy,DefaultScreen(dpy)) ^
+ WhitePixel(dpy,DefaultScreen(dpy)); */
+
+ gcv.line_style=LineOnOffDash;
+ for (i=0; i<NUMLINES-1;i++)
+ {
+ gc[i] = XCreateGC(dpy, win, (GCFont | GCForeground | GCBackground | GCLineStyle ), &gcv);
+ XSetDashes(dpy,gc[i],dash_offset,dash_list[i],dash_list_length[i]);
+ }
+ gcv.line_style=LineSolid;
+ gc[4]=XCreateGC(dpy, win, (GCFont | GCForeground | GCBackground | GCLineStyle ), &gcv);
+ }
+
/************************************************************************/
***************
*** 200,201 ****
--- 361,364 ----
move(x1, y1) {
+
+ OUT=check(&x1,&y1);
x = scalex(x1);
***************
*** 202,203 ****
--- 365,367 ----
y = scaley(y1);
+
}
***************
*** 206,214 ****
/************************************************************************/
! cont(x1, y1) {
! x1 = scalex(x1);
! y1 = scaley(y1);
! XDrawLine(dpy, win, gc, x, y, x1, y1);
! x = x1;
! y = y1;
! XFlush(dpy);
}
--- 370,391 ----
/************************************************************************/
! cont(x1, y1)
! {
! int outside;
!
! outside=check(&x1,&y1);
! if (! (outside && OUT))
! {
! OUT=outside;
! x1 = scalex(x1);
! y1 = scaley(y1);
! XDrawLine(dpy, win, gc[gcnum], x, y, x1, y1);
! x = x1;
! y = y1;
! XFlush(dpy);
! }
! else
! {
! x = scalex(x1);
! y = scaley(y1);
! }
}
***************
*** 217,223 ****
/************************************************************************/
! point(x, y) {
! x = scalex(x);
! y = scaley(y);
! XDrawRectangle(dpy, win, gc, x, y, 1, 1);
! XFlush(dpy);
}
--- 394,405 ----
/************************************************************************/
! point(x, y)
! {
! OUT=check(&x,&y);
! if (! OUT)
! {
! x = scalex(x);
! y = scaley(y);
! XDrawRectangle(dpy, win, gc[gcnum], x, y, 1, 1);
! XFlush(dpy);
! }
}
***************
*** 227,235 ****
line(x1, y1, x2, y2) {
! x1 = scalex(x1);
! y1 = scaley(y1);
! x2 = scalex(x2);
! y2 = scaley(y2);
! XDrawLine(dpy, win, gc, x1, y1, x2, y2);
! XFlush(dpy);
}
/************************************************************************/
--- 409,444 ----
line(x1, y1, x2, y2) {
! int out1,out2;
! out1=check(&x1,&y1);
! out2=check(&x2,&y2);
! if (! (out1 && out2))
! {
! x1 = scalex(x1);
! y1 = scaley(y1);
! x2 = scalex(x2);
! y2 = scaley(y2);
! XDrawLine(dpy, win, gc[gcnum], x1, y1, x2, y2);
! XFlush(dpy);
! }
}
+
+
+ /************************************************************************
+ * box by jvts *
+ ************************************************************************/
+ box(x1, y1, x2, y2) {
+ int out1,out2;
+ out1=check(&x1,&y1);
+ out2=check(&x2,&y2);
+ if (! (out1 && out2))
+ {
+ x1 = scalex(x1);
+ y1 = scaley(y1);
+ x2 = scalex(x2);
+ y2 = scaley(y2);
+ XDrawRectangle(dpy,win,gc[gcnum],x1,y1,x2-x1,y2-y1);
+ XFlush(dpy);
+ }
+ }
+
+
/************************************************************************/
***************
*** 241,244 ****
y1=scaley(y1-r);
! width=scalex(2*r);
! XDrawArc(dpy,win,gc,x1,y1,width,width,0,23040);
XFlush(dpy);
--- 450,453 ----
y1=scaley(y1-r);
! width=2*r;
! XDrawArc(dpy,win,gc[gcnum],x1,y1,width,width,0,23040);
XFlush(dpy);
***************
*** 258,263 ****
{
! if(!use_labelplace){
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
! }
else {
--- 467,485 ----
{
! if(!use_labelplace)
! {
! if (VERTICAL)
! {
! int i,len;
! len=strlen(s);
! for (i=0;i<len;i++)
! {
! XDrawString(dpy,win,gc[gcnum],x,y+i*(fth+2),s++,1);
! }
! }
! else
! {
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
! }
! }
else {
***************
*** 265,270 ****
case 'u':
! x=x-XTextWidth(fontstruct,s,strlen(s))/2;
! y=y+fth;
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
! XFlush(dpy);
break;
--- 487,505 ----
case 'u':
! if (VERTICAL)
! {
! int i,len;
! len=strlen(s);
! y=y-(fth+2)*len/2;
! for (i=0;i<len;i++)
! {
! XDrawString(dpy,win,gc[gcnum],x,y+i*(fth+2),s++,1);
! }
! }
! else
! {
! x=x-XTextWidth(fontstruct,s,strlen(s))/2;
! y=y+fth;
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
! XFlush(dpy);
! }
break;
***************
*** 273,275 ****
x=x-XTextWidth(fontstruct,s,strlen(s))/2;
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
--- 508,510 ----
x=x-XTextWidth(fontstruct,s,strlen(s))/2;
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
***************
*** 281,283 ****
y=y-fth/2+fontstruct->max_bounds.ascent;
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
--- 516,518 ----
y=y-fth/2+fontstruct->max_bounds.ascent;
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
***************
*** 288,290 ****
y=y-fth/2+fontstruct->max_bounds.ascent;
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
--- 523,525 ----
y=y-fth/2+fontstruct->max_bounds.ascent;
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
***************
*** 296,298 ****
/* y=y+fth/2; */
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
--- 531,533 ----
/* y=y+fth/2; */
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
***************
*** 299,301 ****
break;
!
default: /* center the label at the point */
--- 534,536 ----
break;
!
default: /* center the label at the point */
***************
*** 304,306 ****
/* y=y+fth/2; */
! XDrawString(dpy, win, gc, x, y, s, strlen(s));
XFlush(dpy);
--- 539,541 ----
/* y=y+fth/2; */
! XDrawString(dpy, win, gc[gcnum], x, y, s, strlen(s));
XFlush(dpy);
***************
*** 316,318 ****
{
-
switch(s[1]) {
--- 551,552 ----
***************
*** 353,355 ****
/* labelrotation - a homemade function */
! /* not implemented */
/************************************************************************/
--- 587,589 ----
/* labelrotation - a homemade function */
! /* by jvts */
/************************************************************************/
***************
*** 362,363 ****
--- 596,598 ----
case 'h': /* horizontal */
+ VERTICAL=0;
break;
***************
*** 365,366 ****
--- 600,602 ----
case 'v': /* vertical */
+ VERTICAL=1;
break;
***************
*** 371,373 ****
/* selectcolor - a homemade function */
! /* not implemented */
/************************************************************************/
--- 607,609 ----
/* selectcolor - a homemade function */
! /* by jvts */
/************************************************************************/
***************
*** 374,407 ****
selectcolor(s)
! char *s;
{
!
! switch(s[1]) {
!
! case '1': /* select pen 1 */
! break;
!
! case '2': /* select pen 2 */
! break;
!
! case '3': /* select pen 3 */
! break;
!
! case '4': /* select pen 4 */
! break;
!
! case '5': /* select pen 5 */
! break;
!
! case '6': /* select pen 6 */
! break;
!
! case '7': /* select pen 7 */
! break;
!
! case '8': /* select pen 8 */
! break;
!
! default: /* select pen 1 */
! break;
! }
}
--- 610,624 ----
selectcolor(s)
! int s;
{
! int i;
! if (COLOR)
! {
! if (s>=0 && s<MAX_COLORS)
! {
! for (i=0;i<5;i++)
! {
! XSetForeground(dpy,gc[i],colors[s]);
! }
! }
! }
}
***************
*** 418,420 ****
/* linemod */
! /* Not implemented */
/************************************************************************/
--- 635,637 ----
/* linemod */
! /* by jvts */
/************************************************************************/
***************
*** 425,427 ****
switch(s[3]) {
! case 't': /* dotTed */
break;
--- 642,644 ----
switch(s[3]) {
! case 't': gcnum=0;
break;
***************
*** 428,430 ****
! case 'i': /* solId */
default:
--- 645,647 ----
! case 'i': /* solId */ gcnum=4;
default:
***************
*** 432,434 ****
! case 'g': /* lonGdashed */
break;
--- 649,651 ----
! case 'g': gcnum=3;
break;
***************
*** 435,437 ****
! case 'r': /* shoRtdashed */
break;
--- 652,654 ----
! case 'r': gcnum=2;
break;
***************
*** 438,440 ****
! case 'd': /* dotDashed */
break;
--- 655,657 ----
! case 'd': gcnum=1;
break;
***************
*** 449,452 ****
yorig = yorigi;
! xscale = ((float) xsh.width) / (x1 - xorig);
! yscale = ((float) xsh.height) / (y1 - yorig);
}
--- 666,669 ----
yorig = yorigi;
! xscale = ((float) xxwidth) / (x1 - xorig);
! yscale = ((float) xxheight) / (y1 - yorig);
}
***************
*** 453,454 ****
--- 670,688 ----
+
+ /************************************************************************
+ * homemade: window by jon v. tetzchner stephenson *
+ ************************************************************************
+ * sets boundries for drawing (not fully implemented, put there for *
+ * use with the map program). *
+ ************************************************************************/
+ window(x0,y0,x1,y1)
+ int x0,y0,x1,y1;
+ {
+ loX=x0;
+ loY=y0;
+ hiX=x1;
+ hiY=y1;
+ }
+
+
/************************************************************************/
***************
*** 482,484 ****
y = y * yscale;
! y = xsh.height - y; /* origin at lower left. */
return((int) y);
--- 716,718 ----
y = y * yscale;
! y = xxheight - y; /* origin at lower left. */
return((int) y);
***************
*** 485,486 ****
--- 719,762 ----
}
+
+ /***********************************************************************
+ * check by jvts *
+ ***********************************************************************
+ * Checks if the point is inside or outside the area defined *
+ * by the window statement. Sets endpoints in such a way that only the *
+ * part inside the window gets drawn. Returns 1 if the point is *
+ * outside, 0 otherwise. *
+ ***********************************************************************/
+
+ check(x,y)
+ int *x,*y;
+ {
+ int outside=0;
+ if (*x>hiX) {*x=hiX;outside=1;}
+ else if (*x<loX) {*x=loX;outside=1;}
+ if (*y>hiY) {*y=hiY;outside=1;}
+ else if (*y<loY) {*y=loY;outside=1;}
+ return outside;
+ }
+
+ /***********************************************************************
+ * linewid by jvts (customised for mix) *
+ ***********************************************************************/
+
+ linewid(wi) /* set pen width */
+ int wi;
+ {
+ int i;
+ int line_style=LineSolid;
+ int cap_style=CapButt;
+ int join_style=JoinRound;
+ int line_width;
+ line_width=wi;
+ for (i=0;i<5;i++)
+ XSetLineAttributes(dpy,gc[i],line_width,line_style,cap_style,join_style);
+ }
+
+
+
+
+
*** plot1.src/plot.sh Tue Sep 26 11:25:13 1989
--- plot1.src/plot.sh Thu Sep 21 21:29:35 1989
***************
*** 7,12 ****
#
! # There are currently available PD filters for at least HPGL, X11
# and Postscript. The first two are included in the reldb distribution,
! # as the xplot program is new and the hpglplot program has been extended
! # somewhat to accept a few extended plot(5)-commands.
#
--- 7,12 ----
#
! # There are currently available PD filters for at least HPGL, X11, grap
# and Postscript. The first two are included in the reldb distribution,
! # as the xplot and grap programs are new and the hpglplot program has been
! # extended somewhat to accept a few extended plot(5)-commands.
#
***************
*** 18,20 ****
#
! case $1 in
-T*) devarg=$1
--- 18,20 ----
#
! case "$1" in
-T*) devarg=$1
***************
*** 26,28 ****
-Thpgl) hpglplot $* ;;
! -TX*|-Tx*) xplot $* ;;
-Tps*) psplot $* ;;
--- 26,31 ----
-Thpgl) hpglplot $* ;;
! -TX*|-Tx*) case "$#" in
! 0) xplot =1140x860+40+40 ;;
! *) xplot $* ;;
! esac ;;
-Tps*) psplot $* ;;
*** plot1.src/graplot.c Tue Sep 26 11:25:14 1989
--- plot1.src/graplot.c Thu Sep 21 21:26:01 1989
***************
*** 4,9 ****
! /* HP-GL plot(5) library */
! /* - does NOT do line locking */
! /* - aspect ratio is not maintained */
! /* Jim Constantine */
/* Copyright 1985 Sun Microsystems Inc. */
--- 4,10 ----
! /* GRAPLOT - plot routines which output commands for */
! /* grap -- the output of this program can then*/
! /* be piped through troff */
! /* Adapted from HP-GL plot(5) library */
! /* originally by Jim Constantine */
/* Copyright 1985 Sun Microsystems Inc. */
***************
*** 11,16 ****
/* Prepared for redistribution by gunnar at hafro.is */
- /* Notable features: This program is to be used to
- create troff files. It can be used to print to a
- device without putting the statements through a file.
- just use scat < file | graplot | lprenta8 */
--- 12,13 ----
***************
*** 25,26 ****
--- 22,25 ----
printf("\\!! rasterize=300\n");
+ printf("\\!! thickness=2\n");
+ printf(".S 14\n");
printf(".G1\n");
***************
*** 27,29 ****
! printf("frame invis ht 4 wid 6.2\n");
printf("X=1\nY=0\n");
--- 26,28 ----
! printf("frame invis ht 6 wid 6\n");
printf("X=1\nY=0\n");
***************
*** 77,80 ****
--- 76,86 ----
+ /* circle(X,Y,r): Draws a circle whose centre is at X,Y. It's size may
+ be determined by stating the radius, r.
+ */
+
circle(X, Y, r)
+ int X,Y;
+ float r;
{
+ printf("circle at %d,%d radius %f\n",X,Y,r);
}
***************
*** 118,120 ****
! /* switch(s[1]) {
--- 124,128 ----
! /* This routine is a NOOP as there does not seem to be a
! decent way of rotating in grap */
! /* switch(s[1]) {
***************
*** 121,128 ****
case 'h':
! printf("DI 1,0\n");
-
case 'v':
! printf("DI 0,1\n");
!
}
--- 129,136 ----
case 'h':
! printf("\n");
!
case 'v':
! printf("\n");
!
}
***************
*** 179,181 ****
! /* switch(s[1]) {
--- 187,190 ----
! /* Another NOOP - there are no colors in troff */
! /* switch(s[1]) {
***************
*** 222,223 ****
--- 231,261 ----
printf (".G2\n");
+ }
+
+
+ /* box(x1,y1,x2,y2): Draws a box within the given x and y locations. */
+
+ box(x1,y1,x2,y2)
+ int x1,y1,x2,y2;
+ {
+ move(x1,y1);
+ cont(x2,y1);
+ cont(x2,y2);
+ cont(x1,y2);
+ cont(x1,y1);
+ }
+
+ /* window(x1,y1,x2,y2): Allows one to specify the range of the x and y axes
+ explicitly.
+ */
+
+ window(x1,y1,x2,y2)
+ int x1,y1,x2,y2;
+ {
+ printf("coord x %d, %d y %d, %d\n",x1,x2,y1,y2);
+ }
+
+
+
+ linewid(x1)
+ {
}
*** /dev/null Tue Sep 26 10:45:31 1989
--- testgr/picture.sh Mon Sep 25 22:48:06 1989
***************
*** 0 ****
--- 1,33 ----
+ #!/bin/sh
+ #
+ # This gives an example of how a rather complex figure can be generated.
+ #
+ # Since it's a rather complex figure, the input and options are
+ # quite complex.
+ #
+ # The options below are self-explanatory if the manual page for
+ # scat is at hand.
+ #
+ # The data file, picture.data, is best viewed through the
+ # reldb command sideview.
+
+ scat \
+ -H "Fishable stock (ages 4-14) for different TACs." \
+ -X "Year" \
+ -Y "000 tons" \
+ -y 0,2000,100 \
+ -x 1960,1995,1 \
+ -Fx"%.0f" \
+ -Fy"%.0f" \
+ -L lab1 \
+ -L lab2 \
+ -L lab3 \
+ -L lab4 \
+ -T "x 26" \
+ -t "x 1" \
+ -E < picture.data
+
+ #
+ # PS This is a real picture - it is an estimate of the various possible
+ # trends in the Icelandic cod stock, given various TAC's (total
+ # allowable catches).
*** /dev/null Tue Sep 26 10:45:31 1989
--- testgr/picture.data Mon Sep 25 22:39:00 1989
***************
*** 0 ****
--- 1,33 ----
+ year opt1 opt11 lab1 opt2 opt22 lab2 opt3 opt33 lab3 opt4 opt44 lab4
+ ---- ---- ----- ---- ---- ----- ---- ---- ----- ---- ---- ----- ----
+ 1963 1323
+ 1964 1151
+ 1965 1177
+ 1966 1252
+ 1967 1417
+ 1968 1682
+ 1969 1610
+ 1970 1490
+ 1971 1228
+ 1972 987
+ 1973 832
+ 1974 932
+ 1975 891
+ 1976 950
+ 1977 1373
+ 1978 1405
+ 1979 1513
+ 1980 1593
+ 1981 1263
+ 1982 979
+ 1983 794
+ 1984 901
+ 1985 920
+ 1986 865
+ 1987 1048
+ 1988 1103
+ 1989 1067
+ 1990 1007 1007 1007 1007
+ 1991 1100 1040 980 920
+ 1992 1180 1060 940 820
+ 1993.5 1180 200 1060 250 940 300 820 350
--
-----------------------------------------------------------------------------
Gunnar Stefansson Uucp: {mcvax,enea}!hafro!gunnar
Marine Research Institute Internet: gunnar at hafro.is
P.O. Box 1390,Reykjavik Tel: +354 1 20240 Fax: +354 1 623790
More information about the Comp.sources.bugs
mailing list