Back to index

plt-scheme  4.2.1
plmeta.c
Go to the documentation of this file.
00001 /* $Id: plmeta.c,v 1.1 2004/03/01 20:54:52 cozmic Exp $
00002 
00003     Copyright 1991, 1992, 1993, 1994, 1995
00004     Geoffrey Furnish               furnish@dino.ph.utexas.edu
00005     Maurice LeBrun                 mjl@dino.ph.utexas.edu
00006     Institute for Fusion Studies   University of Texas at Austin
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public
00019     License along with this library; if not, write to the Free
00020     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 
00022 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00023        
00024     This is a metafile writer for PLplot.
00025 
00026 */
00027 #include "plDevs.h"
00028 
00029 /*#define DEBUG*/
00030 
00031 #ifdef PLD_plmeta
00032 
00033 #define NEED_PLDEBUG
00034 #include "plplotP.h"
00035 #include "drivers.h"
00036 #include "metadefs.h"
00037 #include <string.h>
00038 
00039 /* Device info */
00040 char* plD_DEVICE_INFO_plmeta = "plmeta:PLplot Native Meta-File:0:plmeta:26:plm";
00041 
00042 
00043 void plD_dispatch_init_plm  ( PLDispatchTable *pdt );
00044 
00045 void plD_init_plm           (PLStream *);
00046 void plD_line_plm           (PLStream *, short, short, short, short);
00047 void plD_polyline_plm              (PLStream *, short *, short *, PLINT);
00048 void plD_eop_plm            (PLStream *);
00049 void plD_bop_plm            (PLStream *);
00050 void plD_tidy_plm           (PLStream *);
00051 void plD_state_plm          (PLStream *, PLINT);
00052 void plD_esc_plm            (PLStream *, PLINT, void *);
00053 
00054 /* Struct to hold device-specific info. */
00055 
00056 typedef struct {
00057     PLFLT pxlx, pxly;
00058     PLINT xold, yold;
00059 
00060     PLINT xmin, xmax, xlen;
00061     PLINT ymin, ymax, ylen;
00062 
00063     FPOS_T lp_offset, index_offset;
00064 
00065     int notfirst;
00066 } PLmDev;
00067 
00068 /* Used for constructing error messages */
00069 
00070 static char buffer[256];
00071 
00072 /* Function prototypes */
00073 
00074 static void WriteFileHeader (PLStream *pls);
00075 static void UpdatePrevPagehdr      (PLStream *pls);
00076 static void WritePageInfo   (PLStream *pls, FPOS_T pp_offset);
00077 static void UpdateIndex            (PLStream *pls, FPOS_T cp_offset);
00078 static void plm_fill        (PLStream *pls);
00079 static void plm_swin        (PLStream *pls);
00080 
00081 /* A little function to help with debugging */
00082 
00083 #ifdef DEBUG
00084 #define DEBUG_PRINT_LOCATION(a) PrintLocation(pls, a)
00085 
00086 static void PrintLocation(PLStream *pls, char *tag)
00087 {
00088     int isfile = (pls->output_type == 0);
00089     if (isfile) {
00090        FILE *file = pls->OutFile;
00091        FPOS_T current_offset;
00092 
00093        if (pl_fgetpos(file, &current_offset))
00094            plexit("PrintLocation (plmeta.c): fgetpos call failed");
00095 
00096        pldebug(tag, "at offset %d in file %s\n",
00097               (int) current_offset, pls->FileName);
00098     }
00099 }
00100 #else
00101 #define DEBUG_PRINT_LOCATION(a)
00102 #endif
00103 
00104 void plD_dispatch_init_plm( PLDispatchTable *pdt )
00105 {
00106     pdt->pl_MenuStr  = "PLplot Native Meta-File";
00107     pdt->pl_DevName  = "plmeta";
00108     pdt->pl_type     = plDevType_FileOriented;
00109     pdt->pl_seq      = 26;
00110     pdt->pl_init     = (plD_init_fp)     plD_init_plm;
00111     pdt->pl_line     = (plD_line_fp)     plD_line_plm;
00112     pdt->pl_polyline = (plD_polyline_fp) plD_polyline_plm;
00113     pdt->pl_eop      = (plD_eop_fp)      plD_eop_plm;
00114     pdt->pl_bop      = (plD_bop_fp)      plD_bop_plm;
00115     pdt->pl_tidy     = (plD_tidy_fp)     plD_tidy_plm;
00116     pdt->pl_state    = (plD_state_fp)    plD_state_plm;
00117     pdt->pl_esc      = (plD_esc_fp)      plD_esc_plm;
00118 }
00119 
00120 /*--------------------------------------------------------------------------*\
00121  * plD_init_plm()
00122  *
00123  * Initialize device.
00124 \*--------------------------------------------------------------------------*/
00125 
00126 void
00127 plD_init_plm(PLStream *pls)
00128 {
00129     PLmDev *dev;
00130     U_CHAR c = (U_CHAR) INITIALIZE;
00131 
00132     dbug_enter("plD_init_plm");
00133 
00134     pls->color = 1;         /* Is a color device */
00135     pls->dev_fill0 = 1;            /* Handle solid fills */
00136     pls->dev_fill1 = 1;            /* Handle pattern fills */
00137 
00138 /* Initialize family file info */
00139 
00140     plFamInit(pls);
00141 
00142 /* Prompt for a file name if not already set */
00143 
00144     plOpenFile(pls);
00145     pls->pdfs = pdf_finit(pls->OutFile);
00146 
00147 /* Allocate and initialize device-specific data */
00148 
00149     pls->dev = calloc(1, (size_t) sizeof(PLmDev));
00150     if (pls->dev == NULL)
00151        plexit("plD_init_plm: Out of memory.");
00152 
00153     dev = (PLmDev *) pls->dev;
00154 
00155     dev->xold = PL_UNDEFINED;
00156     dev->yold = PL_UNDEFINED;
00157 
00158     dev->xmin = 0;
00159     dev->xmax = PIXELS_X - 1;
00160     dev->ymin = 0;
00161     dev->ymax = PIXELS_Y - 1;
00162 
00163     dev->pxlx = (double) PIXELS_X / (double) LPAGE_X;
00164     dev->pxly = (double) PIXELS_Y / (double) LPAGE_Y;
00165 
00166     plP_setpxl(dev->pxlx, dev->pxly);
00167     plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax);
00168 
00169 /* Write Metafile header. */
00170 
00171     WriteFileHeader(pls);
00172 
00173 /* Write color map state info */
00174 
00175     plD_state_plm(pls, PLSTATE_CMAP0);
00176     plD_state_plm(pls, PLSTATE_CMAP1);
00177 
00178 /* Write initialization command. */
00179 
00180     DEBUG_PRINT_LOCATION("before init");
00181     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00182 }
00183 
00184 /*--------------------------------------------------------------------------*\
00185  * plD_line_plm()
00186  *
00187  * Draw a line in the current color from (x1,y1) to (x2,y2).
00188 \*--------------------------------------------------------------------------*/
00189 
00190 void
00191 plD_line_plm(PLStream *pls, short x1, short y1, short x2, short y2)
00192 {
00193     PLmDev *dev = (PLmDev *) pls->dev;
00194     U_CHAR c;
00195     U_SHORT xy[4];
00196 
00197     /* dbug_enter("plD_line_plm"); */
00198 
00199     /* Failsafe check */
00200 
00201 #ifdef DEBUG
00202     if (x1 < dev->xmin || x1 > dev->xmax ||
00203        x2 < dev->xmin || x2 > dev->xmax ||
00204        y1 < dev->ymin || y1 > dev->ymax ||
00205        y2 < dev->ymin || y2 > dev->ymax) {
00206 
00207        pldebug("plD_line_plm",
00208               "coordinates out of bounds -- \nActual: (%i,%i), (%i,%i) Bounds: (%i,%i,%i,%i)\n", 
00209               x1, y1, x2, y2, dev->xmin, dev->xmax, dev->ymin, dev->ymax);
00210     }
00211 #endif
00212 
00213 /* If continuation of previous line send the LINETO command, which uses
00214    the previous (x,y) point as it's starting location.  This results in a
00215    storage reduction of not quite 50%, since the instruction length for
00216    a LINETO is 5/9 of that for the LINE command, and given that most
00217    graphics applications use this command heavily.
00218 
00219    Still not quite as efficient as tektronix format since we also send the
00220    command each time (so shortest command is 25% larger), but a lot easier
00221    to implement than the tek method.  
00222  */
00223     if (x1 == dev->xold && y1 == dev->yold) {
00224 
00225        c = (U_CHAR) LINETO;
00226        plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00227 
00228        xy[0] = x2;
00229        xy[1] = y2;
00230        plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 2) );
00231     }
00232     else {
00233        c = (U_CHAR) LINE;
00234        plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00235 
00236        xy[0] = x1;
00237        xy[1] = y1;
00238        xy[2] = x2;
00239        xy[3] = y2;
00240        plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 4) );
00241     }
00242     dev->xold = x2;
00243     dev->yold = y2;
00244 }
00245 
00246 /*--------------------------------------------------------------------------*\
00247  * plD_polyline_plm()
00248  *
00249  * Draw a polyline in the current color.
00250 \*--------------------------------------------------------------------------*/
00251 
00252 void
00253 plD_polyline_plm(PLStream *pls, short *xa, short *ya, PLINT npts)
00254 {
00255     PLmDev *dev = (PLmDev *) pls->dev;
00256     U_CHAR c = (U_CHAR) POLYLINE;
00257 
00258     dbug_enter("plD_polyline_plm");
00259 
00260     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00261 
00262     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) npts) );
00263 
00264     plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) xa, npts) );
00265     plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) ya, npts) );
00266 
00267     dev->xold = xa[npts - 1];
00268     dev->yold = ya[npts - 1];
00269 }
00270 
00271 /*--------------------------------------------------------------------------*\
00272  * plD_eop_plm()
00273  *
00274  * End of page.
00275 \*--------------------------------------------------------------------------*/
00276 
00277 void
00278 plD_eop_plm(PLStream *pls)
00279 {
00280     U_CHAR c = (U_CHAR) EOP;
00281 
00282     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00283 }
00284 
00285 /*--------------------------------------------------------------------------*\
00286  * plD_bop_plm()
00287  *
00288  * Set up for the next page.
00289  *
00290  * Page header layout as follows:
00291  *
00292  * BOP               (U_CHAR)
00293  * page number              (U_SHORT)
00294  * prev page offset  (U_LONG)
00295  * next page offset  (U_LONG)
00296  *
00297  * Each call after the first is responsible for updating the table of
00298  * contents and the next page offset from the previous page.
00299 \*--------------------------------------------------------------------------*/
00300 
00301 void
00302 plD_bop_plm(PLStream *pls)
00303 {
00304     PLmDev *dev = (PLmDev *) pls->dev;
00305     int isfile = (pls->output_type == 0);
00306     FPOS_T pp_offset = dev->lp_offset;;
00307 
00308     dbug_enter("plD_bop_plm");
00309 
00310     dev->xold = PL_UNDEFINED;
00311     dev->yold = PL_UNDEFINED;
00312 
00313 /* Update previous page header */
00314 
00315     if (isfile)
00316        UpdatePrevPagehdr(pls);
00317 
00318 /* Start next family file if necessary. */
00319 
00320     pls->bytecnt = pls->pdfs->bp;
00321     plGetFam(pls);
00322 
00323 /* Update page counter */
00324 
00325     pls->page++;
00326 
00327 /* Update table of contents info & write new page header. */
00328 
00329     WritePageInfo(pls, pp_offset);
00330 }
00331 
00332 /*--------------------------------------------------------------------------*\
00333  * WritePageInfo()
00334  *
00335  * Update table of contents info & write new page header.
00336 \*--------------------------------------------------------------------------*/
00337 
00338 static void
00339 WritePageInfo(PLStream *pls, FPOS_T pp_offset)
00340 {
00341     PLmDev *dev = (PLmDev *) pls->dev;
00342     FILE *file = pls->OutFile;
00343     int isfile = (pls->output_type == 0);
00344     U_CHAR c;
00345     FPOS_T cp_offset=0;
00346 
00347 /* Update table of contents. */
00348 
00349     if (isfile) {
00350        if (pl_fgetpos(file, &cp_offset))
00351            plexit("WritePageInfo (plmeta.c): fgetpos call failed");
00352 
00353        UpdateIndex(pls, cp_offset);
00354     }
00355 
00356 /* Write new page header */
00357 
00358     if (dev->notfirst)
00359        c = BOP;
00360     else {
00361        c = BOP0;
00362        dev->notfirst = 1;
00363     }
00364     plm_wr( pdf_wr_1byte(pls->pdfs,  c) );
00365     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->page) );
00366     plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) pp_offset) );
00367     plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) 0) );
00368 
00369 /* Update last page offset with current page value */
00370 
00371     dev->lp_offset = cp_offset;
00372 
00373 /* Write some page state information just to make things nice later on */
00374 /* Eventually there will be more */
00375 
00376     plD_state_plm(pls, PLSTATE_COLOR0);
00377 }
00378 
00379 /*--------------------------------------------------------------------------*\
00380  * UpdatePrevPagehdr()
00381  *
00382  * Update previous page header.
00383 \*--------------------------------------------------------------------------*/
00384 
00385 static void
00386 UpdatePrevPagehdr(PLStream *pls)
00387 {
00388     PLmDev *dev = (PLmDev *) pls->dev;
00389     FILE *file = pls->OutFile;
00390     FPOS_T cp_offset=0;
00391 
00392     fflush(file);
00393 
00394 /* Determine where we are */
00395 
00396     if (pl_fgetpos(file, &cp_offset))
00397        plexit("plD_bop_plm: fgetpos call failed");
00398 
00399 /* Seek back to previous page header. */
00400 
00401     if (dev->lp_offset > 0) {
00402        FPOS_T fwbyte_offset=0;
00403 
00404        pldebug("UpdatePrevPagehdr 1 (plmeta.c)",
00405               "Location: %d, seeking to: %d\n",
00406               (int) cp_offset, (int) dev->lp_offset);
00407 
00408     /* The forward byte offset is located exactly 7 bytes after the BOP */
00409        fwbyte_offset = dev->lp_offset + 7;
00410        if (pl_fsetpos(file, &fwbyte_offset)) {
00411            sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to fwbyte_offset (%d) failed",
00412                   (int) fwbyte_offset);
00413            plexit(buffer);
00414        }
00415 
00416     /* DEBUG: verify current location */
00417 
00418 #ifdef DEBUG
00419        if (pl_fgetpos(file, &fwbyte_offset))
00420            plexit("UpdatePrevPagehdr (plmeta.c): fgetpos call failed");
00421 
00422        pldebug("UpdatePrevPagehdr 2 (plmeta.c)",
00423               "Now at: %d, to write: %d\n", 
00424               (int) fwbyte_offset, (int) cp_offset);
00425 #endif
00426 
00427     /* Write forward byte offset into previous page header. */
00428 
00429        plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) cp_offset) );
00430        fflush(file);
00431 
00432     /* DEBUG: move back to before the write & read it to verify */
00433 
00434 #ifdef DEBUG
00435        if (pl_fsetpos(file, &fwbyte_offset)) {
00436            sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to fwbyte_offset (%d) failed",
00437                   (int) fwbyte_offset);
00438            plexit(buffer);
00439        }
00440        {
00441            U_LONG read_offset;
00442            plm_rd(pdf_rd_4bytes(pls->pdfs, &read_offset));
00443            pldebug("UpdatePrevPagehdr 3 (plmeta.c)",
00444                   "Value read as: %d\n", read_offset);
00445        }
00446 #endif
00447 
00448     /* Return to current page offset */
00449 
00450        if (pl_fsetpos(file, &cp_offset)) {
00451            sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to cp_offset (%d) failed",
00452                   (int) cp_offset);
00453            plexit(buffer);
00454        }
00455     }
00456 }
00457 
00458 /*--------------------------------------------------------------------------*\
00459  * UpdateIndex()
00460  *
00461  * Update file index.
00462 \*--------------------------------------------------------------------------*/
00463 
00464 static void
00465 UpdateIndex(PLStream *pls, FPOS_T cp_offset)
00466 {
00467     PLmDev *dev = (PLmDev *) pls->dev;
00468     FILE *file = pls->OutFile;
00469 
00470 /* Update file index.  Right now only number of pages. */
00471 /* The ordering here is critical */
00472 
00473     if (dev->index_offset > 0) {
00474        pldebug("UpdateIndex (plmeta.c)",
00475               "Location: %d, seeking to: %d\n",
00476               (int) cp_offset, (int) dev->lp_offset);
00477 
00478        if (pl_fsetpos(file, &dev->index_offset)) {
00479            sprintf(buffer, "UpdateIndex (plmeta.c): fsetpos to index_offset (%d) failed",
00480                   (int) dev->index_offset);
00481            plexit(buffer);
00482        }
00483        plm_wr( pdf_wr_header(pls->pdfs, "pages") );
00484        plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->page) );
00485 
00486        pldebug("UpdateIndex (plmeta.c)",
00487               "Location: %d, seeking to: %d\n",
00488               (int) dev->lp_offset, (int) cp_offset);
00489 
00490        if (pl_fsetpos(file, &cp_offset)) {
00491            sprintf(buffer, "UpdateIndex (plmeta.c): fsetpos to cp_offset (%d) failed",
00492                   (int) cp_offset);
00493            plexit(buffer);
00494        }
00495     }
00496 }
00497 
00498 /*--------------------------------------------------------------------------*\
00499  * plD_tidy_plm()
00500  *
00501  * Close graphics file
00502 \*--------------------------------------------------------------------------*/
00503 
00504 void
00505 plD_tidy_plm(PLStream *pls)
00506 {
00507     U_CHAR c = (U_CHAR) CLOSE;
00508 
00509     dbug_enter("plD_tidy_plm");
00510 
00511     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00512     pdf_close(pls->pdfs);
00513     free_mem(pls->dev);
00514 }
00515 
00516 /*--------------------------------------------------------------------------*\
00517  * plD_state_plm()
00518  *
00519  * Handle change in PLStream state (color, pen width, fill attribute, etc).
00520 \*--------------------------------------------------------------------------*/
00521 
00522 void 
00523 plD_state_plm(PLStream *pls, PLINT op)
00524 {
00525     U_CHAR c = (U_CHAR) CHANGE_STATE;
00526     int i;
00527 
00528     dbug_enter("plD_state_plm");
00529 
00530     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00531     plm_wr( pdf_wr_1byte(pls->pdfs, op) );
00532 
00533     switch (op) {
00534 
00535     case PLSTATE_WIDTH:
00536        plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) (pls->width)) );
00537        break;
00538 
00539     case PLSTATE_COLOR0:
00540        plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) pls->icol0) );
00541 
00542        if (pls->icol0 == PL_RGB_COLOR) {
00543            plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.r) );
00544            plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.g) );
00545            plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.b) );
00546        }
00547        break;
00548 
00549     case PLSTATE_COLOR1:
00550        plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->icol1) );
00551        break;
00552 
00553     case PLSTATE_FILL:
00554        plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) pls->patt) );
00555        break;
00556 
00557     case PLSTATE_CMAP0:
00558        plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) pls->ncol0) );
00559        for (i = 0; i < pls->ncol0; i++) {
00560            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].r) );
00561            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].g) );
00562            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].b) );
00563        }
00564        break;
00565 
00566     case PLSTATE_CMAP1:
00567        plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->ncol1) );
00568        for (i = 0; i < pls->ncol1; i++) {
00569            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].r) );
00570            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].g) );
00571            plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].b) );
00572        }
00573        break;
00574     }
00575 }
00576 
00577 /*--------------------------------------------------------------------------*\
00578  * plD_esc_plm()
00579  *
00580  * Escape function.  Note that any data written must be in device
00581  * independent form to maintain the transportability of the metafile.
00582  *
00583  * Functions:
00584  *
00585  *     PLESC_FILL    Fill polygon
00586  *     PLESC_SWIN    Set window parameters
00587  *
00588 \*--------------------------------------------------------------------------*/
00589 
00590 void
00591 plD_esc_plm(PLStream *pls, PLINT op, void *ptr)
00592 {
00593     U_CHAR c = (U_CHAR) ESCAPE;
00594 
00595     dbug_enter("plD_esc_plm");
00596 
00597     plm_wr( pdf_wr_1byte(pls->pdfs, c) );
00598     plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) op) );
00599 
00600     switch (op) {
00601     case PLESC_FILL:
00602        plm_fill(pls);
00603        break;
00604 
00605     case PLESC_SWIN:
00606        plm_swin(pls);
00607        break;
00608     }
00609 }
00610 
00611 /*--------------------------------------------------------------------------*\
00612  * plm_fill()
00613  *
00614  * Fill polygon described in points pls->dev_x[] and pls->dev_y[].
00615 \*--------------------------------------------------------------------------*/
00616 
00617 static void
00618 plm_fill(PLStream *pls)
00619 {
00620     PLmDev *dev = (PLmDev *) pls->dev;
00621 
00622     dbug_enter("plm_fill");
00623 
00624     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->dev_npts) );
00625 
00626     plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_x, pls->dev_npts) );
00627     plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_y, pls->dev_npts) );
00628 
00629     dev->xold = PL_UNDEFINED;
00630     dev->yold = PL_UNDEFINED;
00631 }
00632 
00633 /*--------------------------------------------------------------------------*\
00634  * plm_swin()
00635  *
00636  * Set window parameters.
00637  * Each parameter or group of parameters is tagged to make backward
00638  * compatibility easier.
00639 \*--------------------------------------------------------------------------*/
00640 
00641 static void
00642 plm_swin(PLStream *pls)
00643 {
00644     dbug_enter("plm_swin");
00645 }
00646 
00647 /*--------------------------------------------------------------------------*\
00648  * WriteFileHeader()
00649  *
00650  * Writes Metafile header.
00651 \*--------------------------------------------------------------------------*/
00652 
00653 static void
00654 WriteFileHeader(PLStream *pls)
00655 {
00656     PLmDev *dev = (PLmDev *) pls->dev;
00657     FILE *file = pls->OutFile;
00658     int isfile = (pls->output_type == 0);
00659 
00660     dbug_enter("WriteFileHeader(PLStream *pls");
00661 
00662     plm_wr( pdf_wr_header(pls->pdfs, PLMETA_HEADER) );
00663     plm_wr( pdf_wr_header(pls->pdfs, PLMETA_VERSION) );
00664 
00665 /* Write file index info.  Right now only number of pages. */
00666 /* The order here is critical */
00667 
00668     if (isfile) {
00669        if (pl_fgetpos(file, &dev->index_offset))
00670            plexit("WriteFileHeader: fgetpos call failed");
00671     }
00672 
00673     plm_wr( pdf_wr_header(pls->pdfs, "pages") );
00674     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) 0) );
00675 
00676 /* Write initialization info.  Tag via strings to make backward
00677    compatibility with old metafiles as easy as possible. */
00678 
00679     plm_wr( pdf_wr_header(pls->pdfs, "xmin") );
00680     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->xmin) );
00681 
00682     plm_wr( pdf_wr_header(pls->pdfs, "xmax") );
00683     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->xmax) );
00684 
00685     plm_wr( pdf_wr_header(pls->pdfs, "ymin") );
00686     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->ymin) );
00687 
00688     plm_wr( pdf_wr_header(pls->pdfs, "ymax") );
00689     plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->ymax) );
00690 
00691     plm_wr( pdf_wr_header(pls->pdfs, "pxlx") );
00692     plm_wr( pdf_wr_ieeef(pls->pdfs, (float) dev->pxlx) );
00693 
00694     plm_wr( pdf_wr_header(pls->pdfs, "pxly") );
00695     plm_wr( pdf_wr_ieeef(pls->pdfs, (float) dev->pxly) );
00696 
00697     plm_wr( pdf_wr_header(pls->pdfs, "") );
00698 }
00699 
00700 #else
00701 int 
00702 pldummy_plmeta()
00703 {
00704     return 0;
00705 }
00706 
00707 #endif                      /* PLD_plmeta */