The R Project SVN R

Rev

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

Rev 2123 Rev 2124
Line 153... Line 153...
153
    double height, depth, width;
153
    double height, depth, width;
154
    GMetricInfo('g', &height, &depth, &width, MetricUnit, MathDevice);
154
    GMetricInfo('g', &height, &depth, &width, MetricUnit, MathDevice);
155
    return depth;
155
    return depth;
156
}
156
}
157
 
157
 
-
 
158
#ifdef NOT_used_currently/*-- out 'def'  (-Wall) --*/
158
static double AscHeight()
159
static double AscHeight()
159
{
160
{
160
    double height, depth, width, save;
161
    double height, depth, width, save;
161
    GMetricInfo('d', &height, &depth, &width, MetricUnit, MathDevice);
162
    GMetricInfo('d', &height, &depth, &width, MetricUnit, MathDevice);
162
    save = height;
163
    save = height;
163
    GMetricInfo('a', &height, &depth, &width, MetricUnit, MathDevice);
164
    GMetricInfo('a', &height, &depth, &width, MetricUnit, MathDevice);
164
    return save - height;
165
    return save - height;
165
}
166
}
166
 
167
#endif
167
/* Thickness of rules */
168
/* Thickness of rules */
168
static double RuleThickness()
169
static double RuleThickness()
169
{
170
{
170
    return 0.015;
171
    return 0.015;
171
}
172
}
Line 224... Line 225...
224
 
225
 
225
#define SUBS           0.7
226
#define SUBS           0.7
226
 
227
 
227
static double TeX(TEXPAR which)
228
static double TeX(TEXPAR which)
228
{
229
{
229
    double value;
-
 
230
    switch(which) {
230
    switch(which) {
231
    case sigma2:  /* space */
231
    case sigma2:  /* space */
232
    case sigma5:  /* x_height */
232
    case sigma5:  /* x_height */
233
	return xHeight();
233
	return xHeight();
234
 
234
 
Line 554... Line 554...
554
static double CenterShift(BBOX bbox)
554
static double CenterShift(BBOX bbox)
555
{
555
{
556
    return 0.5 * (bboxHeight(bbox) - bboxDepth(bbox));
556
    return 0.5 * (bboxHeight(bbox) - bboxDepth(bbox));
557
}
557
}
558
 
558
 
-
 
559
#ifdef NOT_used_currently/*-- out 'def'  (-Wall) --*/
559
static BBOX DrawBBox(BBOX bbox, double xoffset, double yoffset)
560
static BBOX DrawBBox(BBOX bbox, double xoffset, double yoffset)
560
{
561
{
561
    double xsaved = CurrentX;
562
    double xsaved = CurrentX;
562
    double ysaved = CurrentY;
563
    double ysaved = CurrentY;
563
    double x[5], y[5];
564
    double x[5], y[5];
Line 579... Line 580...
579
    GPolyline(5, x, y, INCHES, MathDevice);
580
    GPolyline(5, x, y, INCHES, MathDevice);
580
    MoveTo(xsaved, ysaved);
581
    MoveTo(xsaved, ysaved);
581
    MathDevice->gp.col = TextColor;
582
    MathDevice->gp.col = TextColor;
582
    return bbox;
583
    return bbox;
583
}
584
}
584
 
585
#endif
585
 
586
 
586
typedef struct {
587
typedef struct {
587
    char *name;
588
    char *name;
588
    int code;
589
    int code;
589
} SymTab;
590
} SymTab;
Line 884... Line 885...
884
static int StringAtom(SEXP expr)
885
static int StringAtom(SEXP expr)
885
{
886
{
886
    return (TYPEOF(expr) == STRSXP);
887
    return (TYPEOF(expr) == STRSXP);
887
}
888
}
888
 
889
 
-
 
890
#ifdef NOT_used_currently/*-- out 'def'  (-Wall) --*/
889
static int symbolAtom(SEXP expr)
891
static int symbolAtom(SEXP expr)
890
{
892
{
891
    int i;
893
    int i;
892
    if (NameAtom(expr)) {
894
    if (NameAtom(expr)) {
893
	for (i = 0; SymbolTable[i].code; i++)
895
	for (i = 0; SymbolTable[i].code; i++)
894
	    if (NameMatch(expr, SymbolTable[i].name))
896
	    if (NameMatch(expr, SymbolTable[i].name))
895
		return 1;
897
		return 1;
896
    }
898
    }
897
    return 0;
899
    return 0;
898
}
900
}
899
 
901
#endif
900
/* Code to determine a font from the */
902
/* Code to determine a font from the */
901
/* nature of the expression */
903
/* nature of the expression */
902
 
904
 
-
 
905
#ifdef NOT_used_currently/*-- out 'def'  (-Wall) --*/
903
static FontType CurrentFont = 3;
906
static FontType CurrentFont = 3;
904
 
907
#endif
905
static FontType GetFont()
908
static FontType GetFont()
906
{
909
{
907
    return MathDevice->gp.font;
910
    return MathDevice->gp.font;
908
}
911
}
909
 
912
 
Line 1076... Line 1079...
1076
/* Code for Symbol Font Atoms */
1079
/* Code for Symbol Font Atoms */
1077
 
1080
 
1078
static BBOX RenderSymbol(SEXP expr, int draw)
1081
static BBOX RenderSymbol(SEXP expr, int draw)
1079
{
1082
{
1080
    int code;
1083
    int code;
1081
    if (code = TranslatedSymbol(expr))
1084
    if ((code = TranslatedSymbol(expr)))
1082
	return RenderSymbolChar(code, draw);
1085
	return RenderSymbolChar(code, draw);
1083
    else
1086
    else
1084
	return RenderSymbolStr(CHAR(PRINTNAME(expr)), draw);
1087
	return RenderSymbolStr(CHAR(PRINTNAME(expr)), draw);
1085
}
1088
}
1086
 
1089
 
1087
static BBOX RenderSymbolString(SEXP expr, int draw)
1090
static BBOX RenderSymbolString(SEXP expr, int draw)
1088
{
1091
{
1089
    int code;
1092
    int code;
1090
    if (code = TranslatedSymbol(expr))
1093
    if ((code = TranslatedSymbol(expr)))
1091
	return RenderSymbolChar(code, draw);
1094
	return RenderSymbolChar(code, draw);
1092
    else
1095
    else
1093
	return RenderStr(CHAR(PRINTNAME(expr)), draw);
1096
	return RenderStr(CHAR(PRINTNAME(expr)), draw);
1094
}
1097
}
1095
 
1098
 
Line 1177... Line 1180...
1177
}
1180
}
1178
 
1181
 
1179
 
1182
 
1180
static BBOX RenderSpace(SEXP expr, int draw)
1183
static BBOX RenderSpace(SEXP expr, int draw)
1181
{
1184
{
1182
    SEXP arg1, arg2;
-
 
-
 
1185
 
1183
    BBOX opBBox, arg1BBox, arg2BBox;
1186
    BBOX opBBox, arg1BBox, arg2BBox;
1184
    int nexpr = length(expr);
1187
    int nexpr = length(expr);
1185
 
1188
 
1186
    if (nexpr == 2) {
1189
    if (nexpr == 2) {
1187
	opBBox = RenderSymbolChar(' ', draw);
1190
	opBBox = RenderSymbolChar(' ', draw);
Line 1358... Line 1361...
1358
    SEXP body = CADR(expr);
1361
    SEXP body = CADR(expr);
1359
    SEXP sub = CADDR(expr);
1362
    SEXP sub = CADDR(expr);
1360
    STYLE style = GetStyle();
1363
    STYLE style = GetStyle();
1361
    double savedX = CurrentX;
1364
    double savedX = CurrentX;
1362
    double savedY = CurrentY;
1365
    double savedY = CurrentY;
1363
    double shift, v, s5, s16;
1366
    double v, s5, s16;
1364
    bodyBBox = RenderElement(body, draw);
1367
    bodyBBox = RenderElement(body, draw);
1365
    bodyBBox = RenderItalicCorr(bodyBBox, draw);
1368
    bodyBBox = RenderItalicCorr(bodyBBox, draw);
1366
    v = bboxSimple(bodyBBox) ? 0 : bboxDepth(bodyBBox) + TeX(sigma19);
1369
    v = bboxSimple(bodyBBox) ? 0 : bboxDepth(bodyBBox) + TeX(sigma19);
1367
    s5 = TeX(sigma5);
1370
    s5 = TeX(sigma5);
1368
    s16 = TeX(sigma16);
1371
    s16 = TeX(sigma16);
Line 1474... Line 1477...
1474
{
1477
{
1475
    double savedX = CurrentX;
1478
    double savedX = CurrentX;
1476
    double savedY = CurrentY;
1479
    double savedY = CurrentY;
1477
    BBOX bbox = RenderElement(CADR(expr), draw);
1480
    BBOX bbox = RenderElement(CADR(expr), draw);
1478
    double height = bboxHeight(bbox);
1481
    double height = bboxHeight(bbox);
1479
    double width = bboxWidth(bbox);
1482
    /*double width = bboxWidth(bbox);*/
1480
    double totalwidth = bboxWidth(bbox) + bboxItalic(bbox);
1483
    double totalwidth = bboxWidth(bbox) + bboxItalic(bbox);
1481
    double delta = totalwidth * (1 - 2 * DELTA) / NTILDE;
1484
    double delta = totalwidth * (1 - 2 * DELTA) / NTILDE;
1482
    double start = DELTA * totalwidth;
1485
    double start = DELTA * totalwidth;
1483
    double accentGap = ACCENT_GAP * XHeight();
1486
    double accentGap = ACCENT_GAP * XHeight();
1484
    double hatHeight = 0.5 * HAT_HEIGHT * XHeight();
1487
    double hatHeight = 0.5 * HAT_HEIGHT * XHeight();
Line 1554... Line 1557...
1554
{
1557
{
1555
    double savedX = CurrentX;
1558
    double savedX = CurrentX;
1556
    double savedY = CurrentY;
1559
    double savedY = CurrentY;
1557
    BBOX bbox = RenderElement(CADR(expr), draw);
1560
    BBOX bbox = RenderElement(CADR(expr), draw);
1558
    double accentGap = ACCENT_GAP * XHeight();
1561
    double accentGap = ACCENT_GAP * XHeight();
1559
    double hatHeight = HAT_HEIGHT * XHeight();
1562
    /*double hatHeight = HAT_HEIGHT * XHeight();*/
1560
    double height = bboxHeight(bbox);
1563
    double height = bboxHeight(bbox);
1561
    double width = bboxWidth(bbox);
1564
    double width = bboxWidth(bbox);
1562
    double offset = bboxItalic(bbox);
1565
    double offset = bboxItalic(bbox);
1563
    double x[2], y[2];
1566
    double x[2], y[2];
1564
 
1567
 
Line 1693... Line 1696...
1693
 
1696
 
1694
static BBOX RenderFraction(SEXP expr, int rule, int draw)
1697
static BBOX RenderFraction(SEXP expr, int rule, int draw)
1695
{
1698
{
1696
    SEXP numerator = CADR(expr);
1699
    SEXP numerator = CADR(expr);
1697
    SEXP denominator = CADDR(expr);
1700
    SEXP denominator = CADDR(expr);
1698
    BBOX numBBox, denomBBox, ansBBox;
1701
    BBOX numBBox, denomBBox;
1699
    double nHShift, dHShift;
1702
    double nHShift, dHShift;
1700
    double nVShift, dVShift;
1703
    double nVShift, dVShift;
1701
    double width, x[2], y[2];
1704
    double width, x[2], y[2];
1702
    double savedX = CurrentX;
1705
    double savedX = CurrentX;
1703
    double savedY = CurrentY;
1706
    double savedY = CurrentY;
Line 1971... Line 1974...
1971
}
1974
}
1972
 
1975
 
1973
static BBOX RenderBGroup(SEXP expr, int draw)
1976
static BBOX RenderBGroup(SEXP expr, int draw)
1974
{
1977
{
1975
    double dist;
1978
    double dist;
1976
    BBOX bbox, bodyBBox;
1979
    BBOX bbox;
1977
    double axisHeight = TeX(sigma22);
1980
    double axisHeight = TeX(sigma22);
1978
    double extra = 0.2 * xHeight();
1981
    double extra = 0.2 * xHeight();
1979
    int delim1, delim2;
1982
    int delim1, delim2;
1980
    if (length(expr) != 4)
1983
    if (length(expr) != 4)
1981
	errorcall(expr, "invalid group specification\n");
1984
	errorcall(expr, "invalid group specification\n");
Line 2128... Line 2131...
2128
 
2131
 
2129
static BBOX RenderOpSymbol(SEXP op, int draw)
2132
static BBOX RenderOpSymbol(SEXP op, int draw)
2130
{
2133
{
2131
    BBOX bbox;
2134
    BBOX bbox;
2132
    double cexSaved = MathDevice->gp.cex;
2135
    double cexSaved = MathDevice->gp.cex;
2133
    double savedX = CurrentX;
2136
    /*double savedX = CurrentX;*/
2134
    double savedY = CurrentY;
2137
    /*double savedY = CurrentY;*/
2135
    double shift;
2138
    double shift;
2136
    int display = (GetStyle() > STYLE_T);
2139
    int display = (GetStyle() > STYLE_T);
2137
    int opId = OpAtom(op);
2140
    int opId = OpAtom(op);
2138
 
2141
 
2139
    if (opId == S_SUM || opId == S_PRODUCT) {
2142
    if (opId == S_SUM || opId == S_PRODUCT) {
Line 2250... Line 2253...
2250
 
2253
 
2251
static BBOX RenderRadical(SEXP expr, int draw)
2254
static BBOX RenderRadical(SEXP expr, int draw)
2252
{
2255
{
2253
    SEXP body = CADR(expr);
2256
    SEXP body = CADR(expr);
2254
    SEXP order = CADDR(expr);
2257
    SEXP order = CADDR(expr);
2255
    BBOX bodyBBox, orderBBox, ansBBox;
2258
    BBOX bodyBBox, orderBBox;
2256
    double radWidth, radHeight, radDepth;
2259
    double radWidth, radHeight, radDepth;
2257
    double leadWidth, leadHeight, twiddleHeight;
2260
    double leadWidth, leadHeight, twiddleHeight;
2258
    double hshift, vshift;
2261
    double hshift, vshift;
2259
    double radGap, radSpace, radTrail;
2262
    double radGap, radSpace, radTrail;
2260
    STYLE style = GetStyle();
2263
    STYLE style = GetStyle();
Line 2696... Line 2699...
2696
    return NameAtom(expr) && NameMatch(expr, "list");
2699
    return NameAtom(expr) && NameMatch(expr, "list");
2697
}
2700
}
2698
 
2701
 
2699
static BBOX RenderList(SEXP expr, int draw)
2702
static BBOX RenderList(SEXP expr, int draw)
2700
{
2703
{
2701
    BBOX bbox;
-
 
2702
    return RenderCommaList(CDR(expr), draw);
2704
    return RenderCommaList(CDR(expr), draw);
2703
}
2705
}
2704
 
2706
 
2705
/* Dispatching procedure which determines nature of expression. */
2707
/* Dispatching procedure which determines nature of expression. */
2706
 
2708