/* epswr_aux.h -- internal prototypes for epswr.c. */ /* Last edited on 2007-12-26 12:16:58 by stolfi */ #ifndef epswr_aux_H #define epswr_aux_H #include #include #include void epswr_aux_write_preamble(epswr_figure_t *epsf); /* Writes the necessary preambles to a newly-created figure file writer. The preamble defines some auxiliary Postscript operators and constants, sets up the caption font, resets some graphics variables (line width and color, fill color, etc.), etc. The figure's bounding box (for the "%%BoundingBox" comment) is taken from the fields {epsf->hSize,epsf->vSize}, rounded up to integers. The Postscript clipping path is set according to the parameters {hMin,hMax,vMin,vMax} stored in {epsf}. */ void epswr_aux_write_postamble(epswr_figure_t *epsf); /* Writes the file's postamble, including the fonts list. */ /* INTERNAL SCALING/CLIPPING PROCEDURES */ void epswr_aux_save_window_data ( epswr_figure_t *epsf, double xMin, double xMax, double yMin, double yMax, double hMin, double hMax, double vMin, double vMax ); /* Saves the given data as the current plot rectangle ({epsf->hMin,epsf->hMax,epsf->vMin,epsf->vMax}) and the current client coordinate ranges ({epsf->xMin,epsf->xMax,epsf->yMin,epsf->yMax}). Writes to the EPS file commands to reset the clipping path and define the Postscript variables {hMin,hMax,vMin,vMax}. */ void epswr_aux_save_grid_data(epswr_figure_t *epsf, int xn, int yn); /* Saves the given data as the current cell grid counts ({epsf->xGridCount,epsf->yGridCount}). */ /* FILE PREMBLES AND POSTAMBLES */ /* The file preamble (produced by both epswr_write_eps_file_header and epswr_write_ps_file_header) creates a Postscript dictionary "epsf$dict" that contains definitions for special Postscript operators and some state variables, such as the plotting rectangle and grid size. This dictionary is closed before the end of the preamble, and must be re-opened at each canvas. */ void epswr_aux_write_eps_file_header ( FILE *psFile, const char *date, double hMin, double hMax, double vMin, double vMax ); /* Writes the file preamble for an encapsulated Postscript file. Must be followed by {epswr_write_canvas_header} to complete the setup. */ void epswr_aux_write_eps_file_trailer(FILE *psFile, int nfonts, char **fonts); /* Writes the file postamble for an encapsulated Postscript file, namely the "%%Trailer" comment followed by the "%%DocumentFonts: {F}" (where {F} is the given list of font names). This call must be preceded by {epswr_write_canvas_trailer}. */ /* DOCUMENT FONT LIST */ void epswr_aux_initialize_font_list(int *nfontsP, char ***fontsP); /* Initializes the font list with the "Courier" font. */ void epswr_aux_add_font(const char *font, int *nfontsP, char ***fontsP); /* Appends a copy of the given {font} string to the font list. */ void epswr_aux_free_font_list(int *nfontsP, char ***fontsP); /* Frees all storage used by the font list and sets it to NULL. */ /* CANVAS PREAMBLES AND POSTAMBLES */ void epswr_aux_write_canvas_header(FILE *psFile, const char *pageName, int pageSeq); /* Writes the preamble for a new canvas of an EPS or non-EPS file. May be called only once per EPS file, and once per page of a non-EPS file. The preamble includes the "%%Page" directive, if applicable, and commands that save the current Postscript state (with "save"), and open the "epsf$dict" dictionary. */ void epswr_aux_write_canvas_trailer(FILE *psFile, int eps); /* Writes the postamble for a canvas in an EPS or non-EPS file. Must be matched to a preceding {epswr_aux_write_canvas_header} The postamble includes a "showpage" command, if {eps} is false. In any case, the postamble includes commands that close the "epsf$dict" dictionary, and restore the Postcript state that was saved when the canvas was started. */ /* MISCELLANEOUS WRITING PROCEDURES */ void epswr_aux_write_proc_defs(FILE *psFile); /* Writes to {psFile} the definition of the operators assumed by other plotting and text writing commands. */ void epswr_aux_write_canvas_graphics_setup_cmds(FILE *psFile, double *fc); /* Writes to {epsf->psFile} some commands that setup some graphics variables, suitable for the beginning of a new canvas. In particular the stroke color is reset to black, and the fill color to {fc}. */ void epswr_aux_write_window_setup_cmds ( FILE *psFile, double hMin, double hMax, double vMin, double vMax ); /* Writes to {psFile} some commands that setup the Postscript variables {xmin,xmax,ymin,ymax} to the values {hMin,hMax,vMin,vMax}, and sets the clip path to that rectangle. ???Those commands also set the Postscript variables {xtext,ytext}, which define the start of the next caption line, to be just below the left ; and {dytext} that defines the caption interline spacing (in pt). Finally, they set the {captionfont} variable to the caption font, properly scaled. */ void epswr_aux_write_grid_setup_cmds(FILE *psFile, int xn, int yn); /* Writes to {psFile} some commands that setup the Postscript variables {xn,yn} that define the cell grid */ void epswr_aux_write_label_font_setup_cmds(FILE *psFile, const char *font, double size); /* Writes to {psFile} commands that create an instance of the font named {font}, scaled by {size} pt, and save it in the Postscript variable {labelfont} (which is used by {epswr_aux_label}). */ void epswr_aux_write_ps_string(FILE *psFile, const char *text, const char *newline); /* Writes the given text out to /psFile/, in Postscript form, properly quoting any special chars and parentheses. Replaces any embedded '\n' by the given /newline/ string --- which could be, for example, ") show mynl (". */ void epswr_aux_write_color(FILE *psFile, double *clr); /* Writes the color value {clr[0..2]} to the Postscript file, with 3 decimals, preceded by spaces. */ void epswr_aux_write_font_list(FILE *psFile, int nfonts, char **fonts); /* Writes the structured comment "%%DocumentFonts: {F}" where {F} is the given list of font names. */ void epswr_aux_write_fill_color_set_cmd(FILE *psFile, double *fc); /* Writes the Postoscript command that saves {fc[0..2]} as the RGB fill color for subsequent figure commands. */ #endif