The R Project SVN R

Rev

Rev 12778 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12778 Rev 12976
Line 1... Line 1...
1
/*
1
/*
2
 *  A PicTeX device, (C) 1996 Valerio Aimale, for
2
 *  A PicTeX device, (C) 1996 Valerio Aimale, for
3
 *  R : A Computer Language for Statistical Data Analysis
3
 *  R : A Computer Language for Statistical Data Analysis
4
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
-
 
5
 *  Copyright (C) 2001  The R Development Core Team
5
 *
6
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *  (at your option) any later version.
Line 141... Line 142...
141
  0.5500030, 0.550003
142
  0.5500030, 0.550003
142
}
143
}
143
};
144
};
144
 
145
 
145
static char *fontname[] = {
146
static char *fontname[] = {
146
	"cmss10",
147
    "cmss10",
147
	"cmssbx10",
148
    "cmssbx10",
148
	"cmssi10",
149
    "cmssi10",
149
	"cmssxi10"
150
    "cmssxi10"
150
};
151
};
151
 
152
 
152
 
153
 
153
	/* Device driver actions */
154
	/* Device driver actions */
154
 
155
 
Line 292... Line 293...
292
 
293
 
293
	/* Close down the driver */
294
	/* Close down the driver */
294
 
295
 
295
static void PicTeX_Close(DevDesc *dd)
296
static void PicTeX_Close(DevDesc *dd)
296
{
297
{
297
	picTeXDesc *ptd = (picTeXDesc *) dd->deviceSpecific;
298
    picTeXDesc *ptd = (picTeXDesc *) dd->deviceSpecific;
298
 
-
 
299
	fprintf(ptd->texfp, "\\endpicture\n}\n");
-
 
300
	fclose(ptd->texfp);
-
 
301
 
-
 
302
	free(ptd);
-
 
303
}
-
 
304
 
299
 
-
 
300
    fprintf(ptd->texfp, "\\endpicture\n}\n");
-
 
301
    fclose(ptd->texfp);
305
 
302
 
306
	/* Seek */
303
    free(ptd);
307
/* NO LONGER USED
-
 
308
static void PicTeX_MoveTo(double x, double y)
-
 
309
{
-
 
310
	xlast = x;
-
 
311
	ylast = y;
-
 
312
}
304
}
313
*/
-
 
314
 
305
 
315
	/* Draw To */
306
	/* Draw To */
316
 
307
 
317
static void PicTeX_ClipLine(double x0, double y0, double x1, double y1,
308
static void PicTeX_ClipLine(double x0, double y0, double x1, double y1,
318
			    picTeXDesc *ptd)
309
			    picTeXDesc *ptd)
Line 400... Line 391...
400
}
391
}
401
 
392
 
402
static void PicTeX_Line(double x1, double y1, double x2, double y2,
393
static void PicTeX_Line(double x1, double y1, double x2, double y2,
403
			int coords, DevDesc *dd)
394
			int coords, DevDesc *dd)
404
{
395
{
405
	picTeXDesc *ptd = (picTeXDesc *) dd->deviceSpecific;
396
    picTeXDesc *ptd = (picTeXDesc *) dd->deviceSpecific;
406
 
397
 
407
	if (x1 != x2 || y1 != y2) {
398
    if (x1 != x2 || y1 != y2) {
408
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
399
	SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
409
	GConvert(&x1, &y1, coords, DEVICE, dd);
400
	GConvert(&x1, &y1, coords, DEVICE, dd);
410
	GConvert(&x2, &y2, coords, DEVICE, dd);
401
	GConvert(&x2, &y2, coords, DEVICE, dd);
411
	if(ptd->debug)
402
	if(ptd->debug)
412
		fprintf(ptd->texfp,
403
	    fprintf(ptd->texfp,
413
			"%% Drawing line from %.2f, %.2f to %.2f, %.2f\n",
404
		    "%% Drawing line from %.2f, %.2f to %.2f, %.2f\n",
414
			x1, y1, x2, y2);
405
		    x1, y1, x2, y2);
415
	PicTeX_ClipLine(x1, y1, x2, y2, ptd);
406
	PicTeX_ClipLine(x1, y1, x2, y2, ptd);
416
	if (ptd->debug)
407
	if (ptd->debug)
417
		fprintf(ptd->texfp,
408
	    fprintf(ptd->texfp,
418
			"%% Drawing clipped line from %.2f, %.2f to %.2f, %.2f\n",
409
		    "%% Drawing clipped line from %.2f, %.2f to %.2f, %.2f\n",
419
			ptd->clippedx0, ptd->clippedy0,
410
		    ptd->clippedx0, ptd->clippedy0,
420
			ptd->clippedx1, ptd->clippedy1);
411
		    ptd->clippedx1, ptd->clippedy1);
421
	fprintf(ptd->texfp, "\\plot %.2f %.2f %.2f %.2f /\n",
412
	fprintf(ptd->texfp, "\\plot %.2f %.2f %.2f %.2f /\n",
422
		ptd->clippedx0, ptd->clippedy0,
413
		ptd->clippedx0, ptd->clippedy0,
423
		ptd->clippedx1, ptd->clippedy1);
414
		ptd->clippedx1, ptd->clippedy1);
424
	}
415
    }
425
}
416
}
426
 
417
 
427
static void PicTeX_Polyline(int n, double *x, double *y, int coords,
418
static void PicTeX_Polyline(int n, double *x, double *y, int coords,
428
			    DevDesc* dd)
419
			    DevDesc* dd)
429
{
420
{
Line 433... Line 424...
433
 
424
 
434
    SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
425
    SetLinetype(dd->gp.lty, dd->gp.lwd, dd);
435
    x1 = x[0];
426
    x1 = x[0];
436
    y1 = y[0];
427
    y1 = y[0];
437
    GConvert(&x1, &y1, coords, DEVICE, dd);
428
    GConvert(&x1, &y1, coords, DEVICE, dd);
438
    for (i=1; i<n; i++) {
429
    for (i = 1; i < n; i++) {
439
	x2 = x[i];
430
	x2 = x[i];
440
	y2 = y[i];
431
	y2 = y[i];
441
	GConvert(&x2, &y2, coords, DEVICE, dd);
432
	GConvert(&x2, &y2, coords, DEVICE, dd);
442
	PicTeX_ClipLine(x1, y1, x2, y2, ptd);
433
	PicTeX_ClipLine(x1, y1, x2, y2, ptd);
443
	fprintf(ptd->texfp, "\\plot %.2f %.2f %.2f %.2f /\n",
434
	fprintf(ptd->texfp, "\\plot %.2f %.2f %.2f %.2f /\n",
444
		ptd->clippedx0, ptd->clippedy0,
435
		ptd->clippedx0, ptd->clippedy0,
445
		ptd->clippedx1, ptd->clippedy1);
436
		ptd->clippedx1, ptd->clippedy1);
-
 
437
	x1 = x2;
-
 
438
	y1 = y2;
446
    }
439
    }
447
}
440
}
448
 
441
 
449
	/* String Width in Rasters */
442
	/* String Width in Rasters */
450
	/* For the current font in pointsize fontsize */
443
	/* For the current font in pointsize fontsize */
Line 463... Line 456...
463
	sum += charwidth[ptd->fontface-1][(int)*p];
456
	sum += charwidth[ptd->fontface-1][(int)*p];
464
    return sum * ptd->fontsize;
457
    return sum * ptd->fontsize;
465
}
458
}
466
 
459
 
467
 
460
 
468
 
-
 
469
 
-
 
470
	/* Start a Path */
-
 
471
/* NO LONGER USED
-
 
472
	static void PicTeX_StartPath()
-
 
473
	{
-
 
474
		SetLinetype(GP->lty, dd->gp.lwd, dd);
-
 
475
	}
-
 
476
*/
-
 
477
 
-
 
478
	/* End a Path */
-
 
479
/* NO LONGER USED
-
 
480
	static void PicTeX_EndPath()
-
 
481
	{
-
 
482
	}
-
 
483
*/
-
 
484
 
-
 
485
/* Possibly Filled Rectangle */
461
/* Possibly Filled Rectangle */
486
static void PicTeX_Rect(double x0, double y0, double x1, double y1,
462
static void PicTeX_Rect(double x0, double y0, double x1, double y1,
487
			int coords, int bg, int fg, DevDesc *dd)
463
			int coords, int bg, int fg, DevDesc *dd)
488
{
464
{
489
    double x[4], y[4];
465
    double x[4], y[4];
-
 
466
 
490
    x[0] = x0; y[0] = y0;
467
    x[0] = x0; y[0] = y0;
491
    x[1] = x0; y[1] = y1;
468
    x[1] = x0; y[1] = y1;
492
    x[2] = x1; y[2] = y1;
469
    x[2] = x1; y[2] = y1;
493
    x[3] = x1; y[3] = y0;
470
    x[3] = x1; y[3] = y0;
494
    PicTeX_Polygon(4, x, y, coords, bg, fg, dd);
471
    PicTeX_Polygon(4, x, y, coords, bg, fg, dd);
Line 501... Line 478...
501
 
478
 
502
    GConvert(&x, &y, coords, DEVICE, dd);
479
    GConvert(&x, &y, coords, DEVICE, dd);
503
    fprintf(ptd->texfp,
480
    fprintf(ptd->texfp,
504
	    "\\circulararc 360 degrees from %.2f %.2f center at %.2f %.2f\n",
481
	    "\\circulararc 360 degrees from %.2f %.2f center at %.2f %.2f\n",
505
	    x, (y + r), x, y);
482
	    x, (y + r), x, y);
506
 
-
 
507
}
483
}
508
 
484
 
509
static void PicTeX_Polygon(int n, double *x, double *y, int coords,
485
static void PicTeX_Polygon(int n, double *x, double *y, int coords,
510
			   int bg, int fg, DevDesc* dd)
486
			   int bg, int fg, DevDesc* dd)
511
{
487
{
Line 588... Line 564...
588
		"%% Writing string of length %.2f, at %.2f %.2f, xc = %.2f yc = %.2f\n",
564
		"%% Writing string of length %.2f, at %.2f %.2f, xc = %.2f yc = %.2f\n",
589
		(double)PicTeX_StrWidth(str, dd), x, y, 0.0, 0.0);
565
		(double)PicTeX_StrWidth(str, dd), x, y, 0.0, 0.0);
590
    fprintf(ptd->texfp,"\\put ");
566
    fprintf(ptd->texfp,"\\put ");
591
    textext(str, ptd);
567
    textext(str, ptd);
592
    if (rot == 90 )
568
    if (rot == 90 )
593
	 fprintf(ptd->texfp," [rB] <%.2fpt,%.2fpt>", xoff, yoff);
569
	fprintf(ptd->texfp," [rB] <%.2fpt,%.2fpt>", xoff, yoff);
594
    else fprintf(ptd->texfp," [lB] <%.2fpt,%.2fpt>", xoff, yoff);
570
    else fprintf(ptd->texfp," [lB] <%.2fpt,%.2fpt>", xoff, yoff);
595
    fprintf(ptd->texfp," at %.2f %.2f\n", x, y);
571
    fprintf(ptd->texfp," at %.2f %.2f\n", x, y);
596
}
572
}
597
 
573
 
598
/* Pick */
574
/* Pick */
Line 600... Line 576...
600
{
576
{
601
    return FALSE;
577
    return FALSE;
602
}
578
}
603
 
579
 
604
 
580
 
605
/* Set Graphics mode - not needed for PS */
-
 
606
static void PicTeX_Mode(int mode, DevDesc* dd)
581
static void PicTeX_Mode(int mode, DevDesc* dd)
607
{
582
{
608
}
583
}
609
 
584
 
610
/* GraphicsInteraction() for the Mac */
-
 
611
static void PicTeX_Hold(DevDesc *dd)
585
static void PicTeX_Hold(DevDesc *dd)
612
{
586
{
613
}
587
}
614
 
588
 
615
Rboolean PicTeXDeviceDriver(DevDesc *dd, char *filename, char *bg, char *fg,
589
Rboolean PicTeXDeviceDriver(DevDesc *dd, char *filename, char *bg, char *fg,