| 4596 | } |
| 4597 | |
| 4598 | int PSL_beginplot (struct PSL_CTRL *PSL, FILE *fp, int orientation, int overlay, int color_mode, char origin[], double offset[], double page_size[], char *title, int font_no[]) { |
| 4599 | /* fp: Output stream or NULL for standard output |
| 4600 | orientation: 0 = landscape, 1 = portrait. If orientation &2 then we write to memory array [Default is to fp] |
| 4601 | If orientation&4 then we must reissue font encoding due to a change in charset |
| 4602 | overlay: true if this is an overlay plot [false means print headers and macros first] |
| 4603 | color_mode: 0 = RGB color, 1 = CMYK color, 2 = HSV color, 3 = Gray scale |
| 4604 | origin: Two characters indicating origin of new position for x and y respectively: |
| 4605 | 'r' = Relative to old position (default) |
| 4606 | 'a' = Relative to old position and resets at PSL_endplot |
| 4607 | 'f' = Relative to lower left corner of the page |
| 4608 | 'c' = Relative to center of the page |
| 4609 | offset: Location of new origin relative to what is specified by "origin" (in user units) |
| 4610 | page_size: Physical width and height of paper used in points |
| 4611 | title: Title of the plot (or NULL if not specified) |
| 4612 | font_no: Array of font numbers used in the document (or NULL if not determined) |
| 4613 | */ |
| 4614 | int i, manual_feed = false, err = 0, change_charset = 0; |
| 4615 | double no_rgb[4] = {-1.0, -1.0, -1.0, 0.0}, dummy_rgb[4] = {-2.0, -2.0, -2.0, 0.0}, black[4] = {0.0, 0.0, 0.0, 0.0}, scl; |
| 4616 | time_t right_now; |
| 4617 | const char *uname[4] = {"cm", "inch", "meter", "point"}, xy[2] = {'x', 'y'}; |
| 4618 | const double units_per_inch[4] = {2.54, 1.0, 0.0254, 72.0}; /* cm, inch, m, points per inch */ |
| 4619 | char PSL_encoding[64] = {""}; |
| 4620 | |
| 4621 | if (!PSL) return (PSL_NO_SESSION); /* Never was allocated */ |
| 4622 | |
| 4623 | PSL->internal.memory = (orientation & PSL_MEMORY); /* true if we wish to write PS to memory instead of to file */ |
| 4624 | if (PSL->internal.memory) orientation -= PSL_MEMORY; |
| 4625 | change_charset = (orientation & PSL_CHANGESET); /* true if we must update the character set */ |
| 4626 | if (change_charset) orientation -= PSL_CHANGESET; |
| 4627 | |
| 4628 | /* Save original initialization settings */ |
| 4629 | |
| 4630 | PSL->internal.call_level++; /* Becomes 1 for first module calling it, 2 if that module calls for plotting, etc */ |
| 4631 | if (PSL->internal.call_level == 1) |
| 4632 | PSL->internal.fp = (fp == NULL) ? stdout : fp; /* For higher levels we reuse existing file pointer */ |
| 4633 | PSL->internal.overlay = overlay; |
| 4634 | memcpy (PSL->init.page_size, page_size, 2 * sizeof(double)); |
| 4635 | |
| 4636 | PSL->internal.color_mode = color_mode; |
| 4637 | if (!origin) |
| 4638 | PSL->internal.origin[0] = PSL->internal.origin[1] = 'r'; |
| 4639 | else |
| 4640 | PSL->internal.origin[0] = origin[0], PSL->internal.origin[1] = origin[1]; |
| 4641 | PSL->internal.p_width = fabs (page_size[0]); |
| 4642 | PSL->internal.p_height = fabs (page_size[1]); |
| 4643 | manual_feed = (page_size[0] < 0.0); /* Want Manual Request for paper */ |
| 4644 | PSL_settransparencymode (PSL, "Normal"); /* Default PDF transparency mode */ |
| 4645 | PSL_setfontdims (PSL, PSL_SUBSUP_SIZE, PSL_SCAPS_SIZE, PSL_SUP_UP_LC, PSL_SUP_UP_UC, PSL_SUB_DOWN); /* Default sub/sup/scaps dimensions */ |
| 4646 | |
| 4647 | PSL->current.linewidth = -1.0; /* Will be changed by PSL_setlinewidth */ |
| 4648 | PSL_rgb_copy (PSL->current.rgb[PSL_IS_STROKE], dummy_rgb); /* Will be changed by PSL_setcolor */ |
| 4649 | PSL->current.outline = -1; /* Will be changed by PSL_setfill */ |
| 4650 | PSL_rgb_copy (PSL->current.rgb[PSL_IS_FILL], dummy_rgb); /* Will be changed by PSL_setfill */ |
| 4651 | |
| 4652 | PSL->internal.dpu = PSL_DOTS_PER_INCH / units_per_inch[PSL->init.unit]; /* Dots per unit resolution of output device */ |
| 4653 | PSL->internal.dpp = PSL_DOTS_PER_INCH / units_per_inch[PSL_PT]; /* Dots per point resolution of output device */ |
| 4654 | PSL->internal.x2ix = PSL->internal.dpu; /* Scales x coordinates to dots */ |
| 4655 | PSL->internal.y2iy = PSL->internal.dpu; /* Scales y coordinates to dots */ |
no test coverage detected