static void cont_mv_store(PLFLT xx, PLFLT yy) { if (cont3d) { if (currline->npts != 0) { /* not an empty list, allocate new */ currline->next = alloc_line(currlev); currline = currline->next; } /* and fill first element */ currline->x[0] = xx; currline->y[0] = yy; currline->npts = 1; } else plP_movwor(xx, yy); }
void c_pljoin(PLFLT xx1, PLFLT yy1, PLFLT xx2, PLFLT yy2) { plP_movwor(xx1, yy1); plP_drawor(xx2, yy2); }
void c_plstripa( PLINT id, PLINT p, PLFLT x, PLFLT y ) { int j, yasc=0, istart; if (p >= PEN) { plabort("Non existent pen"); return; } if ((id < 0) || (id >= MAX_STRIPC) || ((stripc = strip[id]) == NULL)) { plabort("Non existent stripchart"); return; } /* Add new point, allocating memory if necessary */ if (++stripc->npts[p] > stripc->nptsmax[p]) { stripc->nptsmax[p] += 32; stripc->x[p] = (PLFLT *) realloc((void *) stripc->x[p], sizeof(PLFLT)*stripc->nptsmax[p]); stripc->y[p] = (PLFLT *) realloc((void *) stripc->y[p], sizeof(PLFLT)*stripc->nptsmax[p]); if (stripc->x[p] == NULL || stripc->y[p] == NULL) { plabort("plstripc: Out of memory."); plstripd(id); return; } } stripc->x[p][stripc->npts[p]-1] = x; stripc->y[p][stripc->npts[p]-1] = y; stripc->xmax = x; if (stripc->y_ascl == 1 && (y > stripc->ymax || y < stripc->ymin)) yasc=1; if (y > stripc->ymax) stripc->ymax = stripc->ymin + 1.1*(y - stripc->ymin); if (y < stripc->ymin) stripc->ymin = stripc->ymax - 1.1*(stripc->ymax - y); /* Now either plot new point or regenerate plot */ if (stripc->xmax - stripc->xmin < stripc->xlen) { if( yasc == 0) { /* If user has changed subwindow, make shure we have the correct one */ plvsta(); plwind(stripc->wxmin, stripc->wxmax, stripc->wymin, stripc->wymax); /* FIXME - can exist some redundancy here */ plcol(stripc->colline[p]); pllsty(stripc->styline[p]); if ((stripc->npts[p]-2) < 0) plP_movwor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]); else plP_movwor(stripc->x[p][stripc->npts[p]-2], stripc->y[p][stripc->npts[p]-2]); plP_drawor(stripc->x[p][stripc->npts[p]-1], stripc->y[p][stripc->npts[p]-1]); plflush(); } else { stripc->xmax = stripc->xmin + stripc->xlen; plstrip_gen(stripc); } } else { /* Regenerating plot */ if (stripc->acc == 0) { for (j=0; j<PEN; j++) { if (stripc->npts[j] > 0) { istart = 0; while (stripc->x[j][istart] < stripc->xmin + stripc->xlen*stripc->xjump) istart++; stripc->npts[j] = stripc->npts[j] - istart; memcpy( &stripc->x[j][0], &stripc->x[j][istart], (stripc->npts[j])*sizeof(PLFLT)); memcpy( &stripc->y[j][0], &stripc->y[j][istart], (stripc->npts[j])*sizeof(PLFLT)); } } } else stripc->xlen = stripc->xlen * (1 + stripc->xjump); stripc->xmin = stripc->x[p][0]; stripc->xmax = stripc->xmax + stripc->xlen*stripc->xjump; plstrip_gen(stripc); } }
static void plzbx(const char *opt, const char *label, PLINT right, PLFLT dx, PLFLT dy, PLFLT wx, PLFLT wy1, PLFLT wy2, PLFLT vmin_in, PLFLT vmax_in, PLFLT tick, PLINT nsub, PLINT *digits) { static char string[40]; PLINT lb, lc, lf, li, ll, lm, ln, ls, lt, lu, lv; PLINT i, mode, prec, scale; PLINT nsub1, lstring; PLFLT pos, tn, tp, temp, height, tick1; PLFLT dwy, lambda, diag, major, minor, xmajor, xminor; PLFLT ymajor, yminor, dxm, dym, vmin, vmax; vmin = (vmax_in > vmin_in) ? vmin_in : vmax_in; vmax = (vmax_in > vmin_in) ? vmax_in : vmin_in; dwy = wy2 - wy1; /* Tick and subtick sizes in device coords */ major = plsc->majht; minor = plsc->minht; tick1 = tick; nsub1 = nsub; lb = plP_stsearch(opt, 'b'); lc = plP_stsearch(opt, 'c'); lf = plP_stsearch(opt, 'f'); li = plP_stsearch(opt, 'i'); ll = plP_stsearch(opt, 'l'); lm = plP_stsearch(opt, 'm'); ln = plP_stsearch(opt, 'n'); ls = plP_stsearch(opt, 's'); lt = plP_stsearch(opt, 't'); lu = plP_stsearch(opt, 'u'); lv = plP_stsearch(opt, 'v'); if (lu && !right) plztx("h", dx, dy, wx, wy1, wy2, 5.0, 0.5, 0.5, label); if (lv && right) plztx("h", dx, dy, wx, wy1, wy2, -5.0, 0.5, 0.5, label); if (right && !lc) return; if (!right && !lb) return; if (ll) tick1 = 1.0; if (lt) pldtik(vmin, vmax, &tick1, &nsub1); if ((li && !right) || (!li && right)) { minor = -minor; major = -major; } dxm = dx * plsc->wmxscl; dym = dy * plsc->wmyscl; diag = sqrt(dxm * dxm + dym * dym); xminor = minor * dxm / diag; xmajor = major * dxm / diag; yminor = minor * dym / diag; ymajor = major * dym / diag; /* Draw the line */ plP_movwor(wx, wy1); if (lt) { tp = tick1 * floor(vmin / tick1); for (;;) { tn = tp + tick1; if (ls) { if (ll) { for (i = 0; i <= 7; i++) { temp = tp + xlog[i]; if (BETW(temp, vmin, vmax)) { lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plstik(plP_wcmmx(wx), plP_wcmmy((PLFLT) (wy1 + lambda * dwy)), xminor, yminor); } } } else { for (i = 1; i <= nsub1 - 1; i++) { temp = tp + i * tick1 / nsub1; if (BETW(temp, vmin, vmax)) { lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plstik(plP_wcmmx(wx), plP_wcmmy((PLFLT) (wy1 + lambda * dwy)), xminor, yminor); } } } } temp = tn; if (!BETW(temp, vmin, vmax)) break; lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plstik(plP_wcmmx(wx), plP_wcmmy((PLFLT) (wy1 + lambda * dwy)), xmajor, ymajor); tp = tn; } } plP_drawor(wx, wy2); /* Label the line */ if ((ln || lm) && lt) { pldprec(vmin, vmax, tick1, lf, &mode, &prec, *digits, &scale); *digits = 0; tp = tick1 * floor(vmin / tick1); for (tn = tp + tick1; BETW(tn, vmin, vmax); tn += tick1) { plform(tn, scale, prec, string, ll, lf); pos = (vmax_in > vmin_in)? (tn - vmin) / (vmax - vmin): (vmax - tn) / (vmax - vmin); if (ln && !right) plztx("v", dx, dy, wx, wy1, wy2, 0.5, pos, 1.0, string); if (lm && right) plztx("v", dx, dy, wx, wy1, wy2, -0.5, pos, 0.0, string); lstring = strlen(string); *digits = MAX(*digits, lstring); } if (!ll && mode) { sprintf(string, "(x10#u%d#d)", (int) scale); pos = 1.15; height = 0.5; if (ln && !right) { plztx("v", dx, dy, wx, wy1, wy2, height, pos, 0.5, string); } if (lm && right) { plztx("v", dx, dy, wx, wy1, wy2, (PLFLT) -height, pos, 0.5, string); } } } }
static void plxybx(const char *opt, const char *label, PLFLT wx1, PLFLT wy1, PLFLT wx2, PLFLT wy2, PLFLT vmin_in, PLFLT vmax_in, PLFLT tick, PLINT nsub, PLINT nolast, PLINT *digits) { static char string[40]; PLINT lb, lf, li, ll, ln, ls, lt, lu; PLINT major, minor, mode, prec, scale; PLINT i, i1, i2, i3, i4; PLINT nsub1; PLFLT pos, tn, tp, temp, height, tick1, vmin, vmax; /* Note that 'tspace' is the minimim distance away (in fractional number * of ticks) from the boundary that an X or Y numerical label can be drawn. */ PLFLT dwx, dwy, lambda, tcrit, tspace = 0.1; vmin = (vmax_in > vmin_in) ? vmin_in : vmax_in; vmax = (vmax_in > vmin_in) ? vmax_in : vmin_in; dwx = wx2 - wx1; dwy = wy2 - wy1; /* Tick and subtick sizes in device coords */ major = MAX(ROUND(plsc->majht * plsc->ypmm), 1); minor = MAX(ROUND(plsc->minht * plsc->ypmm), 1); tick1 = tick; nsub1 = nsub; lb = plP_stsearch(opt, 'b'); lf = plP_stsearch(opt, 'f'); li = plP_stsearch(opt, 'i'); ll = plP_stsearch(opt, 'l'); ln = plP_stsearch(opt, 'n'); ls = plP_stsearch(opt, 's'); lt = plP_stsearch(opt, 't'); lu = plP_stsearch(opt, 'u'); if (lu) plxytx(wx1, wy1, wx2, wy2, 3.2, 0.5, 0.5, label); if (!lb) return; if (ll) tick1 = (vmax > vmin) ? 1.0 : -1.0 ; if (lt) pldtik(vmin, vmax, &tick1, &nsub1); if (li) { i1 = minor; i2 = 0; i3 = major; i4 = 0; } else { i1 = 0; i2 = minor; i3 = 0; i4 = major; } /* Draw the line */ plP_movwor(wx1, wy1); if (lt) { tp = tick1 * floor(vmin / tick1); for (;;) { tn = tp + tick1; if (ls) { if (ll) { for (i = 0; i <= 7; i++) { temp = tp + xlog[i]; if (BETW(temp, vmin, vmax)) { lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plxtik(plP_wcpcx((PLFLT) (wx1 + lambda * dwx)), plP_wcpcy((PLFLT) (wy1 + lambda * dwy)), i1, i2); } } } else { for (i = 1; i <= nsub1 - 1; i++) { temp = tp + i * (tn - tp) / nsub1; if (BETW(temp, vmin, vmax)) { lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plxtik(plP_wcpcx((PLFLT) (wx1 + lambda * dwx)), plP_wcpcy((PLFLT) (wy1 + lambda * dwy)), i1, i2); } } } } temp = tn; if (!BETW(temp, vmin, vmax)) break; lambda = (vmax_in > vmin_in)? (temp - vmin) / (vmax - vmin): (vmax - temp) / (vmax - vmin); plxtik(plP_wcpcx((PLFLT) (wx1 + lambda * dwx)), plP_wcpcy((PLFLT) (wy1 + lambda * dwy)), i3, i4); tp = tn; } } plP_drawor(wx2, wy2); /* Label the line */ if (ln && lt) { pldprec(vmin, vmax, tick1, lf, &mode, &prec, *digits, &scale); pos = 1.0; height = 3.2; tcrit = tspace*tick1; tp = tick1 * (1. + floor(vmin / tick1)); for (tn = tp; BETW(tn, vmin, vmax); tn += tick1) { if(BETW(tn, vmin+tcrit, vmax-tcrit)) { plform(tn, scale, prec, string, ll, lf); pos = (vmax_in > vmin_in)? (tn - vmin) / (vmax - vmin): (vmax - tn) / (vmax - vmin); plxytx(wx1, wy1, wx2, wy2, 1.5, pos, 0.5, string); } } *digits = 2; if (!ll && mode) { sprintf(string, "(x10#u%d#d)", (int) scale); plxytx(wx1, wy1, wx2, wy2, height, 1.0, 0.5, string); } } }
void c_pljoin(PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2) { plP_movwor(x1, y1); plP_drawor(x2, y2); }