[comp.sys.apollo] apollo driver for gnuplot

oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA) (03/24/90)

Has anyone written an apollo driver (gpr) for gnuplot ?
If you have I would appreciate if you could e-mail it to me.
Thanks.
    
    Roque D Oliveira
    oliveria@caen.engin.umich.edu

aramini@apollo.HP.COM (Michael Aramini) (03/27/90)

Gnuplot does have a driver for the UNIX plot command.  A the BSD version of this
command is available on Apollo.  If your TERM variable is one of the apollo types,
plot will create a DM pad and draw in it.

Here's an example of using gnuplot with plot:

    $ /usr/local/bin/gnuplot | plot
    
    	G N U P L O T
    	unix version 1.10A (Polar)
    	Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
    
    gnuplot> set terminal unixplot
    gnuplot> plot sin(x)
    gnuplot> q


Note that since the UNIX plot command does automatic scaling, it can't begin
plotting until it has seen the entire set of plotting commands it recieves
from standard input (in this case a pipe from gnuplot). Thus, unfortunately, the
DM pad won't get created and you won't see the graphics until you exit out of
gnuplot, meaning you can only draw one graph per gnuplot session.

If that solution is unacceptible to you, note that I have developed a GPR driver
for gnuplot, but I don't know what the procedure is to submit a driver to FSF
or whomever distributes gnuplot so that it becomes part of the gnuplot
distribution, if someone knows, please let me know.

-Michael Aramini

aramini@apollo.HP.COM (Michael Aramini) (03/28/90)

Here is an apollo driver (gpr) for gnuplot which I wrote (gpr.trm).  Also
included are file comparisons showing the changes I made to other source files
in order to integrate this driver into gnuplot.  I'm providing as is and neither
I nor my employer are making any commitment to support it.  (That is, I would
like to hear about any bugs or suggestions for improvements, but I may not have
the time or interest to implement them.)

-Michael Aramini


$ catf gpr.trm
#include </usr/apollo/include/base.h>
#include </usr/apollo/include/error.h>
#include </usr/apollo/include/gpr.h>
#include </usr/apollo/include/pad.h>

#define GPR_XMAX 720
#define GPR_YMAX 450

#define GPR_XLAST (GPR_XMAX - 1)
#define GPR_YLAST (GPR_YMAX - 1)

#define GPR_VCHAR 19
#define GPR_HCHAR 10
#define GPR_VTIC (GPR_YMAX/80)
#define GPR_HTIC (GPR_XMAX/80)

static status_$t status;


static void check(messagex)
char *messagex;
{
  if (status.all = status_$ok) {
    error_$print(status);
    printf("Error occurred while %s.\n", messagex);
  }
}


GPR_init()
{
  gpr_$offset_t dm_bitmap_size;
  gpr_$bitmap_desc_t dm_bitmap_desc;
  pad_$window_desc_t window;
  short font_id;
  stream_$id_t stream_id;

  /* open a pad to do graphics in */
  window.top    = 0;
  window.left   = 0;
  window.width  = GPR_XMAX+7;
  window.height = GPR_YMAX+32;
  pad_$create_window("", (short)0, pad_$transcript, (short)1, window,
                     &stream_id, &status);
  check("pad_$create_window");

  dm_bitmap_size.x_size = GPR_XMAX+2;
  dm_bitmap_size.y_size = GPR_YMAX+2;
  gpr_$init(gpr_$direct, stream_id, dm_bitmap_size, (gpr_$rgb_plane_t)7,
            &dm_bitmap_desc, &status); 
  check("in gpr_$init");
  gpr_$set_obscured_opt(gpr_$pop_if_obs, &status); 
  check("in gpr_$set_obscured_opt");
  gpr_$set_auto_refresh(true, &status); 
  check("in gpr_$set_auto_refresh");

  /* load a font and make it current */
  gpr_$load_font_file("f7x13", 5, &font_id, &status);
  check("in gpr_$load_font_file");
  gpr_$set_text_font(font_id, &status);
  check("in gpr_$set_text_font");

  /* set up color values */
  gpr_$set_draw_value((gpr_$pixel_value_t)7, &status);  /* white */
  check("in gpr_set_draw_value");
  gpr_$set_text_background_value((gpr_$pixel_value_t)(-1), &status); /* trans */
  check("in gpr_$set_text_background_value");
  gpr_$set_text_value((gpr_$pixel_value_t)7, &status);  /* white */
  check("in gpr_$set_text_value");
}


GPR_graphics()
{
  (void) gpr_$acquire_display(&status);
  check("in gpr_$acquire display");
  gpr_$clear((gpr_$pixel_value_t)0, &status);  /* black */
  check("in gpr_$clear");
}


GPR_text()
{
  gpr_$release_display(&status);
  check("gpr_$release_display");
}


GPR_linetype(linetype)
int linetype;
{
  static gpr_$line_pattern_t patterns[2+5] = { { 0xFFFF },   /* solid */
                                               { 0x3FFF },   /* long dashed */
                                               { 0xFFFF },   /* solid */
                                               { 0x5555 },   /* dotted */
                                               { 0x3333 },   /* short dashed */
                                               { 0xB5AD },   /* dot dashed */
                                               { 0x3FFF } }; /* long dashed */

  if (linetype >= 5)
    linetype %= 5;
  gpr_$set_line_pattern((short)1, patterns[linetype+2], (short)16, &status);
  check("in gpr_$set_line_pattern");
}


GPR_move(x, y)
unsigned int x, y;
{
  gpr_$move((short)(x+1), (short)(GPR_YMAX-y), &status);
  check("in gpr_$move");
}


GPR_vector(x, y)
unsigned int x, y;
{
  gpr_$line((short)(x+1), (short)(GPR_YMAX-y), &status);
  check("in gpr_$line");
}


GPR_lrput_text(row, str)
unsigned int row;
char str[];
{
  GPR_move(GPR_XMAX - GPR_HTIC - GPR_HCHAR*(strlen(str)+1),
           GPR_VTIC + GPR_VCHAR*(row+1));
  gpr_$text(str, (short)strlen(str), &status);
  check("in gpr_$text");
}


GPR_ulput_text(row, str)
unsigned int row;
char str[];
{
  GPR_move(GPR_HTIC, GPR_YMAX - GPR_VTIC - GPR_VCHAR*(row+1));
  gpr_$text(str, (short)strlen(str), &status);
  check("in gpr_$text");
}

GPR_reset()
{
  gpr_$terminate(false, &status);
  check("gpr_$terminate");
}

$ cmf internal.c.orig internal.c

A36       matherr()
changed to
B36       matherr(x)
B37       struct exception *x;


1 discrepancy found.

$ cmf makefile.orig makefile

A5        # successfully.  This includes creating the help tree in /usr/local/lib.
changed to
B5        # successfully.  This includes creating the help tree in /usr/local/help.


A16       # where to install man page on 'make man_install'
A17       MANDEST=/usr/man/man1/gnuplot.1
changed to
B16       
B17       # where to install man page on 'make man_install'
B18       #MANDEST=/usr/man/man1/gnuplot.1
B19       CATMANDEST=/usr/man/cat1/gnuplot.1


A23       # -O if you trust your compiler's optimizer
A24       CFLAGS = -DGAMMA -DUNIXPC -O # -gx # debug it.
changed to
B25       # -DGPR if Apollo Graphics Primitives
B26       # -O if you trust your compiler's optimizer
B27       CFLAGS = -DVFORK -DBCOPY -DGAMMA -O -DGPR


A41       TERMFLAGS = -DUNIXPC -DUNIXPLOT
changed to
B44       TERMFLAGS = -DAED -DBITGRAPH -DHP26 -DHP75 -DPOSTSCRIPT -DQMS -DREGIS -DSELANAR -DTEK -DUNIXPLOT


A56       	ld /lib/crt0s.o /lib/shlib.ifile $(OBJS) version.o $(LIBS) -o gnuplot
changed to
B59       	cc $(OBJS) version.o $(LIBS) -o gnuplot


A64       # note that directory /usr/local/lib must exist for the help tree
changed to
B67       # note that directory /usr/local/help must exist for the help tree


A69       	docs/helptree -t /usr/local/lib/gnuplot < docs/gnuplot.hlp
changed to
B72       	docs/helptree -t /usr/local/help/gnuplot < docs/gnuplot.hlp


A73       	cp gnuplot.1 $(MANDEST)
changed to
B76       	nroff -man gnuplot.1 > $(CATMANDEST)
B77       #	cp gnuplot.1 $(MANDEST)


A77       	unixplot.trm v384.trm
changed to
B81       	unixplot.trm gpr.trm v384.trm
B82       	rm -f term.o


9 discrepancies found.

$ cmf plot.h.orig plot.h

B41       #ifdef GPR
B42       #define TERM "gpr"
B43       #else
inserted before
A41       #define TERM "tek40xx"		/* put your most common term type here! */


B47       #endif
inserted before
A44       


2 discrepancies found.

$ cmf term.c.orig term.c

B387      #ifdef GPR  /* Apollo Graphics Primitives */
B388      #include "gpr.trm"
B389      #endif /* GPR */
B390      
inserted before
A387      #ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */


B584      #ifdef GPR
B585      	,{"gpr", GPR_XMAX, GPR_YMAX, GPR_VCHAR, GPR_HCHAR, GPR_VTIC, GPR_HTIC,
B586      		GPR_init, GPR_reset, GPR_text, GPR_graphics, GPR_move, GPR_vector,
B587      		GPR_linetype, GPR_lrput_text, GPR_ulput_text, line_and_point}
B588      #endif
B589      
inserted before
A580      #ifdef V384


2 discrepancies found.