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

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

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

static int orient=0, curwid;
static long bmapx, bmapy, bmapxmax, bmapymax, xdpi, ydpi;
static long dwidth, dheight;

void prefsetup(xddpi, yddpi, xwid, ywid)
int xwid, ywid;
double xddpi, yddpi;
{
   /* Ignore these and use preferences data instead. */
}

void preforient(ori)
int ori;
{
   orient = ori;
}

void prefselect(file)
FILE *file;
{
}

/* Most of the code is in plsupport.c  where it is shared with the menu
   selection printer dump. */
void prefinit()
{
   char line[10];
   int mode, openprinter(), mapinit(), queryprint();
   void closeprinter();

   if(openprinter()) plexit("");

   mode = queryprint(&bmapx, &bmapy, &bmapxmax, &bmapymax, &xdpi, &ydpi);

   /* If mode == 1 we want to adjust the bitmap size so that the aspect
      ratio is maintained. */
   if(mode) {
      if((float)bmapxmax*bmapy > (float)bmapymax*bmapx)
         bmapy = (int)(((float)bmapx*bmapymax)/bmapxmax + .5);
      else
         bmapx = (int)(((float)bmapy*bmapxmax)/bmapymax + .5);
   }

   /* Leave a little space for pen width. */
   dwidth = bmapx - 2;
   dheight = bmapy - 2;

   if(!orient) {
      setpxl((double)(ydpi/25.4), (double)(xdpi/25.4));
      setphy(0,bmapymax,0,bmapxmax);
   }
   else {
      setpxl((double)(xdpi/25.4), (double)(ydpi/25.4));
      setphy(0,bmapxmax,0,bmapymax);
   }

   scol(1);
   swid(1);
   smod(0);

   /* Allocate bitmap and initial for line drawing */
   if(mapinit(bmapx, bmapy)) {
      closeprinter();
      plexit("");
   }
}

void preftext()
{
}

void prefgraph()
{
}

void prefclear()
{
   void ejectpage(), dmpport();

   dmpport(0L,bmapx,bmapy);
   /* Eject the page. */
   ejectpage();
}

void prefpage()
{
   void mapclear();

   mapclear();
}

void prefeop()
{
}

void prefwidth(width)
int width;
{
   if(width < 1)
      curwid = 1;
   else if(width > 3)
      curwid = 3;
   else
      curwid = width;
}

void prefcolor(color)
int color;
{
}

void prefline(x1,y1,x2,y2)
int x1, y1, x2, y2;
{
   long xn1, yn1, xn2, yn2;
   void mapline();

   if(!orient) {
      xn1 = (x1*dheight)/bmapymax;
      yn1 = (y1*dwidth)/bmapxmax;
      xn2 = (x2*dheight)/bmapymax;
      yn2 = (y2*dwidth)/bmapxmax;
      switch(curwid) {
         case 3:
            mapline(yn1,xn1,yn2,xn2);
         case 2:
            mapline(yn1+2,xn1+2,yn2+2,xn2+2);
         case 1:
         default:
            mapline(yn1+1,xn1+1,yn2+1,xn2+1);
      }
   }
   else {
      xn1 = (x1*dwidth)/bmapxmax;
      yn1 = (y1*dheight)/bmapymax;
      xn2 = (x2*dwidth)/bmapxmax;
      yn2 = (y2*dheight)/bmapymax;
      switch(curwid) {
         case 3:
            mapline(xn1,dheight-yn1,xn2,dheight-yn2);
         case 2:
            mapline(xn1+2,dheight-yn1+2,xn2+2,dheight-yn2+2);
         case 1:
         default:
            mapline(xn1+1,dheight-yn1+1,xn2+1,dheight-yn2+1);
      }
   }
}

void preftidy()
{
   void dmpport(), mapfree(), closeprinter();

   dmpport(0L,bmapx,bmapy);
   mapfree();
   closeprinter();
}

void prefcwin()
{
}

void prefgwin()
{
}

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