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