The R Project SVN R

Rev

Rev 4022 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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