The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 r 1
/*
990 maechler 2
 *  R : A Computer Language for Statistical Data Analysis
2 r 3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
4562 pd 4
 *  Copyright (C) 1998--1999  R Development Core Team
2 r 5
 *
6
 *  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
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
 */
20
 
21
#ifndef GRAPHICS_H_
22
#define GRAPHICS_H_
23
 
258 paul 24
#include "Defn.h"
2 r 25
 
26
#ifndef NA_REAL
27
#define NA_REAL R_NaReal
28
#endif
29
 
30
#ifndef NA_INTEGER
31
#define NA_INTEGER R_NaInt
32
#endif
33
 
34
#include <math.h>
35
 
36
#ifdef Windows
2428 maechler 37
#include <windows.h>
2 r 38
#endif
39
 
40
#include <float.h>
41
#include <stdlib.h>
42
#include <stdio.h>
43
 
44
/*
45
 *	Some Notes on Color
46
 *
47
 *	R uses a 24-bit color model.  Colors are specified in 32-bit
48
 *	integers which are partitioned into 4 bytes as follows.
49
 *
2566 maechler 50
 *		<-- most sig	    least sig -->
2 r 51
 *		+-------------------------------+
2566 maechler 52
 *		|   0	| blue	| green |  red	|
2 r 53
 *		+-------------------------------+
54
 *
55
 *	The red, green and blue bytes can be extracted as follows.
56
 *
2566 maechler 57
 *		red   = ((color	     ) & 255)
2 r 58
 *		green = ((color >>  8) & 255)
59
 *		blue  = ((color >> 16) & 255)
60
 */
61
 
62
#define R_RGB(r,g,b)	((r)|((g)<<8)|((b)<<16))
2566 maechler 63
#define R_RED(col)	(((col)	   )&255)
2 r 64
#define R_GREEN(col)	(((col)>> 8)&255)
65
#define R_BLUE(col)	(((col)>>16)&255)
581 paul 66
#define COLOR_TABLE_SIZE 256
2 r 67
 
68
 
69
#ifdef Unix
70
#define LTY_SOLID	0
71
#define LTY_DASHED	4 + (4<<4)
72
#define LTY_DOTTED	1 + (3<<4)
2207 pd 73
#define LTY_DOTDASH	1 + (3<<4) + (4<<8) + (3<<12)
2 r 74
#endif
75
 
3979 ripley 76
#ifdef Win32
77
#define LTY_SOLID	0
78
#define LTY_DASHED	4 + (4<<4)
79
#define LTY_DOTTED	1 + (2<<4)
80
#define LTY_DOTDASH	1 + (3<<4) + (4<<8) + (3<<12)
81
#endif
82
 
3244 ihaka 83
#ifdef Macintosh
84
#define LTY_SOLID	0
85
#define LTY_DASHED	4 + (4<<4)
86
#define LTY_DOTTED	1 + (3<<4)
87
#define LTY_DOTDASH	1 + (3<<4) + (4<<8) + (3<<12)
88
#endif
89
 
2 r 90
#ifdef Windows
91
#define LTY_SOLID	PS_SOLID
92
#define LTY_DASHED	PS_DASH
93
#define LTY_DOTTED	PS_DOT
94
#define LTY_DOTDASH	PS_DASHDOT
95
#endif
96
 
581 paul 97
#define MAX_LAYOUT_ROWS 15
98
#define MAX_LAYOUT_COLS 15
99
 
100
	/* possible coordinate systems (for specifying locations) */
101
 
102
#define DEVICE	0	/* native device coordinates (rasters) */
103
#define NDC	1	/* normalised device coordinates x=(0,1), y=(0,1) */
2566 maechler 104
#define INCHES 13	/* inches x=(0,width), y=(0,height) */
581 paul 105
#define NIC	6	/* normalised inner region coordinates (0,1) */
106
#define OMA1	2	/* outer margin 1 (bottom) x=NIC, y=LINES */
107
#define OMA2	3	/* outer margin 2 (left) */
108
#define OMA3	4	/* outer margin 3 (top) */
109
#define OMA4	5	/* outer margin 4 (right) */
110
#define NFC	7	/* normalised figure region coordinates (0,1) */
2566 maechler 111
#define NPC	16	/* normalised plot region coordinates (0,1) */
581 paul 112
#define USER	12	/* user/data/world corrdinates */
113
			/* x=(xmin,xmax), y=(ymin,ymax) */
114
#define MAR1	8	/* figure margin 1 (bottom) x=USER(x), y=LINES */
115
#define MAR2	9	/* figure margin 2 (left) x=USER(y) y=LINES */
116
#define MAR3	10	/* figure margin 3 (top) x=USER(x), y=LINES */
117
#define MAR4	11	/* figure margin 4 (right) x=USER(y) y=LINES */
118
 
119
	/* possible units (for specifying dimensions) */
120
	/* all of the above, plus ... */
121
 
122
#define LINES 14	/* multiples of a line in the margin (mex) */
123
#define CHARS 15	/* multiples of text height (cex) */
124
 
125
#define R_MaxDevices 64
126
 
2 r 127
typedef unsigned int rcolor;
128
 
129
typedef struct {
130
	double ax;
131
	double bx;
132
	double ay;
133
	double by;
134
} GTrans;
135
 
581 paul 136
struct colorDataBaseEntry {
2566 maechler 137
	char *name;	/* X11 Color Name */
138
	char *rgb;	/* #RRGGBB String */
2505 maechler 139
	unsigned int code;  /* Internal R Color Code */
581 paul 140
};
141
 
990 maechler 142
typedef struct colorDataBaseEntry ColorDataBaseEntry;
581 paul 143
 
3244 ihaka 144
extern int R_ColorTableSize;
145
extern unsigned int R_ColorTable[];
581 paul 146
extern ColorDataBaseEntry ColorDataBase[];
147
extern char *DefaultPalette[];
148
 
2 r 149
/* Graphics State:
150
 *
151
 * The following structure defines state for a graphics device driver.
152
 * Two copies are kept; the ``default'' set of values, and a set which
153
 * can be modified during calls to an application program.  When a
154
 * new graphics frame is started, the values revert to the defaults
581 paul 155
 *
2 r 156
 */
157
 
158
typedef struct {
4022 r 159
    /* Basic Device Driver Properties */
160
    /* These MUST be set by device drivers on open */
2 r 161
 
4022 r 162
    /* These parameters cannot be set by the user */
163
    /* although left, right, bottom, and top can be */
164
    /* interrogated indirectly (i.e., par("din")) */
165
    /* and cra can be interrogated directly (i.e., par("cra")) */
581 paul 166
 
4022 r 167
    double left;	/* left raster coordinate */
168
    double right;	/* right raster coordinate */
169
    double bottom;	/* bottom raster coordinate */
170
    double top;		/* top raster coordinate */
171
    double xCharOffset;	/* x character addressing offset */
172
    double yCharOffset;	/* y character addressing offset */
173
    double yLineBias;	/* 1/2 interline space as fraction of line height */
174
    int canResizePlot;	/* can the graphics surface be resized */
175
    int canChangeFont;	/* device has multiple fonts */
176
    int canRotateText;	/* text can be rotated */
177
    int canResizeText;	/* text can be resized */
178
    int canClip;	/* Hardware clipping */
2 r 179
 
4022 r 180
    /* a couple of the GRZ-like parameters that have to be */
181
    /* set by the device */
581 paul 182
 
4022 r 183
    double ipr[2];	/* Inches per raster; [0]=x, [1]=y */
184
    double asp;		/* Pixel aspect ratio = ipr[1]/ipr[0] */
185
    double cra[2];	/* Character size in rasters; [0]=x, [1]=y */
581 paul 186
 
4022 r 187
    /* Plot State */
188
    /* When the device driver is started this is 0 */
189
    /* After the first call to plot.new it is 1 */
190
    /* Every graphics operation except plot.new */
191
    /* should fail if state = 0 */
192
    /* This is checked at the highest internal function */
193
    /* level (e.g., do_lines, do_axis, do_plot_xy, ...) */
2 r 194
 
4022 r 195
    int	state;		/* Plot State */
196
    int	valid;		/* valid layout ? */
2 r 197
 
4022 r 198
    /* GRZ-like Graphics Parameters */
199
    /* ``The horror, the horror ... '' */
200
    /* Marlon Brando - Appocalypse Now */
2 r 201
 
4022 r 202
    /* General Parameters -- set and interrogated directly */
2 r 203
 
4022 r 204
    double adj;		/* String adjustment */
205
    int	ann;		/* Should annotation take place */
206
    int	ask;		/* User confirmation of ``page eject'' */
207
    rcolor bg;		/* **R ONLY** Background color */
208
    int	bty;		/* Box type */
209
    double cex;		/* Character expansion */
210
    rcolor col;		/* Plotting Color */
211
    double crt;		/* Character/string rotation */
212
    double din[2];	/* device size in inches */
213
    int	err;		/* Error repporting level */
214
    rcolor fg;		/* **R ONLY** Foreground Color */
215
    int	font;		/* Text font */
216
    double gamma;	/* Device Gamma Correction */
217
    int	lab[3];		/* Axis labelling */
218
			/* [0] = # ticks on x-axis */
219
			/* [1] = # ticks on y-axis */
220
			/* [2] = length of axis labels */
221
    int	las;		/* Label style (rotation) */
222
    int	lty;		/* Line texture */
223
    double lwd;		/* Line width */
224
    double mgp[3];	/* Annotation location */
225
			/* [0] = location of axis title */
226
			/* [1] = location of axis label */
227
			/* [2] = location of axis line */
228
    double mkh;		/* Mark size in inches */
229
    int	pch;		/* Plotting character */
230
    int	ps;		/* Text & symbol pointsize */
231
    int	smo;		/* Curve smoothness */
232
    double srt;		/* String Rotation */
233
    double tck;		/* Tick size as in S */
234
    double tcl;		/* Tick size in "lines" */
235
    double tmag;	/* **R ONLY** Title Magnification */
236
    int	type;		/* type of plot desired */
237
    double xaxp[3];	/* X Axis annotation */
238
			/* [0] = coordinate of lower tick */
239
			/* [1] = coordinate of upper tick */
240
			/* [2] = num tick intervals */
241
			/* almost always used internally */
242
    int	xaxs;		/* X Axis style */
243
    int	xaxt;		/* X Axis type */
244
    int	xpd;		/* Clip to plot region indicator */
245
    int	oldxpd;
246
    double yaxp[3];	/* Y Axis annotation */
247
    int	yaxs;		/* Y Axis style */
248
    int	yaxt;		/* Y Axis type */
249
    int	xlog;		/* Log Axis for X */
250
    int	ylog;		/* Log Axis for Y */
1255 maechler 251
 
4022 r 252
    /* Annotation Parameters */
2 r 253
 
4022 r 254
    float cexbase;	/* Base character size */
255
    float cexmain;	/* Main title size */
256
    float cexlab;	/* xlab and ylab size */
257
    float cexsub;	/* Sub title size */
258
    float cexaxis;	/* Axis label size */
2 r 259
 
4022 r 260
    int	fontmain;	/* Main title font */
261
    int	fontlab;	/* Xlab and ylab font */
262
    int	fontsub;	/* Subtitle font */
263
    int	fontaxis;	/* Axis label fonts */
2 r 264
 
4022 r 265
    int	colmain;	/* Main title color */
266
    int	collab;		/* Xlab and ylab color */
267
    int	colsub;		/* Subtitle color */
268
    int	colaxis;	/* Axis label color */
2 r 269
 
4022 r 270
    /* Layout Parameters */
2 r 271
 
4022 r 272
    int	layout;		/* has a layout been specified */
2 r 273
 
4022 r 274
    int	numrows;
275
    int	numcols;
276
    int	currentFigure;
277
    int	lastFigure;
278
    double heights[MAX_LAYOUT_ROWS];
279
    double widths[MAX_LAYOUT_COLS];
280
    int	cmHeights[MAX_LAYOUT_ROWS];
281
    int	cmWidths[MAX_LAYOUT_COLS];
282
    int	order[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
283
    int	rspct;	        /* 0 = none, 1 = full, 2 = see respect */
284
    int	respect[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
671 paul 285
 
4022 r 286
    int	mfind;		/* By row/col indicator */
581 paul 287
 
4022 r 288
    /* Layout parameters which can be set directly by the */
289
    /* user (e.g., par(fig=c(.5,1,0,1))) or otherwise are */
290
    /* calculated automatically */
291
    /* NOTE that *Units parameters are for internal use only */
581 paul 292
 
4022 r 293
    double fig[4];	/* (current) Figure size (proportion) */
294
			/* [0] = left, [1] = right */
295
			/* [2] = bottom, [3] = top */
296
    double fin[2];	/* (current) Figure size (inches) */
297
			/* [0] = width, [1] = height */
298
    int	fUnits;		/* (current) figure size units */
299
    int	defaultFigure;	/* calculate figure from layout ? */
300
    double plt[4];	/* (current) Plot size (proportions) */
301
			/* [0] = left, [1] = right */
302
			/* [2] = bottom, [3] = top */
303
    double pin[2];	/* (current) plot size (inches) */
304
			/* [0] = width, [1] = height */
305
    int	pUnits;		/* (current) plot size units */
306
    int	defaultPlot;	/* calculate plot from figure - margins ? */
581 paul 307
 
4022 r 308
    /* Layout parameters which are set directly by the user */
581 paul 309
 
4022 r 310
    double mar[4];	/* Plot margins in lines */
311
    double mai[4];	/* Plot margins in inches */
312
			/* [0] = bottom, [1] = left */
313
			/* [2] = top, [3] = right */
314
    int	mUnits;		/* plot margin units */
315
    double mex;		/* Margin expansion factor */
316
    double oma[4];	/* Outer margins in lines */
317
    double omi[4];	/* outer margins in inches */
318
    double omd[4];	/* outer margins in NDC */
319
			/* [0] = bottom, [1] = left */
320
			/* [2] = top, [3] = right */
321
    int	oUnits;		/* outer margin units */
322
    int	pty;		/* Plot type */
581 paul 323
 
4022 r 324
    /* Layout parameters which can be set by the user, but */
325
    /* almost always get automatically calculated anyway */
581 paul 326
 
4022 r 327
    double usr[4];	/* Graphics window */
328
			/* [0] = xmin, [1] = xmax */
329
			/* [2] = ymin, [3] = ymax */
581 paul 330
 
4022 r 331
    /* The logged usr parameter;  if xlog, use logusr[0:1] */
332
    /* if ylog, use logusr[2:3] */
990 maechler 333
 
4022 r 334
    double logusr[4];
2 r 335
 
4022 r 336
    /* Layout parameter: Internal flags */
2 r 337
 
4022 r 338
    int	new;		/* Clean plot ? */
339
    int	devmode;	/* creating new image or adding to existing one */
2 r 340
 
4022 r 341
    /* Coordinate System Mappings */
342
    /* These are only used internally (i.e., cannot be */
343
    /* set directly by the user) */
2 r 344
 
4022 r 345
    /* The reliability of these parameters relies on */
346
    /* the fact that plot.new is the */
347
    /* first graphics operation called in the creation */
348
    /* of a graph */
581 paul 349
 
4022 r 350
    /* udpated per plot.new */
581 paul 351
 
4022 r 352
    double xNDCPerChar;	/* Nominal character width (NDC) */
353
    double yNDCPerChar;	/* Nominal character height (NDC) */
354
    double xNDCPerLine;	/* Nominal line width (NDC) */
355
    double yNDCPerLine;	/* Nominal line height (NDC) */
356
    double xNDCPerInch;	/* xNDC -> Inches */
357
    double yNDCPerInch;	/* yNDC -> Inches */
581 paul 358
 
4022 r 359
    /* updated per plot.new and if inner2dev changes */
581 paul 360
 
4022 r 361
    GTrans fig2dev;	/* Figure to device */
581 paul 362
 
4022 r 363
    /* udpated per DevNewPlot and if ndc2dev changes */
581 paul 364
 
4022 r 365
    GTrans inner2dev;	/* Inner region to device */
581 paul 366
 
4022 r 367
    /* udpated per device resize */
581 paul 368
 
4022 r 369
    GTrans ndc2dev;	/* NDC to raw device */
990 maechler 370
 
4022 r 371
    /* updated per plot.new and per plot.window */
2 r 372
 
4022 r 373
    GTrans win2fig;	/* Window to figure mapping */
581 paul 374
 
4022 r 375
    /* NOTE: if user has not set fig and/or plt then */
376
    /* they need to be updated per plot.new too */
581 paul 377
 
4022 r 378
    /* device operations */
379
    int (*open)();
380
    void (*close)();
381
    void (*activate)();
382
    void (*deactivate)();
383
    void (*resize)();
384
    void (*newPage)();
385
    void (*clip)();
386
    double (*strWidth)();
387
    void (*line)();
388
    void (*polyline)();
389
    void (*text)();
390
    void (*dot)();
391
    void (*rect)();
392
    void (*circle)();
393
    void (*polygon)();
394
    int (*locator)();
395
    void (*mode)();
396
    void (*hold)();
397
    void (*metricInfo)();
2 r 398
} GPar;
399
 
581 paul 400
typedef struct {
2566 maechler 401
	GPar dp;		/* current device default parameters */
581 paul 402
	GPar gp;		/* current device current parameters */
2566 maechler 403
	GPar dpSaved;		/* saved device default parameters */
404
	void *deviceSpecific;	/* pointer to device specific parameters */
405
	int displayListOn;	/* toggle for display list status */
406
	SEXP displayList;	/* display list */
581 paul 407
} DevDesc;
408
 
2540 maechler 409
		/* Drivers from ../main/devices.c , description there: */
410
 
411
int PSDeviceDriver(DevDesc*, char*, char*, char*,
412
		   char*, char*, double, double, double, double);
413
 
414
int PicTeXDeviceDriver(DevDesc*, char*, char*, char*, double, double, int);
415
 
416
 
2566 maechler 417
/*ifdef Unix : ../unix/devX11.h	 only in few places*/
418
 
419
#ifdef Win32
420
int WinDeviceDriver(char**, int, double*, int);
421
#endif
422
 
3244 ihaka 423
#ifdef OLD_Macintosh
2566 maechler 424
int MacDeviceDriver(char**, int, double*, int);
425
#endif
426
 
427
 
581 paul 428
		/* User Callable Functions */
2 r 429
 
2505 maechler 430
/*-------------------------------------------------------------------
431
 *
432
 *  DEVICE FUNCTIONS are concerned with the creation and destruction
433
 *  of devices.
434
 *
435
 */
2 r 436
 
2505 maechler 437
 
438
/* Return a pointer to the current device. */
581 paul 439
DevDesc* CurrentDevice();
2505 maechler 440
/* Return a pointer to a device which is identified by number */
581 paul 441
DevDesc* GetDevice(int);
2505 maechler 442
/* Initialise internal device structures. */
990 maechler 443
void InitGraphics(void);
2505 maechler 444
/* Kill device which is identified by number. */
604 paul 445
void KillDevice(DevDesc*);
2505 maechler 446
/* Kill all active devices (used at shutdown). */
581 paul 447
void KillAllDevices();
2505 maechler 448
/* Is the null device the current device? */
581 paul 449
int NoDevices();
2505 maechler 450
/* How many devices exist ? (>= 1) */
581 paul 451
int NumDevices();
2505 maechler 452
/* Get the index of the specified device. */
990 maechler 453
int deviceNumber(DevDesc*);
2505 maechler 454
/* Create a new device. */
581 paul 455
int StartDevice(SEXP, SEXP, int, SEXP, int);
2505 maechler 456
 
457
void DevNull(void);
458
 
3279 pd 459
/* Miscellaneous */
460
void NewFrameConfirm();
990 maechler 461
void recordGraphicOperation(SEXP, SEXP, DevDesc*);
1016 maechler 462
void initDisplayList();
990 maechler 463
void copyDisplayList(int);
464
void playDisplayList(DevDesc*);
465
void inhibitDisplayList(DevDesc*);
2 r 466
 
2505 maechler 467
/*-------------------------------------------------------------------
468
 *
469
 *  DEVICE UTILITIES are concerned with providing information
470
 *  for R interpreted functions.
471
 *
472
 */
2 r 473
 
2505 maechler 474
/* Return the number of the current device. */
581 paul 475
int curDevice();
2505 maechler 476
/* Return the number of the next device. */
581 paul 477
int nextDevice(int);
2505 maechler 478
/* Return the number of the previous device. */
581 paul 479
int prevDevice(int);
2505 maechler 480
/* Make the specified device (specified by number) the current device */
581 paul 481
int selectDevice(int);
2505 maechler 482
/* Kill device which is identified by number. */
604 paul 483
void killDevice(int);
2505 maechler 484
/* ...NO DOC... */
485
void addDevice(DevDesc *);
2 r 486
 
487
 
2505 maechler 488
/*-------------------------------------------------------------------
489
 *
490
 *  GPAR FUNCTIONS are concerned with operations on the
491
 *  entire set of graphics parameters for a device
492
 *  (e.g., initialisation, saving, and restoring)
493
 */
494
 
495
/* Default the settings for general graphical parameters
496
 * (i.e., defaults that do not depend on the device type: */
581 paul 497
void GInit(GPar*);
2505 maechler 498
/* Reset the current graphical parameters from the default ones: */
581 paul 499
void GRestore(DevDesc*);
2505 maechler 500
/* Make a temporary copy of the current parameters */
581 paul 501
void GSavePars(DevDesc*);
2505 maechler 502
/* Restore the temporary copy saved by GSavePars */
581 paul 503
void GRestorePars(DevDesc*);
2505 maechler 504
 
505
		/* More Programmer GPar functions */
506
 
2342 maechler 507
void ProcessInlinePars(SEXP, DevDesc*);
2690 maechler 508
void Specify2(char*, SEXP, DevDesc*);
2 r 509
 
1282 ihaka 510
SEXP FixupPch(SEXP, DevDesc*);
511
SEXP FixupLty(SEXP, DevDesc*);
512
SEXP FixupFont(SEXP);		/* FIXME: need 2nd arg? */
513
SEXP FixupCol(SEXP, DevDesc*);
514
SEXP FixupCex(SEXP);
515
 
516
 
581 paul 517
 
2505 maechler 518
/*-------------------------------------------------------------------
519
 *
520
 *  DEVICE STATE FUNCTIONS are concerned with getting and setting
521
 *  the current state of the device;  is it ready to be drawn into?
522
 */
523
 
524
/* has plot.new been called yet? */
581 paul 525
void GCheckState(DevDesc*);
2505 maechler 526
/* Set to 1 when plot.new succeeds
527
 * Set to 0 when don't want drawing to go ahead */
581 paul 528
void GSetState(int, DevDesc*);
529
 
530
 
2505 maechler 531
 
532
/*-------------------------------------------------------------------
533
 *
534
 *  GRAPHICAL PRIMITIVES are the generic front-end for the functions
535
 *  that every device driver must provide.
536
 *
537
 *  NOTE that locations supplied to these functions may be in any
538
 *  of the valid coordinate systems (each function takes a "coords"
539
 *  parameter to indicate the coordinate system);  the device-specific
540
 *  version of the function is responsible for calling GConvert to get
541
 *  the location into device coordinates.
542
 *
543
 */
544
 
545
 
546
/* Draw a circle, centred on (x,y) with radius r (in inches). */
581 paul 547
void GCircle(double, double, int, double, int, int, DevDesc*);
2505 maechler 548
/* Set clipping region (based on current setting of dd->gp.xpd).
549
 * Only clip if new clipping region is different from the current one */
581 paul 550
void GClip(DevDesc*);
3942 maechler 551
/* Polygon clipping: */
552
int GClipPolygon(double *, double *, int, int, int, 
553
		 double *, double *, DevDesc *);
2505 maechler 554
/* Always clips */
581 paul 555
void GForceClip(DevDesc*);
2505 maechler 556
/* Draw a line from (x1,y1) to (x2,y2): */
581 paul 557
void GLine(double, double, double, double, int, DevDesc*);
2505 maechler 558
/* Return the location of the next mouse click: */
581 paul 559
int  GLocator(double*, double*, int, DevDesc*);
2505 maechler 560
/* Return the height, depth, and width of the specified
561
 * character in the specified units: */
581 paul 562
void GMetricInfo(int, double*, double*, double*, int, DevDesc*);
2505 maechler 563
/* Set device "mode" (drawing or not drawing) here for windows and mac drivers.
564
 */
3367 ihaka 565
void GMode(int, DevDesc*);
2505 maechler 566
/* Draw a polygon using the specified lists of x and y values: */
581 paul 567
void GPolygon(int, double*, double*, int, int, int, DevDesc*);
2505 maechler 568
/* Draw series of straight lines using the specified lists of x and y values: */
581 paul 569
void GPolyline(int, double*, double*, int, DevDesc*);
2505 maechler 570
/* Draw a rectangle given two opposite corners: */
581 paul 571
void GRect(double, double, double, double, int, int, int, DevDesc*);
2505 maechler 572
/* Return the height of the specified string in the specified units: */
581 paul 573
double GStrHeight(char*, int, DevDesc*);
2505 maechler 574
/* Return the width of the specified string in the specified units */
581 paul 575
double GStrWidth(char*, int, DevDesc*);
2505 maechler 576
/* Draw the specified text at location (x,y) with the specified
577
 * rotation and justification: */
581 paul 578
void GText(double, double, int, char*, double, double, double, DevDesc*);
579
 
2505 maechler 580
 
581
void GStartPath(DevDesc*);
582
void GEndPath(DevDesc*);
583
 
990 maechler 584
void GMathText(double, double, int, SEXP, double, double, double, DevDesc*);
585
void GMMathText(SEXP, int, double, int, double, int, DevDesc*);
586
 
581 paul 587
 
2505 maechler 588
/*-------------------------------------------------------------------
589
 *
590
 *  GRAPHICAL UTILITIES are functions that produce graphical output
591
 *  using the graphical primitives (i.e., they are generic - NOT
592
 *  device-specific).
593
 *
594
 */
595
 
596
/* Draw a line from (x1,y1) to (x2,y2) with an arrow head
597
 * at either or both ends. */
581 paul 598
void GArrow(double, double, double, double, int, double, double, int, DevDesc*);
2505 maechler 599
/* Draw a box around specified region:
600
 *  1=plot region, 2=figure region, 3=inner region, 4=device. */
581 paul 601
void GBox(int, DevDesc*);
2505 maechler 602
/* Return a "nice" min, max and number of intervals for a given
603
 * range on a linear or _log_ scale, respectively: */
604
void GPretty(double*, double*, int*);
2 r 605
void GLPretty(double*, double*, int*);
2505 maechler 606
/* Draw text in margins. */
581 paul 607
void GMtext(char*, int, double, int, double, int, DevDesc*);
2505 maechler 608
/* Draw one of the predefined symbols (circle, square, diamond, ...) */
581 paul 609
void GSymbol(double, double, int, int, DevDesc*);
2 r 610
 
2505 maechler 611
double GExpressionHeight(SEXP, int, DevDesc*);
612
double GExpressionWidth(SEXP, int, DevDesc*);
581 paul 613
 
2505 maechler 614
 
615
 
616
/*-------------------------------------------------------------------
617
 *
618
 *  COLOUR CODE is concerned with the internals of R colour representation
619
 *
620
 */
621
 
622
/* Convert an R colour specification (which might be a number or */
623
/* a string) into an internal colour specification. */
624
unsigned int RGBpar(SEXP, int, DevDesc*);
625
 
626
 
627
/*-------------------------------------------------------------------
628
 *
629
 *  LINE TEXTURE CODE is concerned with the internals of R
630
 *  line texture representation.
631
 */
632
unsigned int LTYpar(SEXP, int);
2690 maechler 633
SEXP LTYget(unsigned int);
2505 maechler 634
 
635
 
636
/*----------------------------------------------------------------------
637
 *
638
 *  TRANSFORMATIONS are concerned with converting locations between
639
 *  coordinate systems and dimensions between different units.
640
 */
641
 
642
/* Convert an R unit (e.g., "user") into an internal unit (e.g., USER)> */
643
int GMapUnits(int);
3279 pd 644
/* Convert a LOCATION from one coordinate system to another: */
581 paul 645
void GConvert(double*, double*, int, int, DevDesc*);
3279 pd 646
double GConvertX(double, int, int, DevDesc*);
647
double GConvertY(double, int, int, DevDesc*);
2505 maechler 648
/* Convert an x/y-dimension from one set of units to another: */
581 paul 649
double GConvertXUnits(double, int, int, DevDesc*);
650
double GConvertYUnits(double, int, int, DevDesc*);
2505 maechler 651
 
652
/* Set up the different regions on a device (i.e., inner region,
653
 * figure region, plot region) and transformations for associated
654
 * coordinate systems (called whenever anything that affects the
655
 * coordinate transformations changes):
656
 */
657
void GReset(DevDesc*);
658
 
659
/* Set up the user coordinate transformations: */
660
void GMapWin2Fig(DevDesc*);
661
/* Set up the device for a new plot by Resetting graphics parameters
662
 * and Resetting the regions and coordinate Systems */
663
DevDesc *GNewPlot(int, int);
664
/* Set up the user coordinates based on the axis limits */
581 paul 665
void GScale(double, double, int, DevDesc*);
2505 maechler 666
/* Set up the axis limits based on the user coordinates */
581 paul 667
void GSetupAxis(int, DevDesc*);
2505 maechler 668
/* Return row and column of current figure in the layout matrix */
669
void currentFigureLocation(int*, int*, DevDesc*);
581 paul 670
 
2505 maechler 671
double Log10(double);
672
 
673
double xDevtoNDC(double x, DevDesc *dd);
674
double yDevtoNDC(double y, DevDesc *dd);
675
double xDevtoNFC(double x, DevDesc *dd);
676
double yDevtoNFC(double y, DevDesc *dd);
581 paul 677
double xNPCtoUsr(double, DevDesc*);
678
double yNPCtoUsr(double, DevDesc*);
679
 
990 maechler 680
 
2505 maechler 681
		/* Miscellaneous (from graphics.c & colors.c) */
682
 
990 maechler 683
unsigned int rgb2col(char *);
684
unsigned int name2col(char *);
2505 maechler 685
unsigned int char2col(char *s);/* rgb2col() or name2col() */
686
char* col2name(unsigned int);
687
unsigned int str2col(char *s, DevDesc *dd);
990 maechler 688
 
2505 maechler 689
unsigned int ScaleColor(double x);
690
 
691
char* RGB2rgb(unsigned int, unsigned int, unsigned int);
692
 
693
int StrMatch(char *s, char *t);
694
 
2 r 695
#endif