Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
plctrl.c File Reference
#include "plplotP.h"

Go to the source code of this file.

Defines

#define DEBUG
#define NEED_PLDEBUG
#define PLLIBDEV   "/usr/local/plplot/lib"
#define color_def(i, r, g, b, n)   if (i >= imin && i <= imax) color_set(i, r, g, b, n);
#define MAX_NUM_TRIES   10

Functions

static void color_set (PLINT i, U_CHAR r, U_CHAR g, U_CHAR b, char *name)
static void strcat_delim (char *dirspec)
static void plcmap0_def (int imin, int imax)
static void plcmap1_def (void)
static PLFLT value (double n1, double n2, double hue)
MZ_DLLEXPORT void c_plcol0 (PLINT icol0)
void c_plcol1 (PLFLT col1)
MZ_DLLEXPORT void c_plscolbg (PLINT r, PLINT g, PLINT b)
void c_plgcolbg (PLINT *r, PLINT *g, PLINT *b)
MZ_DLLEXPORT void c_plscol0 (PLINT icol0, PLINT r, PLINT g, PLINT b)
void c_plgcol0 (PLINT icol0, PLINT *r, PLINT *g, PLINT *b)
void c_plscmap0 (PLINT *r, PLINT *g, PLINT *b, PLINT ncol0)
void c_plscmap1 (PLINT *r, PLINT *g, PLINT *b, PLINT ncol1)
MZ_DLLEXPORT void c_plscmap1l (PLINT itype, PLINT npts, PLFLT *pos, PLFLT *coord1, PLFLT *coord2, PLFLT *coord3, PLINT *rev)
void plcmap1_calc (void)
void c_plscmap0n (PLINT ncol0)
MZ_DLLEXPORT void c_plscmap1n (PLINT ncol1)
void c_plscolor (PLINT color)
void c_plrgb (PLFLT r, PLFLT g, PLFLT b)
void c_plrgb1 (PLINT r, PLINT g, PLINT b)
void c_plhls (PLFLT h, PLFLT l, PLFLT s)
void plHLS_RGB (PLFLT h, PLFLT l, PLFLT s, PLFLT *p_r, PLFLT *p_g, PLFLT *p_b)
void plRGB_HLS (PLFLT r, PLFLT g, PLFLT b, PLFLT *p_h, PLFLT *p_l, PLFLT *p_s)
void plwarn (char *errormsg)
void plabort (char *errormsg)
void plexit (char *errormsg)
void plsexit (int(*handler)(char *))
void c_plgra (void)
void c_plxormod (PLINT mode, PLINT *status)
void c_pltext (void)
void pl_cmd (PLINT op, void *ptr)
char * plFindCommand (char *fn)
FILE * plLibOpen (char *fn)
PDFstrmplLibOpenPdfstrm (char *fn)
int plFindName (char *p)
void plGetName (char *dir, char *subdir, char *filename, char **filespec)
void plcol_interp (PLStream *pls, PLColor *newcolor, int i, int ncol)
void plOpenFile (PLStream *pls)
void plP_getmember (PLStream *pls)
void plP_sfnam (PLStream *pls, const char *fnam)
void plFamInit (PLStream *pls)
void plGetFam (PLStream *pls)
void plRotPhy (PLINT orient, PLINT xmin, PLINT ymin, PLINT xmax, PLINT ymax, int *px, int *py)
PLDevplAllocDev (PLStream *pls)
void plGinInit (PLGraphicsIn *gin)
PLINT plGetInt (char *s)
PLFLT plGetFlt (char *s)
char * plstrdup (const char *src)

Variables

MZ_DLLEXPORT char * plplotLibDir = 0
static int(* exit_handler )(char *errormsg)

Define Documentation

#define color_def (   i,
  r,
  g,
  b,
 
)    if (i >= imin && i <= imax) color_set(i, r, g, b, n);

Definition at line 614 of file plctrl.c.

#define DEBUG

Definition at line 8 of file plctrl.c.

#define MAX_NUM_TRIES   10

Definition at line 1427 of file plctrl.c.

#define NEED_PLDEBUG

Definition at line 10 of file plctrl.c.

#define PLLIBDEV   "/usr/local/plplot/lib"

Definition at line 74 of file plctrl.c.


Function Documentation

Definition at line 91 of file plctrl.c.

{
    if (plsc->level < 1) {
       plabort("plcol0: Please call plinit first");
       return;
    }
    if (icol0 < 0 || icol0 >= plsc->ncol0) {
       char buffer[256];
       sprintf(buffer, "plcol0: Invalid color map entry: %d", (int) icol0);
       plabort(buffer);
       return;
    }

    plsc->icol0 = icol0;
    plsc->curcolor.r = plsc->cmap0[icol0].r;
    plsc->curcolor.g = plsc->cmap0[icol0].g;
    plsc->curcolor.b = plsc->cmap0[icol0].b;

    plsc->curcmap = 0;
    plP_state(PLSTATE_COLOR0);
}

Here is the call graph for this function:

void c_plcol1 ( PLFLT  col1)

Definition at line 120 of file plctrl.c.

{
    PLINT icol1;

    if (plsc->level < 1) {
       plabort("plcol1: Please call plinit first");
       return;
    }
    if (col1 < 0 || col1 > 1) {
       char buffer[256];
       sprintf(buffer, "plcol1: Invalid color map position: %f", (PLFLT) col1);
       plabort(buffer);
       return;
    }

    icol1 = col1 * plsc->ncol1;
    icol1 = MIN(icol1, plsc->ncol1-1);

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

    plsc->curcmap = 1;
    plP_state(PLSTATE_COLOR1);
}

Here is the call graph for this function:

void c_plgcol0 ( PLINT  icol0,
PLINT r,
PLINT g,
PLINT b 
)

Definition at line 216 of file plctrl.c.

{
    if (plsc->cmap0 == NULL)
       plscmap0n(0);

    *r = -1;
    *g = -1;
    *b = -1;

    if (icol0 < 0 || icol0 > plsc->ncol0) {
       char buffer[256];
       sprintf(buffer, "plgcol0: Invalid color index: %d", (int) icol0);
       plabort(buffer);
       return;
    }

    *r = plsc->cmap0[icol0].r;
    *g = plsc->cmap0[icol0].g;
    *b = plsc->cmap0[icol0].b;

    return;
}

Here is the call graph for this function:

void c_plgcolbg ( PLINT r,
PLINT g,
PLINT b 
)

Definition at line 167 of file plctrl.c.

{
    plgcol0(0, r, g, b);
}
void c_plgra ( void  )

Definition at line 1031 of file plctrl.c.

{
    if (plsc->level > 0)
       plP_esc(PLESC_GRAPH, NULL);
}

Here is the call graph for this function:

void c_plhls ( PLFLT  h,
PLFLT  l,
PLFLT  s 
)

Definition at line 792 of file plctrl.c.

{
    PLFLT r, g, b;

    plHLS_RGB(h, l, s, &r, &g, &b);
    plrgb(r, g, b);
}

Here is the call graph for this function:

void c_plrgb ( PLFLT  r,
PLFLT  g,
PLFLT  b 
)

Definition at line 739 of file plctrl.c.

{
    if (plsc->level < 1) {
       plabort("plrgb: Please call plinit first");
       return;
    }

    plsc->icol0 = PL_RGB_COLOR;
    plsc->curcolor.r = MAX(0, MIN(255, (int) (256. * r)));
    plsc->curcolor.g = MAX(0, MIN(255, (int) (256. * g)));
    plsc->curcolor.b = MAX(0, MIN(255, (int) (256. * b)));

    plsc->curcmap = 0;
    plP_state(PLSTATE_COLOR0);
}

Here is the call graph for this function:

void c_plrgb1 ( PLINT  r,
PLINT  g,
PLINT  b 
)

Definition at line 763 of file plctrl.c.

{
    if (plsc->level < 1) {
       plabort("plrgb1: Please call plinit first");
       return;
    }
    if ((r < 0 || r > 255) || (g < 0 || g > 255) || (b < 0 || b > 255)) {
       plabort("plrgb1: Invalid color");
       return;
    }

    plsc->icol0 = PL_RGB_COLOR;
    plsc->curcolor.r = r;
    plsc->curcolor.g = g;
    plsc->curcolor.b = b;

    plsc->curcmap = 0;
    plP_state(PLSTATE_COLOR0);
}

Here is the call graph for this function:

void c_plscmap0 ( PLINT r,
PLINT g,
PLINT b,
PLINT  ncol0 
)

Definition at line 247 of file plctrl.c.

{
    int i;

    plscmap0n(ncol0);

    for (i = 0; i < plsc->ncol0; i++) {
       if ((r[i] < 0 || r[i] > 255) ||
           (g[i] < 0 || g[i] > 255) ||
           (b[i] < 0 || b[i] > 255)) {

           char buffer[256];
           sprintf(buffer, "plscmap0: Invalid RGB color: %d, %d, %d",
                  (int) r[i], (int) g[i], (int) b[i]);
           plabort(buffer);
           return;
       }

       plsc->cmap0[i].r = r[i];
       plsc->cmap0[i].g = g[i];
       plsc->cmap0[i].b = b[i];
    }

    if (plsc->level > 0)
       plP_state(PLSTATE_CMAP0);
}

Here is the call graph for this function:

void c_plscmap0n ( PLINT  ncol0)

Definition at line 502 of file plctrl.c.

{
    int ncol, size, imin, imax;

/* No change */

    if (ncol0 > 0 && plsc->ncol0 == ncol0)
       return;

/* Handle all possible startup conditions */

    if (plsc->ncol0 <= 0 && ncol0 <= 0)
       ncol = 16;
    else if (ncol0 <= 0)
       ncol = plsc->ncol0;
    else
        ncol = ncol0;

    imax = ncol-1;
    size = ncol * sizeof(PLColor);

/* Allocate the space */

    if (plsc->cmap0 == NULL) {
       plsc->cmap0 = (PLColor *) calloc(1, size);
       imin = 0;
    }
    else {
       plsc->cmap0 = (PLColor *) realloc(plsc->cmap0, size);
       imin = plsc->ncol0;
    }

/* Fill in default entries */

    plsc->ncol0 = ncol;
    plcmap0_def(imin, imax);
}

Here is the call graph for this function:

void c_plscmap1 ( PLINT r,
PLINT g,
PLINT b,
PLINT  ncol1 
)

Definition at line 282 of file plctrl.c.

{
    int i;

    plscmap1n(ncol1);

    for (i = 0; i < plsc->ncol1; i++) {
       if ((r[i] < 0 || r[i] > 255) ||
           (g[i] < 0 || g[i] > 255) ||
           (b[i] < 0 || b[i] > 255)) {

           char buffer[256];
           sprintf(buffer, "plscmap1: Invalid RGB color: %d, %d, %d",
                  (int) r[i], (int) g[i], (int) b[i]);
           plabort(buffer);
           return;
       }
       plsc->cmap1[i].r = r[i];
       plsc->cmap1[i].g = g[i];
       plsc->cmap1[i].b = b[i];
    }

    if (plsc->level > 0)
       plP_state(PLSTATE_CMAP1);
}

Here is the call graph for this function:

MZ_DLLEXPORT void c_plscmap1l ( PLINT  itype,
PLINT  npts,
PLFLT pos,
PLFLT coord1,
PLFLT coord2,
PLFLT coord3,
PLINT rev 
)

Definition at line 361 of file plctrl.c.

{
    int n;
    PLFLT h, l, s, r, g, b;

    if (npts < 2) {
       plabort("plscmap1l: Must specify at least two control points");
       return;
    }

    if ( (pos[0] != 0) || (pos[npts-1] != 1)) {
       plabort("plscmap1l: First, last control points must lie on boundary");
       return;
    }

    if ( npts > PL_MAX_CMAP1CP ) {
       plabort("plscmap1l: exceeded maximum number of control points");
       return;
    }

/* Allocate if not done yet */

    if (plsc->cmap1 == NULL)
       plscmap1n(0);

/* Save control points */

    plsc->ncp1 = npts;

    for (n = 0; n < npts; n++) {

       if (itype == 0) {
           h = coord1[n];
           l = coord2[n];
           s = coord3[n];
       }
       else {
           r = coord1[n];
           g = coord2[n];
           b = coord3[n];
           plRGB_HLS(r, g, b, &h, &l, &s);
       }

       plsc->cmap1cp[n].h = h;
       plsc->cmap1cp[n].l = l;
       plsc->cmap1cp[n].s = s;
       plsc->cmap1cp[n].p = pos[n];

       if (rev == NULL)
           plsc->cmap1cp[n].rev = 0;
       else
           plsc->cmap1cp[n].rev = rev[n];
    }

/* Calculate and set color map */

    plcmap1_calc();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 552 of file plctrl.c.

{
    int ncol, size;

/* No change */

    if (ncol1 > 0 && plsc->ncol1 == ncol1)
       return;

/* Handle all possible startup conditions */

    if (plsc->ncol1 <= 0 && ncol1 <= 0)
       ncol = 128;
    else if (ncol1 <= 0)
       ncol = plsc->ncol1;
    else
        ncol = ncol1;

    size = ncol * sizeof(PLColor);

/* Allocate the space */

    if (plsc->ncol1 > 0) 
       plsc->cmap1 = (PLColor *) realloc(plsc->cmap1, size);
    else 
       plsc->cmap1 = (PLColor *) calloc(ncol, sizeof(PLColor));

/* Fill in default entries */

    plsc->ncol1 = ncol;
    if (plsc->ncp1 == 0)
       plcmap1_def();
    else
       plcmap1_calc();
}

Here is the call graph for this function:

MZ_DLLEXPORT void c_plscol0 ( PLINT  icol0,
PLINT  r,
PLINT  g,
PLINT  b 
)

Definition at line 181 of file plctrl.c.

{
    if (plsc->cmap0 == NULL)
       plscmap0n(0);

    if (icol0 < 0 || icol0 >= plsc->ncol0) {
       char buffer[256];
       sprintf(buffer, "plscol0: Illegal color table value: %d", (int) icol0);
       plabort(buffer);
       return;
    }
    if ((r < 0 || r > 255) || (g < 0 || g > 255) || (b < 0 || b > 255)) {
       char buffer[256];
       sprintf(buffer, "plscol0: Invalid RGB color: %d, %d, %d",
              (int) r, (int) g, (int) b);
       plabort(buffer);
       return;
    }

    plsc->cmap0[icol0].r = r;
    plsc->cmap0[icol0].g = g;
    plsc->cmap0[icol0].b = b;

    if (plsc->level > 0)
       plP_state(PLSTATE_CMAP0);
}

Here is the call graph for this function:

Definition at line 155 of file plctrl.c.

{
    plscol0(0, r, g, b);
}
void c_plscolor ( PLINT  color)

Definition at line 725 of file plctrl.c.

{
    plsc->colorset = 1;
    plsc->color = color;
}

Definition at line 1065 of file plctrl.c.

{
    if (plsc->level > 0)
       plP_esc(PLESC_TEXT, NULL);
}

Here is the call graph for this function:

void c_plxormod ( PLINT  mode,
PLINT status 
)

Definition at line 1038 of file plctrl.c.

{
  static int ostate = 0;

  if (!plsc->dev_xor) {
    *status = 0;
    return;
  }

  if (plsc->level > 0) {
    plP_esc(PLESC_XORMOD, &mode);
    if (mode) {
      ostate = plsc->plbuf_write;
      plsc->plbuf_write = 0;
    } else
      plsc->plbuf_write = ostate;
  } 
  *status = 1;
}

Here is the call graph for this function:

static void color_set ( PLINT  i,
U_CHAR  r,
U_CHAR  g,
U_CHAR  b,
char *  name 
) [static]

Definition at line 595 of file plctrl.c.

{
    plsc->cmap0[i].r = r;
    plsc->cmap0[i].g = g;
    plsc->cmap0[i].b = b;
    plsc->cmap0[i].name = name;
}

Here is the call graph for this function:

void pl_cmd ( PLINT  op,
void ptr 
)

Definition at line 1080 of file plctrl.c.

{
    plP_esc(op, ptr);
}

Here is the call graph for this function:

void plabort ( char *  errormsg)

Definition at line 950 of file plctrl.c.

{
    if (plsc->errcode != NULL)
       *(plsc->errcode) = 1;

    if (plsc->errmsg != NULL) {
       sprintf(plsc->errmsg, "\n*** PLPLOT ERROR ***\n");
       if (*errormsg != '\0')
           sprintf(plsc->errmsg, "%s, aborting operation\n", errormsg);

    } else {
       int was_gfx = 0;

       if (plsc->graphx == 1) {
           was_gfx = 1;
           pltext();
       }

       fprintf(stderr, "\n*** PLPLOT ERROR ***\n");
       if (*errormsg != '\0')
           fprintf(stderr, "%s, aborting operation\n", errormsg);

       if (was_gfx == 1)
           plgra();
    }
}
PLDev* plAllocDev ( PLStream pls)

Definition at line 1629 of file plctrl.c.

{
    if (pls->dev != NULL)
       free((void *) pls->dev);

    pls->dev = calloc(1, (size_t) sizeof(PLDev));
    if (pls->dev == NULL)
       plexit("plAllocDev: cannot allocate memory\n");

    return (PLDev *) pls->dev;
}

Here is the call graph for this function:

static void plcmap0_def ( int  imin,
int  imax 
) [static]

Definition at line 618 of file plctrl.c.

{
    int i;

    color_def(0,    0,   0,   0, "black" );      /* black */
    color_def(1,  255,   0,   0, "red");  /* red */
    color_def(2,  255, 255,   0, "yellow" );     /* yellow */
    color_def(3,    0, 255,   0, "green" );      /* green */
    color_def(4,  127, 255, 212, "aquamarine" ); /* aquamarine */
    color_def(5,  255, 192, 203, "pink" );       /* pink */
    color_def(6,  245, 222, 179, "wheat" );      /* wheat */
    color_def(7,  190, 190, 190, "grey" );       /* grey */
    color_def(8,  165,  42,  42, "brown" );      /* brown */
    color_def(9,    0,   0, 255, "blue" );       /* blue */
    color_def(10, 138,  43, 226, "BlueViolet" ); /* Blue Violet */
    color_def(11,   0, 255, 255, "cyan" );       /* cyan */
    color_def(12,  64, 224, 208, "turquoise" );  /* turquoise */
    color_def(13, 255,   0, 255, "magenta" );    /* magenta */
    color_def(14, 250, 128, 114, "salmon" );     /* salmon */
    color_def(15, 255, 255, 255, "white" );      /* white */

/* Any others are just arbitrarily set */

    for (i = 16; i <= imax; i++)
       color_def(i, 255, 0, 0, "red");    /* red */
}

Here is the caller graph for this function:

Definition at line 429 of file plctrl.c.

{
    int i, n;
    PLFLT delta, dp, dh, dl, ds;
    PLFLT h, l, s, p, r, g, b;

/* Loop over all control point pairs */

    for (n = 0; n < plsc->ncp1-1; n++) {

       if ( plsc->cmap1cp[n].p == plsc->cmap1cp[n+1].p )
           continue;

    /* Differences in p, h, l, s between ctrl pts */

       dp = plsc->cmap1cp[n+1].p - plsc->cmap1cp[n].p;
       dh = plsc->cmap1cp[n+1].h - plsc->cmap1cp[n].h;
       dl = plsc->cmap1cp[n+1].l - plsc->cmap1cp[n].l;
       ds = plsc->cmap1cp[n+1].s - plsc->cmap1cp[n].s;

    /* Adjust dh if we are to go around "the back side" */

       if (plsc->cmap1cp[n].rev)
           dh = (dh > 0) ? dh-360 : dh+360;

    /* Loop over all color cells.  Only interested in cells located (in */
    /* cmap1 space)  between n_th and n+1_th control points */

       for (i = 0; i < plsc->ncol1; i++) {
           p = (double) i / (plsc->ncol1 - 1.0);
           if ( (p < plsc->cmap1cp[n].p) ||
               (p > plsc->cmap1cp[n+1].p) )
              continue;

       /* Interpolate based on position of color cell in cmap1 space */

           delta = (p - plsc->cmap1cp[n].p) / dp;

       /* Linearly interpolate to get color cell h, l, s values */

           h = plsc->cmap1cp[n].h + dh * delta;
           l = plsc->cmap1cp[n].l + dl * delta;
           s = plsc->cmap1cp[n].s + ds * delta;

           while (h >= 360.)
              h -= 360.;

           while (h < 0.)
              h += 360.;

           plHLS_RGB(h, l, s, &r, &g, &b);

           plsc->cmap1[i].r = MAX(0, MIN(255, (int) (256. * r)));
           plsc->cmap1[i].g = MAX(0, MIN(255, (int) (256. * g)));
           plsc->cmap1[i].b = MAX(0, MIN(255, (int) (256. * b)));
       }
    }

    if (plsc->level > 0)
       plP_state(PLSTATE_CMAP1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void plcmap1_def ( void  ) [static]

Definition at line 659 of file plctrl.c.

{
    PLFLT i[6], h[6], l[6], s[6], midpt = 0., vertex = 0.;

/* Positions of control points */

    i[0] = 0;        /* left boundary */
    i[1] = 0.44;     /* a little left of center */
    i[2] = 0.50;     /* at center */
    i[3] = 0.50;     /* at center */
    i[4] = 0.56;     /* a little right of center */
    i[5] = 1;        /* right boundary */

/* For center control points, pick black or white, whichever is closer to bg */
/* Be carefult to pick just short of top or bottom else hue info is lost */

    if (plsc->cmap0 != NULL)
       vertex = ((PLFLT) plsc->cmap0[0].r +
                (PLFLT) plsc->cmap0[0].g +
                (PLFLT) plsc->cmap0[0].b) / 3. / 255.;

    if (vertex < 0.5) {
       vertex = 0.01;
       midpt  = 0.10;
    } else {
       vertex = 0.99;
       midpt  = 0.90;
    }

/* Set hue */

    h[0] = 260;             /* low: blue-violet */
    h[1] = 260;             /* only change as we go over vertex */
    h[2] = 260;             /* only change as we go over vertex */
    h[3] = 0;        /* high: red */
    h[4] = 0;        /* high: red */
    h[5] = 0;        /* keep fixed */

/* Set lightness */

    l[0] = 0.5;             /* low */
    l[1] = midpt;    /* midpoint value */
    l[2] = vertex;   /* bg */
    l[3] = vertex;   /* bg */
    l[4] = midpt;    /* midpoint value */
    l[5] = 0.5;             /* high */

/* Set saturation -- keep at maximum */

    s[0] = 1;
    s[1] = 1;
    s[2] = 1;
    s[3] = 1;
    s[4] = 1;
    s[5] = 1;

    c_plscmap1l(0, 6, i, h, l, s, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plcol_interp ( PLStream pls,
PLColor newcolor,
int  i,
int  ncol 
)

Definition at line 1394 of file plctrl.c.

{
    PLFLT x, delta;
    int il, ir;

    x = (double) (i * (pls->ncol1-1)) / (double) (ncol-1);
    il = x;
    ir = il + 1;
    delta = x - il;

    if (ir > pls->ncol1 || il < 0)
       fprintf(stderr, "Invalid color\n");

    else if (ir == pls->ncol1 || (delta == 0.)) {
       newcolor->r = pls->cmap1[il].r;
       newcolor->g = pls->cmap1[il].g;
       newcolor->b = pls->cmap1[il].b;
    }
    else {
       newcolor->r = (1.-delta) * pls->cmap1[il].r + delta * pls->cmap1[ir].r;
       newcolor->g = (1.-delta) * pls->cmap1[il].g + delta * pls->cmap1[ir].g;
       newcolor->b = (1.-delta) * pls->cmap1[il].b + delta * pls->cmap1[ir].b;
    }
}
void plexit ( char *  errormsg)

Definition at line 990 of file plctrl.c.

{
    int status = 1;

    if (exit_handler != NULL)
       status = (*exit_handler)(errormsg);

    plsc->nopause = 1;
    if (*errormsg != '\0') {
       fprintf(stderr, "\n*** PLPLOT ERROR ***\n");
       fprintf(stderr, "%s\n", errormsg);
    }
    plend();

    fprintf(stderr, "Program aborted\n");
    exit(status);
}

Here is the caller graph for this function:

void plFamInit ( PLStream pls)

Definition at line 1536 of file plctrl.c.

{
    if (pls->family) {
       pls->bytecnt = 0;
       if ( ! pls->member)
           pls->member = 1;
       if ( ! pls->finc)
           pls->finc = 1;
       if ( ! pls->fflen)
           pls->fflen = 1;
       if ( ! pls->bytemax)
           pls->bytemax = PL_FILESIZE_KB * 1000;
    }
}
char* plFindCommand ( char *  fn)

Definition at line 1099 of file plctrl.c.

{
    char *fs = NULL, *dn;

/* PLPLOT_BIN_ENV = $(PLPLOT_BIN) */

#if defined(PLPLOT_BIN_ENV)
    if ((dn = getenv(PLPLOT_BIN_ENV)) != NULL) {
        plGetName(dn, "", fn, &fs);
        if ( ! plFindName(fs))
            return fs;
        fprintf(stderr, PLPLOT_BIN_ENV"=\"%s\"\n", dn); /* what IS set? */
    }
#endif  /* PLPLOT_BIN_ENV */

/* Current directory */

    plGetName(".", "", fn, &fs);
    if ( ! plFindName(fs))
       return fs;

/* PLPLOT_HOME_ENV/bin = $(PLPLOT_HOME)/bin */

#if defined(PLPLOT_HOME_ENV)
    if ((dn = getenv(PLPLOT_HOME_ENV)) != NULL) {
        plGetName(dn, "bin", fn, &fs);
        if ( ! plFindName(fs))
            return fs;
        fprintf(stderr, PLPLOT_HOME_ENV"=\"%s\"\n",dn); /* what IS set? */
    }
#endif  /* PLPLOT_HOME_ENV */

/* BIN_DIR */

#if defined (BIN_DIR)
    plGetName(BIN_DIR, "", fn, &fs);
    if ( ! plFindName(fs))
       return fs;
#endif

/* Crapped out */

    free_mem(fs);
    fprintf(stderr, "plFindCommand: cannot locate command: %s\n", fn);
#if defined (BIN_DIR)
    fprintf(stderr, "bin dir=\"" BIN_DIR "\"\n" );      /* what WAS set? */
#endif  /* BIN_DIR */
    return NULL;
}

Here is the call graph for this function:

int plFindName ( char *  p)

Definition at line 1323 of file plctrl.c.

{
    return 1;
}

Here is the caller graph for this function:

void plGetFam ( PLStream pls)

Definition at line 1562 of file plctrl.c.

{
    PLFLT xpmm_loc, ypmm_loc;
    if (pls->family) {
       if (pls->bytecnt > pls->bytemax || pls->famadv) {
           plP_tidy();
           pls->member += pls->finc;
           pls->famadv = 0;
           plP_init();
          /* Apply compensating factor to original xpmm and ypmm so that 
           * character aspect ratio is preserved when overall aspect ratio
           * is changed. */
           plP_gpixmm(&xpmm_loc, &ypmm_loc);
           plP_setpxl(xpmm_loc*plsc->caspfactor, ypmm_loc/plsc->caspfactor); 
           return;
       }
    }
}

Here is the call graph for this function:

PLFLT plGetFlt ( char *  s)

Definition at line 1696 of file plctrl.c.

{
    PLFLT m;
    double m1;
    int i = 0;
    char line[256];

    while (i++ < 10) {
       fprintf(stdout, s);
       fgets(line, sizeof(line), stdin);
#ifdef MSDOS
       m = atof(line);
       return (m);
#else
       if (sscanf(line, "%lf", &m1) == 1) {
           m = (PLFLT) m1;
           return (m);
       }
       fprintf(stdout, "No value or value out of range; please try again\n");
#endif
    }
    plexit("Too many tries.");
    return (0.);
}

Here is the call graph for this function:

PLINT plGetInt ( char *  s)

Definition at line 1667 of file plctrl.c.

{
    int m;
    int i = 0;
    char line[256];

    while (i++ < 10) {
       fprintf(stdout, s);
       fgets(line, sizeof(line), stdin);
#ifdef MSDOS
       m = atoi(line);
       return (m);
#else
       if (sscanf(line, "%d", &m) == 1)
           return (m);
       fprintf(stdout, "No value or value out of range; please try again\n");
#endif
    }
    plexit("Too many tries.");
    return (0);
}

Here is the call graph for this function:

void plGetName ( char *  dir,
char *  subdir,
char *  filename,
char **  filespec 
)

Definition at line 1339 of file plctrl.c.

{
    int lfilespec;

/* Malloc space for filespec */

    free_mem(*filespec);
    lfilespec = 10;
    lfilespec = strlen(dir) + strlen(subdir) + strlen(filename) + 10;
    *filespec = (char *) malloc(lfilespec);

    strcpy(*filespec, dir);

    if (*subdir != '\0') {
       strcat_delim(*filespec);
       strcat(*filespec, subdir);
    }
    if (*filename != '\0') {
       strcat_delim(*filespec);
       strcat(*filespec, filename);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1648 of file plctrl.c.

{
    gin->type = 0;
    gin->state = 0;
    gin->keysym = 0;
    gin->button = 0;
    gin->string[0] = '\0';
    gin->pX = gin->pY = -1;
    gin->dX = gin->dY = 0.;
    gin->wX = gin->wY = 0.;
}
void plHLS_RGB ( PLFLT  h,
PLFLT  l,
PLFLT  s,
PLFLT p_r,
PLFLT p_g,
PLFLT p_b 
)

Definition at line 843 of file plctrl.c.

{
    PLFLT m1, m2;

    if (l <= .5)
       m2 = l * (s + 1.);
    else
       m2 = l + s - l * s;

    m1 = 2 * l - m2;

    *p_r = value(m1, m2, h + 120.);
    *p_g = value(m1, m2, h);
    *p_b = value(m1, m2, h - 120.);
}

Here is the caller graph for this function:

FILE* plLibOpen ( char *  fn)

Definition at line 1162 of file plctrl.c.

{
    FILE *ret = NULL;
    
    PDFstrm *pdfs = plLibOpenPdfstrm(fn);
    if (pdfs == NULL) {
        return NULL;
    }
    if (pdfs->file != NULL) {
        ret = pdfs->file;
       pdfs->file = NULL;
    }
    pdf_close(pdfs);
    return ret;
}

Here is the call graph for this function:

PDFstrm* plLibOpenPdfstrm ( char *  fn)

Definition at line 1179 of file plctrl.c.

{
    PDFstrm *file;
    char *fs = NULL, *dn = NULL;

/****  search PLPLOT_LIB_ENV = $(PLPLOT_LIB)     ****/

#if defined(PLPLOT_LIB_ENV)
    if ((dn = getenv(PLPLOT_LIB_ENV)) != NULL) {
        plGetName(dn, "", fn, &fs);

        if ((file = pdf_fopen(fs, "rb")) != NULL)
            goto done;

        fprintf(stderr, PLPLOT_LIB_ENV"=\"%s\"\n", dn); /* what IS set? */
    }
#endif  /* PLPLOT_LIB_ENV */

/****  search current directory    ****/

    if ((file = pdf_fopen(fn, "rb")) != NULL)
        goto done;

/****  search PLPLOT_HOME_ENV/lib = $(PLPLOT_HOME)/lib  ****/

#if defined (PLPLOT_HOME_ENV)
    if ((dn = getenv(PLPLOT_HOME_ENV)) != NULL) {
        plGetName(dn, "lib", fn, &fs);

        if ((file = pdf_fopen(fs, "rb")) != NULL)
            goto done;
        fprintf(stderr, PLPLOT_HOME_ENV"=\"%s\"\n",dn); /* what IS set? */
    }
#endif  /* PLPLOT_HOME_ENV/lib */

/****  search installed location   ****/

#if defined (DATA_DIR)
    plGetName(DATA_DIR, "", fn, &fs);

    if ((file = pdf_fopen(fs, "rb")) != NULL)
        goto done;
#endif  /* DATA_DIR */

/****  search hardwired location   ****/

#ifdef PLLIBDEV
    plGetName(PLLIBDEV, "", fn, &fs);

    if ((file = pdf_fopen(fs, "rb")) != NULL)
       goto done;
#endif /* PLLIBDEV */

#ifdef macintosh
    file = plMacLibOpen(fn);
    if (file != NULL)
        goto done;
#endif /* macintosh */

    if (plplotLibDir != NULL) {
       plGetName(plplotLibDir, "", fn, &fs);
       if ((file = pdf_fopen(fs, "rb")) != NULL)
           goto done;

    }
    
/****  not found, give up   ****/

    return NULL;

 done:
    free_mem(fs);
    return (file);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plOpenFile ( PLStream pls)

Definition at line 1429 of file plctrl.c.

{
    int i = 0, count = 0;
    size_t len;
    char line[256];

    while (pls->OutFile == NULL) {

/* Setting pls->FileName = NULL forces creation of a new family member */
/* You should also free the memory associated with it if you do this */

       if (pls->family && pls->BaseName != NULL)
           plP_getmember(pls);

/* Prompt if filename still not known */

       if (pls->FileName == NULL) {
           do {
              fprintf(stdout, "Enter graphics output file name: ");
              fgets(line, sizeof(line), stdin);
              len = strlen(line);
              if (len)
                  len--;
              line[len] = '\0';    /* strip new-line */
              count++;             /* count zero entries */
           } while (!len && count < MAX_NUM_TRIES);
           plP_sfnam(pls, line);
       }

/* If name is "-", send to stdout */

       if ( ! strcmp(pls->FileName, "-")) {
           pls->OutFile = stdout;
           pls->output_type = 1;
           break;
       }

/* Need this here again, for prompted family initialization */

       if (pls->family && pls->BaseName != NULL) 
           plP_getmember(pls);

       if (i++ > 10)
           plexit("Too many tries.");

       if ((pls->OutFile = fopen(pls->FileName, "wb+")) == NULL) 
           fprintf(stdout, "Can't open %s.\n", pls->FileName);
       else
         {
//         fprintf(stderr, "Opened %s\n", pls->FileName);
//         this is not needed
         }
    }
}

Here is the call graph for this function:

Definition at line 1491 of file plctrl.c.

{
    char tmp[256];

    if (pls->FileName == NULL)
       pls->FileName = (char *) malloc(10 + strlen(pls->BaseName));

    sprintf(tmp, "%s.%%0%1ii", pls->BaseName, (int) pls->fflen);
    sprintf(pls->FileName, tmp, pls->member);
}

Here is the caller graph for this function:

void plP_sfnam ( PLStream pls,
const char *  fnam 
)

Definition at line 1510 of file plctrl.c.

{
    pls->OutFile = NULL;

    if (pls->FileName != NULL)
       free((void *) pls->FileName);

    pls->FileName = (char *) malloc(10 + strlen(fnam));

    strcpy(pls->FileName, fnam);

    if (pls->BaseName != NULL)
       free((void *) pls->BaseName);

    pls->BaseName = (char *) malloc(10 + strlen(fnam));

    strcpy(pls->BaseName, fnam);
}

Here is the caller graph for this function:

void plRGB_HLS ( PLFLT  r,
PLFLT  g,
PLFLT  b,
PLFLT p_h,
PLFLT p_l,
PLFLT p_s 
)

Definition at line 871 of file plctrl.c.

{
    PLFLT h, l, s, d, rc, gc, bc, rgb_min, rgb_max;

    rgb_min = MIN( r, MIN( g, b ));
    rgb_max = MAX( r, MAX( g, b ));

    l = (rgb_min+rgb_max) / 2.0;

    if (rgb_min == rgb_max) {
       s = 0;
       h = 0;
    } 
    else {
       d = rgb_max - rgb_min;
       if (l < 0.5)
           s = 0.5 * d / l;
       else 
           s = 0.5* d / (1.-l);

       rc = (rgb_max-r) / d;
       gc = (rgb_max-g) / d;
       bc = (rgb_max-b) / d;

       if (r == rgb_max)
           h = bc-gc;
       else if (g == rgb_max)
           h = rc-bc+2;
       else
           h = gc-rc-2;

       h = h*60;
       if (h <  0)
           h = h+360;
       else if (h >= 360)
           h = h-360;
    }
    *p_h = h;
    *p_l = l;
    *p_s = s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plRotPhy ( PLINT  orient,
PLINT  xmin,
PLINT  ymin,
PLINT  xmax,
PLINT  ymax,
int px,
int py 
)

Definition at line 1591 of file plctrl.c.

{
    int x, y;

    x = *px;
    y = *py;

    switch (orient%4) {

    case 1:
       *px = xmin + (y - ymin);
       *py = ymin + (xmax - x);
       break;

    case 2:
       *px = xmin + (xmax - x);
       *py = ymin + (ymax - y);
       break;

    case 3:
       *px = xmin + (ymax - y);
       *py = ymin + (x - xmin);
       break;

    default:
       break;               /* do nothing */
    }
}
void plsexit ( int(*)(char *)  handler)

Definition at line 1015 of file plctrl.c.

{
    exit_handler = handler;
}
char* plstrdup ( const char *  src)

Definition at line 1729 of file plctrl.c.

{
    char *dest = (char *) malloc( (strlen(src) + 1) * sizeof(char) );
    if (dest != NULL)
       strcpy(dest, src);
    else
       plabort("Out of memory");

    return dest;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plwarn ( char *  errormsg)

Definition at line 924 of file plctrl.c.

{
    int was_gfx = 0;

    if (plsc->graphx == 1) {
       was_gfx = 1;
       pltext();
    }

    fprintf(stderr, "\n*** PLPLOT WARNING ***\n");
    if (*errormsg != '\0')
       fprintf(stderr, "%s\n", errormsg);

    if (was_gfx == 1)
       plgra();
}

Here is the caller graph for this function:

static void strcat_delim ( char *  dirspec) [static]

Definition at line 1370 of file plctrl.c.

{
    int ldirspec = strlen(dirspec);
#if defined (MSDOS)
    if (dirspec[ldirspec-1] != '\\')
       strcat(dirspec, "\\");
#elif defined (macintosh)
    if (dirspec[ldirspec-1] != ':')
        strcat(dirspec, ":");
#else           /* unix is the default */
    if (dirspec[ldirspec-1] != '/')
       strcat(dirspec, "/");
#endif
}

Here is the caller graph for this function:

static PLFLT value ( double  n1,
double  n2,
double  hue 
) [static]

Variable Documentation

int(* exit_handler)(char *errormsg) [static]

Definition at line 45 of file plctrl.c.

Definition at line 36 of file plctrl.c.