ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/drivers/hp7470.c

This is hp7470.c in view mode; [Download] [Up]

/* This file contains the IMPRESS device dependent subroutines for */
/* use with plplot. */

#include "plplot.h"
#include <stdio.h>

#define ESC          27
#define HP7470X   10299
#define HP7470Y    7649

static FILE *OutFile=NULL;
static int porient=0;
static int fileopen=0;
static int curpen, curwid;

void hp7470setup(xdpi,ydpi,xwid,ywid)
int xwid, ywid;
double xdpi, ydpi;
{
}

/* Open file.  Set up for graphics. */
void hp7470init()
{
  char response[80];

  smod(0);  /* not an interactive terminal */
  scol(1);
  swid(1);
  setpxl(40.,40.);
      
  if(!porient)
     setphy(0,HP7470X,0,HP7470Y);
  else
     setphy(0,HP7470Y,0,HP7470X);

  while(!OutFile) {
     printf("Enter graphics command storage file name. ");
     fgets(response,sizeof(response),stdin);
     response[strlen(response)-1] = '\0';
     if ((OutFile = fopen(response,"w")) == NULL) 
        fprintf(stderr,"Can't open %s.\n",response);
     else {
        fileopen = 1;
        break;
     }
  }
  fprintf(OutFile,"%c.I200;;17:%c.N;19:%c.M;;;10:in;\n",ESC,ESC,ESC);
  fprintf(OutFile,"pg;\n");
}

void hp7470orient(ori)
int ori;
{
  porient = ori;
}

void hp7470select(file)
FILE *file;
{
   OutFile = file;
}

/* Sets the IMPRESS to text mode */
void hp7470text()
{
}

/* Sets the IMPRESS to graphics mode */
void hp7470graph()
{
}

/* Form feed */
void hp7470clear()
{
}

static int xold, yold;

void hp7470page()
{
  xold = -100000;
  yold = -100000;
}

void hp7470eop()
{
  fflush(OutFile);
}

void hp7470color(colour)
int colour;
{
  if(colour<1 || colour>8)
    fprintf(stderr,"\nInvalid pen selection.");
  else {
    fprintf(OutFile,"sp%d %d\n",colour,curwid);
    curpen = colour;
  }
}

void hp7470width(width)
int width;
{
  if(width<1 || width>48)
    fprintf(stderr,"\nInvalid pen width selection.");
  else {
    fprintf(OutFile,"sp%d %d\n",curpen,width);
    curwid = width;
  }
}

void hp7470line(x1,y1,x2,y2)
int x1,y1,x2,y2;
{

      if(!porient) {
         if(x1 == xold && y1 == yold) 
           /* Add new point to path */
           fprintf(OutFile,"pd%d %d\n",x2,y2);
         else 
           /* Write out old path */
           fprintf(OutFile,"pu%d %d pd%d %d\n",x1,y1,x2,y2);
      }
      else {
         if(x1 == xold && y1 == yold) 
           /* Add new point to path */
           fprintf(OutFile,"pd%d %d\n",HP7470X-y2,x2);
         else 
           /* Write out old path */
           fprintf(OutFile,"pu%d %d pd%d %d\n",HP7470X-y1,x1,HP7470X-y2,x2);
      }
        
      xold = x2;
      yold = y2;
}
      
/* Close graphics file */
void hp7470tidy()
{
  fprintf(OutFile,"sp0\n");
  if(fileopen)      /* If we opened it then close it */
    fclose(OutFile);
}

void hp7470cwin()
{
}

void hp7470gwin()
{
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.