The R Project SVN R

Rev

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

Rev 16224 Rev 16881
Line 336... Line 336...
336
    switch (newstyle) {
336
    switch (newstyle) {
337
    case STYLE_D:
337
    case STYLE_D:
338
    case STYLE_T:
338
    case STYLE_T:
339
    case STYLE_D1:
339
    case STYLE_D1:
340
    case STYLE_T1:
340
    case STYLE_T1:
341
	MathDevice->gp.cex = 1.0 * BaseCex;
341
	gpptr(MathDevice)->cex = 1.0 * BaseCex;
342
	break;
342
	break;
343
    case STYLE_S:
343
    case STYLE_S:
344
    case STYLE_S1:
344
    case STYLE_S1:
345
	MathDevice->gp.cex = 0.7 * BaseCex;
345
	gpptr(MathDevice)->cex = 0.7 * BaseCex;
346
	break;
346
	break;
347
    case STYLE_SS:
347
    case STYLE_SS:
348
    case STYLE_SS1:
348
    case STYLE_SS1:
349
	MathDevice->gp.cex = 0.5 * BaseCex;
349
	gpptr(MathDevice)->cex = 0.5 * BaseCex;
350
	break;
350
	break;
351
    default:
351
    default:
352
	error("invalid math style encountered");
352
	error("invalid math style encountered");
353
    }
353
    }
354
    CurrentStyle = newstyle;
354
    CurrentStyle = newstyle;
Line 570... Line 570...
570
    double xsaved = CurrentX;
570
    double xsaved = CurrentX;
571
    double ysaved = CurrentY;
571
    double ysaved = CurrentY;
572
    double x[5], y[5];
572
    double x[5], y[5];
573
    CurrentX += xoffset;
573
    CurrentX += xoffset;
574
    CurrentY += yoffset;
574
    CurrentY += yoffset;
575
    MathDevice->gp.col = BoxColor;
575
    gpptr(MathDevice)->col = BoxColor;
576
    PMoveUp(-bboxDepth(bbox));
576
    PMoveUp(-bboxDepth(bbox));
577
    x[4] = x[0] = ConvertedX();
577
    x[4] = x[0] = ConvertedX();
578
    y[4] = y[0] = ConvertedY();
578
    y[4] = y[0] = ConvertedY();
579
    PMoveAcross(bboxWidth(bbox));
579
    PMoveAcross(bboxWidth(bbox));
580
    x[1] = ConvertedX();
580
    x[1] = ConvertedX();
Line 585... Line 585...
585
    PMoveAcross(-bboxWidth(bbox));
585
    PMoveAcross(-bboxWidth(bbox));
586
    x[3] = ConvertedX();
586
    x[3] = ConvertedX();
587
    y[3] = ConvertedY();
587
    y[3] = ConvertedY();
588
    GPolyline(5, x, y, INCHES, MathDevice);
588
    GPolyline(5, x, y, INCHES, MathDevice);
589
    PMoveTo(xsaved, ysaved);
589
    PMoveTo(xsaved, ysaved);
590
    MathDevice->gp.col = TextColor;
590
    gpptr(MathDevice)->col = TextColor;
591
    return bbox;
591
    return bbox;
592
}
592
}
593
#endif
593
#endif
594
 
594
 
595
typedef struct {
595
typedef struct {
Line 911... Line 911...
911
#ifdef NOT_used_currently/*-- out 'def'	 (-Wall) --*/
911
#ifdef NOT_used_currently/*-- out 'def'	 (-Wall) --*/
912
static FontType CurrentFont = 3;
912
static FontType CurrentFont = 3;
913
#endif
913
#endif
914
static FontType GetFont()
914
static FontType GetFont()
915
{
915
{
916
    return MathDevice->gp.font;
916
    return gpptr(MathDevice)->font;
917
}
917
}
918
 
918
 
919
static FontType SetFont(FontType font)
919
static FontType SetFont(FontType font)
920
{
920
{
921
    FontType prevfont = MathDevice->gp.font;
921
    FontType prevfont = gpptr(MathDevice)->font;
922
    MathDevice->gp.font = font;
922
    gpptr(MathDevice)->font = font;
923
    return prevfont;
923
    return prevfont;
924
}
924
}
925
 
925
 
926
static int UsingItalics()
926
static int UsingItalics()
927
{
927
{
928
    return (MathDevice->gp.font == ItalicFont ||
928
    return (gpptr(MathDevice)->font == ItalicFont ||
929
	    MathDevice->gp.font == BoldItalicFont);
929
	    gpptr(MathDevice)->font == BoldItalicFont);
930
}
930
}
931
 
931
 
932
static BBOX GlyphBBox(int chr)
932
static BBOX GlyphBBox(int chr)
933
{
933
{
934
    BBOX bbox;
934
    BBOX bbox;
Line 1245... Line 1245...
1245
    /* The Default Font Character */
1245
    /* The Default Font Character */
1246
    return RenderSymbolChar(S_SLASH, draw);
1246
    return RenderSymbolChar(S_SLASH, draw);
1247
#endif
1247
#endif
1248
#ifdef SLASH1
1248
#ifdef SLASH1
1249
    /* Symbol Magnify Version */
1249
    /* Symbol Magnify Version */
1250
    double savecex = MathDevice->gp.cex;
1250
    double savecex = gpptr(MathDevice)->cex;
1251
    BBOX bbox;
1251
    BBOX bbox;
1252
    double height1, height2;
1252
    double height1, height2;
1253
    height1 = bboxHeight(RenderSymbolChar(S_SLASH, 0));
1253
    height1 = bboxHeight(RenderSymbolChar(S_SLASH, 0));
1254
    MathDevice->gp.cex = 1.2 * MathDevice->gp.cex;
1254
    gpptr(MathDevice)->cex = 1.2 * gpptr(MathDevice)->cex;
1255
    height2 = bboxHeight(RenderSymbolChar(S_SLASH, 0));
1255
    height2 = bboxHeight(RenderSymbolChar(S_SLASH, 0));
1256
    if (draw)
1256
    if (draw)
1257
	PMoveUp(- 0.5 * (height2 - height1));
1257
	PMoveUp(- 0.5 * (height2 - height1));
1258
    bbox = RenderSymbolChar(S_SLASH, draw);
1258
    bbox = RenderSymbolChar(S_SLASH, draw);
1259
    if (draw)
1259
    if (draw)
1260
	PMoveUp(0.5 * (height2 - height1));
1260
	PMoveUp(0.5 * (height2 - height1));
1261
    MathDevice->gp.cex = savecex;
1261
    gpptr(MathDevice)->cex = savecex;
1262
    return bbox;
1262
    return bbox;
1263
#endif
1263
#endif
1264
#ifdef SLASH2
1264
#ifdef SLASH2
1265
    /* Line Drawing Version */
1265
    /* Line Drawing Version */
1266
    double x[2], y[2];
1266
    double x[2], y[2];
Line 1833... Line 1833...
1833
}
1833
}
1834
 
1834
 
1835
static BBOX RenderDelimiter(int delim, int draw)
1835
static BBOX RenderDelimiter(int delim, int draw)
1836
{
1836
{
1837
    BBOX bbox;
1837
    BBOX bbox;
1838
    double savecex = MathDevice->gp.cex;
1838
    double savecex = gpptr(MathDevice)->cex;
1839
    MathDevice->gp.cex = DelimSymbolMag * MathDevice->gp.cex;
1839
    gpptr(MathDevice)->cex = DelimSymbolMag * gpptr(MathDevice)->cex;
1840
    bbox = RenderSymbolChar(delim, draw);
1840
    bbox = RenderSymbolChar(delim, draw);
1841
    MathDevice->gp.cex = savecex;
1841
    gpptr(MathDevice)->cex = savecex;
1842
    return bbox;
1842
    return bbox;
1843
}
1843
}
1844
 
1844
 
1845
static int GroupAtom(SEXP expr)
1845
static int GroupAtom(SEXP expr)
1846
{
1846
{
1847
    return NameAtom(expr) && NameMatch(expr, "group");
1847
    return NameAtom(expr) && NameMatch(expr, "group");
1848
}
1848
}
1849
 
1849
 
1850
static BBOX RenderGroup(SEXP expr, int draw)
1850
static BBOX RenderGroup(SEXP expr, int draw)
1851
{
1851
{
1852
    double cexSaved = MathDevice->gp.cex;
1852
    double cexSaved = gpptr(MathDevice)->cex;
1853
    BBOX bbox;
1853
    BBOX bbox;
1854
    int code;
1854
    int code;
1855
    if (length(expr) != 4)
1855
    if (length(expr) != 4)
1856
	errorcall(expr, "invalid group specification");
1856
	errorcall(expr, "invalid group specification");
1857
    bbox = NullBBox();
1857
    bbox = NullBBox();
1858
    code = DelimCode(expr, CADR(expr));
1858
    code = DelimCode(expr, CADR(expr));
1859
    MathDevice->gp.cex = DelimSymbolMag * MathDevice->gp.cex;
1859
    gpptr(MathDevice)->cex = DelimSymbolMag * gpptr(MathDevice)->cex;
1860
    if (code == 2) {
1860
    if (code == 2) {
1861
	bbox = RenderSymbolChar('|', draw);
1861
	bbox = RenderSymbolChar('|', draw);
1862
	bbox = RenderSymbolChar('|', draw);
1862
	bbox = RenderSymbolChar('|', draw);
1863
    }
1863
    }
1864
    else if (code != '.')
1864
    else if (code != '.')
1865
	bbox = RenderSymbolChar(code, draw);
1865
	bbox = RenderSymbolChar(code, draw);
1866
    MathDevice->gp.cex = cexSaved;
1866
    gpptr(MathDevice)->cex = cexSaved;
1867
    bbox = CombineBBoxes(bbox, RenderElement(CADDR(expr), draw));
1867
    bbox = CombineBBoxes(bbox, RenderElement(CADDR(expr), draw));
1868
    bbox = RenderItalicCorr(bbox, draw);
1868
    bbox = RenderItalicCorr(bbox, draw);
1869
    code = DelimCode(expr, CADDDR(expr));
1869
    code = DelimCode(expr, CADDDR(expr));
1870
    MathDevice->gp.cex = DelimSymbolMag * MathDevice->gp.cex;
1870
    gpptr(MathDevice)->cex = DelimSymbolMag * gpptr(MathDevice)->cex;
1871
    if (code == 2) {
1871
    if (code == 2) {
1872
	bbox = CombineBBoxes(bbox, RenderSymbolChar('|', draw));
1872
	bbox = CombineBBoxes(bbox, RenderSymbolChar('|', draw));
1873
	bbox = CombineBBoxes(bbox, RenderSymbolChar('|', draw));
1873
	bbox = CombineBBoxes(bbox, RenderSymbolChar('|', draw));
1874
    }
1874
    }
1875
    else if (code != '.')
1875
    else if (code != '.')
1876
	bbox = CombineBBoxes(bbox, RenderSymbolChar(code, draw));
1876
	bbox = CombineBBoxes(bbox, RenderSymbolChar(code, draw));
1877
    MathDevice->gp.cex = cexSaved;
1877
    gpptr(MathDevice)->cex = cexSaved;
1878
    return bbox;
1878
    return bbox;
1879
}
1879
}
1880
 
1880
 
1881
static int BGroupAtom(SEXP expr)
1881
static int BGroupAtom(SEXP expr)
1882
{
1882
{
Line 2144... Line 2144...
2144
}
2144
}
2145
 
2145
 
2146
static BBOX RenderOpSymbol(SEXP op, int draw)
2146
static BBOX RenderOpSymbol(SEXP op, int draw)
2147
{
2147
{
2148
    BBOX bbox;
2148
    BBOX bbox;
2149
    double cexSaved = MathDevice->gp.cex;
2149
    double cexSaved = gpptr(MathDevice)->cex;
2150
    /*double savedX = CurrentX;*/
2150
    /*double savedX = CurrentX;*/
2151
    /*double savedY = CurrentY;*/
2151
    /*double savedY = CurrentY;*/
2152
    double shift;
2152
    double shift;
2153
    int display = (GetStyle() > STYLE_T);
2153
    int display = (GetStyle() > STYLE_T);
2154
    int opId = OpAtom(op);
2154
    int opId = OpAtom(op);
2155
 
2155
 
2156
    if (opId == S_SUM || opId == S_PRODUCT ||
2156
    if (opId == S_SUM || opId == S_PRODUCT ||
2157
	opId == S_UNION || opId == S_INTERSECTION) {
2157
	opId == S_UNION || opId == S_INTERSECTION) {
2158
	if (display) {
2158
	if (display) {
2159
	    MathDevice->gp.cex = OperatorSymbolMag * MathDevice->gp.cex;
2159
	    gpptr(MathDevice)->cex = OperatorSymbolMag * gpptr(MathDevice)->cex;
2160
	    bbox = RenderSymbolChar(OpAtom(op), 0);
2160
	    bbox = RenderSymbolChar(OpAtom(op), 0);
2161
	    shift = 0.5 * (bboxHeight(bbox) - bboxDepth(bbox)) - TeX(sigma22);
2161
	    shift = 0.5 * (bboxHeight(bbox) - bboxDepth(bbox)) - TeX(sigma22);
2162
	    if (draw) {
2162
	    if (draw) {
2163
		PMoveUp(-shift);
2163
		PMoveUp(-shift);
2164
		bbox = RenderSymbolChar(opId, 1);
2164
		bbox = RenderSymbolChar(opId, 1);
2165
		PMoveUp(shift);
2165
		PMoveUp(shift);
2166
	    }
2166
	    }
2167
	    MathDevice->gp.cex = cexSaved;
2167
	    gpptr(MathDevice)->cex = cexSaved;
2168
	    return ShiftBBox(bbox, -shift);
2168
	    return ShiftBBox(bbox, -shift);
2169
	}
2169
	}
2170
	else return RenderSymbolChar(opId, draw);
2170
	else return RenderSymbolChar(opId, draw);
2171
    }
2171
    }
2172
    else {
2172
    else {
Line 2895... Line 2895...
2895
    if ((ascent==0) && (descent==0) && (width==0))
2895
    if ((ascent==0) && (descent==0) && (width==0))
2896
	error("Metric information not yet available for this device");
2896
	error("Metric information not yet available for this device");
2897
#endif
2897
#endif
2898
 
2898
 
2899
    MathDevice = dd;
2899
    MathDevice = dd;
2900
    BaseCex = MathDevice->gp.cex;
2900
    BaseCex = gpptr(MathDevice)->cex;
2901
    BoxColor = name2col("pink");
2901
    BoxColor = name2col("pink");
2902
    TextColor = MathDevice->gp.col;
2902
    TextColor = gpptr(MathDevice)->col;
2903
    CurrentStyle = STYLE_D;
2903
    CurrentStyle = STYLE_D;
2904
    SetFont(PlainFont);
2904
    SetFont(PlainFont);
2905
    bbox = RenderElement(expr, 0);
2905
    bbox = RenderElement(expr, 0);
2906
    ReferenceX = x;
2906
    ReferenceX = x;
2907
    ReferenceY = y;
2907
    ReferenceY = y;
Line 2939... Line 2939...
2939
	error("Metric information not yet available for this device");
2939
	error("Metric information not yet available for this device");
2940
#endif
2940
#endif
2941
 
2941
 
2942
    MathDevice = dd;
2942
    MathDevice = dd;
2943
 
2943
 
2944
    xadj = MathDevice->gp.adj;
2944
    xadj = gpptr(MathDevice)->adj;
2945
 
2945
 
2946
    /* This is MOSTLY the same as the same section of GMtext
2946
    /* This is MOSTLY the same as the same section of GMtext
2947
     * BUT it differs because it sets different values for yadj for
2947
     * BUT it differs because it sets different values for yadj for
2948
     * different situations.
2948
     * different situations.
2949
     * Paul
2949
     * Paul
Line 2964... Line 2964...
2964
	case 3:	    coords = MAR3;	break;
2964
	case 3:	    coords = MAR3;	break;
2965
	case 4:	    coords = MAR4;	break;
2965
	case 4:	    coords = MAR4;	break;
2966
	}
2966
	}
2967
	subcoords = USER;
2967
	subcoords = USER;
2968
    }
2968
    }
2969
    /* Note: I changed dd->gp.yLineBias to 0.3 here. */
2969
    /* Note: I changed gpptr(dd)->yLineBias to 0.3 here. */
2970
    /* Purely visual tuning. RI */
2970
    /* Purely visual tuning. RI */
2971
    /* Note: I removed the 0.3 fiddle here because mathematical
2971
    /* Note: I removed the 0.3 fiddle here because mathematical
2972
     * annotation stuff can do "exact" centering.
2972
     * annotation stuff can do "exact" centering.
2973
     * i.e., 0.3 fiddle is effectively replaced by yadj=0.5
2973
     * i.e., 0.3 fiddle is effectively replaced by yadj=0.5
2974
     */
2974
     */
Line 2977... Line 2977...
2977
	if(las == 2 || las == 3) {
2977
	if(las == 2 || las == 3) {
2978
	    angle = 90;
2978
	    angle = 90;
2979
	    yadj = 0.5;
2979
	    yadj = 0.5;
2980
	}
2980
	}
2981
	else {
2981
	else {
2982
	    line = line + 1 - dd->gp.yLineBias;
2982
	    line = line + 1 - gpptr(dd)->yLineBias;
2983
	    angle = 0;
2983
	    angle = 0;
2984
	    yadj = NA_REAL;
2984
	    yadj = NA_REAL;
2985
	}
2985
	}
2986
	break;
2986
	break;
2987
    case 2:
2987
    case 2:
2988
	if(las == 1 || las == 2) {
2988
	if(las == 1 || las == 2) {
2989
	    angle = 0;
2989
	    angle = 0;
2990
	    yadj = 0.5;
2990
	    yadj = 0.5;
2991
	}
2991
	}
2992
	else {
2992
	else {
2993
	    line = line + dd->gp.yLineBias;
2993
	    line = line + gpptr(dd)->yLineBias;
2994
	    angle = 90;
2994
	    angle = 90;
2995
	    yadj = NA_REAL;
2995
	    yadj = NA_REAL;
2996
	}
2996
	}
2997
	break;
2997
	break;
2998
    case 3:
2998
    case 3:
2999
	if(las == 2 || las == 3) {
2999
	if(las == 2 || las == 3) {
3000
	    angle = 90;
3000
	    angle = 90;
3001
	    yadj = 0.5;
3001
	    yadj = 0.5;
3002
	}
3002
	}
3003
	else {
3003
	else {
3004
	    line = line + dd->gp.yLineBias;
3004
	    line = line + gpptr(dd)->yLineBias;
3005
	    angle = 0;
3005
	    angle = 0;
3006
	    yadj = NA_REAL;
3006
	    yadj = NA_REAL;
3007
	}
3007
	}
3008
	break;
3008
	break;
3009
    case 4:
3009
    case 4:
3010
	if(las == 1 || las == 2) {
3010
	if(las == 1 || las == 2) {
3011
	    angle = 0;
3011
	    angle = 0;
3012
	    yadj = 0.5;
3012
	    yadj = 0.5;
3013
	}
3013
	}
3014
	else {
3014
	else {
3015
	    line = line + 1 - dd->gp.yLineBias;
3015
	    line = line + 1 - gpptr(dd)->yLineBias;
3016
	    angle = 90;
3016
	    angle = 90;
3017
	    yadj = NA_REAL;
3017
	    yadj = NA_REAL;
3018
	}
3018
	}
3019
	break;
3019
	break;
3020
    }
3020
    }