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 )
1079 #ifdef HAVE_LIBUNICODE
1080 const char * ptr = unicode_get_utf8(
string + i, &unichar );
1082 const char * ptr =
utf8_to_ucs4(
string + i, &unichar );
1088 strncpy( tmpstring,
string, 30 );
1089 tmpstring[30] =
'\0';
1091 tmpstring, strlen(
string ) > 30 ?
"[...]" :
"" );
1095 i += (int) ( ptr - (
string + i ) - 1 );
1100 if (
string[i] == esc &&
string[i + 1] == esc )
1122 if ( plsc->dev_unicode )
1138 plstr( base, xform, refx, refy,
string );
1158 if ( (
unsigned char) ( tmp & 0x80 ) == 0x00 )
1160 *unichar = (
unsigned int) tmp & 0x7F;
1163 else if ( (
unsigned char) ( tmp & 0xE0 ) == 0xC0 )
1165 *unichar = (
unsigned int) tmp & 0x1F;
1168 else if ( (
unsigned char) ( tmp & 0xF0 ) == 0xE0 )
1170 *unichar = (
unsigned char) tmp & 0x0F;
1173 else if ( (
unsigned char) ( tmp & 0xF8 ) == 0xF0 )
1175 *unichar = (
unsigned char) tmp & 0x07;
1178 else if ( (
unsigned char) ( tmp & 0xFC ) == 0xF8 )
1180 *unichar = (
unsigned char) tmp & 0x03;
1183 else if ( (
unsigned char) ( tmp & 0xFE ) == 0xFC )
1185 *unichar = (
unsigned char) tmp & 0x01;
1196 if ( (
unsigned char) ( tmp & 0xC0 ) == 0x80 )
1198 *unichar = ( *unichar << 6 ) | ( (
unsigned int) tmp & 0x3F );
1207 }
while ( cnt > 0 );
1218 tmp = (
unsigned char *) ptr;
1220 if ( ( unichar & 0xffff80 ) == 0 )
1222 *tmp = (
unsigned char) unichar;
1226 else if ( ( unichar & 0xfff800 ) == 0 )
1228 *tmp = (
unsigned char) 0xc0 | (
unsigned char) ( unichar >> 6 );
1230 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & (
PLUINT) 0x3f ) );
1234 else if ( ( unichar & 0xff0000 ) == 0 )
1236 *tmp = (
unsigned char) 0xe0 | (
unsigned char) ( unichar >> 12 );
1238 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1240 *tmp = (
unsigned char) ( 0x80 | ( (
unsigned char) unichar & 0x3f ) );
1244 else if ( ( unichar & 0xe0000 ) == 0 )
1246 *tmp = (
unsigned char) 0xf0 | (
unsigned char) ( unichar >> 18 );
1248 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 12 ) & 0x3f ) );
1250 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( ( unichar >> 6 ) & 0x3f ) );
1252 *tmp = (
unsigned char) ( 0x80 | (
unsigned char) ( unichar & 0x3f ) );
1269 if ( !plsc->stream_closed )
1271 ( *plsc->dispatch_table->pl_line )( (
struct PLStream_struct *) plsc,
1272 x[0], y[0], x[1], y[1] );
1281 if ( !plsc->stream_closed )
1283 ( *plsc->dispatch_table->pl_polyline )( (
struct PLStream_struct *) plsc,
1293 plsc->dev_npts = npts;
1298 if ( !plsc->stream_closed )
1300 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1310 plsc->dev_npts = npts;
1315 if ( !plsc->stream_closed )
1317 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1353 for ( i = 0; i < npts; i++ )
1355 xsc[i] = (
PLINT) ( plsc->dimxax * xsc[i] + plsc->dimxb );
1356 ysc[i] = (
PLINT) ( plsc->dimyay * ysc[i] + plsc->dimyb );
1364 for ( i = 0; i < npts; i++ )
1366 x = (
PLINT) ( plsc->dioxax * xsc[i] + plsc->dioxay * ysc[i] + plsc->dioxb );
1367 y = (
PLINT) ( plsc->dioyax * xsc[i] + plsc->dioyay * ysc[i] + plsc->dioyb );
1377 for ( i = 0; i < npts; i++ )
1379 xsc[i] = (
PLINT) ( plsc->dipxax * xsc[i] + plsc->dipxb );
1380 ysc[i] = (
PLINT) ( plsc->dipyay * ysc[i] + plsc->dipyb );
1389 for ( i = 0; i < npts; i++ )
1391 xsc[i] = (
PLINT) ( plsc->didxax * xsc[i] + plsc->didxb );
1392 ysc[i] = (
PLINT) ( plsc->didyay * ysc[i] + plsc->didyb );
1394 *clpxmi = plsc->diclpxmi;
1395 *clpxma = plsc->diclpxma;
1396 *clpymi = plsc->diclpymi;
1397 *clpyma = plsc->diclpyma;
1401 *clpxmi = plsc->phyxmi;
1402 *clpxma = plsc->phyxma;
1403 *clpymi = plsc->phyymi;
1404 *clpyma = plsc->phyyma;
1489 PLINT x1c, x2c, y1c, y2c;
1503 difilt( x_coords, y_coords, 4, &x1c, &x2c, &y1c, &y2c );
1517 plsc->dipxmin = 0.0;
1518 plsc->dipxmax = 1.0;
1519 plsc->dipymin = 0.0;
1520 plsc->dipymax = 1.0;
1541 if ( plsc->level >= 1 )
1575 PLFLT pxmin, pymin, pxmax, pymax;
1576 PLFLT sxmin, symin, sxmax, symax;
1577 PLFLT rxmin, rymin, rxmax, rymax;
1581 pldebug(
"pldid2pc",
1582 "Relative device coordinates (in): %f, %f, %f, %f\n",
1583 *xmin, *ymin, *xmax, *ymax );
1590 sxmin = ( pxmin - plsc->didxb ) / plsc->didxax;
1591 symin = ( pymin - plsc->didyb ) / plsc->didyay;
1592 sxmax = ( pxmax - plsc->didxb ) / plsc->didxax;
1593 symax = ( pymax - plsc->didyb ) / plsc->didyay;
1600 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1601 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1602 *ymin = ( rymin < 0 ) ? 0 : rymin;
1603 *ymax = ( rymax > 1 ) ? 1 : rymax;
1605 pldebug(
"pldid2pc",
1606 "Relative plot coordinates (out): %f, %f, %f, %f\n",
1607 rxmin, rymin, rxmax, rymax );
1621 PLFLT pxmin, pymin, pxmax, pymax;
1622 PLFLT sxmin, symin, sxmax, symax;
1623 PLFLT rxmin, rymin, rxmax, rymax;
1627 pldebug(
"pldip2pc",
1628 "Relative plot coordinates (in): %f, %f, %f, %f\n",
1629 *xmin, *ymin, *xmax, *ymax );
1636 sxmin = pxmin * plsc->didxax + plsc->didxb;
1637 symin = pymin * plsc->didyay + plsc->didyb;
1638 sxmax = pxmax * plsc->didxax + plsc->didxb;
1639 symax = pymax * plsc->didyay + plsc->didyb;
1646 *xmin = ( rxmin < 0 ) ? 0 : rxmin;
1647 *xmax = ( rxmax > 1 ) ? 1 : rxmax;
1648 *ymin = ( rymin < 0 ) ? 0 : rymin;
1649 *ymax = ( rymax > 1 ) ? 1 : rymax;
1651 pldebug(
"pldip2pc",
1652 "Relative device coordinates (out): %f, %f, %f, %f\n",
1653 rxmin, rymin, rxmax, rymax );
1666 plsc->dipxmin = ( xmin <
xmax ) ? xmin : xmax;
1667 plsc->dipxmax = ( xmin <
xmax ) ? xmax : xmin;
1668 plsc->dipymin = ( ymin <
ymax ) ? ymin : ymax;
1669 plsc->dipymax = ( ymin <
ymax ) ? ymax : ymin;
1671 if ( xmin == 0. && xmax == 1. && ymin == 0. && ymax == 1. )
1692 xmin = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmin;
1693 ymin = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymin;
1694 xmax = plsc->dipxmin + ( plsc->dipxmax - plsc->dipxmin ) * xmax;
1695 ymax = plsc->dipymin + ( plsc->dipymax - plsc->dipymin ) * ymax;
1698 plsdiplt( xmin, ymin, xmax, ymax );
1715 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1720 if ( !plsc->stream_closed )
1722 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1728 if ( !( plsc->difilt &
PLDI_PLT ) )
1736 pxlen = pxmax - pxmin;
1737 pylen = pymax - pymin;
1738 pxlen =
MAX( 1, pxlen );
1739 pylen =
MAX( 1, pylen );
1741 plsc->dipxax = plsc->phyxlen / (double) pxlen;
1742 plsc->dipyay = plsc->phyylen / (double) pylen;
1743 plsc->dipxb = plsc->phyxmi - plsc->dipxax * pxmin;
1744 plsc->dipyb = plsc->phyymi - plsc->dipyay * pymin;
1756 *p_xmin = plsc->dipxmin;
1757 *p_xmax = plsc->dipxmax;
1758 *p_ymin = plsc->dipymin;
1759 *p_ymax = plsc->dipymax;
1781 if ( mar == 0. && aspect == 0. && jx == 0. && jy == 0. &&
1802 PLFLT lx, ly, aspect, aspdev;
1804 PLINT pxmin, pxmax, pymin, pymax, pxlen, pylen;
1809 if ( !plsc->stream_closed )
1811 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1817 if ( !( plsc->difilt &
PLDI_DEV ) )
1822 lx = plsc->phyxlen / plsc->xpmm;
1823 ly = plsc->phyylen / plsc->ypmm;
1827 aspect = plsc->aspori;
1829 aspect = plsc->aspect;
1832 aspect = plsc->aspdev;
1836 plsc->mar = ( plsc->mar > 0.5 ) ? 0.5 : plsc->mar;
1837 plsc->mar = ( plsc->mar < 0.0 ) ? 0.0 : plsc->mar;
1838 plsc->jx = ( plsc->jx > 0.5 ) ? 0.5 : plsc->jx;
1839 plsc->jx = ( plsc->jx < -0.5 ) ? -0.5 : plsc->jx;
1840 plsc->jy = ( plsc->jy > 0.5 ) ? 0.5 : plsc->jy;
1841 plsc->jy = ( plsc->jy < -0.5 ) ? -0.5 : plsc->jy;
1845 xlen = ( aspect < aspdev ) ? ( aspect / aspdev ) : 1.0;
1846 ylen = ( aspect < aspdev ) ? 1.0 : ( aspdev / aspect );
1848 xlen *= ( 1.0 - 2. * plsc->mar );
1849 ylen *= ( 1.0 - 2. * plsc->mar );
1851 xmin = ( 1. - xlen ) * ( 0.5 + plsc->jx );
1854 ymin = ( 1. - ylen ) * ( 0.5 + plsc->jy );
1864 pxlen = pxmax - pxmin;
1865 pylen = pymax - pymin;
1866 pxlen =
MAX( 1, pxlen );
1867 pylen =
MAX( 1, pylen );
1869 plsc->didxax = pxlen / (double) plsc->phyxlen;
1870 plsc->didyay = pylen / (
double) plsc->phyylen;
1871 plsc->didxb = pxmin - plsc->didxax * plsc->phyxmi;
1872 plsc->didyb = pymin - plsc->didyay * plsc->phyymi;
1876 plsc->diclpxmi = (
PLINT) ( plsc->didxax * plsc->phyxmi + plsc->didxb );
1877 plsc->diclpxma = (
PLINT) ( plsc->didxax * plsc->phyxma + plsc->didxb );
1878 plsc->diclpymi = (
PLINT) ( plsc->didyay * plsc->phyymi + plsc->didyb );
1879 plsc->diclpyma = (
PLINT) ( plsc->didyay * plsc->phyyma + plsc->didyb );
1892 *p_aspect = plsc->aspect;
1929 PLFLT x0, y0, lx, ly, aspect;
1935 if ( !plsc->stream_closed )
1937 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
1943 if ( !( plsc->difilt &
PLDI_ORI ) )
1948 x0 = ( plsc->phyxma + plsc->phyxmi ) / 2.;
1949 y0 = ( plsc->phyyma + plsc->phyymi ) / 2.;
1953 cost =
ABS( cos( plsc->diorot *
PI / 2. ) );
1954 sint =
ABS( sin( plsc->diorot *
PI / 2. ) );
1958 aspect = plsc->aspect;
1960 aspect = plsc->aspdev;
1962 if ( plsc->freeaspect )
1963 plsc->aspori = aspect;
1965 plsc->aspori = ( aspect * cost + sint ) / ( aspect * sint + cost );
1967 if ( !( plsc->difilt &
PLDI_DEV ) )
2012 plsc->dioxax = affine_result[0];
2013 plsc->dioxay = affine_result[2];
2014 plsc->dioxb = affine_result[4];
2015 plsc->dioyax = affine_result[1];
2016 plsc->dioyay = affine_result[3];
2017 plsc->dioyb = affine_result[5];
2029 *p_rot = plsc->diorot;
2045 plsetvar( plsc->dimxmin, dimxmin );
2046 plsetvar( plsc->dimxmax, dimxmax );
2047 plsetvar( plsc->dimymin, dimymin );
2048 plsetvar( plsc->dimymax, dimymax );
2049 plsetvar( plsc->dimxpmm, dimxpmm );
2050 plsetvar( plsc->dimypmm, dimypmm );
2069 PLINT pxmin, pxmax, pymin, pymax;
2070 PLFLT dimxlen, dimylen, pxlen, pylen;
2072 if ( ( plsc->dimxmin == plsc->phyxmi ) && ( plsc->dimxmax == plsc->phyxma ) &&
2073 ( plsc->dimymin == plsc->phyymi ) && ( plsc->dimymax == plsc->phyyma ) &&
2074 ( plsc->dimxpmm == plsc->xpmm ) && ( plsc->dimypmm == plsc->ypmm ) )
2082 lx = ( plsc->dimxmax - plsc->dimxmin + 1 ) / plsc->dimxpmm;
2083 ly = ( plsc->dimymax - plsc->dimymin + 1 ) / plsc->dimypmm;
2085 plsc->aspdev = lx / ly;
2089 dimxlen = plsc->dimxmax - plsc->dimxmin;
2090 dimylen = plsc->dimymax - plsc->dimymin;
2092 pxmin = plsc->phyxmi;
2093 pxmax = plsc->phyxma;
2094 pymin = plsc->phyymi;
2095 pymax = plsc->phyyma;
2096 pxlen = pxmax - pxmin;
2097 pylen = pymax - pymin;
2099 plsc->dimxax = pxlen / dimxlen;
2100 plsc->dimyay = pylen / dimylen;
2101 plsc->dimxb = pxmin - pxlen * plsc->dimxmin / dimxlen;
2102 plsc->dimyb = pymin - pylen * plsc->dimymin / dimylen;
2114 if ( plsc->dev_flush )
2117 if ( !plsc->stream_closed )
2119 ( *plsc->dispatch_table->pl_esc )( (
struct PLStream_struct *) plsc,
2126 if ( plsc->OutFile != NULL )
2127 fflush( plsc->OutFile );
2150 #ifdef ENABLE_DYNDRIVERS
2172 if ( plsc->level != 0 )
2191 if ( plsc->level != 0 )
2209 PLFLT def_arrow_x[6] = { -0.5, 0.5, 0.3, 0.5, 0.3, 0.5 };
2210 PLFLT def_arrow_y[6] = { 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 };
2211 PLFLT lx, ly, xpmm_loc, ypmm_loc, aspect_old, aspect_new;
2212 PLINT inc = 0, del = 2000;
2216 if ( plsc->level != 0 )
2232 if ( plsc->plwindow == NULL )
2234 if ( plsc->program )
2236 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) ( 1 + strlen( plsc->program ) ) * sizeof (
char ) ) ) == NULL )
2238 plexit(
"plinit: Insufficient memory" );
2240 strcpy( plsc->plwindow, plsc->program );
2244 if ( ( plsc->plwindow = (
char *) malloc( (
size_t) 7 *
sizeof (
char ) ) ) == NULL )
2246 plexit(
"plinit: Insufficient memory" );
2248 strcpy( plsc->plwindow,
"PLplot" );
2275 if ( plsc->aspect > 0. )
2277 lx = plsc->phyxlen / plsc->xpmm;
2278 ly = plsc->phyylen / plsc->ypmm;
2279 aspect_old = lx / ly;
2280 aspect_new = plsc->aspect;
2281 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2285 else if ( plsc->freeaspect &&
ABS( cos( plsc->diorot *
PI / 2. ) ) <= 1.e-5 )
2287 lx = plsc->phyxlen / plsc->xpmm;
2288 ly = plsc->phyylen / plsc->ypmm;
2289 aspect_old = lx / ly;
2290 aspect_new = ly / lx;
2291 plsc->caspfactor = sqrt( aspect_old / aspect_new );
2295 plsc->caspfactor = 1.;
2309 if ( plsc->xdigmax == 0 )
2312 if ( plsc->ydigmax == 0 )
2315 if ( plsc->zdigmax == 0 )
2318 if ( plsc->timefmt == NULL )
2324 if ( plsc->qsasconfig == NULL )
2325 c_plconfigtime( 0., 0., 0., 0x0, 0, 0, 0, 0, 0, 0, 0. );
2333 plpat( 1, &inc, &del );
2335 plsvect( def_arrow_x, def_arrow_y, 6, 0 );
2339 plsc->clpxmi = plsc->phyxmi;
2340 plsc->clpxma = plsc->phyxma;
2341 plsc->clpymi = plsc->phyymi;
2342 plsc->clpyma = plsc->phyyma;
2346 lx = plsc->phyxlen / plsc->xpmm;
2347 ly = plsc->phyylen / plsc->ypmm;
2348 plsc->aspdev = lx / ly;
2361 plP_setpxl( xpmm_loc * plsc->caspfactor, ypmm_loc / plsc->caspfactor );
2380 if (
pls[i] != NULL )
2387 #ifdef ENABLE_DYNDRIVERS
2393 free_mem( loadable_device_list[i].devnam );
2394 free_mem( loadable_device_list[i].description );
2395 free_mem( loadable_device_list[i].drvnam );
2396 free_mem( loadable_device_list[i].tag );
2399 for ( i = 0; i < nloadabledrivers; i++ )
2401 free_mem( loadable_driver_list[i].drvnam );
2431 if ( plsc->level > 0 )
2438 if ( plsc->FileName )
2449 #ifndef BUFFERED_FILE
2452 if ( plsc->program )
2454 if ( plsc->server_name )
2456 if ( plsc->server_host )
2458 if ( plsc->server_port )
2462 if ( plsc->plserver )
2464 if ( plsc->auto_path )
2467 if ( plsc->arrow_x )
2469 if ( plsc->arrow_y )
2472 if ( plsc->timefmt )
2507 "plsstrm: Illegal stream number %d, must be in [0, %d]\n",
2517 plexit(
"plsstrm: Out of memory." );
2558 if (
pls[i] == NULL )
2562 if ( i == PL_NSTREAMS )
2564 fprintf( stderr,
"plmkstrm: Cannot create new stream\n" );
2594 if ( !plsc->initialized )
2596 plsc->initialized = 1;
2598 if ( plsc->cmap0 == NULL )
2601 if ( plsc->cmap1 == NULL )
2605 plsc->cmap1_min = 0.0;
2606 plsc->cmap1_max = 1.0;
2650 fprintf( stderr,
"plcpstrm: stream %d not in use\n", (
int) iplsr );
2656 plsc->debug = plsr->
debug;
2661 #ifdef BUFFERED_FILE
2662 plsc->plbufFile = plsr->plbufFile;
2668 if ( ( plsc->plbuf_buffer = malloc( plsc->plbuf_buffer_size ) ) == NULL )
2669 plexit(
"plcpstrm: Error allocating plot buffer." );
2687 if ( !( flags & 0x01 ) )
2689 pldebug(
"plcpstrm",
"mapping parameters: %d %d %d %d %f %f\n",
2702 plsc->icol0 = plsr->
icol0;
2703 plsc->ncol0 = plsr->
ncol0;
2704 if ( plsc->cmap0 != NULL )
2705 free( (
void *) plsc->cmap0 );
2707 if ( ( plsc->cmap0 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol0 * sizeof (
PLColor ) ) ) == NULL )
2709 plexit(
"c_plcpstrm: Insufficient memory" );
2712 for ( i = 0; i < plsc->ncol0; i++ )
2717 plsc->icol1 = plsr->
icol1;
2718 plsc->ncol1 = plsr->
ncol1;
2721 if ( plsc->cmap1 != NULL )
2722 free( (
void *) plsc->cmap1 );
2724 if ( ( plsc->cmap1 = (
PLColor *) calloc( 1, (
size_t) plsc->ncol1 * sizeof (
PLColor ) ) ) == NULL )
2726 plexit(
"c_plcpstrm: Insufficient memory" );
2729 for ( i = 0; i < plsc->ncol1; i++ )
2734 if ( plsc->level == 0 )
2762 if ( plsc->dev_initialized )
2764 plsc->dev_initialized = 1;
2776 static int inited = 0;
2777 static int inBuildTree = 0;
2786 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2797 pldebug(
"plInBuildTree():",
"Not enough buffer space" );
2802 if ( strncmp( builddir + 1, currdir + 1, strlen( builddir + 1 ) ) == 0 &&
2803 tolower( builddir[0] ) == tolower( currdir[0] ) )
2808 if ( chdir( currdir ) != 0 )
2809 pldebug(
"plInBuildTree():",
"Unable to chdir to current directory" );
2817 #ifdef ENABLE_DYNDRIVERS
2831 pldebug(
"plGetDrvDir",
"Using %s as the driver directory.\n", drvdir );
2835 pldebug(
"plGetDrvDir",
"Trying to read env var PLPLOT_DRV_DIR\n" );
2836 drvdir = getenv(
"PLPLOT_DRV_DIR" );
2838 if ( drvdir == NULL )
2840 pldebug(
"plGetDrvDir",
2841 "Will use drivers dir: " DRV_DIR "\n" );
2874 #ifdef ENABLE_DYNDRIVERS
2876 const char * drvdir;
2877 char *devnam, *devdesc, *devtype, *driver, *tag, *seqstr;
2879 int i, j, driver_found, done = 0;
2880 FILE *fp_drvdb = NULL;
2881 DIR * dp_drvdir = NULL;
2887 nloadabledrivers = 0;
2892 if ( fp_drvdb == NULL )
2894 plabort(
"plInitDispatchTable: Could not open temporary file" );
2899 drvdir = plGetDrvDir();
2900 dp_drvdir =
opendir( drvdir );
2901 if ( dp_drvdir == NULL )
2904 plabort(
"plInitDispatchTable: Could not open drivers directory" );
2910 pldebug(
"plInitDispatchTable",
"Scanning dyndrivers dir\n" );
2911 while ( ( entry =
readdir( dp_drvdir ) ) != NULL )
2915 size_t len = strlen( name ) - 12;
2917 pldebug(
"plInitDispatchTable",
2918 "Consider file %s\n", name );
2921 if ( ( len > 0 ) && ( strcmp( name + len,
".driver_info" ) == 0 ) )
2928 fd = fopen( path,
"r" );
2934 "plInitDispatchTable: Could not open driver info file %s\n",
2944 pldebug(
"plInitDispatchTable",
2945 "Opened driver info file %s\n", name );
2948 fprintf( fp_drvdb,
"%s", buf );
2949 if ( buf [strlen( buf ) - 1] !=
'\n' )
2950 fprintf( fp_drvdb,
"\n" );
2968 #ifdef ENABLE_DYNDRIVERS
2971 plexit(
"plInitDispatchTable: Insufficient memory" );
2983 #ifdef ENABLE_DYNDRIVERS
2986 plexit(
"plInitDispatchTable: Insufficient memory" );
2993 #ifdef ENABLE_DYNDRIVERS
2998 if ( ( ( loadable_device_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDevice ) ) ) == NULL ) ||
2999 ( ( loadable_driver_list = malloc( (
size_t)
npldynamicdevices *
sizeof ( PLLoadableDriver ) ) ) == NULL ) )
3002 plexit(
"plInitDispatchTable: Insufficient memory" );
3019 devnam = strtok( buf,
":" );
3020 devdesc = strtok( 0,
":" );
3021 devtype = strtok( 0,
":" );
3022 driver = strtok( 0,
":" );
3023 seqstr = strtok( 0,
":" );
3024 tag = strtok( 0,
"\n" );
3026 if ( devnam == NULL || devdesc == NULL || devtype == NULL || driver == NULL ||
3027 seqstr == NULL || tag == NULL )
3032 seq = atoi( seqstr );
3039 plexit(
"plInitDispatchTable: Insufficient memory" );
3057 loadable_device_list[i].devnam =
plstrdup( devnam );
3058 loadable_device_list[i].description =
plstrdup( devdesc );
3059 loadable_device_list[i].drvnam =
plstrdup( driver );
3060 loadable_device_list[i].tag =
plstrdup( tag );
3065 for ( j = 0; j < nloadabledrivers; j++ )
3066 if ( strcmp( driver, loadable_driver_list[j].drvnam ) == 0 )
3072 if ( !driver_found )
3074 loadable_driver_list[nloadabledrivers].drvnam =
plstrdup( driver );
3075 loadable_driver_list[nloadabledrivers].dlhand = 0;
3079 loadable_device_list[i].drvidx = j;
3093 plexit(
"No device drivers found - please check the environment variable PLPLOT_DRV_DIR" );
3124 if ( plsc->DevName[0] ==
'\0' )
3126 devname_env = getenv(
"PLPLOT_DEV" );
3129 strncpy( plsc->DevName, devname_env, sizeof ( plsc->DevName ) - 1 );
3130 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3136 if ( *( plsc->DevName ) !=
'\0' && *( plsc->DevName ) !=
'?' )
3138 length = strlen( plsc->DevName );
3142 ( strncmp( plsc->DevName,
3146 if ( i < npldrivers )
3148 plsc->device = i + 1;
3153 fprintf( stderr,
"Requested device %s not available\n",
3168 fprintf( stdout,
"\nPlotting Options:\n" );
3171 fprintf( stdout,
" <%2d> %-10s %s\n", i + 1,
3176 fprintf( stdout,
"\nEnter device number or keyword: " );
3178 fprintf( stdout,
"\nEnter device number or keyword (stream %d): ",
3181 plio_fgets( response,
sizeof ( response ), stdin );
3186 length = strlen( response );
3187 if ( *( response - 1 + length ) ==
'\n' )
3193 (
unsigned int) length ) )
3196 if ( i < npldrivers )
3202 if ( ( dev = atoi( response ) ) < 1 )
3204 fprintf( stdout,
"\nInvalid device: %s", response );
3209 plexit(
"plSelectDev: Too many tries." );
3226 #ifdef ENABLE_DYNDRIVERS
3231 int n = plsc->device - 1;
3233 PLLoadableDriver *driver = 0;
3241 pldebug(
"plLoadDriver",
"Device not loaded!\n" );
3246 if ( strcmp( dev->
pl_DevName, loadable_device_list[i].devnam ) == 0 )
3252 if ( i == npldynamicdevices )
3254 fprintf( stderr,
"No such device: %s.\n", dev->
pl_DevName );
3255 plexit(
"plLoadDriver detected device logic screwup" );
3261 tag = loadable_device_list[i].tag;
3262 drvidx = loadable_device_list[i].drvidx;
3264 pldebug(
"plLoadDriver",
"tag=%s, drvidx=%d\n", tag, drvidx );
3266 driver = &loadable_driver_list[drvidx];
3269 if ( !driver->dlhand )
3272 #if defined ( LTDL_WIN32 ) || defined ( __CYGWIN__ )
3276 #endif // LTDL_WIN32
3278 pldebug(
"plLoadDriver",
"Trying to load %s on %s\n",
3279 driver->drvnam, drvspec );
3290 if ( !( strcmp( driver->drvnam,
"mem" ) == 0 ||
3291 strcmp( driver->drvnam,
"null" ) == 0 ||
3292 strcmp( driver->drvnam,
"plmeta" ) == 0 ||
3293 strcmp( driver->drvnam,
"ps" ) == 0 ||
3294 strcmp( driver->drvnam,
"svg" ) == 0 ||
3295 strcmp( driver->drvnam,
"xfig" ) == 0 ) )
3300 if ( !driver->dlhand )
3302 pldebug(
"plLoadDriver",
"lt_dlopenext failed because of "
3303 "the following reason:\n%s\n",
lt_dlerror() );
3304 fprintf( stderr,
"Unable to load driver: %s.\n", driver->drvnam );
3305 plexit(
"Unable to load driver" );
3314 if ( !dispatch_init )
3317 "Unable to locate dispatch table initialization function for driver: %s.\n",
3322 ( *dispatch_init )( dev );
3339 if ( plsc->level > 0 )
3354 #ifdef BUFFERED_FILE
3355 if ( plsc->plbufFile != NULL )
3358 if ( plsc->plbuf_buffer != NULL )
3365 plwarn(
"plreplot: plot buffer not available" );
3381 plgFileDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3383 plgdevlst( *p_menustr, *p_devname, p_ndev, 0 );
3393 plgDevs(
const char ***p_menustr,
const char ***p_devname,
int *p_ndev )
3395 plgdevlst( *p_menustr, *p_devname, p_ndev, -1 );
3399 plgdevlst(
const char **p_menustr,
const char **p_devname,
int *p_ndev,
int type )
3411 if ( ++j + 1 >= *p_ndev )
3413 plwarn(
"plgdevlst: too many devices" );
3418 p_menustr[j] = NULL;
3419 p_devname[j] = NULL;
3435 *p_xleng = plsc->xlength;
3436 *p_yleng = plsc->ylength;
3437 *p_xoff = plsc->xoffset;
3438 *p_yoff = plsc->yoffset;
3446 if ( plsc->level > 0 )
3447 plwarn(
"calling plspage() after plinit() may give unpredictable results" );
3455 plsc->xlength = xleng;
3457 plsc->ylength = yleng;
3460 plsc->xoffset = xoff;
3462 plsc->yoffset = yoff;
3479 if ( plsc->level > 0 )
3492 if ( plsc->level > 0 )
3494 plwarn(
"plsdev: Must be called before plinit." );
3497 if ( devname != NULL )
3499 strncpy( plsc->DevName, devname, sizeof ( plsc->DevName ) - 1 );
3500 plsc->DevName[
sizeof ( plsc->DevName ) - 1] =
'\0';
3510 strcpy( p_dev, plsc->DevName );
3525 plsc->dev = plotmem;
3526 plsc->dev_mem_alpha = 0;
3535 plsc->dev = plotmem;
3536 plsc->dev_mem_alpha = 1;
3559 *p_level = plsc->level;
3568 plsc->KeyEH = KeyEH;
3569 plsc->KeyEH_data = KeyEH_data;
3576 void *ButtonEH_data )
3578 plsc->ButtonEH = ButtonEH;
3579 plsc->ButtonEH_data = ButtonEH_data;
3585 plsbopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3587 plsc->bop_handler = handler;
3588 plsc->bop_data = handler_data;
3594 plseopH(
void ( *handler )(
void *,
int * ),
void *handler_data )
3596 plsc->eop_handler = handler;
3597 plsc->eop_data = handler_data;
3605 if ( errcode != NULL )
3606 plsc->errcode = errcode;
3608 if ( errmsg != NULL )
3629 if ( width != plsc->width && width >= 0. )
3631 plsc->width = width;
3633 if ( plsc->level > 0 )
3635 if ( !plsc->widthlock )
3646 *p_file = plsc->OutFile;
3654 plsc->OutFile = file;
3665 plabort(
"filename string must be preallocated to >=80 bytes" );
3670 if ( plsc->FileName != NULL )
3672 strncpy( fnam, plsc->FileName, 79 );
3698 plsc->setpre = setp;
3699 plsc->precis = prec;
3707 *p_setp = plsc->setpre;
3708 *p_prec = plsc->precis;
3714 return (
const char *) plsc->timefmt;
3743 plwarn(
"plsesc: Invalid escape character, ignoring." );
3752 if ( plsc->esc ==
'\0' )
3786 *pfci = *pfci & mask;
3788 *pfci = *pfci | mask;
3799 *phexdigit = (
unsigned char) ( ( fci & mask ) >>
3816 plsc->window_id = window_id;
3833 *p_fam = plsc->family;
3834 *p_num = plsc->member;
3835 *p_bmax = plsc->bytemax;
3843 if ( plsc->level > 0 )
3844 plwarn(
"plsfam: Must be called before plinit." );
3851 plsc->bytemax = bmax;
3872 *p_digmax = plsc->xdigmax;
3873 *p_digits = plsc->xdigits;
3881 plsc->xdigmax = digmax;
3882 plsc->xdigits = digits;
3890 *p_digmax = plsc->ydigmax;
3891 *p_digits = plsc->ydigits;
3899 plsc->ydigmax = digmax;
3900 plsc->ydigits = digits;
3908 *p_digmax = plsc->zdigmax;
3909 *p_digits = plsc->zdigits;
3917 plsc->zdigmax = digmax;
3918 plsc->zdigits = digits;
3926 *p_def = plsc->chrdef;
3927 *p_ht = plsc->chrht;
3935 *p_xmin = plsc->vpdxmi;
3936 *p_xmax = plsc->vpdxma;
3937 *p_ymin = plsc->vpdymi;
3938 *p_ymax = plsc->vpdyma;
3946 *p_xmin = plsc->vpwxmi;
3947 *p_xmax = plsc->vpwxma;
3948 *p_ymin = plsc->vpwymi;
3949 *p_ymax = plsc->vpwyma;
3958 dx = ( plsc->vpwxma - plsc->vpwxmi ) * 1.0e-5;
3959 dy = ( plsc->vpwyma - plsc->vpwymi ) * 1.0e-5;
3964 *p_xmin = plsc->vpwxmi -
dx;
3965 *p_xmax = plsc->vpwxma +
dx;
3966 *p_ymin = plsc->vpwymi -
dy;
3967 *p_ymax = plsc->vpwyma +
dy;
3979 *p_xmin = plsc->domxmi;
3980 *p_xmax = plsc->domxma;
3981 *p_ymin = plsc->domymi;
3982 *p_ymax = plsc->domyma;
3990 *p_zscl = plsc->zzscl;
3991 *p_zmin = plsc->ranmi;
3992 *p_zmax = plsc->ranma;
4012 *p_ixmin = plsc->clpxmi;
4013 *p_ixmax = plsc->clpxma;
4014 *p_iymin = plsc->clpymi;
4015 *p_iymax = plsc->clpyma;
4023 plsc->clpxmi = ixmin;
4024 plsc->clpxma = ixmax;
4025 plsc->clpymi = iymin;
4026 plsc->clpyma = iymax;
4034 *p_ixmin = plsc->phyxmi;
4035 *p_ixmax = plsc->phyxma;
4036 *p_iymin = plsc->phyymi;
4037 *p_iymax = plsc->phyyma;
4045 *p_nx = plsc->nsubx;
4046 *p_ny = plsc->nsuby;
4047 *p_cs = plsc->cursub;
4076 plsc->umx = (
PLINT) ( 1000.0 / plsc->xpmm );
4077 plsc->umy = (
PLINT) ( 1000.0 / plsc->ypmm );
4085 if ( xmin > xmax || ymin > ymax )
4086 plexit(
"plP_setphy: device minima must not exceed maxima" );
4088 plsc->phyxmi =
xmin;
4089 plsc->phyxma =
xmax;
4090 plsc->phyymi =
ymin;
4091 plsc->phyyma =
ymax;
4092 plsc->phyxlen = xmax -
xmin;
4093 plsc->phyylen = ymax -
ymin;
4106 if ( plsc->level <= 0 )
4108 plsc->dev_compression = compression;
4121 *compression = plsc->dev_compression;
4142 if (
pls[i] != NULL )
4145 strcpy( names,
pls[i]->DevName );
4148 strcat( names,
" " );
4149 strcat( names,
pls[i]->DevName );
4172 buff = (
char *) malloc( (
size_t)
PL_NSTREAMS * 8 );
4180 for ( tok = strtok( buff,
" ," );
4181 tok; tok = strtok( 0,
" ," ) )
4183 if ( strstr( names, tok ) != NULL )
4225 #if 0 // BEGIN dev_fastimg COMMENT
4232 if ( plsc->dev_fastimg == 0 )
4235 xmin, ymin, dx, dy, zmin, zmax );
4239 if ( plsc->plbuf_write )
4251 plsc->dev_nptsX =
nx;
4252 plsc->dev_nptsY =
ny;
4253 plsc->dev_zmin = zmin;
4254 plsc->dev_zmax = zmax;
4260 plbuf_write = plsc->plbuf_write;
4261 plsc->plbuf_write = 0;
4266 PLINT clpxmi, clpxma, clpymi, clpyma;
4268 if ( ( ( xscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) ||
4269 ( ( yscl = (
short *) malloc( nx * ny *
sizeof (
short ) ) ) == NULL ) )
4271 plexit(
"plP_image: Insufficient memory" );
4274 for ( i = 0; i < npts; i++ )
4279 sdifilt( xscl, yscl, npts, &clpxmi, &clpxma, &clpymi, &clpyma );
4280 plsc->imclxmin = clpxmi;
4281 plsc->imclymin = clpymi;
4282 plsc->imclxmax = clpxma;
4283 plsc->imclymax = clpyma;
4284 grimage( xscl, yscl, z, nx, ny );
4290 plsc->imclxmin = plsc->phyxmi;
4291 plsc->imclymin = plsc->phyymi;
4292 plsc->imclxmax = plsc->phyxma;
4293 plsc->imclymax = plsc->phyyma;
4296 plsc->plbuf_write = plbuf_write;
4297 #endif // END dev_fastimg COMMENT
4309 plsc->coordinate_transform = coordinate_transform;
4310 plsc->coordinate_transform_data = coordinate_transform_data;