The R Project SVN R

Rev

Rev 30316 | Rev 30980 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30316 Rev 30819
Line 1350... Line 1350...
1350
}/* do_axis */
1350
}/* do_axis */
1351
 
1351
 
1352
 
1352
 
1353
SEXP do_plot_xy(SEXP call, SEXP op, SEXP args, SEXP env)
1353
SEXP do_plot_xy(SEXP call, SEXP op, SEXP args, SEXP env)
1354
{
1354
{
1355
/*	plot.xy(xy, type, pch, lty, col, cex, ...)
1355
/*	plot.xy(xy, type, pch, lty, col, cex, lwd, ...)
1356
 
1356
 
1357
 *	plot points or lines of various types
1357
 *	plot points or lines of various types
1358
 */
1358
 */
1359
    SEXP sxy, sx, sy, pch, cex, col, bg, lty;
1359
    SEXP sxy, sx, sy, pch, cex, col, bg, lty, lwd;
1360
    double *x, *y, xold, yold, xx, yy, thiscex;
1360
    double *x, *y, xold, yold, xx, yy, thiscex, thislwd;
1361
    int i, n, npch, ncex, ncol, nbg, nlty, type=0, start=0, thispch, thiscol;
1361
    int i, n, npch, ncex, ncol, nbg, /*nlty,*/ nlwd,
-
 
1362
	type=0, start=0, thispch, thiscol;
1362
 
1363
 
1363
    SEXP originalArgs = args;
1364
    SEXP originalArgs = args;
1364
    DevDesc *dd = CurrentDevice();
1365
    DevDesc *dd = CurrentDevice();
1365
 
1366
 
1366
    /* Basic Checks */
1367
    /* Basic Checks */
1367
    GCheckState(dd);
1368
    GCheckState(dd);
1368
    if (length(args) < 6)
1369
    if (length(args) < 7)
1369
	errorcall(call, "too few arguments");
1370
	errorcall(call, "too few arguments");
1370
 
1371
 
1371
    /* Required Arguments */
1372
    /* Required Arguments */
1372
#define PLOT_XY_DEALING(subname)				\
1373
#define PLOT_XY_DEALING(subname)				\
1373
    sx = R_NilValue;		/* -Wall */			\
1374
    sx = R_NilValue;		/* -Wall */			\
Line 1405... Line 1406...
1405
 
1406
 
1406
    PROTECT(pch = FixupPch(CAR(args), Rf_gpptr(dd)->pch));	args = CDR(args);
1407
    PROTECT(pch = FixupPch(CAR(args), Rf_gpptr(dd)->pch));	args = CDR(args);
1407
    npch = length(pch);
1408
    npch = length(pch);
1408
 
1409
 
1409
    PROTECT(lty = FixupLty(CAR(args), Rf_gpptr(dd)->lty));	args = CDR(args);
1410
    PROTECT(lty = FixupLty(CAR(args), Rf_gpptr(dd)->lty));	args = CDR(args);
1410
    nlty = length(lty);
1411
    /* nlty = length(lty);*/
1411
 
1412
 
1412
    /* Default col was NA_INTEGER (0x80000000) which was interpreted
1413
    /* Default col was NA_INTEGER (0x80000000) which was interpreted
1413
       as zero (black) or "don't draw" depending on line/rect/circle
1414
       as zero (black) or "don't draw" depending on line/rect/circle
1414
       situation. Now we set the default to zero and don't plot at all
1415
       situation. Now we set the default to zero and don't plot at all
1415
       if col==NA.
1416
       if col==NA.
1416
 
1417
 
1417
       FIXME: bg needs similar change, but that requires changes to
1418
       FIXME: bg needs similar change, but that requires changes to
1418
       the specific drivers. */
1419
       the specific drivers. */
1419
 
1420
 
1420
    PROTECT(col = FixupCol(CAR(args), 0)); args = CDR(args);
1421
    PROTECT(col = FixupCol(CAR(args), 0));		args = CDR(args);
1421
    ncol = LENGTH(col);
1422
    ncol = LENGTH(col);
1422
 
1423
 
1423
    PROTECT(bg = FixupCol(CAR(args), NA_INTEGER));	args = CDR(args);
1424
    PROTECT(bg = FixupCol(CAR(args), NA_INTEGER));	args = CDR(args);
1424
    nbg = LENGTH(bg);
1425
    nbg = LENGTH(bg);
1425
 
1426
 
1426
    PROTECT(cex = FixupCex(CAR(args), 1.0));	args = CDR(args);
1427
    PROTECT(cex = FixupCex(CAR(args), 1.0));		args = CDR(args);
1427
    ncex = LENGTH(cex);
1428
    ncex = LENGTH(cex);
1428
 
1429
 
-
 
1430
    PROTECT(lwd = FixupLwd(CAR(args), Rf_gpptr(dd)->lwd)); args = CDR(args);
-
 
1431
    nlwd = LENGTH(lwd);
-
 
1432
 
1429
    /* Miscellaneous Graphical Parameters -- e.g., lwd */
1433
    /* Miscellaneous Graphical Parameters */
1430
    GSavePars(dd);
1434
    GSavePars(dd);
1431
    ProcessInlinePars(args, dd, call);
1435
    ProcessInlinePars(args, dd, call);
1432
 
1436
 
1433
    x = REAL(sx);
1437
    x = REAL(sx);
1434
    y = REAL(sy);
1438
    y = REAL(sy);
1435
 
1439
 
1436
    if (nlty && INTEGER(lty)[0] != NA_INTEGER)
1440
    if (INTEGER(lty)[0] != NA_INTEGER)
1437
	Rf_gpptr(dd)->lty = INTEGER(lty)[0];
1441
	Rf_gpptr(dd)->lty = INTEGER(lty)[0];
-
 
1442
    if (R_FINITE(thislwd = REAL(lwd)[0]))
-
 
1443
	Rf_gpptr(dd)->lwd = thislwd; /* but do recycle for "p" etc */
1438
 
1444
 
1439
    GMode(1, dd);
1445
    GMode(1, dd);
1440
    /* removed by paul 26/5/99 because all clipping now happens in graphics.c
1446
    /* removed by paul 26/5/99 because all clipping now happens in graphics.c
1441
     * GClip(dd);
1447
     * GClip(dd);
1442
     */
1448
     */
Line 1583... Line 1589...
1583
		    && (thispch = INTEGER(pch)[i % npch]) != NA_INTEGER
1589
		    && (thispch = INTEGER(pch)[i % npch]) != NA_INTEGER
1584
		    && !R_TRANSPARENT(thiscol = INTEGER(col)[i % ncol]))
1590
		    && !R_TRANSPARENT(thiscol = INTEGER(col)[i % ncol]))
1585
		{
1591
		{
1586
		    Rf_gpptr(dd)->cex = thiscex * Rf_gpptr(dd)->cexbase;
1592
		    Rf_gpptr(dd)->cex = thiscex * Rf_gpptr(dd)->cexbase;
1587
		    Rf_gpptr(dd)->col = thiscol;
1593
		    Rf_gpptr(dd)->col = thiscol;
-
 
1594
		    if(nlwd > 1 && R_FINITE(thislwd = REAL(lwd)[i % nlwd]))
-
 
1595
			Rf_gpptr(dd)->lwd = thislwd;
1588
		    Rf_gpptr(dd)->bg = INTEGER(bg)[i % nbg];
1596
		    Rf_gpptr(dd)->bg = INTEGER(bg)[i % nbg];
1589
		    GSymbol(xx, yy, DEVICE, thispch, dd);
1597
		    GSymbol(xx, yy, DEVICE, thispch, dd);
1590
		}
1598
		}
1591
	    }
1599
	    }
1592
	}
1600
	}
1593
    }
1601
    }
1594
    GMode(0, dd);
1602
    GMode(0, dd);
1595
    GRestorePars(dd);
1603
    GRestorePars(dd);
1596
    UNPROTECT(5);
1604
    UNPROTECT(6);
1597
    /* NOTE: only record operation if no "error"  */
1605
    /* NOTE: only record operation if no "error"  */
1598
    if (GRecording(call))
1606
    if (GRecording(call))
1599
	recordGraphicOperation(op, originalArgs, dd);
1607
	recordGraphicOperation(op, originalArgs, dd);
1600
    return R_NilValue;
1608
    return R_NilValue;
1601
}/* do_plot_xy */
1609
}/* do_plot_xy */
Line 1830... Line 1838...
1830
    args = CDR(args);
1838
    args = CDR(args);
1831
 
1839
 
1832
    PROTECT(lty = FixupLty(CAR(args), Rf_gpptr(dd)->lty));
1840
    PROTECT(lty = FixupLty(CAR(args), Rf_gpptr(dd)->lty));
1833
    nlty = length(lty);
1841
    nlty = length(lty);
1834
    args = CDR(args);
1842
    args = CDR(args);
-
 
1843
    /* use FixupLwd, as segments() does too! */
1835
 
1844
#ifdef R_1_x_y
1836
    PROTECT(lwd = CAR(args));/*need  FixupLwd ?*/
1845
    PROTECT(lwd = CAR(args));
1837
    nlwd = length(lwd);
1846
    nlwd = length(lwd);
1838
    if (nlwd == 0)
1847
    if (nlwd == 0)
1839
	errorcall(call, "'lwd' must be numeric of length >=1");
1848
	errorcall(call, "'lwd' must be numeric of length >=1");
-
 
1849
#else
-
 
1850
    PROTECT(lwd = FixupLwd(CAR(args), Rf_gpptr(dd)->lwd));
-
 
1851
    nlwd = length(lwd);
-
 
1852
#endif
1840
    args = CDR(args);
1853
    args = CDR(args);
1841
 
1854
 
1842
    sxpd = CAR(args);
1855
    sxpd = CAR(args);
1843
    if (sxpd != R_NilValue)
1856
    if (sxpd != R_NilValue)
1844
	xpd = asInteger(sxpd);
1857
	xpd = asInteger(sxpd);
Line 2083... Line 2096...
2083
	xpd = Rf_gpptr(dd)->xpd;
2096
	xpd = Rf_gpptr(dd)->xpd;
2084
    args = CDR(args);
2097
    args = CDR(args);
2085
 
2098
 
2086
    x = REAL(sx);
2099
    x = REAL(sx);
2087
    y = REAL(sy);
2100
    y = REAL(sy);
2088
    n = LENGTH(sx);
2101
    /* n = LENGTH(sx) = LENGTH(sy) */
2089
    ntxt = LENGTH(txt);
2102
    ntxt = LENGTH(txt);
2090
 
2103
 
2091
    GSavePars(dd);
2104
    GSavePars(dd);
2092
    ProcessInlinePars(args, dd, call);
2105
    ProcessInlinePars(args, dd, call);
2093
 
2106
 
2094
    Rf_gpptr(dd)->xpd = (xpd == NA_INTEGER)? 2 : xpd;
2107
    Rf_gpptr(dd)->xpd = (xpd == NA_INTEGER)? 2 : xpd;
2095
 
2108
 
2096
    GMode(1, dd);
2109
    GMode(1, dd);
2097
    for (i = 0; i < n; i++) {
2110
    for (i = 0; i < imax2(n,ntxt); i++) {
2098
	xx = x[i % n];
2111
	xx = x[i % n];
2099
	yy = y[i % n];
2112
	yy = y[i % n];
2100
	GConvert(&xx, &yy, USER, INCHES, dd);
2113
	GConvert(&xx, &yy, USER, INCHES, dd);
2101
	if (R_FINITE(xx) && R_FINITE(yy)) {
2114
	if (R_FINITE(xx) && R_FINITE(yy)) {
2102
	    if (ncol && !isNAcol(rawcol, i, ncol))
2115
	    if (ncol && !isNAcol(rawcol, i, ncol))