The R Project SVN R

Rev

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

Rev 45971 Rev 47460
Line 547... Line 547...
547
static double CenterShift(BBOX bbox)
547
static double CenterShift(BBOX bbox)
548
{
548
{
549
    return 0.5 * (bboxHeight(bbox) - bboxDepth(bbox));
549
    return 0.5 * (bboxHeight(bbox) - bboxDepth(bbox));
550
}
550
}
551
 
551
 
552
#ifdef NOT_used_currently/*-- out 'def'	 (-Wall) --*/
-
 
553
static BBOX DrawBBox(BBOX bbox, double xoffset, double yoffset,
-
 
554
		     mathContext *mc, pGEcontext gc, pGEDevDesc dd)
-
 
555
{
-
 
556
    double xsaved = mc->CurrentX;
-
 
557
    double ysaved = mc->CurrentY;
-
 
558
    double x[5], y[5];
-
 
559
    int savedcol = gc->col;
-
 
560
    int savedlty = gc->lty;
-
 
561
    double savedlwd = gc->lwd;
-
 
562
    mc->CurrentX += xoffset;
-
 
563
    mc->CurrentY += yoffset;
-
 
564
    PMoveUp(-bboxDepth(bbox), mc);
-
 
565
    x[4] = x[0] = ConvertedX(mc, dd);
-
 
566
    y[4] = y[0] = ConvertedY(mc, dd);
-
 
567
    PMoveAcross(bboxWidth(bbox), mc);
-
 
568
    x[1] = ConvertedX(mc, dd);
-
 
569
    y[1] = ConvertedY(mc, dd);
-
 
570
    PMoveUp(bboxHeight(bbox) + bboxDepth(bbox), mc);
-
 
571
    x[2] = ConvertedX(mc, dd);
-
 
572
    y[2] = ConvertedY(mc, dd);
-
 
573
    PMoveAcross(-bboxWidth(bbox), mc);
-
 
574
    x[3] = ConvertedX(mc, dd);
-
 
575
    y[3] = ConvertedY(mc, dd);
-
 
576
    gc->col = mc->BoxColor;
-
 
577
    gc->lty = LTY_SOLID;
-
 
578
    /*
-
 
579
     * We used to just force lwd = 1, which is a reasonable sanity check
-
 
580
     * because if the user had set lwd = 10 for something, your
-
 
581
     * mathematical annotation would look REALLY bad.
-
 
582
     * Unfortunately, this meant that the user could not set a nice
-
 
583
     * small lwd to get a finer line;  we always bumped it back up to 1.
-
 
584
     * NOW we just reduce lwd to 1 (as a sanity check) ONLY if
-
 
585
     * lwd is greater than 1.
-
 
586
     */
-
 
587
    if (gc->lwd > 1)
-
 
588
	gc->lwd = 1;
-
 
589
    GEPolyline(5, x, y, gc, dd);
-
 
590
    PMoveTo(xsaved, ysaved, mc);
-
 
591
    gc->col = savedcol;
-
 
592
    gc->lty = savedlty;
-
 
593
    gc->lwd = savedlwd;
-
 
594
    return bbox;
-
 
595
}
-
 
596
#endif
-
 
597
 
552
 
598
typedef struct {
553
typedef struct {
599
    char *name;
554
    char *name;
600
    int code;
555
    int code;
601
} SymTab;
556
} SymTab;
Line 902... Line 857...
902
static int StringAtom(SEXP expr)
857
static int StringAtom(SEXP expr)
903
{
858
{
904
    return (TYPEOF(expr) == STRSXP);
859
    return (TYPEOF(expr) == STRSXP);
905
}
860
}
906
 
861
 
907
#ifdef NOT_used_currently/*-- out 'def'	 (-Wall) --*/
-
 
908
static int symbolAtom(SEXP expr)
-
 
909
{
-
 
910
    int i;
-
 
911
    if (NameAtom(expr)) {
-
 
912
	for (i = 0; SymbolTable[i].code; i++)
-
 
913
	    if (NameMatch(expr, SymbolTable[i].name))
-
 
914
		return 1;
-
 
915
    }
-
 
916
    return 0;
-
 
917
}
-
 
918
#endif
-
 
919
/* Code to determine a font from the */
862
/* Code to determine a font from the */
920
/* nature of the expression */
863
/* nature of the expression */
921
 
864
 
922
#ifdef NOT_used_currently/*-- out 'def'	 (-Wall) --*/
-
 
923
static FontType mc->CurrentFont = 3;
-
 
924
#endif
-
 
925
static FontType GetFont(pGEcontext gc)
865
static FontType GetFont(pGEcontext gc)
926
{
866
{
927
    return gc->fontface;
867
    return gc->fontface;
928
}
868
}
929
 
869
 
Line 1357... Line 1297...
1357
	if (NameMatch(expr, BinTable[i].name))
1297
	if (NameMatch(expr, BinTable[i].name))
1358
	    return BinTable[i].code;
1298
	    return BinTable[i].code;
1359
    return 0;
1299
    return 0;
1360
}
1300
}
1361
 
1301
 
1362
#define SLASH2
-
 
1363
 
-
 
1364
static BBOX RenderSlash(int draw, mathContext *mc, pGEcontext gc,
1302
static BBOX RenderSlash(int draw, mathContext *mc, pGEcontext gc,
1365
			pGEDevDesc dd)
1303
			pGEDevDesc dd)
1366
{
1304
{
1367
#ifdef SLASH0
-
 
1368
    /* The Default Font Character */
-
 
1369
    return RenderSymbolChar(S_SLASH, draw, mc, gc, dd);
-
 
1370
#endif
-
 
1371
#ifdef SLASH1
-
 
1372
    /* Symbol Magnify Version */
-
 
1373
    double savecex = gc->cex;
-
 
1374
    BBOX bbox;
-
 
1375
    double height1, height2;
-
 
1376
    height1 = bboxHeight(RenderSymbolChar(S_SLASH, 0), mc, gc, dd);
-
 
1377
    gc->cex = 1.2 * gc->cex;
-
 
1378
    height2 = bboxHeight(RenderSymbolChar(S_SLASH, 0), mc, gc, dd);
-
 
1379
    if (draw)
-
 
1380
	PMoveUp(- 0.5 * (height2 - height1), mc);
-
 
1381
    bbox = RenderSymbolChar(S_SLASH, draw, mc, gc, dd);
-
 
1382
    if (draw)
-
 
1383
	PMoveUp(0.5 * (height2 - height1), mc);
-
 
1384
    gc->cex = savecex;
-
 
1385
    return bbox;
-
 
1386
#endif
-
 
1387
#ifdef SLASH2
-
 
1388
    /* Line Drawing Version */
1305
    /* Line Drawing Version */
1389
    double x[2], y[2];
1306
    double x[2], y[2];
1390
    double depth = 0.5 * TeX(sigma22, gc, dd);
1307
    double depth = 0.5 * TeX(sigma22, gc, dd);
1391
    double height = XHeight(gc, dd) + 0.5 * TeX(sigma22, gc, dd);
1308
    double height = XHeight(gc, dd) + 0.5 * TeX(sigma22, gc, dd);
1392
    double width = 0.5 * xHeight(gc, dd);
1309
    double width = 0.5 * xHeight(gc, dd);
Line 1409... Line 1326...
1409
	PMoveAcross(0.5 * width, mc);
1326
	PMoveAcross(0.5 * width, mc);
1410
	gc->lty = savedlty;
1327
	gc->lty = savedlty;
1411
	gc->lwd = savedlwd;
1328
	gc->lwd = savedlwd;
1412
    }
1329
    }
1413
    return MakeBBox(height, depth, 2 * width);
1330
    return MakeBBox(height, depth, 2 * width);
1414
#endif
-
 
1415
#ifdef SLASH3
-
 
1416
    /* Offset Overprinting - A Failure! */
-
 
1417
    BBOX slashBBox = RenderSymbolChar(S_SLASH, 0, mc, gc, dd);
-
 
1418
    BBOX ansBBox;
-
 
1419
    double height = bboxHeight(slashBBox);
-
 
1420
    double depth = bboxDepth(slashBBox);
-
 
1421
    double width = bboxWidth(slashBBox);
-
 
1422
    double slope = (height + depth) / slope;
-
 
1423
    double delta = TeX(sigma22, gc, dd);
-
 
1424
    if (draw)
-
 
1425
	PMoveUp(-delta, mc);
-
 
1426
    ansBBox = ShiftBBox(RenderSymbolChar(S_SLASH, draw), -delta, mc, gc, dd);
-
 
1427
    PMoveUp(2 * delta, mc);
-
 
1428
    ansBBox = CombineBBoxes(ansBBox, RenderGap(2 * delta / slope, draw,
-
 
1429
					       mc, gc, dd));
-
 
1430
    ansBBox = ShiftBBox(RenderSymbolChar(S_SLASH, draw), 2 * delta,
-
 
1431
			mc, gc, dd);
-
 
1432
    PMoveUp(-delta, mc);
-
 
1433
    return ansBBox;
-
 
1434
#endif
-
 
1435
}
1331
}
1436
 
1332
 
1437
static BBOX RenderBin(SEXP expr, int draw, mathContext *mc,
1333
static BBOX RenderBin(SEXP expr, int draw, mathContext *mc,
1438
		      pGEcontext gc, pGEDevDesc dd)
1334
		      pGEcontext gc, pGEDevDesc dd)
1439
{
1335
{