The R Project SVN R

Rev

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

Rev 2124 Rev 2679
Line 2804... Line 2804...
2804
/* BBOXes are in INCHES (see MetricUnit) */
2804
/* BBOXes are in INCHES (see MetricUnit) */
2805
 
2805
 
2806
void GExpressionBBox(SEXP expr, int units, double *width,
2806
void GExpressionBBox(SEXP expr, int units, double *width,
2807
		     double *height, double *depth, DevDesc *dd)
2807
		     double *height, double *depth, DevDesc *dd)
2808
{
2808
{
-
 
2809
    BBOX bbox;
-
 
2810
    MathDevice = dd;
-
 
2811
/* The following two lines don't look right to me, but I inserted them
-
 
2812
   because otherwise you get trouble if you calculate BBoxes without
-
 
2813
   plotting any math first... Similar problem in the next two functions
-
 
2814
	 --pd */
-
 
2815
    CurrentStyle = STYLE_D;
-
 
2816
    SetFont(PlainFont);
2809
    BBOX bbox = RenderElement(expr, 0);
2817
    bbox = RenderElement(expr, 0);
2810
    *width  = bboxWidth(bbox);
2818
    *width  = bboxWidth(bbox);
2811
    *height  = bboxHeight(bbox);
2819
    *height  = bboxHeight(bbox);
2812
    *depth  = bboxDepth(bbox);
2820
    *depth  = bboxDepth(bbox);
2813
    if (units != INCHES) {
2821
    if (units != INCHES) {
2814
	*width = GConvertXUnits(*width, INCHES, units, dd);
2822
	*width = GConvertXUnits(*width, INCHES, units, dd);
Line 2817... Line 2825...
2817
    }
2825
    }
2818
}
2826
}
2819
 
2827
 
2820
double GExpressionWidth(SEXP expr, int units, DevDesc *dd)
2828
double GExpressionWidth(SEXP expr, int units, DevDesc *dd)
2821
{
2829
{
-
 
2830
    BBOX bbox;
-
 
2831
    double width;
-
 
2832
    MathDevice = dd;
-
 
2833
    CurrentStyle = STYLE_D;
-
 
2834
    SetFont(PlainFont);
2822
    BBOX bbox = RenderElement(expr, 0);
2835
    bbox = RenderElement(expr, 0);
2823
    double width  = bboxWidth(bbox);
2836
    width  = bboxWidth(bbox);
2824
    if (units == INCHES)
2837
    if (units == INCHES)
2825
	return width;
2838
	return width;
2826
    else
2839
    else
2827
	return GConvertXUnits(width, INCHES, units, dd);
2840
	return GConvertXUnits(width, INCHES, units, dd);
2828
}
2841
}
2829
 
2842
 
2830
double GExpressionHeight(SEXP expr, int units, DevDesc *dd)
2843
double GExpressionHeight(SEXP expr, int units, DevDesc *dd)
2831
{
2844
{
-
 
2845
    BBOX bbox;
-
 
2846
    double height;
-
 
2847
    MathDevice = dd;
-
 
2848
    CurrentStyle = STYLE_D;
-
 
2849
    SetFont(PlainFont);
2832
    BBOX bbox = RenderElement(expr, 0);
2850
    bbox = RenderElement(expr, 0);
2833
    double height = bboxHeight(bbox) + bboxDepth(bbox);
2851
    height = bboxHeight(bbox) + bboxDepth(bbox);
2834
    if (units == INCHES)
2852
    if (units == INCHES)
2835
	return height;
2853
	return height;
2836
    else
2854
    else
2837
	return GConvertYUnits(height, INCHES, units, dd);
2855
	return GConvertYUnits(height, INCHES, units, dd);
2838
}
2856
}