The R Project SVN R

Rev

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

Rev 2540 Rev 2566
Line 48... Line 48...
48
 *	Some Notes on Color
48
 *	Some Notes on Color
49
 *
49
 *
50
 *	R uses a 24-bit color model.  Colors are specified in 32-bit
50
 *	R uses a 24-bit color model.  Colors are specified in 32-bit
51
 *	integers which are partitioned into 4 bytes as follows.
51
 *	integers which are partitioned into 4 bytes as follows.
52
 *
52
 *
53
 *		<-- most sig        least sig -->
53
 *		<-- most sig	    least sig -->
54
 *		+-------------------------------+
54
 *		+-------------------------------+
55
 *		|   0   | blue  | green |  red  |
55
 *		|   0	| blue	| green |  red	|
56
 *		+-------------------------------+
56
 *		+-------------------------------+
57
 *
57
 *
58
 *	The red, green and blue bytes can be extracted as follows.
58
 *	The red, green and blue bytes can be extracted as follows.
59
 *
59
 *
60
 *		red   = ((color      ) & 255)
60
 *		red   = ((color	     ) & 255)
61
 *		green = ((color >>  8) & 255)
61
 *		green = ((color >>  8) & 255)
62
 *		blue  = ((color >> 16) & 255)
62
 *		blue  = ((color >> 16) & 255)
63
 */
63
 */
64
 
64
 
65
#define R_RGB(r,g,b)	((r)|((g)<<8)|((b)<<16))
65
#define R_RGB(r,g,b)	((r)|((g)<<8)|((b)<<16))
66
#define R_RED(col)	(((col)    )&255)
66
#define R_RED(col)	(((col)	   )&255)
67
#define R_GREEN(col)	(((col)>> 8)&255)
67
#define R_GREEN(col)	(((col)>> 8)&255)
68
#define R_BLUE(col)	(((col)>>16)&255)
68
#define R_BLUE(col)	(((col)>>16)&255)
69
#define COLOR_TABLE_SIZE 256
69
#define COLOR_TABLE_SIZE 256
70
 
70
 
71
 
71
 
Line 88... Line 88...
88
 
88
 
89
	/* possible coordinate systems (for specifying locations) */
89
	/* possible coordinate systems (for specifying locations) */
90
 
90
 
91
#define DEVICE	0	/* native device coordinates (rasters) */
91
#define DEVICE	0	/* native device coordinates (rasters) */
92
#define NDC	1	/* normalised device coordinates x=(0,1), y=(0,1) */
92
#define NDC	1	/* normalised device coordinates x=(0,1), y=(0,1) */
93
#define INCHES 13 	/* inches x=(0,width), y=(0,height) */
93
#define INCHES 13	/* inches x=(0,width), y=(0,height) */
94
#define NIC	6	/* normalised inner region coordinates (0,1) */
94
#define NIC	6	/* normalised inner region coordinates (0,1) */
95
#define OMA1	2	/* outer margin 1 (bottom) x=NIC, y=LINES */
95
#define OMA1	2	/* outer margin 1 (bottom) x=NIC, y=LINES */
96
#define OMA2	3	/* outer margin 2 (left) */
96
#define OMA2	3	/* outer margin 2 (left) */
97
#define OMA3	4	/* outer margin 3 (top) */
97
#define OMA3	4	/* outer margin 3 (top) */
98
#define OMA4	5	/* outer margin 4 (right) */
98
#define OMA4	5	/* outer margin 4 (right) */
99
#define NFC	7	/* normalised figure region coordinates (0,1) */
99
#define NFC	7	/* normalised figure region coordinates (0,1) */
100
#define NPC     16	/* normalised plot region coordinates (0,1) */
100
#define NPC	16	/* normalised plot region coordinates (0,1) */
101
#define USER	12	/* user/data/world corrdinates */
101
#define USER	12	/* user/data/world corrdinates */
102
			/* x=(xmin,xmax), y=(ymin,ymax) */
102
			/* x=(xmin,xmax), y=(ymin,ymax) */
103
#define MAR1	8	/* figure margin 1 (bottom) x=USER(x), y=LINES */
103
#define MAR1	8	/* figure margin 1 (bottom) x=USER(x), y=LINES */
104
#define MAR2	9	/* figure margin 2 (left) x=USER(y) y=LINES */
104
#define MAR2	9	/* figure margin 2 (left) x=USER(y) y=LINES */
105
#define MAR3	10	/* figure margin 3 (top) x=USER(x), y=LINES */
105
#define MAR3	10	/* figure margin 3 (top) x=USER(x), y=LINES */
Line 121... Line 121...
121
	double ay;
121
	double ay;
122
	double by;
122
	double by;
123
} GTrans;
123
} GTrans;
124
 
124
 
125
struct colorDataBaseEntry {
125
struct colorDataBaseEntry {
126
	char *name;     /* X11 Color Name */
126
	char *name;	/* X11 Color Name */
127
	char *rgb;      /* #RRGGBB String */
127
	char *rgb;	/* #RRGGBB String */
128
	unsigned int code;  /* Internal R Color Code */
128
	unsigned int code;  /* Internal R Color Code */
129
};
129
};
130
 
130
 
131
typedef struct colorDataBaseEntry ColorDataBaseEntry;
131
typedef struct colorDataBaseEntry ColorDataBaseEntry;
132
 
132
 
Line 180... Line 180...
180
		/* should fail if state = 0 */
180
		/* should fail if state = 0 */
181
		/* This is checked at the highest internal function */
181
		/* This is checked at the highest internal function */
182
		/* level (e.g., do_lines, do_axis, do_plot_xy, ...) */
182
		/* level (e.g., do_lines, do_axis, do_plot_xy, ...) */
183
 
183
 
184
	int	state;		/* Plot State */
184
	int	state;		/* Plot State */
185
	int 	valid;		/* valid layout ? */
185
	int	valid;		/* valid layout ? */
186
 
186
 
187
	/* GRZ-like Graphics Parameters */
187
	/* GRZ-like Graphics Parameters */
188
		/* ``The horror, the horror ... '' */
188
		/* ``The horror, the horror ... '' */
189
		/* Marlon Brando - Appocalypse Now */
189
		/* Marlon Brando - Appocalypse Now */
190
 
190
 
Line 219... Line 219...
219
	int	pch;		/* Plotting character */
219
	int	pch;		/* Plotting character */
220
	int	ps;		/* Text & symbol pointsize */
220
	int	ps;		/* Text & symbol pointsize */
221
	int	smo;		/* Curve smoothness */
221
	int	smo;		/* Curve smoothness */
222
	double	srt;		/* String Rotation */
222
	double	srt;		/* String Rotation */
223
	double	tck;		/* Tick size as in S */
223
	double	tck;		/* Tick size as in S */
224
	double  tcl;            /* Tick size in "lines" */
224
	double	tcl;		/* Tick size in "lines" */
225
	double	tmag;		/* **R ONLY** Title Magnification */
225
	double	tmag;		/* **R ONLY** Title Magnification */
226
	int	type;		/* type of plot desired */
226
	int	type;		/* type of plot desired */
227
	double	xaxp[3];	/* X Axis annotation */
227
	double	xaxp[3];	/* X Axis annotation */
228
				/* [0] = coordinate of lower tick */
228
				/* [0] = coordinate of lower tick */
229
				/* [1] = coordinate of upper tick */
229
				/* [1] = coordinate of upper tick */
230
				/* [2] = num tick intervals */
230
				/* [2] = num tick intervals */
231
				/* almost always used internally */
231
				/* almost always used internally */
232
	int	xaxs;		/* X Axis style */
232
	int	xaxs;		/* X Axis style */
233
	int	xaxt;		/* X Axis type */
233
	int	xaxt;		/* X Axis type */
234
	int	xpd;		/* Clip to plot region indicator */
234
	int	xpd;		/* Clip to plot region indicator */
235
	int 	oldxpd;
235
	int	oldxpd;
236
	double	yaxp[3];	/* Y Axis annotation */
236
	double	yaxp[3];	/* Y Axis annotation */
237
	int	yaxs;		/* Y Axis style */
237
	int	yaxs;		/* Y Axis style */
238
	int	yaxt;		/* Y Axis type */
238
	int	yaxt;		/* Y Axis type */
239
	int	xlog;		/* Log Axis for X */
239
	int	xlog;		/* Log Axis for X */
240
	int	ylog;		/* Log Axis for Y */
240
	int	ylog;		/* Log Axis for Y */
Line 257... Line 257...
257
	int	colsub;		/* Subtitle color */
257
	int	colsub;		/* Subtitle color */
258
	int	colaxis;	/* Axis label color */
258
	int	colaxis;	/* Axis label color */
259
 
259
 
260
		/* Layout Parameters */
260
		/* Layout Parameters */
261
 
261
 
262
	int     layout;		/* has a layout been specified */
262
	int	layout;		/* has a layout been specified */
263
 
263
 
264
	int 	numrows;
264
	int	numrows;
265
	int 	numcols;
265
	int	numcols;
266
	int 	currentFigure;
266
	int	currentFigure;
267
	int 	lastFigure;
267
	int	lastFigure;
268
	double	heights[MAX_LAYOUT_ROWS];
268
	double	heights[MAX_LAYOUT_ROWS];
269
	double 	widths[MAX_LAYOUT_COLS];
269
	double	widths[MAX_LAYOUT_COLS];
270
	int 	cmHeights[MAX_LAYOUT_ROWS];
270
	int	cmHeights[MAX_LAYOUT_ROWS];
271
	int 	cmWidths[MAX_LAYOUT_COLS];
271
	int	cmWidths[MAX_LAYOUT_COLS];
272
	int 	order[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
272
	int	order[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
273
	int 	rspct;	/* 0 = none, 1 = full, 2 = see respect */
273
	int	rspct;	/* 0 = none, 1 = full, 2 = see respect */
274
	int 	respect[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
274
	int	respect[MAX_LAYOUT_ROWS][MAX_LAYOUT_COLS];
275
 
275
 
276
	int     mfind;          /* By row/col indicator */
276
	int	mfind;		/* By row/col indicator */
277
 
277
 
278
		/* Layout parameters which can be set directly by the */
278
		/* Layout parameters which can be set directly by the */
279
		/* user (e.g., par(fig=c(.5,1,0,1))) or otherwise are */
279
		/* user (e.g., par(fig=c(.5,1,0,1))) or otherwise are */
280
		/* calculated automatically */
280
		/* calculated automatically */
281
		/* NOTE that *Units parameters are for internal use only */
281
		/* NOTE that *Units parameters are for internal use only */
282
 
282
 
283
	double	fig[4];		/* (current) Figure size (proportion) */
283
	double	fig[4];		/* (current) Figure size (proportion) */
284
				/* [0] = left, [1] = right */
284
				/* [0] = left, [1] = right */
285
				/* [2] = bottom, [3] = top */
285
				/* [2] = bottom, [3] = top */
286
	double  fin[2];		/* (current) Figure size (inches) */
286
	double	fin[2];		/* (current) Figure size (inches) */
287
				/* [0] = width, [1] = height */
287
				/* [0] = width, [1] = height */
288
	int 	fUnits;		/* (current) figure size units */
288
	int	fUnits;		/* (current) figure size units */
289
	int 	defaultFigure;	/* calculate figure from layout ? */
289
	int	defaultFigure;	/* calculate figure from layout ? */
290
	double	plt[4];		/* (current) Plot size (proportions) */
290
	double	plt[4];		/* (current) Plot size (proportions) */
291
				/* [0] = left, [1] = right */
291
				/* [0] = left, [1] = right */
292
				/* [2] = bottom, [3] = top */
292
				/* [2] = bottom, [3] = top */
293
	double  pin[2];		/* (current) plot size (inches) */
293
	double	pin[2];		/* (current) plot size (inches) */
294
				/* [0] = width, [1] = height */
294
				/* [0] = width, [1] = height */
295
	int 	pUnits;		/* (current) plot size units */
295
	int	pUnits;		/* (current) plot size units */
296
	int 	defaultPlot;	/* calculate plot from figure - margins ? */
296
	int	defaultPlot;	/* calculate plot from figure - margins ? */
297
 
297
 
298
		/* Layout parameters which are set directly by the user */
298
		/* Layout parameters which are set directly by the user */
299
 
299
 
300
	double	mar[4];		/* Plot margins in lines */
300
	double	mar[4];		/* Plot margins in lines */
301
	double  mai[4];		/* Plot margins in inches */
301
	double	mai[4];		/* Plot margins in inches */
302
				/* [0] = bottom, [1] = left */
302
				/* [0] = bottom, [1] = left */
303
				/* [2] = top, [3] = right */
303
				/* [2] = top, [3] = right */
304
	int 	mUnits;		/* plot margin units */
304
	int	mUnits;		/* plot margin units */
305
	double	mex;		/* Margin expansion factor */
305
	double	mex;		/* Margin expansion factor */
306
	double	oma[4];		/* Outer margins in lines */
306
	double	oma[4];		/* Outer margins in lines */
307
	double  omi[4];		/* outer margins in inches */
307
	double	omi[4];		/* outer margins in inches */
308
	double	omd[4];		/* outer margins in NDC */
308
	double	omd[4];		/* outer margins in NDC */
309
				/* [0] = bottom, [1] = left */
309
				/* [0] = bottom, [1] = left */
310
				/* [2] = top, [3] = right */
310
				/* [2] = top, [3] = right */
311
	int 	oUnits;		/* outer margin units */
311
	int	oUnits;		/* outer margin units */
312
	int	pty;		/* Plot type */
312
	int	pty;		/* Plot type */
313
 
313
 
314
		/* Layout parameters which can be set by the user, but */
314
		/* Layout parameters which can be set by the user, but */
315
		/* almost always get automatically calculated anyway */
315
		/* almost always get automatically calculated anyway */
316
 
316
 
317
	double	usr[4];		/* Graphics window */
317
	double	usr[4];		/* Graphics window */
318
				/* [0] = xmin, [1] = xmax */
318
				/* [0] = xmin, [1] = xmax */
319
				/* [2] = ymin, [3] = ymax */
319
				/* [2] = ymin, [3] = ymax */
320
 
320
 
321
		/* The logged usr parameter;  if xlog, use logusr[0:1] */
321
		/* The logged usr parameter;  if xlog, use logusr[0:1] */
322
		/*                            if ylog, use logusr[2:3] */
322
		/*			      if ylog, use logusr[2:3] */
323
 
323
 
324
	double logusr[4];
324
	double logusr[4];
325
 
325
 
326
		/* Layout parameter: Internal flags */
326
		/* Layout parameter: Internal flags */
327
 
327
 
328
	int	new;		/* Clean plot ? */
328
	int	new;		/* Clean plot ? */
329
	int 	devmode;	/* creating new image or adding to existing one */
329
	int	devmode;	/* creating new image or adding to existing one */
330
 
330
 
331
		/* Coordinate System Mappings */
331
		/* Coordinate System Mappings */
332
		/* These are only used internally (i.e., cannot be */
332
		/* These are only used internally (i.e., cannot be */
333
		/* set directly by the user) */
333
		/* set directly by the user) */
334
 
334
 
Line 350... Line 350...
350
 
350
 
351
	GTrans	fig2dev;	/* Figure to device */
351
	GTrans	fig2dev;	/* Figure to device */
352
 
352
 
353
		/* udpated per DevNewPlot and if ndc2dev changes */
353
		/* udpated per DevNewPlot and if ndc2dev changes */
354
 
354
 
355
	GTrans 	inner2dev;	/* Inner region to device */
355
	GTrans	inner2dev;	/* Inner region to device */
356
 
356
 
357
		/* udpated per device resize */
357
		/* udpated per device resize */
358
 
358
 
359
	GTrans	ndc2dev;	/* NDC to raw device */
359
	GTrans	ndc2dev;	/* NDC to raw device */
360
 
360
 
Line 386... Line 386...
386
	void (*hold)();
386
	void (*hold)();
387
	void (*metricInfo)();
387
	void (*metricInfo)();
388
} GPar;
388
} GPar;
389
 
389
 
390
typedef struct {
390
typedef struct {
391
	GPar dp;          	/* current device default parameters */
391
	GPar dp;		/* current device default parameters */
392
	GPar gp;		/* current device current parameters */
392
	GPar gp;		/* current device current parameters */
393
	GPar dpSaved; 		/* saved device default parameters */
393
	GPar dpSaved;		/* saved device default parameters */
394
	void *deviceSpecific;   /* pointer to device specific parameters */
394
	void *deviceSpecific;	/* pointer to device specific parameters */
395
	int displayListOn;    	/* toggle for display list status */
395
	int displayListOn;	/* toggle for display list status */
396
	SEXP displayList;     	/* display list */
396
	SEXP displayList;	/* display list */
397
} DevDesc;
397
} DevDesc;
398
 
398
 
399
		/* Drivers from ../main/devices.c , description there: */
399
		/* Drivers from ../main/devices.c , description there: */
400
 
400
 
401
int PSDeviceDriver(DevDesc*, char*, char*, char*,
401
int PSDeviceDriver(DevDesc*, char*, char*, char*,
402
		   char*, char*, double, double, double, double);
402
		   char*, char*, double, double, double, double);
403
 
403
 
404
int PicTeXDeviceDriver(DevDesc*, char*, char*, char*, double, double, int);
404
int PicTeXDeviceDriver(DevDesc*, char*, char*, char*, double, double, int);
405
 
405
 
406
 
406
 
-
 
407
/*ifdef Unix : ../unix/devX11.h	 only in few places*/
-
 
408
 
-
 
409
#ifdef Win32
-
 
410
int WinDeviceDriver(char**, int, double*, int);
-
 
411
#endif
-
 
412
 
-
 
413
#ifdef Macintosh
-
 
414
int MacDeviceDriver(char**, int, double*, int);
-
 
415
#endif
-
 
416
 
-
 
417
 
407
		/* User Callable Functions */
418
		/* User Callable Functions */
408
 
419
 
409
/*-------------------------------------------------------------------
420
/*-------------------------------------------------------------------
410
 *
421
 *
411
 *  DEVICE FUNCTIONS are concerned with the creation and destruction
422
 *  DEVICE FUNCTIONS are concerned with the creation and destruction