static void rdbuf_swin(PLStream *pls) { 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); }
void c_plwind(PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax) { PLFLT dx, dy, mmxmi, mmxma, mmymi, mmyma; PLWindow w; if (plsc->level < 2) { plabort("plwind: Please set up viewport first"); return; } /* Best to just warn and recover on bounds errors */ if (xmin == xmax) { plwarn("plwind: Invalid window limits in x."); xmin--; xmax++; } if (ymin == ymax) { plwarn("plwind: Invalid window limits in y."); ymin--; ymax++; } dx = (xmax - xmin) * 1.0e-5; dy = (ymax - ymin) * 1.0e-5; /* The true plot window is made slightly larger than requested so that */ /* the end limits will be on the graph */ plsc->vpwxmi = xmin - dx; plsc->vpwxma = xmax + dx; plsc->vpwymi = ymin - dy; plsc->vpwyma = ymax + dy; /* Compute the scaling between coordinate systems */ dx = plsc->vpwxma - plsc->vpwxmi; dy = plsc->vpwyma - plsc->vpwymi; plsc->wpxscl = (plsc->vppxma - plsc->vppxmi) / dx; plsc->wpxoff = (xmax * plsc->vppxmi - xmin * plsc->vppxma) / dx; plsc->wpyscl = (plsc->vppyma - plsc->vppymi) / dy; plsc->wpyoff = (ymax * plsc->vppymi - ymin * plsc->vppyma) / dy; mmxmi = plP_dcmmx(plsc->vpdxmi); mmxma = plP_dcmmx(plsc->vpdxma); mmymi = plP_dcmmy(plsc->vpdymi); mmyma = plP_dcmmy(plsc->vpdyma); /* Set transformation variables for world coordinates to mm */ plsc->wmxscl = (mmxma - mmxmi) / dx; plsc->wmxoff = (xmax * mmxmi - xmin * mmxma) / dx; plsc->wmyscl = (mmyma - mmymi) / dy; plsc->wmyoff = (ymax * mmymi - ymin * mmyma) / dy; /* Set transformation variables for world coordinates to device coords */ plsc->wdxscl = plsc->wmxscl * plsc->xpmm / (plsc->phyxma - plsc->phyxmi); plsc->wdxoff = plsc->wmxoff * plsc->xpmm / (plsc->phyxma - plsc->phyxmi); plsc->wdyscl = plsc->wmyscl * plsc->ypmm / (plsc->phyyma - plsc->phyymi); plsc->wdyoff = plsc->wmyoff * plsc->ypmm / (plsc->phyyma - plsc->phyymi); /* Register plot window attributes */ w.dxmi = plsc->vpdxmi; w.dxma = plsc->vpdxma; w.dymi = plsc->vpdymi; w.dyma = plsc->vpdyma; w.wxmi = plsc->vpwxmi; w.wxma = plsc->vpwxma; w.wymi = plsc->vpwymi; w.wyma = plsc->vpwyma; plP_swin(&w); /* Go to level 3 */ plsc->level = 3; }