README.HARDCOPY
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:11k
- /*
- * Hardcopy Interface for Xgraph
- *
- * Major differences from first version:
- * A flags argument has been added to xg_init(). This new argument
- * is used to specify a new binary option: D_DOCU. See below
- * for details.
- *
- * Four new parameters are passed to the device initialization routine:
- * title_family, title_size, axis_family, and axis_size. See the
- * description of xg_init() for details.
- *
- * Clipping is done automatically by xgraph. The xg_clip() routine
- * is obsolete.
- *
- * The xg_line() routine has become the xg_seg() routine. It now
- * draws segments rather than a series of lines.
- *
- * A new field (max_segs) in the device structure now specifies
- * the maximum number of segments the device can handle in a group.
- */
- /*
- * Adding an output device to xgraph
- *
- * Step 1
- * Write versions of the following routines for your device:
- * xg_init(), xg_text(), xg_seg(), xg_dot(), and xg_end().
- * The interface and function of these routines are described
- * in detail below. These routines should be named according
- * to your device. For example, the initialization routine
- * for the Postscript output device is psInit(). Also, name
- * your source file after your device (e.g. the postscript
- * routines are in the file ps.c). Instructions continue
- * after the description of the interface routines.
- *
- * The definitions below are quoted here as a convenience. In
- * your output module, you can include "xgout.h" to obtain these
- * definitions.
- */
- #define D_COLOR 0x01
- #define ERRBUFSIZE 2048
- #define D_DOCU 0x01
- typedef struct xg_out {
- int dev_flags; /* Device characteristic flags */
- int area_w, area_h; /* Width and height in pixels */
- int bdr_pad; /* Padding from border */
- int axis_pad; /* Extra space around axis labels */
- int tick_len; /* Length of a tick mark */
- int legend_pad; /* Top of legend text to legend line */
- int axis_width; /* Width of big character of axis font */
- int axis_height; /* Height of big character of axis font */
- int title_width; /* Width of big character of title font */
- int title_height; /* Height of big character of title font */
- int max_segs; /* Maximum number of segments in group */
- void (*xg_text)(); /* Draws text at a location */
- void (*xg_seg)(); /* Draws a series of segments */
- void (*xg_dot)(); /* Draws a dot or marker at a location */
- void (*xg_end)(); /* Stops the drawing sequence */
- char *user_state; /* User supplied state information */
- } xgOut;
- int xg_init(strm, width, height, title_family, title_size,
- axis_family, axis_size, out_info, errmsg)
- FILE *strm; /* Output stream */
- int width, height; /* Size of space (microns) */
- char *title_family; /* Name of title font family */
- double title_size; /* Title font height (points) */
- char *axis_family; /* Name of axis font family */
- double axis_size; /* Axis font height (points) */
- int flags; /* Flags (see below) */
- xgOut *out_info; /* Device info (RETURN) */
- char errmsg[ERRBUFSIZE]; /* Error message area */
- /*
- * This routine is called by xgraph just before drawing is to
- * begin. The desired size of the plot is given by `width'
- * and `height'. The parameters `title_family', `title_size',
- * `axis_family', and `axis_size' specify the names of the
- * title and axis fonts and their vertical sizes (in points).
- * These parameters can be ignored if your device does not
- * support multiple fonts. The `flags' argument specifies
- * certain binary flags to the output routines. These
- * flags are:
- * D_DOCU:
- * If this flag is set, it indicates the user has specified that
- * the output will be included in some larger document. Devices
- * may choose to use this information to produce output that
- * can be integrated into documents with less effort. For example,
- * the Postscript output routines produce bounding box information
- * when this flag is set.
- * The routine should fill in all of the fields of `out_info' with
- * appropriate values. The values are described below:
- * area_w, area_h:
- * Size of the drawing space in device coordinates.
- * This should take in account the requested area
- * given by `width', and `height'.
- * bdr_pad:
- * Xgraph will leave this number of device coordinates around
- * all of the outer edges of the graph.
- * axis_pad:
- * Additional space around axis labels (in devcoords)
- * so that the labels do not appear crowded.
- * legend_pad:
- * Space (in devcoords) from the top of legend text to
- * the representative line drawn above the legend text.
- * tick_len:
- * Size of a tick mark placed on axis (in devcoords)
- * axis_width:
- * An estimate of the width of a large character in
- * the axis font (in devcoords). This can be an overestimate. An
- * underestimate may produce bad results.
- * axis_height:
- * An estimate of the height of a large character in
- * the axis labeling font (in devcoords).
- * title_width, title_height:
- * Same as above except for the title font.
- * max_segs:
- * Due to buffering constraints, some devices may not be able to
- * handle massive segment lists. This parameter tells xgraph not
- * to send more than `max_segs' segments in one request.
- * Output to the device should be written to the stream `strm'.
- * The functions are described individually below. After filling
- * in the parameters and setting the function pointers, the routine
- * should initialize its drawing state and store any extra needed
- * information in `user_state'. This value will be passed to all
- * other routines during the drawing sequence. If the device
- * cannot initialize, it should return a zero status and fill
- * `errmsg' with an informative error message.
- */
- /* Text justifications */
- #define T_CENTER 0
- #define T_LEFT 1
- #define T_UPPERLEFT 2
- #define T_TOP 3
- #define T_UPPERRIGHT 4
- #define T_RIGHT 5
- #define T_LOWERRIGHT 6
- #define T_BOTTOM 7
- #define T_LOWERLEFT 8
- /* Text styles */
- #define T_AXIS 0
- #define T_TITLE 1
- void xg_text(user_state, x, y, text, just, style)
- char *user_state; /* Value set in xg_init */
- int x, y; /* Text position (pixels) */
- char *text; /* Null terminated text */
- int just; /* Justification (above) */
- int style; /* Text style (above) */
- /*
- * This routine should draw text at the indicated position using
- * the indicated justification and style. The justification refers
- * to the location of the point in reference to the text. For example,
- * if just is T_LOWERLEFT, (x,y) should be located at the lower left
- * edge of the text string.
- */
- /* Line Styles */
- #define L_AXIS 0
- #define L_ZERO 1
- #define L_VAR 2
- void xg_seg(user_state, ns, seglist, width, style, lappr, color)
- char *user_state; /* Value set in xg_init */
- int ns; /* Number of segments */
- XSegment *seglist; /* X array of segments */
- int width; /* Width of lines */
- int style; /* See above */
- int lappr; /* Line appearence */
- int color; /* Line color (if any) */
- /*
- * This routine draws a number of line segments at the points
- * given in `seglist'. Note that contiguous segments need not share
- * endpoints but often do. All segments should be `width' devcoords wide
- * and drawn in style `style'. The `width' may be zero meaning that
- * the line should be drawn as thin as the device allows. If `style' is
- * L_VAR, the parameters `color' and `lappr' should be used to draw the
- * line. Both parameters vary from 0 to 7. If the device is capable of
- * color, `color' varies faster than `style'. If the device
- * has no color, `style' will vary faster than `color' and
- * `color' can be safely ignored. However, if the
- * the device has more than 8 line appearences, the two can
- * be combined to specify 64 line style variations.
- * Xgraph promises not to send more than the `max_segs' in the
- * xgOut structure passed back from xg_init().
- */
- /* Marker styles */
- #define P_PIXEL 0
- #define P_DOT 1
- #define P_MARK 2
- void xg_dot(user_state, x, y, style, type, color)
- char *user_state; /* Value set in xg_init */
- int x, y; /* Location in pixel units */
- int style; /* Dot style */
- int type; /* Type of marker */
- int color; /* Marker color (if any) */
- /*
- * This routine should draw a marker at location `x,y'. If the
- * style is P_PIXEL, the dot should be a single pixel. If
- * the style is P_DOT, the dot should be a reasonably large
- * dot. If the style is P_MARK, it should be a distinguished
- * mark which is specified by `type' (0-7). If the output
- * device is capable of color, the marker should be drawn in
- * `color' (0-7) which corresponds with the color for xg_line.
- */
- void xg_end(user_state)
- char *user_state;
- /*
- * This routine is called after a drawing sequence is complete.
- * It can be used to clean up the user state and set the device
- * state appropriately. This routine is optional in the structure.
- */
- /*
- * Adding an output device to xgraph
- *
- * Step 2
- * Edit the file hard_devices.c. Declare your initialization
- * function and add your device to the list of devices,
- * hard_devices[]. The structure hard_dev is described below
- * and is defined in hard_devices.h:
- */
- #define MFNAME 25
- typedef enum hard_dev_docu_defn { NONE, NO, YES } hard_dev_docu;
- typedef struct hard_dev {
- char *dev_name; /* Device name */
- int (*dev_init)(); /* Initialization function */
- char *dev_spec; /* Default pipe program */
- char dev_file[MFNAME]; /* Default file name */
- char dev_printer[MFNAME]; /* Default printer name */
- double dev_max_dim; /* Default maximum dimension (cm) */
- char dev_title_font[MFNAME];/* Default name of title font */
- double dev_title_size; /* Default size of title font (pnts) */
- char dev_axis_font[MFNAME]; /* Default name of axis font */
- double dev_axis_size; /* Default size of axis font (pnts) */
- hard_dev_docu dev_docu; /* Document predicate */
- };
- /*
- * dev_spec:
- * The dev_spec field should be a command that directly outputs to
- * your device. The command should contain one %s directive that
- * will be filled in with the name of the device from the hardcopy
- * dialog.
- * dev_file:
- * The default file to write output to if the user selects `To File'.
- * dev_printer:
- * The default printer to write output to if the user selects
- * `To Device'.
- * dev_max_dim:
- * The default maximum dimension for the device in centimeters.
- * dev_title_font, dev_title_size:
- * The default title font and size. Sizes are specified in
- * points (1/72 inch).
- * dev_axis_font, dev_axis_size:
- * The default axis font and size.
- * dev_docu
- * Some devices may require extra preparation when including xgraph
- * output in a document. This parameter indicates the default
- * value of the Document predicate in the hardcopy dialog. If
- * the value is NONE, the device doesn't need any special preparation
- * for producing output for inclusion in documents.
- */
- /*
- * Adding an output device to xgraph
- *
- * Step 3
- * Edit the file Makefile. Add your source file to the SRC variable
- * and the corresponding object file to the OBJ variable. Finally,
- * remake xgraph. Your device should now be available in the
- * hardcopy dialog.
- */