39 #ifdef ENABLE_DYNDRIVERS
51 # ifdef NEED_SYS_TYPE_H
52 # include <sys/types.h>
55 # define NAMLEN( dirent ) strlen( ( dirent )->d_name )
57 # if defined ( _MSC_VER )
60 # define dirent direct
61 # define NAMLEN( dirent ) ( dirent )->d_namlen
63 # include <sys/ndir.h>
80 #if defined ( _MSC_VER )
82 # define getcwd _getcwd
86 #define BUFFER_SIZE 80
87 #define BUFFER2_SIZE 300
88 #define DRVSPEC_SIZE 400
96 text2fci(
const char *
text,
unsigned char *hexdigit,
unsigned char *hexpower );
142 plsc->page_status =
AT_EOP;
143 plsc->stream_closed =
FALSE;
146 ( *plsc->dispatch_table->pl_init )( (
struct PLStream_struct *) plsc );
149 if ( plsc->plbuf_write )
160 int skip_driver_eop = 0;
162 if ( plsc->page_status ==
AT_EOP )
165 plsc->page_status =
AT_EOP;
167 if ( plsc->plbuf_write )
172 if ( plsc->eop_handler != NULL )
173 ( *plsc->eop_handler )( plsc->eop_data, &skip_driver_eop );
175 if ( !skip_driver_eop )
178 if ( !plsc->stream_closed )
180 ( *plsc->dispatch_table->pl_eop )( (
struct PLStream_struct *) plsc );
194 int skip_driver_bop = 0;
197 if ( plsc->page_status ==
AT_BOP )
200 plsc->page_status =
AT_BOP;
205 if ( plsc->bop_handler != NULL )
206 ( *plsc->bop_handler )( plsc->bop_data, &skip_driver_bop );
208 if ( !skip_driver_bop )
211 if ( !plsc->stream_closed )
213 ( *plsc->dispatch_table->pl_bop )( (
struct PLStream_struct *) plsc );
218 if ( plsc->plbuf_write )
230 ( *plsc->tidy )( plsc->tidy_data );
232 plsc->tidy_data = NULL;
236 if ( !plsc->stream_closed )
238 ( *plsc->dispatch_table->pl_tidy )( (
struct PLStream_struct *) plsc );
242 if ( plsc->plbuf_write )
247 plsc->OutFile = NULL;
256 if ( plsc->plbuf_write )
260 if ( !plsc->stream_closed )
262 ( *plsc->dispatch_table->pl_state )( (
struct PLStream_struct *) plsc, op );
273 PLINT clpxmi, clpxma, clpymi, clpyma;
277 if ( plsc->plbuf_write )
288 difilt( &( args->
x ), &( args->
y ), 1, &clpxmi, &clpxma, &clpymi, &clpyma );
293 if ( !plsc->stream_closed )
295 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc, op, ptr );
308 PLINT clpxmi, clpxma, clpymi, clpyma;
312 if ( plsc->plbuf_write )
345 if ( plsc->dev_swin )
348 if ( !plsc->stream_closed )
350 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
367 PLINT i, npts = 2, clpxmi, clpxma, clpymi, clpyma;
371 if ( plsc->plbuf_write )
376 for ( i = 0; i < npts; i++ )
396 PLINT i, clpxmi, clpxma, clpymi, clpyma;
400 if ( plsc->plbuf_write )
405 for ( i = 0; i < npts; i++ )
430 PLINT i, clpxmi, clpxma, clpymi, clpyma;
434 if ( plsc->plbuf_write )
436 plsc->dev_npts = npts;
444 if ( plsc->patt == 0 && !plsc->dev_fill0 )
448 plwarn(
"Driver does not support hardware solid fills, switching to software fill.\n" );
454 if ( plsc->dev_fill1 )
456 plsc->patt = -
ABS( plsc->patt );
464 if ( plsc->patt > 0 )
471 for ( i = 0; i < npts; i++ )
495 PLINT i, clpxmi, clpxma, clpymi, clpyma;
499 if ( plsc->plbuf_write )
501 plsc->dev_npts = npts;
510 for ( i = 0; i < npts; i++ )
548 *num = (
PLUNICODE) strtoul( text, &endptr, 0 );
550 if ( end != endptr[0] )
552 snprintf( msgbuf,
BUFFER_SIZE,
"text2num: invalid control string detected - %c expected", end );
556 return (
int) ( endptr -
text );
577 int text2fci(
const char *
text,
unsigned char *hexdigit,
unsigned char *hexpower )
582 unsigned char hexdigit;
583 unsigned char hexpower;
589 #define N_TextLookupTable 10
605 length = (int) strlen( lookup[i].ptext );
606 if ( !strncmp( text, lookup[i].ptext, (
size_t) length ) )
608 *hexdigit = lookup[i].hexdigit;
609 *hexpower = lookup[i].hexpower;
624 if ( plsc->dev_text )
643 if ( plsc->dev_unicode )
648 unsigned char hexdigit, hexpower;
652 if (
string != NULL )
657 len = (short) strlen(
string );
677 for ( j = i = 0; i < len; i++ )
681 if (
string[i] == esc )
683 switch (
string[i + 1] )
686 i += ( 2 +
text2num( &
string[i + 2],
')', &code ) );
706 i += ( 2 +
text2num( &
string[i + 2],
']', &code ) );
724 if (
'0' <=
string[i + 2] &&
string[i + 2] <=
'9' )
726 i += 2 +
text2num( &
string[i + 2],
'>', &code );
752 i +=
text2fci( &
string[i + 1], &hexdigit, &hexpower );
771 if (
string[i + 2] ==
'n' )
776 else if (
string[i + 2] ==
'r' )
781 else if (
string[i + 2] ==
'i' )
787 else if (
string[i + 2] ==
's' )
822 else if ( ig == 634 )
824 else if ( ig == 647 )
850 #ifdef HAVE_LIBUNICODE
851 const char * ptr = unicode_get_utf8(
string + i, &unichar );
853 const char * ptr =
utf8_to_ucs4(
string + i, &unichar );
859 strncpy( tmpstring,
string, 30 );
860 tmpstring[30] =
'\0';
862 tmpstring, strlen(
string ) > 30 ?
"[...]" :
"" );
867 i += (int) ( ptr - (
string + i ) - 1 );
893 if ( plsc->alt_unicode )
895 args.
n_fci = orig_fci;
898 for ( i = 0; i < len; i++ )
902 if (
string[i] == esc )
904 switch (
string[i + 1] )
907 i += 2 +
text2num( &
string[i + 2],
')', &code );
917 i += 2 +
text2num( &
string[i + 2],
']', &code );
924 if (
'0' <=
string[i + 2] &&
string[i + 2] <=
'9' )
926 i += 2 +
text2num( &
string[i + 2],
'>', &code );
958 i +=
text2fci( &
string[i + 1], &hexdigit, &hexpower );
980 if (
string[i + 2] ==
'n' )
985 else if (
string[i + 2] ==
'r' )
990 else if (
string[i + 2] ==
'i' )
996 else if (
string[i + 2] ==
's' )
1033 else if ( ig == 634 )
1035 else if ( ig == 647 )
1097 #ifdef HAVE_LIBUNICODE
1098 const char * ptr = unicode_get_utf8(
string + i, &unichar );
1100 const char * ptr =
utf8_to_ucs4(
string + i, &unichar );
1106 strncpy( tmpstring,
string, 30 );
1107 tmpstring[30] =
'\0';
1109 tmpstring, strlen(
string ) > 30 ?
"[...]" :
"" );
1113 i += (int) ( ptr - (
string + i ) - 1 );
1118 if (
string[i] == esc &&
string[i + 1] == esc )
1140 if ( plsc->dev_unicode )
1156 plstr( base, xform, refx, refy,
string );
1176 if ( (
unsigned char) ( tmp & 0x80 ) == 0x00 )
1178 *unichar = (
unsigned int) tmp & 0x7F;
1181 else if ( (
unsigned char) ( tmp & 0xE0 ) == 0xC0 )
1183 *unichar = (
unsigned int) tmp & 0x1F;
1186 else if ( (
unsigned char) ( tmp & 0xF0 ) == 0xE0 )
1188 *unichar = (
unsigned char) tmp & 0x0F;
1191 else if ( (
unsigned char) ( tmp & 0xF8 ) == 0xF0 )
1193 *unichar = (
unsigned char) tmp & 0x07;
1196 else if ( (
unsigned char) ( tmp & 0xFC ) == 0xF8 )
1198 *unichar = (
unsigned char) tmp & 0x03;
1201 else if ( (
unsigned char) ( tmp & 0xFE ) == 0xFC )
1203 *unichar = (
unsigned char) tmp & 0x01;
1214 if ( (
unsigned char) ( tmp & 0xC0 ) == 0x80 )
1216 *unichar = ( *unichar << 6 ) | ( (
unsigned int) tmp & 0x3F );
1225 }
while ( cnt > 0 );
1236 tmp = (
unsigned char *) ptr;
1238 if ( ( unichar & 0xffff80 ) == 0 )
1240 *tmp = (
unsigned char) unichar;
1244 else if ( ( unichar & 0xfff800 ) == 0 )
1246 *tmp = (
unsigned char) 0xc0 | (
unsigned char) ( unichar >> 6 );
1248 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & (
PLUINT) 0x3f ) );
1252 else if ( ( unichar & 0xff0000 ) == 0 )
1254 *tmp = (
unsigned char) 0xe0 | (
unsigned char) ( unichar >> 12 );
1256 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1258 *tmp = (
unsigned char) ( 0x80 | ( (
unsigned char) unichar & 0x3f ) );
1262 else if ( ( unichar & 0xe0000 ) == 0 )
1264 *tmp = (
unsigned char) 0xf0 | (
unsigned char) ( unichar >> 18 );
1266 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 12 ) & 0x3f ) );
1268 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1270 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & 0x3f ) );
1287 if ( !plsc->stream_closed )
1289 ( *plsc->dispatch_table->pl_line )( (
struct PLStream_struct *) plsc,
1290 x[0], y[0], x[1], y[1] );
1299 if ( !plsc->stream_closed )
1301 ( *plsc->dispatch_table->pl_polyline )( (
struct PLStream_struct *) plsc,
1311 plsc->dev_npts = npts;
1316 if ( !plsc->stream_closed )
1318 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1328 plsc->dev_npts = npts;
1333 if ( !plsc->stream_closed )
1335 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1371 for ( i = 0; i < npts; i++ )
1373 xsc[i] = (
PLINT) ( plsc->dimxax * xsc[i] + plsc->dimxb );
1374 ysc[i] = (
PLINT) ( plsc->dimyay * ysc[i] + plsc->dimyb );
1382 for ( i = 0; i < npts; i++ )
1384 x = (
PLINT) ( plsc->dioxax * xsc[i] + plsc->dioxay * ysc[i] + plsc->dioxb );
1385 y = (
PLINT) ( plsc->dioyax * xsc[i] + plsc->dioyay * ysc[i] + plsc->dioyb );
1395 for ( i = 0; i < npts; i++ )
1397 xsc[i] = (
PLINT) ( plsc->dipxax * xsc[i] + plsc->dipxb );
1398 ysc[i] = (
PLINT) ( plsc->dipyay * ysc[i] + plsc->dipyb );
1407 for ( i = 0; i < npts; i++ )
1409 xsc[i] = (
PLINT) ( plsc->didxax * xsc[i] + plsc->didxb );
1410 ysc[i] = (
PLINT) ( plsc->didyay * ysc[i] + plsc->didyb );
1412 *clpxmi = plsc->diclpxmi;
1413 *clpxma = plsc->diclpxma;
1414 *clpymi = plsc->diclpymi;
1415 *clpyma = plsc->diclpyma;
1419 *clpxmi = plsc->phyxmi;
1420 *clpxma = plsc->phyxma;
1421 *clpymi = plsc->phyymi;
1422 *clpyma = plsc->phyyma;
1507 PLINT x1c, x2c, y1c, y2c;
1521 difilt( x_coords, y_coords, 4, &x1c, &x2c, &y1c, &y2c );
1535 plsc->dipxmin = 0.0;
1536 plsc->dipxmax = 1.0;
1537 plsc->dipymin = 0.0;
1538 plsc->dipymax = 1.0;
1559 if ( plsc->level >= 1 )
1593 PLFLT pxmin, pymin, pxmax, pymax;
1594 PLFLT sxmin, symin, sxmax, symax;
1595 PLFLT rxmin, rymin, rxmax, rymax;
1599 pldebug(
"pldid2pc",
1600 "Relative device coordinates (in): %f, %f, %f, %f\n",
1601 *xmin, *ymin, *xmax, *ymax );
1608 sxmin = ( pxmin - plsc->didxb ) / plsc->didxax;
1609 symin = ( pymin - plsc->didyb ) / plsc->didyay;
1610 sxmax = ( pxmax - plsc->didxb ) / plsc->didxax;
1611 symax = ( pymax - plsc->didyb ) / plsc->didyay;
1618 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1619 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1620 *ymin = ( rymin < 0 ) ? 0 : rymin;
1621 *ymax = ( rymax > 1 ) ? 1 : rymax;
1623 pldebug(
"pldid2pc",
1624 "Relative plot coordinates (out): %f, %f, %f, %f\n",
1625 rxmin, rymin, rxmax, rymax );
1639 PLFLT pxmin, pymin, pxmax, pymax;
1640 PLFLT sxmin, symin, sxmax, symax;
1641 PLFLT rxmin, rymin, rxmax, rymax;
1645 pldebug(
"pldip2pc",
1646 "Relative plot coordinates (in): %f, %f, %f, %f\n",
1647 *xmin, *ymin, *xmax, *ymax );
1654 sxmin = pxmin * plsc->didxax + plsc->didxb;
1655 symin = pymin * plsc->didyay + plsc->didyb;
1656 sxmax = pxmax * plsc->didxax + plsc->didxb;
1657 symax = pymax * plsc->didyay + plsc->didyb;
1664 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1665 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1666 *ymin = ( rymin < 0 ) ? 0 : rymin;
1667 *ymax = ( rymax > 1 ) ? 1 : rymax;
1669 pldebug(
"pldip2pc",
1670 "Relative device coordinates (out): %f, %f, %f, %f\n",
1671 rxmin, rymin, rxmax, rymax );
1684 plsc->dipxmin = ( xmin <
xmax ) ? xmin : xmax;
1685 plsc->dipxmax = ( xmin <
xmax ) ? xmax : xmin;
1686 plsc->dipymin = ( ymin <
ymax ) ? ymin : ymax;
1687 plsc->dipymax = ( ymin <
ymax ) ? ymax : ymin;
1689 if ( xmin == 0. && xmax == 1. && ymin == 0. && ymax == 1. )
1710 xmin = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmin;
1711 ymin = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymin;
1712 xmax = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmax;
1713 ymax = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymax;
1716 plsdiplt( xmin, ymin, xmax, ymax );
1733 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1738 if ( !plsc->stream_closed )
1740 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1746 if ( !( plsc->difilt &
PLDI_PLT ) )
1754 pxlen = pxmax - pxmin;
1755 pylen = pymax - pymin;
1756 pxlen =
MAX( 1, pxlen );
1757 pylen =
MAX( 1, pylen );
1759 plsc->dipxax = plsc->phyxlen / (double) pxlen;
1760 plsc->dipyay = plsc->phyylen / (double) pylen;
1761 plsc->dipxb = plsc->phyxmi - plsc->dipxax * pxmin;
1762 plsc->dipyb = plsc->phyymi - plsc->dipyay * pymin;
1774 *p_xmin = plsc->dipxmin;
1775 *p_xmax = plsc->dipxmax;
1776 *p_ymin = plsc->dipymin;
1777 *p_ymax = plsc->dipymax;
1799 if ( mar == 0. && aspect == 0. && jx == 0. && jy == 0. &&
1820 PLFLT lx, ly, aspect, aspdev;
1822 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1827 if ( !plsc->stream_closed )
1829 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1835 if ( !( plsc->difilt &
PLDI_DEV ) )
1840 lx = plsc->phyxlen / plsc->xpmm;
1841 ly = plsc->phyylen / plsc->ypmm;
1845 aspect = plsc->aspori;
1847 aspect = plsc->aspect;
1850 aspect = plsc->aspdev;
1854 plsc->mar = ( plsc->mar > 0.5 ) ? 0.5 : plsc->mar;
1855 plsc->mar = ( plsc->mar < 0.0 ) ? 0.0 : plsc->mar;
1856 plsc->jx = ( plsc->jx > 0.5 ) ? 0.5 : plsc->jx;
1857 plsc->jx = ( plsc->jx < -0.5 ) ? -0.5 : plsc->jx;
1858 plsc->jy = ( plsc->jy > 0.5 ) ? 0.5 : plsc->jy;
1859 plsc->jy = ( plsc->jy < -0.5 ) ? -0.5 : plsc->jy;
1863 xlen = ( aspect < aspdev ) ? ( aspect / aspdev ) : 1.0;
1864 ylen = ( aspect < aspdev ) ? 1.0 : ( aspdev / aspect );
1866 xlen *= ( 1.0 - 2. * plsc->mar );
1867 ylen *= ( 1.0 - 2. * plsc->mar );
1869 xmin = ( 1. - xlen ) * ( 0.5 + plsc->jx );
1872 ymin = ( 1. - ylen ) * ( 0.5 + plsc->jy );
1882 pxlen = pxmax - pxmin;
1883 pylen = pymax - pymin;
1884 pxlen =
MAX( 1, pxlen );
1885 pylen =
MAX( 1, pylen );
1887 plsc->didxax = pxlen / (double) plsc->phyxlen;
1888 plsc->didyay = pylen / (
double) plsc->phyylen;
1889 plsc->didxb = pxmin - plsc->didxax * plsc->phyxmi;
1890 plsc->didyb = pymin - plsc->didyay * plsc->phyymi;
1894 plsc->diclpxmi = (
PLINT) ( plsc->didxax * plsc->phyxmi + plsc->didxb );
1895 plsc->diclpxma = (
PLINT) ( plsc->didxax * plsc->phyxma + plsc->didxb );
1896 plsc->diclpymi = (
PLINT) ( plsc->didyay * plsc->phyymi + plsc->didyb );
1897 plsc->diclpyma = (
PLINT) ( plsc->didyay * plsc->phyyma + plsc->didyb );
1910 *p_aspect = plsc->aspect;
1947 PLFLT x0, y0, lx, ly, aspect;
1953 if ( !plsc->stream_closed )
1955 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1961 if ( !( plsc->difilt &
PLDI_ORI ) )
1966 x0 = ( plsc->phyxma + plsc->phyxmi ) / 2.;
1967 y0 = ( plsc->phyyma + plsc->phyymi ) / 2.;
1971 cost =
ABS( cos( plsc->diorot *
PI / 2. ) );
1972 sint =
ABS( sin( plsc->diorot *
PI / 2. ) );
1976 aspect = plsc->aspect;
1978 aspect = plsc->aspdev;
1980 if ( plsc->freeaspect )
1981 plsc->aspori = aspect;
1983 plsc->aspori = ( aspect * cost + sint ) / ( aspect * sint + cost );
1985 if ( !( plsc->difilt &
PLDI_DEV ) )
2030 plsc->dioxax = affine_result[0];
2031 plsc->dioxay = affine_result[2];
2032 plsc->dioxb = affine_result[4];
2033 plsc->dioyax = affine_result[1];
2034 plsc->dioyay = affine_result[3];
2035 plsc->dioyb = affine_result[5];
2047 *p_rot = plsc->diorot;
2063 plsetvar( plsc->dimxmin, dimxmin );
2064 plsetvar( plsc->dimxmax, dimxmax );
2065 plsetvar( plsc->dimymin, dimymin );
2066 plsetvar( plsc->dimymax, dimymax );
2067 plsetvar( plsc->dimxpmm, dimxpmm );
2068 plsetvar( plsc->dimypmm, dimypmm );
2087 PLINT pxmin, pxmax, pymin, pymax;
2088 PLFLT dimxlen, dimylen, pxlen, pylen;
2090 if ( ( plsc->dimxmin == plsc->phyxmi ) && ( plsc->dimxmax == plsc->phyxma ) &&
2091 ( plsc->dimymin == plsc->phyymi ) && ( plsc->dimymax == plsc->phyyma ) &&
2092 ( plsc->dimxpmm == plsc->xpmm ) && ( plsc->dimypmm == plsc->ypmm ) )
2100 lx = ( plsc->dimxmax - plsc->dimxmin + 1 ) / plsc->dimxpmm;
2101 ly = ( plsc->dimymax - plsc->dimymin + 1 ) / plsc->dimypmm;
2103 plsc->aspdev = lx / ly;
2107 dimxlen = plsc->dimxmax - plsc->dimxmin;
2108 dimylen = plsc->dimymax - plsc->dimymin;
2110 pxmin = plsc->phyxmi;
2111 pxmax = plsc->phyxma;
2112 pymin = plsc->phyymi;
2113 pymax = plsc->phyyma;
2114 pxlen = pxmax - pxmin;
2115 pylen = pymax - pymin;
2117 plsc->dimxax = pxlen / dimxlen;
2118 plsc->dimyay = pylen / dimylen;
2119 plsc->dimxb = pxmin - pxlen * plsc->dimxmin / dimxlen;
2120 plsc->dimyb = pymin - pylen * plsc->dimymin / dimylen;
2132 if ( plsc->dev_flush )
2135 if ( !plsc->stream_closed )
2137 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
2144 if ( plsc->OutFile != NULL )
2145 fflush( plsc->OutFile );
2168 #ifdef ENABLE_DYNDRIVERS
2190 if ( plsc->level != 0 )
2209 if ( plsc->level != 0 )
2227 PLFLT lx, ly, xpmm_loc, ypmm_loc, aspect_old, aspect_new;
2228 PLINT inc = 0, del = 2000;
2232 if ( plsc->level != 0 )
2248 if ( plsc->plwindow == NULL )
2250 if ( plsc->program )
2252 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) ( 1 + strlen( plsc->program ) ) * sizeof (
char ) ) ) == NULL )
2254 plexit(
"plinit: Insufficient memory" );
2256 strcpy( plsc->plwindow, plsc->program );
2260 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) 7 *
sizeof (
char ) ) ) == NULL )
2262 plexit(
"plinit: Insufficient memory" );
2264 strcpy( plsc->plwindow,
"PLplot" );
2291 if ( plsc->aspect > 0. )
2293 lx = plsc->phyxlen / plsc->xpmm;
2294 ly = plsc->phyylen / plsc->ypmm;
2295 aspect_old = lx / ly;
2296 aspect_new = plsc->aspect;
2297 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2301 else if ( plsc->freeaspect &&
ABS( cos( plsc->diorot *
PI / 2. ) ) <= 1.e-5 )
2303 lx = plsc->phyxlen / plsc->xpmm;
2304 ly = plsc->phyylen / plsc->ypmm;
2305 aspect_old = lx / ly;
2306 aspect_new = ly / lx;
2307 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2311 plsc->caspfactor = 1.;
2325 if ( plsc->xdigmax == 0 )
2328 if ( plsc->ydigmax == 0 )
2331 if ( plsc->zdigmax == 0 )
2334 if ( plsc->timefmt == NULL )
2340 if ( plsc->qsasconfig == NULL )
2341 c_plconfigtime( 0., 0., 0., 0x0, 0, 0, 0, 0, 0, 0, 0. );
2349 plpat( 1, &inc, &del );
2356 plsc->clpxmi = plsc->phyxmi;
2357 plsc->clpxma = plsc->phyxma;
2358 plsc->clpymi = plsc->phyymi;
2359 plsc->clpyma = plsc->phyyma;
2363 lx = plsc->phyxlen / plsc->xpmm;
2364 ly = plsc->phyylen / plsc->ypmm;
2365 plsc->aspdev = lx / ly;
2378 plP_setpxl( xpmm_loc * plsc->caspfactor, ypmm_loc / plsc->caspfactor );
2397 if (
pls[i] != NULL )
2404 #ifdef ENABLE_DYNDRIVERS
2410 free_mem( loadable_device_list[i].devnam );
2411 free_mem( loadable_device_list[i].description );
2412 free_mem( loadable_device_list[i].drvnam );
2413 free_mem( loadable_device_list[i].tag );
2416 for ( i = 0; i < nloadabledrivers; i++ )
2418 free_mem( loadable_driver_list[i].drvnam );
2448 if ( plsc->level > 0 )
2455 if ( plsc->FileName )
2466 #ifndef BUFFERED_FILE
2469 if ( plsc->program )
2471 if ( plsc->server_name )
2473 if ( plsc->server_host )
2475 if ( plsc->server_port )
2479 if ( plsc->plserver )
2481 if ( plsc->auto_path )
2484 if ( plsc->arrow_x )
2486 if ( plsc->arrow_y )
2489 if ( plsc->timefmt )
2524 "plsstrm: Illegal stream number %d, must be in [0, %d]\n",
2534 plexit(
"plsstrm: Out of memory." );
2575 if (
pls[i] == NULL )
2579 if ( i == PL_NSTREAMS )
2581 fprintf( stderr,
"plmkstrm: Cannot create new stream\n" );
2611 if ( !plsc->initialized )
2613 plsc->initialized = 1;
2615 if ( plsc->cmap0 == NULL )
2618 if ( plsc->cmap1 == NULL )
2622 plsc->cmap1_min = 0.0;
2623 plsc->cmap1_max = 1.0;
2667 fprintf( stderr,
"plcpstrm: stream %d not in use\n", (
int) iplsr );
2673 plsc->debug = plsr->
debug;
2678 #ifdef BUFFERED_FILE
2679 plsc->plbufFile = plsr->plbufFile;
2685 if ( ( plsc->plbuf_buffer = malloc( plsc->plbuf_buffer_size ) ) == NULL )
2686 plexit(
"plcpstrm: Error allocating plot buffer." );
2704 if ( !( flags & 0x01 ) )
2706 pldebug(
"plcpstrm",
"mapping parameters: %d %d %d %d %f %f\n",
2719 plsc->icol0 = plsr->
icol0;
2720 plsc->ncol0 = plsr->
ncol0;
2721 if ( plsc->cmap0 != NULL )
2722 free( (
void *) plsc->cmap0 );
2724 if ( ( plsc->cmap0 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol0 * sizeof (
PLColor ) ) ) == NULL )
2726 plexit(
"c_plcpstrm: Insufficient memory" );
2729 for ( i = 0; i < plsc->ncol0; i++ )
2734 plsc->icol1 = plsr->
icol1;
2735 plsc->ncol1 = plsr->
ncol1;
2738 if ( plsc->cmap1 != NULL )
2739 free( (
void *) plsc->cmap1 );
2741 if ( ( plsc->cmap1 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol1 * sizeof (
PLColor ) ) ) == NULL )
2743 plexit(
"c_plcpstrm: Insufficient memory" );
2746 for ( i = 0; i < plsc->ncol1; i++ )
2751 if ( plsc->level == 0 )
2779 if ( plsc->dev_initialized )
2781 plsc->dev_initialized = 1;
2793 static int inited = 0;
2794 static int inBuildTree = 0;
2803 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2814 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2819 if ( strncmp( builddir + 1, currdir + 1, strlen( builddir + 1 ) ) == 0 &&
2820 tolower( builddir[0] ) == tolower( currdir[0] ) )
2825 if ( chdir( currdir ) != 0 )
2826 pldebug(
"plInBuildTree():",
"Unable to chdir to current directory" );
2834 #ifdef ENABLE_DYNDRIVERS
2848 pldebug(
"plGetDrvDir",
"Using %s as the driver directory.\n", drvdir );
2852 pldebug(
"plGetDrvDir",
"Trying to read env var PLPLOT_DRV_DIR\n" );
2853 drvdir = getenv(
"PLPLOT_DRV_DIR" );
2855 if ( drvdir == NULL )
2857 pldebug(
"plGetDrvDir",
2858 "Will use drivers dir: " DRV_DIR "\n" );
2891 #ifdef ENABLE_DYNDRIVERS
2893 const char * drvdir;
2894 char *devnam, *devdesc, *devtype, *driver, *tag, *seqstr;
2896 int i, j, driver_found, done = 0;
2897 FILE *fp_drvdb = NULL;
2898 DIR * dp_drvdir = NULL;
2904 nloadabledrivers = 0;
2909 if ( fp_drvdb == NULL )
2911 plabort(
"plInitDispatchTable: Could not open temporary file" );
2916 drvdir = plGetDrvDir();
2917 dp_drvdir =
opendir( drvdir );
2918 if ( dp_drvdir == NULL )
2921 plabort(
"plInitDispatchTable: Could not open drivers directory" );
2927 pldebug(
"plInitDispatchTable",
"Scanning dyndrivers dir\n" );
2928 while ( ( entry =
readdir( dp_drvdir ) ) != NULL )
2932 size_t len = strlen( name ) - 12;
2934 pldebug(
"plInitDispatchTable",
2935 "Consider file %s\n", name );
2938 if ( ( len > 0 ) && ( strcmp( name + len,
".driver_info" ) == 0 ) )
2945 fd = fopen( path,
"r" );
2951 "plInitDispatchTable: Could not open driver info file %s\n",
2961 pldebug(
"plInitDispatchTable",
2962 "Opened driver info file %s\n", name );
2965 fprintf( fp_drvdb,
"%s", buf );
2966 if ( buf [strlen( buf ) - 1] !=
'\n' )
2967 fprintf( fp_drvdb,
"\n" );
2985 #ifdef ENABLE_DYNDRIVERS
2988 plexit(
"plInitDispatchTable: Insufficient memory" );
3000 #ifdef ENABLE_DYNDRIVERS
3003 plexit(
"plInitDispatchTable: Insufficient memory" );
3010 #ifdef ENABLE_DYNDRIVERS
3015 if ( ( ( loadable_device_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDevice ) ) ) == NULL ) ||
3016 ( ( loadable_driver_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDriver ) ) ) == NULL ) )
3019 plexit(
"plInitDispatchTable: Insufficient memory" );
3036 devnam = strtok( buf,
":" );
3037 devdesc = strtok( 0,
":" );
3038 devtype = strtok( 0,
":" );
3039 driver = strtok( 0,
":" );
3040 seqstr = strtok( 0,
":" );
3041 tag = strtok( 0,
"\n" );
3043 if ( devnam == NULL || devdesc == NULL || devtype == NULL || driver == NULL ||
3044 seqstr == NULL || tag == NULL )
3049 seq = atoi( seqstr );
3056 plexit(
"plInitDispatchTable: Insufficient memory" );
3074 loadable_device_list[i].devnam =
plstrdup( devnam );
3075 loadable_device_list[i].description =
plstrdup( devdesc );
3076 loadable_device_list[i].drvnam =
plstrdup( driver );
3077 loadable_device_list[i].tag =
plstrdup( tag );
3082 for ( j = 0; j < nloadabledrivers; j++ )
3083 if ( strcmp( driver, loadable_driver_list[j].drvnam ) == 0 )
3089 if ( !driver_found )
3091 loadable_driver_list[nloadabledrivers].drvnam =
plstrdup( driver );
3092 loadable_driver_list[nloadabledrivers].dlhand = 0;
3096 loadable_device_list[i].drvidx = j;
3110 plexit(
"No device drivers found - please check the environment variable PLPLOT_DRV_DIR" );
3141 if ( plsc->DevName[0] ==
'\0' )
3143 devname_env = getenv(
"PLPLOT_DEV" );
3146 strncpy( plsc->DevName, devname_env, sizeof ( plsc->DevName ) - 1 );
3147 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3153 if ( *( plsc->DevName ) !=
'\0' && *( plsc->DevName ) !=
'?' )
3155 length = strlen( plsc->DevName );
3159 ( strncmp( plsc->DevName,
3163 if ( i < npldrivers )
3165 plsc->device = i + 1;
3170 fprintf( stderr,
"Requested device %s not available\n",
3185 fprintf( stdout,
"\nPlotting Options:\n" );
3188 fprintf( stdout,
" <%2d> %-10s %s\n", i + 1,
3193 fprintf( stdout,
"\nEnter device number or keyword: " );
3195 fprintf( stdout,
"\nEnter device number or keyword (stream %d): ",
3198 plio_fgets( response,
sizeof ( response ), stdin );
3203 length = strlen( response );
3204 if ( *( response - 1 + length ) ==
'\n' )
3210 (
unsigned int) length ) )
3213 if ( i < npldrivers )
3219 if ( ( dev = atoi( response ) ) < 1 )
3221 fprintf( stdout,
"\nInvalid device: %s", response );
3226 plexit(
"plSelectDev: Too many tries." );
3243 #ifdef ENABLE_DYNDRIVERS
3248 int n = plsc->device - 1;
3250 PLLoadableDriver *driver = 0;
3258 pldebug(
"plLoadDriver",
"Device not loaded!\n" );
3263 if ( strcmp( dev->
pl_DevName, loadable_device_list[i].devnam ) == 0 )
3269 if ( i == npldynamicdevices )
3271 fprintf( stderr,
"No such device: %s.\n", dev->
pl_DevName );
3272 plexit(
"plLoadDriver detected device logic screwup" );
3278 tag = loadable_device_list[i].tag;
3279 drvidx = loadable_device_list[i].drvidx;
3281 pldebug(
"plLoadDriver",
"tag=%s, drvidx=%d\n", tag, drvidx );
3283 driver = &loadable_driver_list[drvidx];
3286 if ( !driver->dlhand )
3289 #if defined ( LTDL_WIN32 ) || defined ( __CYGWIN__ )
3293 #endif // LTDL_WIN32
3295 pldebug(
"plLoadDriver",
"Trying to load %s on %s\n",
3296 driver->drvnam, drvspec );
3307 if ( !( strcmp( driver->drvnam,
"mem" ) == 0 ||
3308 strcmp( driver->drvnam,
"null" ) == 0 ||
3309 strcmp( driver->drvnam,
"plmeta" ) == 0 ||
3310 strcmp( driver->drvnam,
"ps" ) == 0 ||
3311 strcmp( driver->drvnam,
"svg" ) == 0 ||
3312 strcmp( driver->drvnam,
"xfig" ) == 0 ) )
3317 if ( !driver->dlhand )
3319 pldebug(
"plLoadDriver",
"lt_dlopenext failed because of "
3320 "the following reason:\n%s\n",
lt_dlerror() );
3321 fprintf( stderr,
"Unable to load driver: %s.\n", driver->drvnam );
3322 plexit(
"Unable to load driver" );
3331 if ( !dispatch_init )
3334 "Unable to locate dispatch table initialization function for driver: %s.\n",
3339 ( *dispatch_init )( dev );
3356 if ( plsc->level > 0 )
3371 #ifdef BUFFERED_FILE
3372 if ( plsc->plbufFile != NULL )
3375 if ( plsc->plbuf_buffer != NULL )
3382 plwarn(
"plreplot: plot buffer not available" );
3398 plgFileDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3400 plgdevlst( *p_menustr, *p_devname, p_ndev, 0 );
3410 plgDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3412 plgdevlst( *p_menustr, *p_devname, p_ndev, -1 );
3416 plgdevlst(
const char **p_menustr,
const char **p_devname,
int *p_ndev,
int type )
3428 if ( ++j + 1 >= *p_ndev )
3430 plwarn(
"plgdevlst: too many devices" );
3435 p_menustr[j] = NULL;
3436 p_devname[j] = NULL;
3452 *p_xleng = plsc->xlength;
3453 *p_yleng = plsc->ylength;
3454 *p_xoff = plsc->xoffset;
3455 *p_yoff = plsc->yoffset;
3463 if ( plsc->level > 0 )
3464 plwarn(
"calling plspage() after plinit() may give unpredictable results" );
3472 plsc->xlength = xleng;
3474 plsc->ylength = yleng;
3477 plsc->xoffset = xoff;
3479 plsc->yoffset = yoff;
3496 if ( plsc->level > 0 )
3509 if ( plsc->level > 0 )
3511 plwarn(
"plsdev: Must be called before plinit." );
3514 if ( devname != NULL )
3516 strncpy( plsc->DevName, devname, sizeof ( plsc->DevName ) - 1 );
3517 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3527 strcpy( p_dev, plsc->DevName );
3542 plsc->dev = plotmem;
3543 plsc->dev_mem_alpha = 0;
3552 plsc->dev = plotmem;
3553 plsc->dev_mem_alpha = 1;
3576 *p_level = plsc->level;
3585 plsc->KeyEH = KeyEH;
3586 plsc->KeyEH_data = KeyEH_data;
3593 void *ButtonEH_data )
3595 plsc->ButtonEH = ButtonEH;
3596 plsc->ButtonEH_data = ButtonEH_data;
3602 plsbopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3604 plsc->bop_handler = handler;
3605 plsc->bop_data = handler_data;
3611 plseopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3613 plsc->eop_handler = handler;
3614 plsc->eop_data = handler_data;
3622 if ( errcode != NULL )
3623 plsc->errcode = errcode;
3625 if ( errmsg != NULL )
3646 if ( width != plsc->width && width >= 0. )
3648 plsc->width = width;
3650 if ( plsc->level > 0 )
3652 if ( !plsc->widthlock )
3663 *p_file = plsc->OutFile;
3671 plsc->OutFile = file;
3682 plabort(
"filename string must be preallocated to >=80 bytes" );
3687 if ( plsc->FileName != NULL )
3689 strncpy( fnam, plsc->FileName, 79 );
3715 plsc->setpre = setp;
3716 plsc->precis = prec;
3724 *p_setp = plsc->setpre;
3725 *p_prec = plsc->precis;
3731 return (
const char *) plsc->timefmt;
3760 plwarn(
"plsesc: Invalid escape character, ignoring." );
3769 if ( plsc->esc ==
'\0' )
3803 *pfci = *pfci & mask;
3805 *pfci = *pfci | mask;
3816 *phexdigit = (
unsigned char) ( ( fci & mask ) >>
3833 plsc->window_id = window_id;
3850 *p_fam = plsc->family;
3851 *p_num = plsc->member;
3852 *p_bmax = plsc->bytemax;
3860 if ( plsc->level > 0 )
3861 plwarn(
"plsfam: Must be called before plinit." );
3868 plsc->bytemax = bmax;
3889 *p_digmax = plsc->xdigmax;
3890 *p_digits = plsc->xdigits;
3898 plsc->xdigmax = digmax;
3899 plsc->xdigits = digits;
3907 *p_digmax = plsc->ydigmax;
3908 *p_digits = plsc->ydigits;
3916 plsc->ydigmax = digmax;
3917 plsc->ydigits = digits;
3925 *p_digmax = plsc->zdigmax;
3926 *p_digits = plsc->zdigits;
3934 plsc->zdigmax = digmax;
3935 plsc->zdigits = digits;
3943 *p_def = plsc->chrdef;
3944 *p_ht = plsc->chrht;
3952 *p_xmin = plsc->vpdxmi;
3953 *p_xmax = plsc->vpdxma;
3954 *p_ymin = plsc->vpdymi;
3955 *p_ymax = plsc->vpdyma;
3963 *p_xmin = plsc->vpwxmi;
3964 *p_xmax = plsc->vpwxma;
3965 *p_ymin = plsc->vpwymi;
3966 *p_ymax = plsc->vpwyma;
3975 dx = ( plsc->vpwxma - plsc->vpwxmi ) * 1.0e-5;
3976 dy = ( plsc->vpwyma - plsc->vpwymi ) * 1.0e-5;
3981 *p_xmin = plsc->vpwxmi -
dx;
3982 *p_xmax = plsc->vpwxma +
dx;
3983 *p_ymin = plsc->vpwymi -
dy;
3984 *p_ymax = plsc->vpwyma +
dy;
3996 *p_xmin = plsc->domxmi;
3997 *p_xmax = plsc->domxma;
3998 *p_ymin = plsc->domymi;
3999 *p_ymax = plsc->domyma;
4007 *p_zscl = plsc->zzscl;
4008 *p_zmin = plsc->ranmi;
4009 *p_zmax = plsc->ranma;
4029 *p_ixmin = plsc->clpxmi;
4030 *p_ixmax = plsc->clpxma;
4031 *p_iymin = plsc->clpymi;
4032 *p_iymax = plsc->clpyma;
4040 plsc->clpxmi = ixmin;
4041 plsc->clpxma = ixmax;
4042 plsc->clpymi = iymin;
4043 plsc->clpyma = iymax;
4051 *p_ixmin = plsc->phyxmi;
4052 *p_ixmax = plsc->phyxma;
4053 *p_iymin = plsc->phyymi;
4054 *p_iymax = plsc->phyyma;
4062 *p_nx = plsc->nsubx;
4063 *p_ny = plsc->nsuby;
4064 *p_cs = plsc->cursub;
4093 plsc->umx = (
PLINT) ( 1000.0 / plsc->xpmm );
4094 plsc->umy = (
PLINT) ( 1000.0 / plsc->ypmm );
4102 if ( xmin > xmax || ymin > ymax )
4103 plexit(
"plP_setphy: device minima must not exceed maxima" );
4105 plsc->phyxmi =
xmin;
4106 plsc->phyxma =
xmax;
4107 plsc->phyymi =
ymin;
4108 plsc->phyyma =
ymax;
4109 plsc->phyxlen = xmax -
xmin;
4110 plsc->phyylen = ymax -
ymin;
4123 if ( plsc->level <= 0 )
4125 plsc->dev_compression = compression;
4138 *compression = plsc->dev_compression;
4159 if (
pls[i] != NULL )
4162 strcpy( names,
pls[i]->DevName );
4165 strcat( names,
" " );
4166 strcat( names,
pls[i]->DevName );
4189 buff = (
char *) malloc( (
size_t)
PL_NSTREAMS * 8 );
4197 for ( tok = strtok( buff,
" ," );
4198 tok; tok = strtok( 0,
" ," ) )
4200 if ( strstr( names, tok ) != NULL )
4242 #if 0 // BEGIN dev_fastimg COMMENT
4249 if ( plsc->dev_fastimg == 0 )
4252 xmin, ymin, dx, dy, zmin, zmax );
4256 if ( plsc->plbuf_write )
4268 plsc->dev_nptsX =
nx;
4269 plsc->dev_nptsY = ny;
4270 plsc->dev_zmin = zmin;
4271 plsc->dev_zmax = zmax;
4277 plbuf_write = plsc->plbuf_write;
4278 plsc->plbuf_write = 0;
4283 PLINT clpxmi, clpxma, clpymi, clpyma;
4285 if ( ( ( xscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) ||
4286 ( ( yscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) )
4288 plexit(
"plP_image: Insufficient memory" );
4291 for ( i = 0; i < npts; i++ )
4296 sdifilt( xscl, yscl, npts, &clpxmi, &clpxma, &clpymi, &clpyma );
4297 plsc->imclxmin = clpxmi;
4298 plsc->imclymin = clpymi;
4299 plsc->imclxmax = clpxma;
4300 plsc->imclymax = clpyma;
4301 grimage( xscl, yscl, z, nx, ny );
4307 plsc->imclxmin = plsc->phyxmi;
4308 plsc->imclymin = plsc->phyymi;
4309 plsc->imclxmax = plsc->phyxma;
4310 plsc->imclymax = plsc->phyyma;
4313 plsc->plbuf_write = plbuf_write;
4314 #endif // END dev_fastimg COMMENT
4326 plsc->coordinate_transform = coordinate_transform;
4327 plsc->coordinate_transform_data = coordinate_transform_data;