The R Project SVN R

Rev

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

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