11 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_xfig = 
"xfig:Fig file:0:xfig:31:xfig\n";
    20     PLFLT xscale_dev, yscale_dev;
    22     int   *buffptr, bufflen;
    27     long  cmap0_pos, cmap1_pos;
    28     int   cmap0_ncol, cmap1_ncol;
    29     int   offset, offset_inc;
    37 void plD_line_xfig( 
PLStream *, 
short, 
short, 
short, 
short );
    38 void plD_polyline_xfig( 
PLStream *, 
short *, 
short *, 
PLINT );
    45 static void flushbuffer( 
PLStream * );
    49 #define FIGX    297 // portrait A4 mm    58 #define XFIG_COLBASE    33 // xfig first user color, plplot colormap0[0],    68 static DrvOpt xfig_options[] = { { 
"text", 
DRV_INT, &
text, 
"Use Postscript text (text=1|0)" },
    69                                  { NULL,   
DRV_INT, NULL,  NULL                             } };
    73 #ifndef ENABLE_DYNDRIVERS   114     if ( pls->
dev != NULL )
   115         free( (
void *) pls->
dev );
   117     pls->
dev = calloc( 1, (
size_t) 
sizeof ( xfig_Dev ) );
   119     if ( pls->
dev == NULL )
   120         plexit( 
"plD_init_xfig: cannot allocate memory\n" );
   122     dev = (xfig_Dev *) pls->
dev;
   124     dev->curwid    = pls->
width < 1 ? 1 : (
int) pls->
width;
   133     dev->xscale_dev = 
DPI / 25.4;
   134     dev->yscale_dev = 
DPI / 25.4;
   135     dev->offset_inc = dev->ymax * (
PLINT) dev->yscale_dev;
   136     dev->offset     = -dev->offset_inc;
   141     plP_setpxl( dev->xscale_dev, dev->xscale_dev );                                             
   146     fprintf( pls->
OutFile, 
"#FIG 3.2\n" );
   147     fprintf( pls->
OutFile, 
"Landscape\n" );
   148     fprintf( pls->
OutFile, 
"Center\n" );
   149     fprintf( pls->
OutFile, 
"Metric\n" );
   150     fprintf( pls->
OutFile, 
"A4\n" );
   151     fprintf( pls->
OutFile, 
"100.0\n" );
   152     fprintf( pls->
OutFile, 
"Single\n" );
   153     fprintf( pls->
OutFile, 
"-2\n" );
   157     dev->cmap0_ncol = 2 * pls->
ncol0; 
   158     dev->cmap0_pos  = ftell( pls->
OutFile );
   162     dev->cmap1_ncol = 2 * pls->
ncol1; 
   163     dev->cmap1_pos  = ftell( pls->
OutFile );
   166     dev->bufflen = 2 * BSIZE;
   167     dev->buffptr = (
int *) malloc( 
sizeof ( 
int ) * (size_t) ( dev->bufflen ) );
   168     if ( dev->buffptr == NULL )
   169         plexit( 
"plD_init_xfig: Out of memory!" );
   179     dev = (xfig_Dev *) pls->
dev;
   181     if ( pls->
ncol0 > dev->cmap0_ncol )
   182         plwarn( 
"Too many colors for cmap0. Preallocate using command line '-ncol0 n.\n'" );
   184     cur_pos = ftell( pls->
OutFile );
   186     if ( fseek( pls->
OutFile, dev->cmap0_pos, SEEK_SET ) )
   187         plexit( 
"Sorry, only file based output, no pipes.\n" );
   190     for ( i = 0; i < pls->
ncol0; i++ )
   191         fprintf( pls->
OutFile, 
"0 %d #%.2x%.2x%.2x\n", i + XFIG_COLBASE,
   195     for ( i = pls->
ncol0; i < dev->cmap0_ncol; i++ )
   196         fprintf( pls->
OutFile, 
"0 %d #000000\n", i + XFIG_COLBASE );
   198     if ( cur_pos != dev->cmap0_pos )
   199         fseek( pls->
OutFile, cur_pos, SEEK_SET );
   209     dev = (xfig_Dev *) pls->
dev;
   211     if ( pls->
ncol1 > dev->cmap1_ncol )
   212         plwarn( 
"Too many colors for cmap1. Preallocate using command line '-ncol1 n.\n'" );
   214     cur_pos = ftell( pls->
OutFile );
   216     if ( fseek( pls->
OutFile, dev->cmap1_pos, SEEK_SET ) )
   217         plexit( 
"Sorry, only file based output, no pipes.\n" );
   220     for ( i = 0; i < pls->
ncol1; i++ )
   221         fprintf( pls->
OutFile, 
"0 %d #%.2x%.2x%.2x\n", i + XFIG_COLBASE + dev->cmap0_ncol,
   225     for ( i = pls->
ncol1; i < dev->cmap1_ncol; i++ )
   226         fprintf( pls->
OutFile, 
"0 %d #000000\n", i + XFIG_COLBASE + dev->cmap0_ncol );
   228     if ( cur_pos != dev->cmap1_pos )
   229         fseek( pls->
OutFile, cur_pos, SEEK_SET );
   239 plD_line_xfig( 
PLStream *pls, 
short x1a, 
short y1a, 
short x2a, 
short y2a )
   241     xfig_Dev *dev = (xfig_Dev *) pls->
dev;
   242     int      x1   = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
   250     if ( dev->firstline )
   253         *( dev->buffptr + count++ ) = x1;
   254         *( dev->buffptr + count++ ) = y1;
   255         *( dev->buffptr + count++ ) = x2;
   256         *( dev->buffptr + count++ ) = y2;
   259     else if ( x1 == dev->xold && y1 == dev->yold )
   262         if ( count + 2 >= dev->bufflen )
   264             dev->bufflen += 2 * BSIZE;
   266                             realloc( (
void *) dev->buffptr, (size_t) ( dev->bufflen ) * 
sizeof ( int ) );
   267             if ( tempptr == NULL )
   269                 free( (
void *) dev->buffptr );
   270                 plexit( 
"plD_line_xfig: Out of memory!" );
   272             dev->buffptr = tempptr;
   274         *( dev->buffptr + count++ ) = x2;
   275         *( dev->buffptr + count++ ) = y2;
   281         *( dev->buffptr + count++ ) = x1;
   282         *( dev->buffptr + count++ ) = y1;
   283         *( dev->buffptr + count++ ) = x2;
   284         *( dev->buffptr + count++ ) = y2;
   298 plD_polyline_xfig( 
PLStream *pls, 
short *xa, 
short *ya, 
PLINT npts )
   302     for ( i = 0; i < npts - 1; i++ )
   303         plD_line_xfig( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
   315     xfig_Dev *dev = (xfig_Dev *) pls->
dev;
   317     if ( !dev->firstline )
   336     dev = (xfig_Dev *) pls->
dev;
   345     dev->offset += dev->offset_inc;
   349     dev->curcol = XFIG_COLBASE; 
   350     fprintf( pls->
OutFile, 
"2 1 0 1 %d %d 50 0 20 0.0 0 0 -1 0 0 5\n", dev->curcol, dev->curcol );
   351     fprintf( pls->
OutFile, 
"%d %d %d %d %d %d %d %d %d %d\n",
   353         0, (
int) ( FIGY * dev->yscale_dev ) + dev->offset,
   354         (
int) ( FIGX * dev->xscale_dev ), (
int) ( FIGY * dev->yscale_dev ) + dev->offset,
   355         (
int) ( FIGX * dev->xscale_dev ), dev->offset,
   368     xfig_Dev *dev = (xfig_Dev *) pls->
dev;
   371     free( (
void *) dev->buffptr );
   384     xfig_Dev *dev = (xfig_Dev *) pls->
dev;
   391         dev->curwid    = pls->
width < 1 ? 1 : (int) pls->
width;
   396         dev->curcol = pls->
icol0 + XFIG_COLBASE;
   401         dev->curcol = pls->
icol1 + XFIG_COLBASE + pls->
ncol0;
   424     xfig_Dev *dev = pls->
dev;
   434         fprintf( pls->
OutFile, 
"2 1 0 1 %d %d 50 0 20 0.0 0 0 0 0 0 %d\n",
   435             dev->curcol, dev->curcol, npts );
   437         for ( i = 0; i < npts; i++ )
   439                 dev->offset + dev->ymax * (
int) dev->xscale_dev - pls->
dev_y[i] );
   457     xfig_Dev *dev = pls->
dev;
   460     if ( dev->count == 0 )
   463     fprintf( pls->
OutFile, 
"2 1 0 %d %d 0 50 0 -1 0.0 0 0 0 0 0 %d\n",
   464         dev->curwid, dev->curcol, dev->count / 2 );
   465     while ( i < dev->count )
   467         fprintf( pls->
OutFile, 
"%d %d ", *( dev->buffptr + i ),
   468             dev->offset + dev->ymax * (
int) dev->yscale_dev - *( dev->buffptr + i + 1 ) );
   479     PLFLT    a1, alpha, ft_ht, angle, ref;
   480     xfig_Dev *dev = (xfig_Dev *) pls->
dev;
   481     PLINT    clxmin, clxmax, clymin, clymax;
   485     ft_ht = pls->
chrht * 72.0 / 25.4; 
   488     angle = pls->
diorot * 90.;
   489     a1    = acos( t[0] ) * 180. / 
PI;
   493         alpha = 360. - a1 - angle;
   495     alpha = alpha * 
PI / 180.;
   501     difilt( &args->
x, &args->
y, 1, &clxmin, &clxmax, &clymin, &clymax );
   508     if ( args->
x < clxmin || args->
x > clxmax || args->
y < clymin || args->
y > clymax )
   517     if ( args->
just == 0.5 )
   519     else if ( args->
just == 1. )
   524         args->
x = args->
refx; 
   525         args->
y = args->
refy;
   537     if ( args->
base == 2 )             
   538         ref = -
DPI / 72. * ft_ht / 2.; 
   539     else if ( args->
base == 1 )
   542         ref = 
DPI / 72. * ft_ht / 2.;
   545     args->
y = (
PLINT) ( dev->offset + dev->ymax * (
int) dev->xscale_dev - ( args->
y - ref * cos( alpha ) ) );
   546     args->
x = (
PLINT) ( args->
x + ref * sin( alpha ) );
   558     switch ( pls->
cfont )
   560     case ( 1 ): font = 0; 
break;
   561     case ( 2 ): font = 1; 
break;
   562     case ( 3 ): font = 3; 
break;
   563     case ( 4 ): font = 4; 
break;
   567     fprintf( pls->
OutFile, 
"4 %d %d 50 0 %d %f %f 4 1 1 %d %d %s\\001\n",
   568         jst, dev->curcol, font, 1.8  * ft_ht, alpha, args->
x, args->
y, args->
string );
 int plParseDrvOpts(DrvOpt *acc_opt)
void plexit(PLCHAR_VECTOR errormsg)
PLDLLIMPEXP_DRIVER void plD_dispatch_init_xfig(PLDispatchTable *pdt)
void plOpenFile(PLStream *pls)
void plCloseFile(PLStream *pls)
void plGetFam(PLStream *pls)
void(* plD_tidy_fp)(struct PLStream_struct *)
void(* plD_init_fp)(struct PLStream_struct *)
void(* plD_eop_fp)(struct PLStream_struct *)
void plFamInit(PLStream *pls)
void(* plD_line_fp)(struct PLStream_struct *, short, short, short, short)
void(* plD_esc_fp)(struct PLStream_struct *, PLINT, void *)
void(* plD_polyline_fp)(struct PLStream_struct *, short *, short *, PLINT)
void difilt(PLINT *xsc, PLINT *ysc, PLINT npts, PLINT *clpxmi, PLINT *clpxma, PLINT *clpymi, PLINT *clpyma)
void plP_setpxl(PLFLT xpmm, PLFLT ypmm)
#define PLDLLIMPEXP_DRIVER
static PLStream * pls[PL_NSTREAMS]
void plP_setphy(PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax)
static void proc_str(PLStream *, EscText *)
void(* plD_bop_fp)(struct PLStream_struct *)
void plwarn(PLCHAR_VECTOR errormsg)
plD_polyline_fp pl_polyline
void(* plD_state_fp)(struct PLStream_struct *, PLINT)