The R Project SVN R

Rev

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

Rev 44108 Rev 44148
Line 3316... Line 3316...
3316
    rot *= M_PI_2 / 90 ;/* radians */
3316
    rot *= M_PI_2 / 90 ;/* radians */
3317
    mc.CosAngle = cos(rot);
3317
    mc.CosAngle = cos(rot);
3318
    mc.SinAngle = sin(rot);
3318
    mc.SinAngle = sin(rot);
3319
    RenderElement(expr, 1, &mc, gc, dd);
3319
    RenderElement(expr, 1, &mc, gc, dd);
3320
}/* GEMathText */
3320
}/* GEMathText */
3321
 
-
 
3322
 
-
 
3323
/********************************
-
 
3324
 * Code below here ...
-
 
3325
 * ... should be moved to base.c and
-
 
3326
 * ... is part of the base graphics API NOT the graphics engine API
-
 
3327
 ********************************
-
 
3328
 */
-
 
3329
double GExpressionWidth(SEXP expr, GUnit units, DevDesc *dd)
-
 
3330
{
-
 
3331
    R_GE_gcontext gc;
-
 
3332
    double width;
-
 
3333
    gcontextFromGP(&gc, dd);
-
 
3334
    width = GEExpressionWidth(expr, &gc, (GEDevDesc*) dd);
-
 
3335
    if (units == DEVICE)
-
 
3336
	return width;
-
 
3337
    else
-
 
3338
	return GConvertXUnits(width, DEVICE, units, dd);
-
 
3339
}
-
 
3340
 
-
 
3341
double GExpressionHeight(SEXP expr, GUnit units, DevDesc *dd)
-
 
3342
{
-
 
3343
    R_GE_gcontext gc;
-
 
3344
    double height;
-
 
3345
    gcontextFromGP(&gc, dd);
-
 
3346
    height = GEExpressionHeight(expr, &gc, (GEDevDesc*) dd);
-
 
3347
    if (units == DEVICE)
-
 
3348
	return height;
-
 
3349
    else
-
 
3350
	return GConvertYUnits(height, DEVICE, units, dd);
-
 
3351
}
-
 
3352
 
-
 
3353
/* This is just here to satisfy the Rgraphics.h API.
-
 
3354
 * This allows new graphics API (GraphicsDevice.h, GraphicsEngine.h)
-
 
3355
 * to be developed alongside.
-
 
3356
 * Could be removed if Rgraphics.h ever gets REPLACED by new API
-
 
3357
 * NOTE that base graphics code no longer calls this -- the base
-
 
3358
 * graphics system directly calls the graphics engine for mathematical
-
 
3359
 * annotation (GEMathText)
-
 
3360
 */
-
 
3361
void GMathText(double x, double y, int coords, SEXP expr,
-
 
3362
	       double xc, double yc, double rot,
-
 
3363
	       DevDesc *dd)
-
 
3364
{
-
 
3365
    R_GE_gcontext gc;
-
 
3366
    gcontextFromGP(&gc, dd);
-
 
3367
    GConvert(&x, &y, coords, DEVICE, dd);
-
 
3368
    GClip(dd);
-
 
3369
    GEMathText(x, y, expr, xc, yc, rot, &gc, (GEDevDesc*) dd);
-
 
3370
}
-
 
3371
 
-
 
3372
void GMMathText(SEXP str, int side, double line, int outer,
-
 
3373
		double at, int las, double yadj, DevDesc *dd)
-
 
3374
{
-
 
3375
    int coords = 0, subcoords;
-
 
3376
    double xadj, angle = 0;
-
 
3377
 
-
 
3378
#ifdef BUG61
-
 
3379
#else
-
 
3380
    /* IF font metric information is not available for device */
-
 
3381
    /* then bail out */
-
 
3382
    double ascent, descent, width;
-
 
3383
    GMetricInfo(0, &ascent, &descent, &width, DEVICE, dd);
-
 
3384
    if ((ascent==0) && (descent==0) && (width==0))
-
 
3385
	error(_("Metric information not available for this device"));
-
 
3386
#endif
-
 
3387
 
-
 
3388
    xadj = Rf_gpptr(dd)->adj;
-
 
3389
 
-
 
3390
    /* This is MOSTLY the same as the same section of GMtext
-
 
3391
     * BUT it differs because it sets different values for yadj for
-
 
3392
     * different situations.
-
 
3393
     * Paul
-
 
3394
     */
-
 
3395
     /* changed to unify behaviour with changes in GMText. Uwe */
-
 
3396
    if(outer) {
-
 
3397
	switch(side) {
-
 
3398
	case 1:	    coords = OMA1;	break;
-
 
3399
	case 2:	    coords = OMA2;	break;
-
 
3400
	case 3:	    coords = OMA3;	break;
-
 
3401
	case 4:	    coords = OMA4;	break;
-
 
3402
	}
-
 
3403
	subcoords = NIC;
-
 
3404
    }
-
 
3405
    else {
-
 
3406
	switch(side) {
-
 
3407
	case 1:	    coords = MAR1;	break;
-
 
3408
	case 2:	    coords = MAR2;	break;
-
 
3409
	case 3:	    coords = MAR3;	break;
-
 
3410
	case 4:	    coords = MAR4;	break;
-
 
3411
	}
-
 
3412
	subcoords = USER;
-
 
3413
    }
-
 
3414
    /* Note: I changed Rf_gpptr(dd)->yLineBias to 0.3 here. */
-
 
3415
    /* Purely visual tuning. RI */
-
 
3416
    /* Note: I removed the 0.3 fiddle here because mathematical
-
 
3417
     * annotation stuff can do "exact" centering.
-
 
3418
     * i.e., 0.3 fiddle is effectively replaced by yadj=0.5
-
 
3419
     */
-
 
3420
    switch(side) {
-
 
3421
    case 1:
-
 
3422
	if(las == 2 || las == 3) {
-
 
3423
	    angle = 90;
-
 
3424
	}
-
 
3425
	else {
-
 
3426
	    /*	    line = line + 1 - Rf_gpptr(dd)->yLineBias;
-
 
3427
		    angle = 0;
-
 
3428
		    yadj = NA_REAL; */
-
 
3429
	    line = line + 1;
-
 
3430
	    angle = 0;
-
 
3431
	}
-
 
3432
	break;
-
 
3433
    case 2:
-
 
3434
	if(las == 1 || las == 2) {
-
 
3435
	    angle = 0;
-
 
3436
	}
-
 
3437
	else {
-
 
3438
	    /*	    line = line + Rf_gpptr(dd)->yLineBias;
-
 
3439
		    angle = 90;
-
 
3440
		    yadj = NA_REAL; */
-
 
3441
	    angle = 90;
-
 
3442
	}
-
 
3443
	break;
-
 
3444
    case 3:
-
 
3445
	if(las == 2 || las == 3) {
-
 
3446
	    angle = 90;
-
 
3447
	}
-
 
3448
	else {
-
 
3449
	    /*   line = line + Rf_gpptr(dd)->yLineBias;
-
 
3450
		 angle = 0;
-
 
3451
		 yadj = NA_REAL; */
-
 
3452
	    angle = 0;
-
 
3453
	}
-
 
3454
	break;
-
 
3455
    case 4:
-
 
3456
	if(las == 1 || las == 2) {
-
 
3457
	    angle = 0;
-
 
3458
	}
-
 
3459
	else {
-
 
3460
	    /*   line = line + 1 - Rf_gpptr(dd)->yLineBias;
-
 
3461
		 angle = 90;
-
 
3462
		 yadj = NA_REAL; */
-
 
3463
	    line = line + 1;
-
 
3464
	    angle = 90;
-
 
3465
	}
-
 
3466
	break;
-
 
3467
    }
-
 
3468
    GMathText(at, line, coords, str, xadj, yadj, angle, dd);
-
 
3469
}/* GMMathText */
-