The R Project SVN R

Rev

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

Rev 10960 Rev 11067
Line 32... Line 32...
32
#define COLOR_TABLE_SIZE 1024
32
#define COLOR_TABLE_SIZE 1024
33
 
33
 
34
#define MAX_LAYOUT_ROWS 15
34
#define MAX_LAYOUT_ROWS 15
35
#define MAX_LAYOUT_COLS 15
35
#define MAX_LAYOUT_COLS 15
36
 
36
 
-
 
37
/* NOTE: during replays, call == R_NilValue;
-
 
38
   ----  the following adds readability: */
-
 
39
#define GRecording(call)  (call != R_NilValue)
-
 
40
 
37
typedef unsigned int rcolor;
41
typedef unsigned int rcolor;
38
 
42
 
39
typedef struct {
43
typedef struct {
40
	double ax;
44
	double ax;
41
	double bx;
45
	double bx;
Line 84... Line 88...
84
    double bottom;	/* bottom raster coordinate */
88
    double bottom;	/* bottom raster coordinate */
85
    double top;		/* top raster coordinate */
89
    double top;		/* top raster coordinate */
86
    double xCharOffset;	/* x character addressing offset */
90
    double xCharOffset;	/* x character addressing offset */
87
    double yCharOffset;	/* y character addressing offset */
91
    double yCharOffset;	/* y character addressing offset */
88
    double yLineBias;	/* 1/2 interline space as fraction of line height */
92
    double yLineBias;	/* 1/2 interline space as fraction of line height */
89
    int canResizePlot;	/* can the graphics surface be resized */
93
    Rboolean canResizePlot;	/* can the graphics surface be resized */
90
    int canChangeFont;	/* device has multiple fonts */
94
    Rboolean canChangeFont;	/* device has multiple fonts */
91
    int canRotateText;	/* text can be rotated */
95
    Rboolean canRotateText;	/* text can be rotated */
92
    int canResizeText;	/* text can be resized */
96
    Rboolean canResizeText;	/* text can be resized */
93
    int canClip;	/* Hardware clipping */
97
    Rboolean canClip;		/* Hardware clipping */
94
    int canHAdj;	/* Can do at least some horizontal adjustment of text
98
    int canHAdj;	/* Can do at least some horizontal adjustment of text
95
			   0 = none, 1 = {0,0.5, 1}, 2 = [0,1] */
99
			   0 = none, 1 = {0,0.5, 1}, 2 = [0,1] */
96
 
100
 
97
    /* a couple of the GRZ-like parameters that have to be */
101
    /* a couple of the GRZ-like parameters that have to be */
98
    /* set by the device */
102
    /* set by the device */
Line 108... Line 112...
108
    /* should fail if state = 0 */
112
    /* should fail if state = 0 */
109
    /* This is checked at the highest internal function */
113
    /* This is checked at the highest internal function */
110
    /* level (e.g., do_lines, do_axis, do_plot_xy, ...) */
114
    /* level (e.g., do_lines, do_axis, do_plot_xy, ...) */
111
 
115
 
112
    int	state;		/* Plot State */
116
    int	state;		/* Plot State */
113
    Rboolean valid;		/* valid layout ? */
117
    Rboolean valid;	/* valid layout ? */
114
 
118
 
115
    /* GRZ-like Graphics Parameters */
119
    /* GRZ-like Graphics Parameters */
116
    /* ``The horror, the horror ... '' */
120
    /* ``The horror, the horror ... '' */
117
    /* Marlon Brando - Appocalypse Now */
121
    /* Marlon Brando - Appocalypse Now */
118
 
122
 
119
    /* General Parameters -- set and interrogated directly */
123
    /* General Parameters -- set and interrogated directly */
120
 
124
 
121
    double adj;		/* String adjustment */
125
    double adj;		/* String adjustment */
122
    int	ann;		/* Should annotation take place */
126
    Rboolean ann;	/* Should annotation take place */
123
    int	ask;		/* User confirmation of ``page eject'' */
127
    Rboolean ask;	/* User confirmation of ``page eject'' */
124
    rcolor bg;		/* **R ONLY** Background color */
128
    rcolor bg;		/* **R ONLY** Background color */
125
    int	bty;		/* Box type */
129
    int	bty;		/* Box type */
126
    double cex;		/* Character expansion */
130
    double cex;		/* Character expansion */
127
    rcolor col;		/* Plotting Color */
131
    rcolor col;		/* Plotting Color */
128
    double crt;		/* Character/string rotation */
132
    double crt;		/* Character/string rotation */
Line 184... Line 188...
184
    int	colsub;		/* Subtitle color */
188
    int	colsub;		/* Subtitle color */
185
    int	colaxis;	/* Axis label color */
189
    int	colaxis;	/* Axis label color */
186
 
190
 
187
    /* Layout Parameters */
191
    /* Layout Parameters */
188
 
192
 
189
    int	layout;		/* has a layout been specified */
193
    Rboolean layout;	/* has a layout been specified */
190
 
194
 
191
    int	numrows;
195
    int	numrows;
192
    int	numcols;
196
    int	numcols;
193
    int	currentFigure;
197
    int	currentFigure;
194
    int	lastFigure;
198
    int	lastFigure;
Line 211... Line 215...
211
			/* [0] = left, [1] = right */
215
			/* [0] = left, [1] = right */
212
			/* [2] = bottom, [3] = top */
216
			/* [2] = bottom, [3] = top */
213
    double fin[2];	/* (current) Figure size (inches) */
217
    double fin[2];	/* (current) Figure size (inches) */
214
			/* [0] = width, [1] = height */
218
			/* [0] = width, [1] = height */
215
    GUnit fUnits;	/* (current) figure size units */
219
    GUnit fUnits;	/* (current) figure size units */
216
    int	defaultFigure;	/* calculate figure from layout ? */
-
 
217
    double plt[4];	/* (current) Plot size (proportions) */
220
    double plt[4];	/* (current) Plot size (proportions) */
218
			/* [0] = left, [1] = right */
221
			/* [0] = left, [1] = right */
219
			/* [2] = bottom, [3] = top */
222
			/* [2] = bottom, [3] = top */
220
    double pin[2];	/* (current) plot size (inches) */
223
    double pin[2];	/* (current) plot size (inches) */
221
			/* [0] = width, [1] = height */
224
			/* [0] = width, [1] = height */
222
    GUnit	pUnits;		/* (current) plot size units */
225
    GUnit pUnits;	/* (current) plot size units */
-
 
226
    Rboolean defaultFigure;	/* calculate figure from layout ? */
223
    int	defaultPlot;	/* calculate plot from figure - margins ? */
227
    Rboolean defaultPlot;	/* calculate plot from figure - margins ? */
224
 
228
 
225
    /* Layout parameters which are set directly by the user */
229
    /* Layout parameters which are set directly by the user */
226
 
230
 
227
    double mar[4];	/* Plot margins in lines */
231
    double mar[4];	/* Plot margins in lines */
228
    double mai[4];	/* Plot margins in inches */
232
    double mai[4];	/* Plot margins in inches */
229
			/* [0] = bottom, [1] = left */
233
			/* [0] = bottom, [1] = left */
230
			/* [2] = top, [3] = right */
234
			/* [2] = top, [3] = right */
231
    GUnit	mUnits;		/* plot margin units */
235
    GUnit mUnits;	/* plot margin units */
232
    double mex;		/* Margin expansion factor */
236
    double mex;		/* Margin expansion factor */
233
    double oma[4];	/* Outer margins in lines */
237
    double oma[4];	/* Outer margins in lines */
234
    double omi[4];	/* outer margins in inches */
238
    double omi[4];	/* outer margins in inches */
235
    double omd[4];	/* outer margins in NDC */
239
    double omd[4];	/* outer margins in NDC */
236
			/* [0] = bottom, [1] = left */
240
			/* [0] = bottom, [1] = left */
237
			/* [2] = top, [3] = right */
241
			/* [2] = top, [3] = right */
238
    GUnit	oUnits;		/* outer margin units */
242
    GUnit oUnits;	/* outer margin units */
239
    int	pty;		/* Plot type */
243
    int	pty;		/* Plot type */
240
 
244
 
241
    /* Layout parameters which can be set by the user, but */
245
    /* Layout parameters which can be set by the user, but */
242
    /* almost always get automatically calculated anyway */
246
    /* almost always get automatically calculated anyway */
243
 
247
 
Line 291... Line 295...
291
 
295
 
292
    /* NOTE: if user has not set fig and/or plt then */
296
    /* NOTE: if user has not set fig and/or plt then */
293
    /* they need to be updated per plot.new too */
297
    /* they need to be updated per plot.new too */
294
 
298
 
295
    /* device operations */
299
    /* device operations */
296
    int (*open)();
300
    Rboolean (*open)();
297
    void (*close)();
301
    void (*close)();
298
    void (*activate)();
302
    void (*activate)();
299
    void (*deactivate)();
303
    void (*deactivate)();
300
    void (*resize)();
304
    void (*resize)();
301
    void (*newPage)();
305
    void (*newPage)();
Line 306... Line 310...
306
    void (*text)();
310
    void (*text)();
307
    void (*dot)();
311
    void (*dot)();
308
    void (*rect)();
312
    void (*rect)();
309
    void (*circle)();
313
    void (*circle)();
310
    void (*polygon)();
314
    void (*polygon)();
311
    int (*locator)();
315
    Rboolean (*locator)();
312
    void (*mode)();
316
    void (*mode)();
313
    void (*hold)();
317
    void (*hold)();
314
    void (*metricInfo)();
318
    void (*metricInfo)();
315
} GPar;
319
} GPar;
316
 
320
 
317
typedef struct {
321
typedef struct {
318
	GPar dp;		/* current device default parameters */
322
	GPar dp;		/* current device default parameters */
319
	GPar gp;		/* current device current parameters */
323
	GPar gp;		/* current device current parameters */
320
	GPar dpSaved;		/* saved device default parameters */
324
	GPar dpSaved;		/* saved device default parameters */
321
	void *deviceSpecific;	/* pointer to device specific parameters */
325
	void *deviceSpecific;	/* pointer to device specific parameters */
322
	int displayListOn;	/* toggle for display list status */
326
	Rboolean displayListOn;	/* toggle for display list status */
323
	SEXP displayList;	/* display list */
327
	SEXP displayList;	/* display list */
324
} DevDesc;
328
} DevDesc;
325
 
329
 
-
 
330
/* For easy reference: Here are the source files of 
-
 
331
 * currently existing device drivers:
-
 
332
 * FILE				driver name prefix
-
 
333
 * ----------------------	------------------
-
 
334
 * ../main/devPS.c		PS  _and_  XFig
-
 
335
 * ../main/devPicTeX.c		PicTeX
-
 
336
 * ../unix/X11/devX11.c		X11
-
 
337
 * ../gnuwin32/devga.c		GA
-
 
338
 * ../unix/gnome/devGTK.c	GTK
-
 
339
 * ../unix/gnome/devGNOME.c	Gnome
-
 
340
 */
-
 
341
 
326
#include "R_ext/Graphics.h"
342
#include "R_ext/Graphics.h"
327
 
343
 
328
/* Default the settings for general graphical parameters
344
/* Default the settings for general graphical parameters
329
 * (i.e., defaults that do not depend on the device type: */
345
 * (i.e., defaults that do not depend on the device type: */
330
#define GInit			Rf_GInit
346
#define GInit			Rf_GInit