void wipgetcxy(float *cx, float *cy) { double arg; LOGICAL error; arg = wipgetvar("cx", &error); *cx = (error == TRUE) ? 0.0 : arg; arg = wipgetvar("cy", &error); *cy = (error == TRUE) ? 0.0 : arg; return; }
void wipvfield(float x[], float y[], float r[], float phi[], int npts, float angle, float vent) { register int i; int fill; float x1, y1, x2, y2; double darg; LOGICAL error; darg = wipgetvar("fill", &error); fill = (error == TRUE) ? 1 : NINT(darg); cpgbbuf(); cpgsah(fill, angle, vent); for (i = 0; i < npts; i++) { x1 = x[i]; y1 = y[i]; x2 = x1 + (r[i] * COS(phi[i] * RPDEG)); y2 = y1 + (r[i] * SIN(phi[i] * RPDEG)); cpgarro(x1, y1, x2, y2); } cpgebuf(); return; }
void wipdecode(const char *string, char *outstr, size_t maxout) { char *ptr, *tmptr, *savptr; char ch; char tempstr[BUFSIZ], variable[BUFSIZ]; int nsig, nopen; double arg; LOGICAL error; ptr = (char *)string; if (Strchr(string, ESC) != (char *)NULL) { arg = wipgetvar("nsig", &error); nsig = NINT(arg); /* Tells how to format a user variable. */ tmptr = tempstr; while (*ptr) { if (*ptr != ESC) { *tmptr++ = *ptr++; /* Just copy the character. */ continue; /* Get the next character. */ } /* At this point an ESC character has been found. */ ch = *ptr++; /* save the ESC character. */ if (*ptr != '[') { /* No user variable here, so just store... */ *tmptr++ = ch; /* ...the two characters and continue. */ *tmptr++ = *ptr++; /* This is so "\\" gets passed. */ continue; /* Get the next character. */ } /* At this point a user variable flag has been found. */ ptr++; /* Increment ptr past the '['. */ savptr = variable; /* Set up user variable name pointer. */ nopen = 1; /* Initialize the number of open '['s. */ while ((*ptr) && (nopen)) { /* Get user variable name. */ if (*ptr == '[') nopen++; if (*ptr == ']') nopen--; if (nopen) *savptr++ = *ptr++; } if (*ptr != Null) ptr++; /* Skip over last ']' */ *savptr = Null; /* Skip last ']'; add terminating Null. */ if (wipisstring(variable)) { /* User string variable. */ savptr = wipgetstring(variable); /* Find string variable. */ if (savptr == (char *)NULL) savptr = ""; /* Error check. */ } else { /* Standard user variable. */ arg = wipevaluate(variable, &error); /* Find user variable. */ savptr = wipfpfmt(arg, nsig); /* Format the value. */ } while ((*savptr != Null) && (isspace(*savptr))) savptr++; /* Strip off leading blanks. */ while (*savptr) *tmptr++ = *savptr++; /* Include the value. */ } /* End of "while (*ptr)" loop. */ *tmptr = Null; /* Terminate the string with a Null. */ ptr = tempstr; /* Assign the work pointer to this string. */ } /* End of "(domacs == TRUE)" if block. */ if (Strlen(ptr) >= maxout) wipoutput(stderr, "Decoded string overflows output string size.\n"); (void)Strncpy(outstr, ptr, maxout); outstr[maxout-1] = Null; /* Make sure it is Null terminated. */ return; }
/* * Arrow draws one arrow from the current cursor position to the * specified position (xp, yp). The acute angle of the arrow point, * in degrees, is specified by the input "angle"; angles in the * range 20.0 to 90.0 give reasonable results. The default angle * is 45.0 degrees. The fraction of the triangular arrow-head that * is cut away from the back is specified by the input "vent". A * value of 0.0 gives a triangular wedge arrow-head; 1.0 gives an * open >. Values of 0.3 to 0.7 give reasonable results. The * default value for "vent" is 0.3. */ void wiparrow(float xp, float yp, float angle, float vent) { int fill; float cx, cy; double darg; LOGICAL error; wipgetcxy(&cx, &cy); darg = wipgetvar("fill", &error); fill = (error == TRUE) ? 1 : NINT(darg); cpgsah(fill, angle, vent); cpgarro(cx, cy, xp, yp); return; }
/* * LOCATION = 1-4 for bars to quadrant j less 45 deg, eg 1 for +X * Returns 0 on success; 1 on error. */ int wiperrorbar(int location, float x[], float y[], float err[], int nxy) { float expsiz; LOGICAL error; if (nxy < 1) return(1); cpgbbuf(); /* Set up buffered output. */ expsiz = wipgetvar("expand", &error); if (error == TRUE) expsiz = 1.0; expsiz /= 10.0; cpgerrb(location, nxy, x, y, err, expsiz); cpgebuf(); /* Finish up buffered output. */ return(0); }