/* CANVAS PREAMBLES AND POSTAMBLES */ void epswr_aux_write_canvas_header(FILE *psFile); /* Writes the preamble for a new canvas of an EPS file. May be called only once per EPS file. The preamble includes commands that save the current Postscript state (with "save"), and open the "epsf$dict" dictionary. */ void epswr_aux_write_canvas_trailer(FILE *psFile); /* Writes the postamble for a canvas in an EPS file Must be matched to a preceding {epswr_aux_write_canvas_header}. The postamble includes commands that close the "epsf$dict" dictionary, and restore the Postcript state that was saved when the canvas was started. */ /* INTERNAL WINDOW SETUP */ void epswr_save_window_data ( epswr_figure_t *epsf, double xMin, double xMax, double yMin, double yMax, double hMin, double hMax, double vMin, double vMax ) { /* Save the actual plot window: */ epsf->hMin = hMin; epsf->hMax = hMax; epsf->vMin = vMin; epsf->vMax = vMax; /* Save the client scales: */ epsf->xMin = xMin; epsf->xMax = xMax; epsf->yMin = yMin; epsf->yMax = yMax; /* Compute client-to-file scales: */ } /* Caption cursor. */ fprintf(wr, "%% Parameters of text area:\n" "/dytext 10 pt mul def\n" "/xtext hMin def\n" "/ytext vMin def\n" "\n" ); fprintf(wr, "%% Caption font setup:\n" "/captionfont\n" " /Courier findfont\n" " dytext scalefont\n" "def\n" "\n" ); void epswr_def_set_grid(epswr_def_figure_t *epsf, int xn, int yn) { /* Save client grid size: */ epsf->xGridN = xn; epsf->yGridN = yn; } void epswr_set_grid(epswr_figure_t *epsf, int nx, int ny) { /* Save the grid parameters in the {epswr_figure_t} record: */ epswr_def_set_grid(epsf, nx, ny); /* Write the grid setup commands in the Postcript file: */ FILE *wr = epsf->wr; epswr_aux_write_grid_set_cmds(wr, nx, ny); fflush(wr); } void epswr_aux_write_grid_set_cmds(FILE *wr, int hGridN, int vGridN) { fprintf(wr, "/hGridN %d def %% grid cells along x axis\n", hGridN); fprintf(wr, "/vGridN %d def %% grid cells along y axis\n", vGridN); fprintf(wr, "/dhGrid hMax hMin sub hGridN div def %% x-size of grid cell\n"); fprintf(wr, "/dvGrid vMax vMin sub vGridN div def %% y-size of grid cell\n"); fflush(wr); } fprintf(wr, "%% Draw all grid lines:\n" "%% {nh} {nv} gridlines --> \n" "/gridlines\n" "{ gsave\n" " initclip\n" " dup 0 exch 1 exch \n" /* --- {nh} {nv} 0 1 {nv} */ " {\n" /* --- {nh} {nv} {iv} */ " exch dup\n" /* --- {nh} {iv} {nv} {nv} */ " 3 2 roll\n" /* --- {nh} {nv} {nv} {iv} */ " vMax vMin sub\n" /* --- {nh} {nv} {nv} {iv} {dv} */ " mul div vMin add\n" /* --- {nh} {nv} {v} */ " ygrd\n" /* --- {nh} {nv} */ " } for\n" /* --- {nh} {nv} */ " pop\n" /* --- {nh} */ "\n" " dup 0 exch 1 exch \n" /* --- {nh} 0 1 {nh} */ " {\n" /* --- {nh} {ih} */ " exch dup\n" /* --- {ih} {nh} {nh} */ " 3 2 roll\n" /* --- {nh} {nh} {ih} */ " hMax hMin sub\n" /* --- {nh} {nh} {ih} {dh} */ " mul div hMin add\n" /* --- {nh} {h} */ " xgrd\n" /* --- {nh} */ " } for\n" /* --- {nh} */ " pop\n" /* --- */ "\n" " grestore\n" "} bind def\n" "\n" ); double pt_per_mm = (72.0/25.4); /* One mm in pt. */ double hSize = 150.00*pt_per_mm; /* Figure X size excluding margin (pt). */ double vSize = 150.00*pt_per_mm; /* Figure Y size excluding margin (pt). */ double mrg = 4.0; /* Figure margin width (pt). */ double mrg_bot = mrg + nCap*fontHeight + mrg; /* Bottom margin (pt). */ /* Add caption only if there is a user caption, or it is not EPS. */ /* Select a good figure size: */ epswr_figure_t *eps = epswr_new_named_figure ( NULL, prefix, NULL, -1, NULL, hSize, vSize, mrg, mrg, mrg_bot, mrg, eps_verbose ); epswr_set_client_window(eps, xmin,xmax, ymin, ymax); /* Caption: */ epswr_set_text_geomptry(eps, FALSE, 0,xSize, mrg-mrg_bot, -mrg, 0.0); epswr_set_text_font(eps, "Courier", fontHeight);