37 #ifdef ENABLE_DYNDRIVERS
49 # ifdef NEED_SYS_TYPE_H
50 # include <sys/types.h>
53 # define NAMLEN( dirent ) strlen( ( dirent )->d_name )
55 # if defined ( _MSC_VER )
58 # define dirent direct
59 # define NAMLEN( dirent ) ( dirent )->d_namlen
61 # include <sys/ndir.h>
78 #if defined ( _MSC_VER )
80 # define getcwd _getcwd
84 #define BUFFER_SIZE 80
85 #define BUFFER2_SIZE 300
86 #define DRVSPEC_SIZE 400
94 text2fci(
const char *
text,
unsigned char *hexdigit,
unsigned char *hexpower );
140 plsc->page_status =
AT_EOP;
141 plsc->stream_closed =
FALSE;
144 ( *plsc->dispatch_table->pl_init )( (
struct PLStream_struct *) plsc );
147 if ( plsc->plbuf_write )
158 int skip_driver_eop = 0;
160 if ( plsc->page_status ==
AT_EOP )
163 plsc->page_status =
AT_EOP;
165 if ( plsc->plbuf_write )
170 if ( plsc->eop_handler != NULL )
171 ( *plsc->eop_handler )( plsc->eop_data, &skip_driver_eop );
173 if ( !skip_driver_eop )
176 if ( !plsc->stream_closed )
178 ( *plsc->dispatch_table->pl_eop )( (
struct PLStream_struct *) plsc );
192 int skip_driver_bop = 0;
195 if ( plsc->page_status ==
AT_BOP )
198 plsc->page_status =
AT_BOP;
203 if ( plsc->bop_handler != NULL )
204 ( *plsc->bop_handler )( plsc->bop_data, &skip_driver_bop );
206 if ( !skip_driver_bop )
209 if ( !plsc->stream_closed )
211 ( *plsc->dispatch_table->pl_bop )( (
struct PLStream_struct *) plsc );
216 if ( plsc->plbuf_write )
228 ( *plsc->tidy )( plsc->tidy_data );
230 plsc->tidy_data = NULL;
234 if ( !plsc->stream_closed )
236 ( *plsc->dispatch_table->pl_tidy )( (
struct PLStream_struct *) plsc );
240 if ( plsc->plbuf_write )
245 plsc->OutFile = NULL;
254 if ( plsc->plbuf_write )
258 if ( !plsc->stream_closed )
260 ( *plsc->dispatch_table->pl_state )( (
struct PLStream_struct *) plsc, op );
271 PLINT clpxmi, clpxma, clpymi, clpyma;
275 if ( plsc->plbuf_write )
286 difilt( &( args->
x ), &( args->
y ), 1, &clpxmi, &clpxma, &clpymi, &clpyma );
291 if ( !plsc->stream_closed )
293 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc, op, ptr );
306 PLINT clpxmi, clpxma, clpymi, clpyma;
310 if ( plsc->plbuf_write )
343 if ( plsc->dev_swin )
346 if ( !plsc->stream_closed )
348 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
365 PLINT i, npts = 2, clpxmi, clpxma, clpymi, clpyma;
369 if ( plsc->plbuf_write )
374 for ( i = 0; i < npts; i++ )
394 PLINT i, clpxmi, clpxma, clpymi, clpyma;
398 if ( plsc->plbuf_write )
403 for ( i = 0; i < npts; i++ )
428 PLINT i, clpxmi, clpxma, clpymi, clpyma;
432 if ( plsc->plbuf_write )
434 plsc->dev_npts = npts;
442 if ( plsc->patt == 0 && !plsc->dev_fill0 )
446 plwarn(
"Driver does not support hardware solid fills, switching to software fill.\n" );
452 if ( plsc->dev_fill1 )
454 plsc->patt = -
ABS( plsc->patt );
462 if ( plsc->patt > 0 )
469 for ( i = 0; i < npts; i++ )
493 PLINT i, clpxmi, clpxma, clpymi, clpyma;
497 if ( plsc->plbuf_write )
499 plsc->dev_npts = npts;
508 for ( i = 0; i < npts; i++ )
546 *num = (
PLUNICODE) strtoul( text, &endptr, 0 );
548 if ( end != endptr[0] )
550 snprintf( msgbuf,
BUFFER_SIZE,
"text2num: invalid control string detected - %c expected", end );
554 return (
int) ( endptr -
text );
575 int text2fci(
const char *
text,
unsigned char *hexdigit,
unsigned char *hexpower )
580 unsigned char hexdigit;
581 unsigned char hexpower;
587 #define N_TextLookupTable 10
603 length = (int) strlen( lookup[i].ptext );
604 if ( !strncmp( text, lookup[i].ptext, (
size_t) length ) )
606 *hexdigit = lookup[i].hexdigit;
607 *hexpower = lookup[i].hexpower;
621 unsigned char hexdigit, hexpower;
632 len = strlen(
string );
649 for ( i = 0; i < len; i++ )
653 if (
string[i] == esc )
655 switch (
string[i + 1] )
658 i += 2 +
text2num( &
string[i + 2],
')', &code );
668 i += 2 +
text2num( &
string[i + 2],
']', &code );
675 if (
'0' <=
string[i + 2] &&
string[i + 2] <=
'9' )
677 i += 2 +
text2num( &
string[i + 2],
'>', &code );
709 i +=
text2fci( &
string[i + 1], &hexdigit, &hexpower );
731 if (
string[i + 2] ==
'n' )
736 else if (
string[i + 2] ==
'r' )
741 else if (
string[i + 2] ==
'i' )
747 else if (
string[i + 2] ==
's' )
784 else if ( ig == 634 )
786 else if ( ig == 647 )
848 #ifdef HAVE_LIBUNICODE
849 const char * ptr = unicode_get_utf8(
string + i, &unichar );
851 const char * ptr =
utf8_to_ucs4(
string + i, &unichar );
857 strncpy( tmpstring,
string, 30 );
858 tmpstring[30] =
'\0';
860 tmpstring, strlen(
string ) > 30 ?
"[...]" :
"" );
864 i += (int) ( ptr - (
string + i ) - 1 );
869 if (
string[i] == esc &&
string[i + 1] == esc )
893 unsigned char hexdigit, hexpower;
905 len = strlen(
string );
927 for ( j = i = 0; i < len; i++ )
931 if (
string[i] == esc )
935 switch (
string[i + 1] )
938 i += ( 2 +
text2num( &
string[i + 2],
')', &code ) );
957 i += ( 2 +
text2num( &
string[i + 2],
']', &code ) );
974 if (
'0' <=
string[i + 2] &&
string[i + 2] <=
'9' )
976 i += 2 +
text2num( &
string[i + 2],
'>', &code );
1002 i +=
text2fci( &
string[i + 1], &hexdigit, &hexpower );
1021 if (
string[i + 2] ==
'n' )
1026 else if (
string[i + 2] ==
'r' )
1031 else if (
string[i + 2] ==
'i' )
1037 else if (
string[i + 2] ==
's' )
1072 else if ( ig == 634 )
1074 else if ( ig == 647 )
1100 #ifdef HAVE_LIBUNICODE
1101 const char * ptr = unicode_get_utf8(
string + i, &unichar );
1103 const char * ptr =
utf8_to_ucs4(
string + i, &unichar );
1109 strncpy( tmpstring,
string, 30 );
1110 tmpstring[30] =
'\0';
1112 tmpstring, strlen(
string ) > 30 ?
"[...]" :
"" );
1117 i += (int) ( ptr - (
string + i ) - 1 );
1123 &&
string[i + 1] == esc )
1147 if (
string == NULL )
1150 if ( plsc->dev_text )
1169 if ( plsc->dev_unicode )
1171 if ( plsc->alt_unicode )
1196 len = strlen(
string );
1208 plstr( base, xform, refx, refy,
string );
1228 if ( (
unsigned char) ( tmp & 0x80 ) == 0x00 )
1230 *unichar = (
unsigned int) tmp & 0x7F;
1233 else if ( (
unsigned char) ( tmp & 0xE0 ) == 0xC0 )
1235 *unichar = (
unsigned int) tmp & 0x1F;
1238 else if ( (
unsigned char) ( tmp & 0xF0 ) == 0xE0 )
1240 *unichar = (
unsigned char) tmp & 0x0F;
1243 else if ( (
unsigned char) ( tmp & 0xF8 ) == 0xF0 )
1245 *unichar = (
unsigned char) tmp & 0x07;
1248 else if ( (
unsigned char) ( tmp & 0xFC ) == 0xF8 )
1250 *unichar = (
unsigned char) tmp & 0x03;
1253 else if ( (
unsigned char) ( tmp & 0xFE ) == 0xFC )
1255 *unichar = (
unsigned char) tmp & 0x01;
1266 if ( (
unsigned char) ( tmp & 0xC0 ) == 0x80 )
1268 *unichar = ( *unichar << 6 ) | ( (
unsigned int) tmp & 0x3F );
1277 }
while ( cnt > 0 );
1288 tmp = (
unsigned char *) ptr;
1290 if ( ( unichar & 0xffff80 ) == 0 )
1292 *tmp = (
unsigned char) unichar;
1296 else if ( ( unichar & 0xfff800 ) == 0 )
1298 *tmp = (
unsigned char) 0xc0 | (
unsigned char) ( unichar >> 6 );
1300 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & (
PLUINT) 0x3f ) );
1304 else if ( ( unichar & 0xff0000 ) == 0 )
1306 *tmp = (
unsigned char) 0xe0 | (
unsigned char) ( unichar >> 12 );
1308 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1310 *tmp = (
unsigned char) ( 0x80 | ( (
unsigned char) unichar & 0x3f ) );
1314 else if ( ( unichar & 0xe0000 ) == 0 )
1316 *tmp = (
unsigned char) 0xf0 | (
unsigned char) ( unichar >> 18 );
1318 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 12 ) & 0x3f ) );
1320 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1322 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & 0x3f ) );
1339 if ( !plsc->stream_closed )
1341 ( *plsc->dispatch_table->pl_line )( (
struct PLStream_struct *) plsc,
1342 x[0], y[0], x[1], y[1] );
1351 if ( !plsc->stream_closed )
1353 ( *plsc->dispatch_table->pl_polyline )( (
struct PLStream_struct *) plsc,
1363 plsc->dev_npts = npts;
1368 if ( !plsc->stream_closed )
1370 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1380 plsc->dev_npts = npts;
1385 if ( !plsc->stream_closed )
1387 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1423 for ( i = 0; i < npts; i++ )
1425 xsc[i] = (
PLINT) ( plsc->dimxax * xsc[i] + plsc->dimxb );
1426 ysc[i] = (
PLINT) ( plsc->dimyay * ysc[i] + plsc->dimyb );
1434 for ( i = 0; i < npts; i++ )
1436 x = (
PLINT) ( plsc->dioxax * xsc[i] + plsc->dioxay * ysc[i] + plsc->dioxb );
1437 y = (
PLINT) ( plsc->dioyax * xsc[i] + plsc->dioyay * ysc[i] + plsc->dioyb );
1447 for ( i = 0; i < npts; i++ )
1449 xsc[i] = (
PLINT) ( plsc->dipxax * xsc[i] + plsc->dipxb );
1450 ysc[i] = (
PLINT) ( plsc->dipyay * ysc[i] + plsc->dipyb );
1459 for ( i = 0; i < npts; i++ )
1461 xsc[i] = (
PLINT) ( plsc->didxax * xsc[i] + plsc->didxb );
1462 ysc[i] = (
PLINT) ( plsc->didyay * ysc[i] + plsc->didyb );
1464 *clpxmi = plsc->diclpxmi;
1465 *clpxma = plsc->diclpxma;
1466 *clpymi = plsc->diclpymi;
1467 *clpyma = plsc->diclpyma;
1471 *clpxmi = plsc->phyxmi;
1472 *clpxma = plsc->phyxma;
1473 *clpymi = plsc->phyymi;
1474 *clpyma = plsc->phyyma;
1559 PLINT x1c, x2c, y1c, y2c;
1573 difilt( x_coords, y_coords, 4, &x1c, &x2c, &y1c, &y2c );
1587 plsc->dipxmin = 0.0;
1588 plsc->dipxmax = 1.0;
1589 plsc->dipymin = 0.0;
1590 plsc->dipymax = 1.0;
1611 if ( plsc->level >= 1 )
1613 if ( plsc->plbuf_write )
1647 PLFLT pxmin, pymin, pxmax, pymax;
1648 PLFLT sxmin, symin, sxmax, symax;
1649 PLFLT rxmin, rymin, rxmax, rymax;
1653 pldebug(
"pldid2pc",
1654 "Relative device coordinates (in): %f, %f, %f, %f\n",
1655 *xmin, *ymin, *xmax, *ymax );
1662 sxmin = ( pxmin - plsc->didxb ) / plsc->didxax;
1663 symin = ( pymin - plsc->didyb ) / plsc->didyay;
1664 sxmax = ( pxmax - plsc->didxb ) / plsc->didxax;
1665 symax = ( pymax - plsc->didyb ) / plsc->didyay;
1672 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1673 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1674 *ymin = ( rymin < 0 ) ? 0 : rymin;
1675 *ymax = ( rymax > 1 ) ? 1 : rymax;
1677 pldebug(
"pldid2pc",
1678 "Relative plot coordinates (out): %f, %f, %f, %f\n",
1679 rxmin, rymin, rxmax, rymax );
1693 PLFLT pxmin, pymin, pxmax, pymax;
1694 PLFLT sxmin, symin, sxmax, symax;
1695 PLFLT rxmin, rymin, rxmax, rymax;
1699 pldebug(
"pldip2pc",
1700 "Relative plot coordinates (in): %f, %f, %f, %f\n",
1701 *xmin, *ymin, *xmax, *ymax );
1708 sxmin = pxmin * plsc->didxax + plsc->didxb;
1709 symin = pymin * plsc->didyay + plsc->didyb;
1710 sxmax = pxmax * plsc->didxax + plsc->didxb;
1711 symax = pymax * plsc->didyay + plsc->didyb;
1718 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1719 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1720 *ymin = ( rymin < 0 ) ? 0 : rymin;
1721 *ymax = ( rymax > 1 ) ? 1 : rymax;
1723 pldebug(
"pldip2pc",
1724 "Relative device coordinates (out): %f, %f, %f, %f\n",
1725 rxmin, rymin, rxmax, rymax );
1738 plsc->dipxmin = ( xmin <
xmax ) ? xmin : xmax;
1739 plsc->dipxmax = ( xmin <
xmax ) ? xmax : xmin;
1740 plsc->dipymin = ( ymin <
ymax ) ? ymin : ymax;
1741 plsc->dipymax = ( ymin <
ymax ) ? ymax : ymin;
1743 if ( xmin == 0. && xmax == 1. && ymin == 0. && ymax == 1. )
1764 xmin = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmin;
1765 ymin = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymin;
1766 xmax = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmax;
1767 ymax = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymax;
1770 plsdiplt( xmin, ymin, xmax, ymax );
1787 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1792 if ( !plsc->stream_closed )
1794 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1800 if ( !( plsc->difilt &
PLDI_PLT ) )
1808 pxlen = pxmax - pxmin;
1809 pylen = pymax - pymin;
1810 pxlen =
MAX( 1, pxlen );
1811 pylen =
MAX( 1, pylen );
1813 plsc->dipxax = plsc->phyxlen / (double) pxlen;
1814 plsc->dipyay = plsc->phyylen / (double) pylen;
1815 plsc->dipxb = plsc->phyxmi - plsc->dipxax * pxmin;
1816 plsc->dipyb = plsc->phyymi - plsc->dipyay * pymin;
1828 *p_xmin = plsc->dipxmin;
1829 *p_xmax = plsc->dipxmax;
1830 *p_ymin = plsc->dipymin;
1831 *p_ymax = plsc->dipymax;
1853 if ( mar == 0. && aspect == 0. && jx == 0. && jy == 0. &&
1874 PLFLT lx, ly, aspect, aspdev;
1876 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1881 if ( !plsc->stream_closed )
1883 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1889 if ( !( plsc->difilt &
PLDI_DEV ) )
1894 lx = plsc->phyxlen / plsc->xpmm;
1895 ly = plsc->phyylen / plsc->ypmm;
1899 aspect = plsc->aspori;
1901 aspect = plsc->aspect;
1904 aspect = plsc->aspdev;
1908 plsc->mar = ( plsc->mar > 0.5 ) ? 0.5 : plsc->mar;
1909 plsc->mar = ( plsc->mar < 0.0 ) ? 0.0 : plsc->mar;
1910 plsc->jx = ( plsc->jx > 0.5 ) ? 0.5 : plsc->jx;
1911 plsc->jx = ( plsc->jx < -0.5 ) ? -0.5 : plsc->jx;
1912 plsc->jy = ( plsc->jy > 0.5 ) ? 0.5 : plsc->jy;
1913 plsc->jy = ( plsc->jy < -0.5 ) ? -0.5 : plsc->jy;
1917 xlen = ( aspect < aspdev ) ? ( aspect / aspdev ) : 1.0;
1918 ylen = ( aspect < aspdev ) ? 1.0 : ( aspdev / aspect );
1920 xlen *= ( 1.0 - 2. * plsc->mar );
1921 ylen *= ( 1.0 - 2. * plsc->mar );
1923 xmin = ( 1. - xlen ) * ( 0.5 + plsc->jx );
1926 ymin = ( 1. - ylen ) * ( 0.5 + plsc->jy );
1936 pxlen = pxmax - pxmin;
1937 pylen = pymax - pymin;
1938 pxlen =
MAX( 1, pxlen );
1939 pylen =
MAX( 1, pylen );
1941 plsc->didxax = pxlen / (double) plsc->phyxlen;
1942 plsc->didyay = pylen / (
double) plsc->phyylen;
1943 plsc->didxb = pxmin - plsc->didxax * plsc->phyxmi;
1944 plsc->didyb = pymin - plsc->didyay * plsc->phyymi;
1948 plsc->diclpxmi = (
PLINT) ( plsc->didxax * plsc->phyxmi + plsc->didxb );
1949 plsc->diclpxma = (
PLINT) ( plsc->didxax * plsc->phyxma + plsc->didxb );
1950 plsc->diclpymi = (
PLINT) ( plsc->didyay * plsc->phyymi + plsc->didyb );
1951 plsc->diclpyma = (
PLINT) ( plsc->didyay * plsc->phyyma + plsc->didyb );
1964 *p_aspect = plsc->aspect;
2001 PLFLT x0, y0, lx, ly, aspect;
2007 if ( !plsc->stream_closed )
2009 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
2015 if ( !( plsc->difilt &
PLDI_ORI ) )
2020 x0 = ( plsc->phyxma + plsc->phyxmi ) / 2.;
2021 y0 = ( plsc->phyyma + plsc->phyymi ) / 2.;
2025 cost =
ABS( cos( plsc->diorot *
PI / 2. ) );
2026 sint =
ABS( sin( plsc->diorot *
PI / 2. ) );
2030 aspect = plsc->aspect;
2032 aspect = plsc->aspdev;
2034 if ( plsc->freeaspect )
2035 plsc->aspori = aspect;
2037 plsc->aspori = ( aspect * cost + sint ) / ( aspect * sint + cost );
2039 if ( !( plsc->difilt &
PLDI_DEV ) )
2084 plsc->dioxax = affine_result[0];
2085 plsc->dioxay = affine_result[2];
2086 plsc->dioxb = affine_result[4];
2087 plsc->dioyax = affine_result[1];
2088 plsc->dioyay = affine_result[3];
2089 plsc->dioyb = affine_result[5];
2101 *p_rot = plsc->diorot;
2117 plsetvar( plsc->dimxmin, dimxmin );
2118 plsetvar( plsc->dimxmax, dimxmax );
2119 plsetvar( plsc->dimymin, dimymin );
2120 plsetvar( plsc->dimymax, dimymax );
2121 plsetvar( plsc->dimxpmm, dimxpmm );
2122 plsetvar( plsc->dimypmm, dimypmm );
2141 PLINT pxmin, pxmax, pymin, pymax;
2142 PLFLT dimxlen, dimylen, pxlen, pylen;
2144 if ( ( plsc->dimxmin == plsc->phyxmi ) && ( plsc->dimxmax == plsc->phyxma ) &&
2145 ( plsc->dimymin == plsc->phyymi ) && ( plsc->dimymax == plsc->phyyma ) &&
2146 ( plsc->dimxpmm == plsc->xpmm ) && ( plsc->dimypmm == plsc->ypmm ) )
2154 lx = ( plsc->dimxmax - plsc->dimxmin + 1 ) / plsc->dimxpmm;
2155 ly = ( plsc->dimymax - plsc->dimymin + 1 ) / plsc->dimypmm;
2157 plsc->aspdev = lx / ly;
2161 dimxlen = plsc->dimxmax - plsc->dimxmin;
2162 dimylen = plsc->dimymax - plsc->dimymin;
2164 pxmin = plsc->phyxmi;
2165 pxmax = plsc->phyxma;
2166 pymin = plsc->phyymi;
2167 pymax = plsc->phyyma;
2168 pxlen = pxmax - pxmin;
2169 pylen = pymax - pymin;
2171 plsc->dimxax = pxlen / dimxlen;
2172 plsc->dimyay = pylen / dimylen;
2173 plsc->dimxb = pxmin - pxlen * plsc->dimxmin / dimxlen;
2174 plsc->dimyb = pymin - pylen * plsc->dimymin / dimylen;
2186 if ( plsc->dev_flush )
2189 if ( !plsc->stream_closed )
2191 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
2198 if ( plsc->OutFile != NULL )
2199 fflush( plsc->OutFile );
2222 #ifdef ENABLE_DYNDRIVERS
2244 if ( plsc->level != 0 )
2263 if ( plsc->level != 0 )
2281 PLFLT lx, ly, xpmm_loc, ypmm_loc, aspect_old, aspect_new;
2285 if ( plsc->level != 0 )
2301 if ( plsc->plwindow == NULL )
2303 if ( plsc->program )
2305 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) ( 1 + strlen( plsc->program ) ) * sizeof (
char ) ) ) == NULL )
2307 plexit(
"plinit: Insufficient memory" );
2309 strcpy( plsc->plwindow, plsc->program );
2313 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) 7 *
sizeof (
char ) ) ) == NULL )
2315 plexit(
"plinit: Insufficient memory" );
2317 strcpy( plsc->plwindow,
"PLplot" );
2344 if ( plsc->aspect > 0. )
2346 lx = plsc->phyxlen / plsc->xpmm;
2347 ly = plsc->phyylen / plsc->ypmm;
2348 aspect_old = lx / ly;
2349 aspect_new = plsc->aspect;
2350 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2354 else if ( plsc->freeaspect &&
ABS( cos( plsc->diorot *
PI / 2. ) ) <= 1.e-5 )
2356 lx = plsc->phyxlen / plsc->xpmm;
2357 ly = plsc->phyylen / plsc->ypmm;
2358 aspect_old = lx / ly;
2359 aspect_new = ly / lx;
2360 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2364 plsc->caspfactor = 1.;
2378 if ( plsc->xdigmax == 0 )
2381 if ( plsc->ydigmax == 0 )
2384 if ( plsc->zdigmax == 0 )
2387 if ( plsc->timefmt == NULL )
2393 if ( plsc->qsasconfig == NULL )
2394 c_plconfigtime( 0., 0., 0., 0x0, 0, 0, 0, 0, 0, 0, 0. );
2409 plsc->clpxmi = plsc->phyxmi;
2410 plsc->clpxma = plsc->phyxma;
2411 plsc->clpymi = plsc->phyymi;
2412 plsc->clpyma = plsc->phyyma;
2416 lx = plsc->phyxlen / plsc->xpmm;
2417 ly = plsc->phyylen / plsc->ypmm;
2418 plsc->aspdev = lx / ly;
2431 plP_setpxl( xpmm_loc * plsc->caspfactor, ypmm_loc / plsc->caspfactor );
2450 if (
pls[i] != NULL )
2457 #ifdef ENABLE_DYNDRIVERS
2463 free_mem( loadable_device_list[i].devnam );
2464 free_mem( loadable_device_list[i].description );
2465 free_mem( loadable_device_list[i].drvnam );
2466 free_mem( loadable_device_list[i].tag );
2469 for ( i = 0; i < nloadabledrivers; i++ )
2471 free_mem( loadable_driver_list[i].drvnam );
2501 if ( plsc->level > 0 )
2508 if ( plsc->FileName )
2521 if ( plsc->program )
2523 if ( plsc->server_name )
2525 if ( plsc->server_host )
2527 if ( plsc->server_port )
2531 if ( plsc->plserver )
2533 if ( plsc->auto_path )
2536 if ( plsc->arrow_x )
2538 if ( plsc->arrow_y )
2541 if ( plsc->timefmt )
2550 if ( plsc->mf_infile )
2552 if ( plsc->mf_outfile )
2582 "plsstrm: Illegal stream number %d, must be in [0, %d]\n",
2592 plexit(
"plsstrm: Out of memory." );
2633 if (
pls[i] == NULL )
2637 if ( i == PL_NSTREAMS )
2639 fprintf( stderr,
"plmkstrm: Cannot create new stream\n" );
2669 if ( !plsc->initialized )
2671 plsc->initialized = 1;
2673 if ( plsc->cmap0 == NULL )
2676 if ( plsc->cmap1 == NULL )
2680 plsc->cmap1_min = 0.0;
2681 plsc->cmap1_max = 1.0;
2725 fprintf( stderr,
"plcpstrm: stream %d not in use\n", (
int) iplsr );
2731 plsc->debug = plsr->
debug;
2739 if ( ( plsc->plbuf_buffer = malloc( plsc->plbuf_buffer_size ) ) == NULL )
2740 plexit(
"plcpstrm: Error allocating plot buffer." );
2757 if ( !( flags & 0x01 ) )
2759 pldebug(
"plcpstrm",
"mapping parameters: %d %d %d %d %f %f\n",
2772 plsc->icol0 = plsr->
icol0;
2773 plsc->ncol0 = plsr->
ncol0;
2774 if ( plsc->cmap0 != NULL )
2775 free( (
void *) plsc->cmap0 );
2777 if ( ( plsc->cmap0 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol0 * sizeof (
PLColor ) ) ) == NULL )
2779 plexit(
"c_plcpstrm: Insufficient memory" );
2782 for ( i = 0; i < plsc->ncol0; i++ )
2787 plsc->icol1 = plsr->
icol1;
2788 plsc->ncol1 = plsr->
ncol1;
2791 if ( plsc->cmap1 != NULL )
2792 free( (
void *) plsc->cmap1 );
2794 if ( ( plsc->cmap1 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol1 * sizeof (
PLColor ) ) ) == NULL )
2796 plexit(
"c_plcpstrm: Insufficient memory" );
2799 for ( i = 0; i < plsc->ncol1; i++ )
2804 if ( plsc->level == 0 )
2832 if ( plsc->dev_initialized )
2834 plsc->dev_initialized = 1;
2846 static int inited = 0;
2847 static int inBuildTree = 0;
2851 int len_currdir, len_builddir;
2858 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2869 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2873 len_currdir = strlen( currdir );
2874 len_builddir = strlen( builddir );
2875 #if defined ( _MSC_VER )
2878 for (; *pcurrdir; ++pcurrdir )
2879 *pcurrdir = tolower( *pcurrdir );
2880 for (; *pbuilddir; ++pbuilddir )
2881 *pbuilddir = tolower( *pbuilddir );
2882 #define PLPLOT_PATH_DELIMITER '\\'
2884 #define PLPLOT_PATH_DELIMITER '/'
2894 if ( strncmp( builddir, currdir, len_builddir ) == 0 &&
2900 if ( chdir( currdir ) != 0 )
2901 pldebug(
"plInBuildTree():",
"Unable to chdir to current directory" );
2909 #ifdef ENABLE_DYNDRIVERS
2923 pldebug(
"plGetDrvDir",
"Using %s as the driver directory.\n", drvdir );
2927 pldebug(
"plGetDrvDir",
"Trying to read env var PLPLOT_DRV_DIR\n" );
2928 drvdir = getenv(
"PLPLOT_DRV_DIR" );
2930 if ( drvdir == NULL )
2932 pldebug(
"plGetDrvDir",
2933 "Will use drivers dir: " DRV_DIR "\n" );
2966 #ifdef ENABLE_DYNDRIVERS
2968 const char * drvdir;
2969 char *devnam, *devdesc, *devtype, *driver, *tag, *seqstr;
2971 int i, j, driver_found, done = 0;
2972 FILE *fp_drvdb = NULL;
2973 DIR * dp_drvdir = NULL;
2979 nloadabledrivers = 0;
2984 if ( fp_drvdb == NULL )
2986 plabort(
"plInitDispatchTable: Could not open temporary file" );
2991 drvdir = plGetDrvDir();
2992 dp_drvdir =
opendir( drvdir );
2993 if ( dp_drvdir == NULL )
2996 plabort(
"plInitDispatchTable: Could not open drivers directory" );
3002 pldebug(
"plInitDispatchTable",
"Scanning dyndrivers dir\n" );
3003 while ( ( entry =
readdir( dp_drvdir ) ) != NULL )
3007 size_t len = strlen( name ) - 12;
3009 pldebug(
"plInitDispatchTable",
3010 "Consider file %s\n", name );
3013 if ( ( len > 0 ) && ( strcmp( name + len,
".driver_info" ) == 0 ) )
3020 fd = fopen( path,
"r" );
3026 "plInitDispatchTable: Could not open driver info file %s\n",
3036 pldebug(
"plInitDispatchTable",
3037 "Opened driver info file %s\n", name );
3040 fprintf( fp_drvdb,
"%s", buf );
3041 if ( buf [strlen( buf ) - 1] !=
'\n' )
3042 fprintf( fp_drvdb,
"\n" );
3060 #ifdef ENABLE_DYNDRIVERS
3063 plexit(
"plInitDispatchTable: Insufficient memory" );
3075 #ifdef ENABLE_DYNDRIVERS
3078 plexit(
"plInitDispatchTable: Insufficient memory" );
3085 #ifdef ENABLE_DYNDRIVERS
3090 if ( ( ( loadable_device_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDevice ) ) ) == NULL ) ||
3091 ( ( loadable_driver_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDriver ) ) ) == NULL ) )
3094 plexit(
"plInitDispatchTable: Insufficient memory" );
3111 devnam = strtok( buf,
":" );
3112 devdesc = strtok( 0,
":" );
3113 devtype = strtok( 0,
":" );
3114 driver = strtok( 0,
":" );
3115 seqstr = strtok( 0,
":" );
3116 tag = strtok( 0,
"\n" );
3118 if ( devnam == NULL || devdesc == NULL || devtype == NULL || driver == NULL ||
3119 seqstr == NULL || tag == NULL )
3124 seq = atoi( seqstr );
3131 plexit(
"plInitDispatchTable: Insufficient memory" );
3149 loadable_device_list[i].devnam =
plstrdup( devnam );
3150 loadable_device_list[i].description =
plstrdup( devdesc );
3151 loadable_device_list[i].drvnam =
plstrdup( driver );
3152 loadable_device_list[i].tag =
plstrdup( tag );
3157 for ( j = 0; j < nloadabledrivers; j++ )
3158 if ( strcmp( driver, loadable_driver_list[j].drvnam ) == 0 )
3164 if ( !driver_found )
3166 loadable_driver_list[nloadabledrivers].drvnam =
plstrdup( driver );
3167 loadable_driver_list[nloadabledrivers].dlhand = 0;
3171 loadable_device_list[i].drvidx = j;
3185 plexit(
"No device drivers found - please check the environment variable PLPLOT_DRV_DIR" );
3216 if ( plsc->DevName[0] ==
'\0' )
3218 devname_env = getenv(
"PLPLOT_DEV" );
3221 strncpy( plsc->DevName, devname_env, sizeof ( plsc->DevName ) - 1 );
3222 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3228 if ( *( plsc->DevName ) !=
'\0' && *( plsc->DevName ) !=
'?' )
3230 length = strlen( plsc->DevName );
3234 ( strncmp( plsc->DevName,
3238 if ( i < npldrivers )
3240 plsc->device = i + 1;
3245 fprintf( stderr,
"Requested device %s not available\n",
3260 fprintf( stdout,
"\nPlotting Options:\n" );
3263 fprintf( stdout,
" <%2d> %-10s %s\n", i + 1,
3268 fprintf( stdout,
"\nEnter device number or keyword: " );
3270 fprintf( stdout,
"\nEnter device number or keyword (stream %d): ",
3273 plio_fgets( response,
sizeof ( response ), stdin );
3278 length = strlen( response );
3279 if ( *( response - 1 + length ) ==
'\n' )
3285 (
unsigned int) length ) )
3288 if ( i < npldrivers )
3294 if ( ( dev = atoi( response ) ) < 1 )
3296 fprintf( stdout,
"\nInvalid device: %s", response );
3301 plexit(
"plSelectDev: Too many tries." );
3318 #ifdef ENABLE_DYNDRIVERS
3323 int n = plsc->device - 1;
3325 PLLoadableDriver *driver = 0;
3333 pldebug(
"plLoadDriver",
"Device not loaded!\n" );
3338 if ( strcmp( dev->
pl_DevName, loadable_device_list[i].devnam ) == 0 )
3344 if ( i == npldynamicdevices )
3346 fprintf( stderr,
"No such device: %s.\n", dev->
pl_DevName );
3347 plexit(
"plLoadDriver detected device logic screwup" );
3353 tag = loadable_device_list[i].tag;
3354 drvidx = loadable_device_list[i].drvidx;
3356 pldebug(
"plLoadDriver",
"tag=%s, drvidx=%d\n", tag, drvidx );
3358 driver = &loadable_driver_list[drvidx];
3361 if ( !driver->dlhand )
3364 #if defined ( LTDL_WIN32 ) || defined ( __CYGWIN__ )
3368 #endif // LTDL_WIN32
3370 pldebug(
"plLoadDriver",
"Trying to load %s on %s\n",
3371 driver->drvnam, drvspec );
3382 if ( !( strcmp( driver->drvnam,
"mem" ) == 0 ||
3383 strcmp( driver->drvnam,
"null" ) == 0 ||
3384 strcmp( driver->drvnam,
"plmeta" ) == 0 ||
3385 strcmp( driver->drvnam,
"ps" ) == 0 ||
3386 strcmp( driver->drvnam,
"svg" ) == 0 ||
3387 strcmp( driver->drvnam,
"xfig" ) == 0 ) )
3392 if ( !driver->dlhand )
3394 pldebug(
"plLoadDriver",
"lt_dlopenext failed because of "
3395 "the following reason:\n%s\n",
lt_dlerror() );
3396 fprintf( stderr,
"Unable to load driver: %s.\n", driver->drvnam );
3397 plexit(
"Unable to load driver" );
3406 if ( !dispatch_init )
3409 "Unable to locate dispatch table initialization function for driver: %s.\n",
3414 ( *dispatch_init )( dev );
3431 if ( plsc->level > 0 )
3446 if ( plsc->plbuf_buffer != NULL )
3452 plwarn(
"plreplot: plot buffer not available" );
3468 plgFileDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3470 plgdevlst( *p_menustr, *p_devname, p_ndev, 0 );
3480 plgDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3482 plgdevlst( *p_menustr, *p_devname, p_ndev, -1 );
3486 plgdevlst(
const char **p_menustr,
const char **p_devname,
int *p_ndev,
int type )
3498 if ( ++j + 1 >= *p_ndev )
3500 plwarn(
"plgdevlst: too many devices" );
3505 p_menustr[j] = NULL;
3506 p_devname[j] = NULL;
3522 *p_xleng = plsc->xlength;
3523 *p_yleng = plsc->ylength;
3524 *p_xoff = plsc->xoffset;
3525 *p_yoff = plsc->yoffset;
3533 if ( plsc->level > 0 )
3534 plwarn(
"calling plspage() after plinit() may give unpredictable results" );
3542 plsc->xlength = xleng;
3544 plsc->ylength = yleng;
3547 plsc->xoffset = xoff;
3549 plsc->yoffset = yoff;
3566 if ( plsc->level > 0 )
3579 if ( plsc->level > 0 )
3581 plwarn(
"plsdev: Must be called before plinit." );
3584 if ( devname != NULL )
3586 strncpy( plsc->DevName, devname, sizeof ( plsc->DevName ) - 1 );
3587 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3597 strcpy( p_dev, plsc->DevName );
3612 plsc->dev = plotmem;
3613 plsc->dev_mem_alpha = 0;
3622 plsc->dev = plotmem;
3623 plsc->dev_mem_alpha = 1;
3646 *p_level = plsc->level;
3655 plsc->KeyEH = KeyEH;
3656 plsc->KeyEH_data = KeyEH_data;
3663 void *ButtonEH_data )
3665 plsc->ButtonEH = ButtonEH;
3666 plsc->ButtonEH_data = ButtonEH_data;
3672 plsbopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3674 plsc->bop_handler = handler;
3675 plsc->bop_data = handler_data;
3681 plseopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3683 plsc->eop_handler = handler;
3684 plsc->eop_data = handler_data;
3692 if ( errcode != NULL )
3693 plsc->errcode = errcode;
3695 if ( errmsg != NULL )
3716 if ( width != plsc->width && width >= 0. )
3718 plsc->width = width;
3720 if ( plsc->level > 0 )
3722 if ( !plsc->widthlock )
3733 *p_file = plsc->OutFile;
3741 plsc->OutFile = file;
3752 plabort(
"filename string must be preallocated to >=80 bytes" );
3757 if ( plsc->FileName != NULL )
3759 strncpy( fnam, plsc->FileName, 79 );
3783 plsc->dev_data =
data;
3799 plsc->setpre = setp;
3800 plsc->precis = prec;
3808 *p_setp = plsc->setpre;
3809 *p_prec = plsc->precis;
3815 return (
const char *) plsc->timefmt;
3844 plwarn(
"plsesc: Invalid escape character, ignoring." );
3853 if ( plsc->esc ==
'\0' )
3887 *pfci = *pfci & mask;
3889 *pfci = *pfci | mask;
3900 *phexdigit = (
unsigned char) ( ( fci & mask ) >>
3917 plsc->window_id = window_id;
3934 *p_fam = plsc->family;
3935 *p_num = plsc->member;
3936 *p_bmax = plsc->bytemax;
3944 if ( plsc->level > 0 )
3945 plwarn(
"plsfam: Must be called before plinit." );
3952 plsc->bytemax = bmax;
3973 *p_digmax = plsc->xdigmax;
3974 *p_digits = plsc->xdigits;
3982 plsc->xdigmax = digmax;
3983 plsc->xdigits = digits;
3991 *p_digmax = plsc->ydigmax;
3992 *p_digits = plsc->ydigits;
4000 plsc->ydigmax = digmax;
4001 plsc->ydigits = digits;
4009 *p_digmax = plsc->zdigmax;
4010 *p_digits = plsc->zdigits;
4018 plsc->zdigmax = digmax;
4019 plsc->zdigits = digits;
4027 *p_def = plsc->chrdef;
4028 *p_ht = plsc->chrht;
4036 *p_xmin = plsc->vpdxmi;
4037 *p_xmax = plsc->vpdxma;
4038 *p_ymin = plsc->vpdymi;
4039 *p_ymax = plsc->vpdyma;
4047 *p_xmin = plsc->vpwxmi;
4048 *p_xmax = plsc->vpwxma;
4049 *p_ymin = plsc->vpwymi;
4050 *p_ymax = plsc->vpwyma;
4059 dx = ( plsc->vpwxma - plsc->vpwxmi ) * 1.0e-5;
4060 dy = ( plsc->vpwyma - plsc->vpwymi ) * 1.0e-5;
4065 *p_xmin = plsc->vpwxmi -
dx;
4066 *p_xmax = plsc->vpwxma +
dx;
4067 *p_ymin = plsc->vpwymi -
dy;
4068 *p_ymax = plsc->vpwyma +
dy;
4080 *p_xmin = plsc->domxmi;
4081 *p_xmax = plsc->domxma;
4082 *p_ymin = plsc->domymi;
4083 *p_ymax = plsc->domyma;
4091 *p_zscl = plsc->zzscl;
4092 *p_zmin = plsc->ranmi;
4093 *p_zmax = plsc->ranma;
4113 *p_ixmin = plsc->clpxmi;
4114 *p_ixmax = plsc->clpxma;
4115 *p_iymin = plsc->clpymi;
4116 *p_iymax = plsc->clpyma;
4124 plsc->clpxmi = ixmin;
4125 plsc->clpxma = ixmax;
4126 plsc->clpymi = iymin;
4127 plsc->clpyma = iymax;
4135 *p_ixmin = plsc->phyxmi;
4136 *p_ixmax = plsc->phyxma;
4137 *p_iymin = plsc->phyymi;
4138 *p_iymax = plsc->phyyma;
4146 *p_nx = plsc->nsubx;
4147 *p_ny = plsc->nsuby;
4148 *p_cs = plsc->cursub;
4177 plsc->umx = (
PLINT) ( 1000.0 / plsc->xpmm );
4178 plsc->umy = (
PLINT) ( 1000.0 / plsc->ypmm );
4186 if ( xmin > xmax || ymin > ymax )
4187 plexit(
"plP_setphy: device minima must not exceed maxima" );
4189 plsc->phyxmi =
xmin;
4190 plsc->phyxma =
xmax;
4191 plsc->phyymi =
ymin;
4192 plsc->phyyma =
ymax;
4193 plsc->phyxlen = xmax -
xmin;
4194 plsc->phyylen = ymax -
ymin;
4207 if ( plsc->level <= 0 )
4209 plsc->dev_compression = compression;
4222 *compression = plsc->dev_compression;
4243 if (
pls[i] != NULL )
4246 strcpy( names,
pls[i]->DevName );
4249 strcat( names,
" " );
4250 strcat( names,
pls[i]->DevName );
4273 buff = (
char *) malloc( (
size_t)
PL_NSTREAMS * 8 );
4281 for ( tok = strtok( buff,
" ," );
4282 tok; tok = strtok( 0,
" ," ) )
4284 if ( strstr( names, tok ) != NULL )
4326 #if 0 // BEGIN dev_fastimg COMMENT
4333 if ( plsc->dev_fastimg == 0 )
4336 xmin, ymin, dx, dy, zmin, zmax );
4340 if ( plsc->plbuf_write )
4352 plsc->dev_nptsX = nx;
4353 plsc->dev_nptsY = ny;
4354 plsc->dev_zmin = zmin;
4355 plsc->dev_zmax = zmax;
4361 plbuf_write = plsc->plbuf_write;
4362 plsc->plbuf_write = 0;
4367 PLINT clpxmi, clpxma, clpymi, clpyma;
4369 if ( ( ( xscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) ||
4370 ( ( yscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) )
4372 plexit(
"plP_image: Insufficient memory" );
4375 for ( i = 0; i < npts; i++ )
4380 sdifilt( xscl, yscl, npts, &clpxmi, &clpxma, &clpymi, &clpyma );
4381 plsc->imclxmin = clpxmi;
4382 plsc->imclymin = clpymi;
4383 plsc->imclxmax = clpxma;
4384 plsc->imclymax = clpyma;
4385 grimage( xscl, yscl, z, nx, ny );
4391 plsc->imclxmin = plsc->phyxmi;
4392 plsc->imclymin = plsc->phyymi;
4393 plsc->imclxmax = plsc->phyxma;
4394 plsc->imclymax = plsc->phyyma;
4398 #endif // END dev_fastimg COMMENT
4410 plsc->coordinate_transform = coordinate_transform;
4411 plsc->coordinate_transform_data = coordinate_transform_data;