void openpl(char *s) /* initialize device; s is residue of .PS invocation line */ { double maxw, maxh, ratio = 1; double odeltx = deltx, odelty = delty; hpos = vpos = 0; maxw = getfval("maxpswid"); maxh = getfval("maxpsht"); if (deltx > maxw) { /* shrink horizontal */ ratio = maxw / deltx; deltx *= ratio; delty *= ratio; } if (delty > maxh) { /* shrink vertical */ ratio = maxh / delty; deltx *= ratio; delty *= ratio; } if (ratio != 1) { fprintf(stderr, "pic: %g X %g picture shrunk to", odeltx, odelty); fprintf(stderr, " %g X %g\n", deltx, delty); } space(xmin, ymin, xmax, ymax); printf(".\\\" %g %g %g %g\n", xmin, ymin, xmax, ymax); printf(".\\\" %.3fi %.3fi %.3fi %.3fi\n", xconv(xmin), yconv(ymin), xconv(xmax), yconv(ymax)); printf(".nr 00 \\n(.u\n"); printf(".nf\n"); printf(".PS %.3fi %.3fi %s", yconv(ymin), xconv(xmax), s); /* assumes \n comes as part of s */ }
void openpl(char *s) /* initialize device */ /* char *s; / * residue of .PS invocation line */ { double maxw, maxh, ratio = 1; double odeltx = deltx, odelty = delty; hpos = vpos = 0; maxw = getfval("maxpswid"); maxh = getfval("maxpsht"); /* if (deltx > getfval("maxpswid") || delty > getfval("maxpsht")) { / * 8.5x11 inches max * / * fprintf(stderr, "pic: %g X %g picture shrunk to", deltx, delty); * maxdelt = max(deltx, delty); * deltx *= 7/maxdelt; / * screwed up anyway; * / * delty *= 7/maxdelt; / * make it 7x7 so someone can see it * / * fprintf(stderr, " %g X %g\n", deltx, delty); * } */ if (deltx > maxw) { /* shrink horizontal */ ratio = maxw / deltx; deltx *= ratio; delty *= ratio; } if (delty > maxh) { /* shrink vertical */ ratio = maxh / delty; deltx *= ratio; delty *= ratio; } if (ratio != 1) { fprintf(stderr, "pic: %g X %g picture shrunk to", odeltx, odelty); fprintf(stderr, " %g X %g\n", deltx, delty); } space(xmin, ymin, xmax, ymax); printf("... %g %g %g %g\n", xmin, ymin, xmax, ymax); printf("... %.3fi %.3fi %.3fi %.3fi\n", xconv(xmin), yconv(ymin), xconv(xmax), yconv(ymax)); printf(".nr 00 \\n(.u\n"); printf(".nf\n"); printf(".PS %.3fi %.3fi %s", yconv(ymin), xconv(xmax), s); /* assumes \n comes as part of s */ }
void cont(double x, double y) /* continue line from here to x,y */ { double h1, v1; double dh, dv; h1 = xconv(x); v1 = yconv(y); dh = h1 - hpos; dv = v1 - vpos; hvflush(); printf("\\D'l%.3fi %.3fi'\n", dh, dv); flyback(); /* expensive */ hpos = h1; vpos = v1; }
int iscontained(int gno, double wx, double wy) { int i; double xconv(double x), yconv(double y); double x = xconv(wx), y = yconv(wy); for (i = 0; i < maxgraph; i++) { if (g[i].active == ON) { if ((g[i].v.xv1 <= x && g[i].v.xv2 >= x) && (g[i].v.yv1 <= y && g[i].v.yv2 >= y)) { return i; } } } return gno; }
SAFEARRAY* CGainer::convert(BSTR bstr) { if (!SysStringLen(bstr) || !wcschr(L"IiRr", *bstr)) { return NULL; } bool digital = *bstr == 'R' || *bstr == 'r'; int len = (digital) ? (SysStringLen(bstr) - 1) : (SysStringLen(bstr) - 1) / 2; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].cElements = len; rgsabound[0].lLbound = 0L; #ifdef USE_VARIANT SAFEARRAY* pNewAry = SafeArrayCreate(VT_VARIANT, 1, rgsabound); #else SAFEARRAY* pNewAry = SafeArrayCreate(VT_UI1, 1, rgsabound); #endif SafeArrayLock(pNewAry); #ifdef USE_VARIANT VARIANT* ps = (VARIANT*)pNewAry->pvData; #else LPBYTE ps = (LPBYTE)pNewAry->pvData; #endif for (int i = 0; i < len; i++, ps++) { #ifdef USE_VARIANT VariantInit(ps); if (digital) { ps->vt = VT_UI1; ps->bVal = (byte)xconv(*(bstr + i + 1)); } else { ps->vt = VT_UI1; ps->bVal = (byte)((xconv(*(bstr + i * 2 + 1)) << 4) | xconv(*(bstr + i * 2 + 2))); } #else if (digital) { *ps = (byte)xconv(*(bstr + i + 1)); } else { *ps = (byte)((xconv(*(bstr + i * 2 + 1)) << 4) | xconv(*(bstr + i * 2 + 2))); } #endif } SafeArrayUnlock(pNewAry); return pNewAry; }
void cont(double x, double y) /* continue line from here to x,y */ { double h1, v1; double dh, dv; int rh = 0; h1 = xconv(x); v1 = yconv(y); dh = h1 - hpos; dv = v1 - vpos; if (dh > 0 && !dv) { rh = 1; move(x, y); dh = -dh; } hvflush(); printf("\\D'l%.3fi %.3fi'\n", dh, dv); if (rh) move(x, y); flyback(); /* expensive */ hpos = h1; vpos = v1; }
void move(double x, double y) /* go to position x, y in external coords */ { hgoto(xconv(x)); vgoto(yconv(y)); }
move(xi,yi){ movep(xconv(xsc(xi)),yconv(ysc(yi))); return; }
void cont(int x0, int y0) { iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0))); return; }
void line(int x0, int y0, int x1, int y1) { iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1))); return; }
cont(x0,y0){ iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0))); return; }
line(x0,y0,x1,y1){ iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1))); return; }