Back to index

plt-scheme  4.2.1
Defines | Functions
plbuf.c File Reference
#include "plplotP.h"
#include "drivers.h"
#include "metadefs.h"
#include <string.h>

Go to the source code of this file.

Defines

#define NEED_PLDEBUG

Functions

static int rd_command (PLStream *pls, U_CHAR *p_c)
static int wr_command (PLStream *pls, U_CHAR c)
static void plbuf_control (PLStream *pls, U_CHAR c)
static void rdbuf_init (PLStream *pls)
static void rdbuf_line (PLStream *pls)
static void rdbuf_polyline (PLStream *pls)
static void rdbuf_eop (PLStream *pls)
static void rdbuf_bop (PLStream *pls)
static void rdbuf_state (PLStream *pls)
static void rdbuf_esc (PLStream *pls)
static void plbuf_fill (PLStream *pls)
static void rdbuf_fill (PLStream *pls)
static void plbuf_swin (PLStream *pls, PLWindow *plwin)
static void rdbuf_swin (PLStream *pls)
void plbuf_init (PLStream *pls)
void plbuf_line (PLStream *pls, short x1a, short y1a, short x2a, short y2a)
void plbuf_polyline (PLStream *pls, short *xa, short *ya, PLINT npts)
void plbuf_eop (PLStream *pls)
void plbuf_bop (PLStream *pls)
void plbuf_tidy (PLStream *pls)
void plbuf_state (PLStream *pls, PLINT op)
static void plbuf_image (PLStream *pls, IMG_DT *img_dt)
void plbuf_esc (PLStream *pls, PLINT op, void *ptr)
static void rdbuf_image (PLStream *pls)
void plRemakePlot (PLStream *pls)

Define Documentation

#define NEED_PLDEBUG

Definition at line 18 of file plbuf.c.


Function Documentation

void plbuf_bop ( PLStream pls)

Definition at line 128 of file plbuf.c.

{
    dbug_enter("plbuf_bop");

    plbuf_tidy(pls);

    pls->plbufFile = tmpfile();
    if (pls->plbufFile == NULL) 
       plexit("plbuf_init: Error opening plot data storage file.");

    wr_command(pls, (U_CHAR) BOP);
    plbuf_state(pls, PLSTATE_COLOR0);
    plbuf_state(pls, PLSTATE_WIDTH);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void plbuf_control ( PLStream pls,
U_CHAR  c 
) [static]

Definition at line 647 of file plbuf.c.

{
    static U_CHAR c_old = 0;

    dbug_enter("plbuf_control");

    switch ((int) c) {

    case INITIALIZE:
       rdbuf_init(pls);
       break;

    case EOP:
       rdbuf_eop(pls);
       break;

    case BOP:
       rdbuf_bop(pls);
       break;

    case CHANGE_STATE:
       rdbuf_state(pls);
       break;

    case LINE:
       rdbuf_line(pls);
       break;

    case POLYLINE:
       rdbuf_polyline(pls);
       break;

    case ESCAPE:
       rdbuf_esc(pls);
       break;

    default:
      pldebug("plbuf_control", "Unrecognized command %d, previous %d\n", c, c_old);
    }
    c_old = c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plbuf_eop ( PLStream pls)

Definition at line 111 of file plbuf.c.

{
    dbug_enter("plbuf_eop");
}

Here is the caller graph for this function:

void plbuf_esc ( PLStream pls,
PLINT  op,
void ptr 
)

Definition at line 260 of file plbuf.c.

{
    dbug_enter("plbuf_esc");

    wr_command(pls, (U_CHAR) ESCAPE);
    wr_command(pls, (U_CHAR) op);

    switch (op) {
    case PLESC_FILL:
       plbuf_fill(pls);
       break;
    case PLESC_SWIN:
       plbuf_swin(pls, (PLWindow *) ptr);
       break;
    case PLESC_IMAGE:
       plbuf_image(pls, (IMG_DT *) ptr);
       break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void plbuf_fill ( PLStream pls) [static]

Definition at line 287 of file plbuf.c.

{
    dbug_enter("plbuf_fill");

    fwrite(&pls->dev_npts, sizeof(PLINT), 1, pls->plbufFile);
    fwrite(pls->dev_x, sizeof(short), pls->dev_npts, pls->plbufFile);
    fwrite(pls->dev_y, sizeof(short), pls->dev_npts, pls->plbufFile);
}

Here is the caller graph for this function:

static void plbuf_image ( PLStream pls,
IMG_DT img_dt 
) [static]

Definition at line 224 of file plbuf.c.

{
    PLINT npts = pls->dev_nptsX * pls->dev_nptsY;

    dbug_enter("plbuf_image");

    fwrite(&pls->dev_nptsX, sizeof(PLINT), 1, pls->plbufFile);
    fwrite(&pls->dev_nptsY, sizeof(PLINT), 1, pls->plbufFile);

    fwrite(&img_dt->xmin, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&img_dt->ymin, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&img_dt->dx, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&img_dt->dy, sizeof(PLFLT), 1, pls->plbufFile);

    fwrite(&pls->dev_zmin, sizeof(short), 1, pls->plbufFile);
    fwrite(&pls->dev_zmax, sizeof(short), 1, pls->plbufFile);

    fwrite(pls->dev_ix, sizeof(short), npts, pls->plbufFile);
    fwrite(pls->dev_iy, sizeof(short), npts, pls->plbufFile);
    fwrite(pls->dev_z, sizeof(unsigned short), (pls->dev_nptsX-1)*(pls->dev_nptsY-1), pls->plbufFile);
}

Here is the caller graph for this function:

void plbuf_init ( PLStream pls)

Definition at line 53 of file plbuf.c.

{
    dbug_enter("plbuf_init");

    pls->plbuf_read = FALSE;
    if (pls->plbufFile != NULL) 
       pls->plbuf_write = FALSE;
}

Here is the caller graph for this function:

void plbuf_line ( PLStream pls,
short  x1a,
short  y1a,
short  x2a,
short  y2a 
)

Definition at line 69 of file plbuf.c.

{
    short xpl[2], ypl[2];

    dbug_enter("plbuf_line");

    wr_command(pls, (U_CHAR) LINE);

    xpl[0] = x1a;
    xpl[1] = x2a;
    ypl[0] = y1a;
    ypl[1] = y2a;

    fwrite(xpl, sizeof(short), 2, pls->plbufFile);
    fwrite(ypl, sizeof(short), 2, pls->plbufFile);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plbuf_polyline ( PLStream pls,
short *  xa,
short *  ya,
PLINT  npts 
)

Definition at line 93 of file plbuf.c.

{
    dbug_enter("plbuf_polyline");

    wr_command(pls, (U_CHAR) POLYLINE);
    fwrite(&npts, sizeof(PLINT), 1, pls->plbufFile);

    fwrite(xa, sizeof(short), npts, pls->plbufFile);
    fwrite(ya, sizeof(short), npts, pls->plbufFile);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plbuf_state ( PLStream pls,
PLINT  op 
)

Definition at line 168 of file plbuf.c.

{
    dbug_enter("plbuf_state");

    wr_command(pls, (U_CHAR) CHANGE_STATE);
    wr_command(pls, (U_CHAR) op);

    switch (op) {

    case PLSTATE_WIDTH: {
       U_CHAR width = pls->width;

       fwrite(&width, sizeof(U_CHAR), 1, pls->plbufFile);
       break;
    }

    case PLSTATE_COLOR0: {
       U_CHAR icol0 = pls->icol0;
       U_CHAR r = pls->curcolor.r;
       U_CHAR g = pls->curcolor.g;
       U_CHAR b = pls->curcolor.b;

       fwrite(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
       if (icol0 == PL_RGB_COLOR) {
           fwrite(&r, sizeof(U_CHAR), 1, pls->plbufFile);
           fwrite(&g, sizeof(U_CHAR), 1, pls->plbufFile);
           fwrite(&b, sizeof(U_CHAR), 1, pls->plbufFile);
       }
       break;
    }

    case PLSTATE_COLOR1: {
       U_CHAR icol1 = pls->icol1;

       fwrite(&icol1, sizeof(U_CHAR), 1, pls->plbufFile);
       break;
    }

    case PLSTATE_FILL:{
       signed char patt = pls->patt;

       fwrite(&patt, sizeof(signed char), 1, pls->plbufFile);
       break;
    }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void plbuf_swin ( PLStream pls,
PLWindow plwin 
) [static]

Definition at line 303 of file plbuf.c.

{
    fwrite(&plwin->dxmi, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->dxma, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->dymi, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->dyma, sizeof(PLFLT), 1, pls->plbufFile);

    fwrite(&plwin->wxmi, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->wxma, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->wymi, sizeof(PLFLT), 1, pls->plbufFile);
    fwrite(&plwin->wyma, sizeof(PLFLT), 1, pls->plbufFile);
}

Here is the caller graph for this function:

void plbuf_tidy ( PLStream pls)

Definition at line 150 of file plbuf.c.

{
    dbug_enter("plbuf_tidy");

    if (pls->plbufFile == NULL)
       return;

    fclose(pls->plbufFile);
    pls->plbufFile = NULL;
}

Here is the caller graph for this function:

Definition at line 617 of file plbuf.c.

{
    U_CHAR c;
    int plbuf_status;

    dbug_enter("plRemakePlot");

    if (pls->plbufFile == NULL)
       return;

    rewind(pls->plbufFile);

    plbuf_status = pls->plbuf_write;
    pls->plbuf_write = FALSE;
    pls->plbuf_read = TRUE;
    while (rd_command(pls, &c)) {
       plbuf_control(pls, c);
    }

    pls->plbuf_read = FALSE;
    pls->plbuf_write = plbuf_status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int rd_command ( PLStream pls,
U_CHAR p_c 
) [static]

Definition at line 696 of file plbuf.c.

{
    int count;
    
    count = fread(p_c, sizeof(U_CHAR), 1, pls->plbufFile);
    return (count);
}

Here is the caller graph for this function:

static void rdbuf_bop ( PLStream pls) [static]

Definition at line 392 of file plbuf.c.

{
    dbug_enter("rdbuf_bop");

    pls->nplwin = 0;
}

Here is the caller graph for this function:

static void rdbuf_eop ( PLStream pls) [static]

Definition at line 380 of file plbuf.c.

{
    dbug_enter("rdbuf_eop");
}

Here is the caller graph for this function:

static void rdbuf_esc ( PLStream pls) [static]

Definition at line 500 of file plbuf.c.

{
    U_CHAR op;

    dbug_enter("rdbuf_esc");

    fread(&op, sizeof(U_CHAR), 1, pls->plbufFile);

    switch (op) {
    case PLESC_FILL:
       rdbuf_fill(pls);
       break;
    case PLESC_SWIN:
       rdbuf_swin(pls);
       break;
    case PLESC_IMAGE:
       rdbuf_image(pls);
       break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_fill ( PLStream pls) [static]

Definition at line 528 of file plbuf.c.

{
    short xpl[PL_MAXPOLY], ypl[PL_MAXPOLY];
    PLINT npts;

    dbug_enter("rdbuf_fill");

    fread(&npts, sizeof(PLINT), 1, pls->plbufFile);
    fread(xpl, sizeof(short), npts, pls->plbufFile);
    fread(ypl, sizeof(short), npts, pls->plbufFile);
    
    plP_fill(xpl, ypl, npts);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_image ( PLStream pls) [static]

Definition at line 549 of file plbuf.c.

{
  short *dev_ix, *dev_iy;
  unsigned short *dev_z, dev_zmin, dev_zmax;
  PLINT nptsX,nptsY, npts;
  PLFLT xmin, ymin, dx, dy;

    dbug_enter("rdbuf_image");

    fread(&nptsX, sizeof(PLINT), 1, pls->plbufFile);
    fread(&nptsY, sizeof(PLINT), 1, pls->plbufFile);
    npts = nptsX*nptsY;

    fread(&xmin, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&ymin, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&dx, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&dy, sizeof(PLFLT), 1, pls->plbufFile);

    fread(&dev_zmin, sizeof(short), 1, pls->plbufFile);
    fread(&dev_zmax, sizeof(short), 1, pls->plbufFile);

    dev_ix=(short *)malloc(npts*sizeof(short));
    dev_iy=(short *)malloc(npts*sizeof(short));
    dev_z=(unsigned short *)malloc((nptsX-1)*(nptsY-1)*sizeof(unsigned short));

    fread(dev_ix, sizeof(short), npts, pls->plbufFile);
    fread(dev_iy, sizeof(short), npts, pls->plbufFile);
    fread(dev_z, sizeof(unsigned short), (nptsX-1)*(nptsY-1), pls->plbufFile);

    plP_image(dev_ix, dev_iy, dev_z, nptsX, nptsY, xmin, ymin, dx, dy, dev_zmin, dev_zmax);

    free(dev_ix);
    free(dev_iy);
    free(dev_z);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_init ( PLStream pls) [static]

Definition at line 327 of file plbuf.c.

{
    dbug_enter("rdbuf_init");
}

Here is the caller graph for this function:

static void rdbuf_line ( PLStream pls) [static]

Definition at line 339 of file plbuf.c.

{
    short xpl[2], ypl[2];
    PLINT npts = 2;

    dbug_enter("rdbuf_line");

    fread(xpl, sizeof(short), npts, pls->plbufFile);
    fread(ypl, sizeof(short), npts, pls->plbufFile);

    plP_line(xpl, ypl);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_polyline ( PLStream pls) [static]

Definition at line 359 of file plbuf.c.

{
    short xpl[PL_MAXPOLY], ypl[PL_MAXPOLY];
    PLINT npts;

    dbug_enter("rdbuf_polyline");

    fread(&npts, sizeof(PLINT), 1, pls->plbufFile);
    fread(xpl, sizeof(short), npts, pls->plbufFile);
    fread(ypl, sizeof(short), npts, pls->plbufFile);

    plP_polyline(xpl, ypl, npts);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_state ( PLStream pls) [static]

Definition at line 406 of file plbuf.c.

{
    U_CHAR op;

    dbug_enter("rdbuf_state");

    fread(&op, sizeof(U_CHAR), 1, pls->plbufFile);

    switch (op) {

    case PLSTATE_WIDTH:{
       U_CHAR width;

       fread(&width, sizeof(U_CHAR), 1, pls->plbufFile);
       pls->width = width;
       plP_state(PLSTATE_WIDTH);

       break;
    }

    case PLSTATE_COLOR0:{
       U_CHAR icol0, r, g, b;

       fread(&icol0, sizeof(U_CHAR), 1, pls->plbufFile);
       if (icol0 == PL_RGB_COLOR) {
           fread(&r, sizeof(U_CHAR), 1, pls->plbufFile);
           fread(&g, sizeof(U_CHAR), 1, pls->plbufFile);
           fread(&b, sizeof(U_CHAR), 1, pls->plbufFile);
       }
       else {
           if ((int) icol0 > 15) {
              plwarn("rdbuf_state: Color map 0 entry hosed");
              icol0 = 1;
           }
           r = pls->cmap0[icol0].r;
           g = pls->cmap0[icol0].g;
           b = pls->cmap0[icol0].b;
       }
       pls->icol0 = icol0;
       pls->curcolor.r = r;
       pls->curcolor.g = g;
       pls->curcolor.b = b;

       plP_state(PLSTATE_COLOR0);
       break;
    }

    case PLSTATE_COLOR1: {
       U_CHAR icol1;

       fread(&icol1, sizeof(U_CHAR), 1, pls->plbufFile);

       pls->icol1 = icol1;
       pls->curcolor.r = pls->cmap1[icol1].r;
       pls->curcolor.g = pls->cmap1[icol1].g;
       pls->curcolor.b = pls->cmap1[icol1].b;

       plP_state(PLSTATE_COLOR1);
       break;
    }

    case PLSTATE_FILL: {
       signed char patt;

       fread(&patt, sizeof(signed char), 1, pls->plbufFile);

       pls->patt = patt;
       plP_state(PLSTATE_FILL);
       break;
    }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void rdbuf_swin ( PLStream pls) [static]

Definition at line 592 of file plbuf.c.

{
    PLWindow plwin;

    fread(&plwin.dxmi, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.dxma, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.dymi, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.dyma, sizeof(PLFLT), 1, pls->plbufFile);

    fread(&plwin.wxmi, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.wxma, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.wymi, sizeof(PLFLT), 1, pls->plbufFile);
    fread(&plwin.wyma, sizeof(PLFLT), 1, pls->plbufFile);

    plP_swin(&plwin);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int wr_command ( PLStream pls,
U_CHAR  c 
) [static]

Definition at line 711 of file plbuf.c.

{
    U_CHAR c1 = c;
    int count;

    count = fwrite(&c1, sizeof(U_CHAR), 1, pls->plbufFile);
    return (count);
}

Here is the caller graph for this function: