The R Project SVN R

Rev

Rev 56854 | Rev 57567 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56854 Rev 57122
Line 27... Line 27...
27
#endif
27
#endif
28
 
28
 
29
/*
29
/*
30
 * The current graphics engine (including graphics device) API version
30
 * The current graphics engine (including graphics device) API version
31
 * MUST be integer
31
 * MUST be integer
32
 * 
32
 *
33
 * This number should be bumped whenever there are changes to 
33
 * This number should be bumped whenever there are changes to
34
 * GraphicsEngine.h or GraphicsDevice.h so that add-on packages
34
 * GraphicsEngine.h or GraphicsDevice.h so that add-on packages
35
 * that compile against these headers (graphics systems such as
35
 * that compile against these headers (graphics systems such as
36
 * graphics and grid;  graphics devices such as gtkDevice, RSvgDevice)
36
 * graphics and grid;  graphics devices such as gtkDevice, RSvgDevice)
37
 * can detect any version mismatch.
37
 * can detect any version mismatch.
38
 *
38
 *
Line 48... Line 48...
48
 *             Remove asp, dot(), hold(), open() from NewDevDesc.
48
 *             Remove asp, dot(), hold(), open() from NewDevDesc.
49
 *             Move displayList, DLlastElt, savedSnapshot from
49
 *             Move displayList, DLlastElt, savedSnapshot from
50
 *             NewDevDesc to GEDevDesc.
50
 *             NewDevDesc to GEDevDesc.
51
 *             Add 'ask' to GEDevDesc. (R 2.8.0)
51
 *             Add 'ask' to GEDevDesc. (R 2.8.0)
52
 * Version 6:  Add dev_Raster() and dev_Cap()  (R 2.11.0)
52
 * Version 6:  Add dev_Raster() and dev_Cap()  (R 2.11.0)
53
 * Version 7:  Change graphics event handling, adding eventEnv and eventHelper() 
53
 * Version 7:  Change graphics event handling, adding eventEnv and eventHelper()
54
 *	       to DevDesc.  (R 2.12.0)
54
 *	       to DevDesc.  (R 2.12.0)
55
 * Version 8:  Add dev_Path() (R 2.12.0)
55
 * Version 8:  Add dev_Path() (R 2.12.0)
56
 * Version 9:  Add dev_HoldFlush(), haveTrans*, haveRaster, 
56
 * Version 9:  Add dev_HoldFlush(), haveTrans*, haveRaster,
57
 *             haveCapture, haveLocator.  (R 2.14.0)
57
 *             haveCapture, haveLocator.  (R 2.14.0)
58
 */
58
 */
59
 
59
 
60
#define R_GE_version 9
60
#define R_GE_version 9
61
 
61
 
62
int R_GE_getVersion(void);
62
int R_GE_getVersion(void);
63
 
63
 
64
void R_GE_checkVersionOrDie(int version);
64
void R_GE_checkVersionOrDie(int version);
65
 
65
 
66
/* The graphics engine will only accept locations and dimensions 
66
/* The graphics engine will only accept locations and dimensions
67
 * in native device coordinates, but it provides the following functions
67
 * in native device coordinates, but it provides the following functions
68
 * for converting between a couple of simple alternative coordinate 
68
 * for converting between a couple of simple alternative coordinate
69
 * systems and device coordinates:
69
 * systems and device coordinates:
70
 *    DEVICE = native units of the device
70
 *    DEVICE = native units of the device
71
 *    NDC = Normalised device coordinates 
71
 *    NDC = Normalised device coordinates
72
 *    INCHES = inches (!)
72
 *    INCHES = inches (!)
73
 *    CM = centimetres (!!)
73
 *    CM = centimetres (!!)
74
 */
74
 */
75
 
75
 
76
typedef enum {
76
typedef enum {
Line 83... Line 83...
83
#define MAX_GRAPHICS_SYSTEMS 24
83
#define MAX_GRAPHICS_SYSTEMS 24
84
 
84
 
85
typedef enum {
85
typedef enum {
86
    /* In response to this event, the registered graphics system
86
    /* In response to this event, the registered graphics system
87
     * should allocate and initialise the systemSpecific structure
87
     * should allocate and initialise the systemSpecific structure
88
     * 
88
     *
89
     * Should return R_NilValue on failure so that engine
89
     * Should return R_NilValue on failure so that engine
90
     * can tidy up memory allocation
90
     * can tidy up memory allocation
91
     */
91
     */
92
    GE_InitState = 0,
92
    GE_InitState = 0,
93
    /* This event gives the registered system a chance to undo
93
    /* This event gives the registered system a chance to undo
Line 117... Line 117...
117
     */
117
     */
118
    GE_SaveSnapshotState = 4,
118
    GE_SaveSnapshotState = 4,
119
    /* Restore the system state that is saved by GE_SaveSnapshotState
119
    /* Restore the system state that is saved by GE_SaveSnapshotState
120
     */
120
     */
121
    GE_RestoreSnapshotState = 5,
121
    GE_RestoreSnapshotState = 5,
122
    /* When replaying the display list, the graphics engine 
122
    /* When replaying the display list, the graphics engine
123
     * checks, after each replayed action, that the action 
123
     * checks, after each replayed action, that the action
124
     * produced valid output.  This is the graphics system's
124
     * produced valid output.  This is the graphics system's
125
     * chance to say that the output is crap (in which case the
125
     * chance to say that the output is crap (in which case the
126
     * graphics engine will abort the display list replay).
126
     * graphics engine will abort the display list replay).
127
     */
127
     */
128
    GE_CheckPlot = 7,
128
    GE_CheckPlot = 7,
129
    /* The device wants to scale the current pointsize
129
    /* The device wants to scale the current pointsize
130
     * (for scaling an image)
130
     * (for scaling an image)
131
     * This is not a nice general solution, but a quick fix for 
131
     * This is not a nice general solution, but a quick fix for
132
     * the Windows device.
132
     * the Windows device.
133
     */
133
     */
134
    GE_ScalePS = 8
134
    GE_ScalePS = 8
135
} GEevent;
135
} GEevent;
136
 
136
 
Line 147... Line 147...
147
  GE_ROUND_JOIN = 1,
147
  GE_ROUND_JOIN = 1,
148
  GE_MITRE_JOIN = 2,
148
  GE_MITRE_JOIN = 2,
149
  GE_BEVEL_JOIN = 3
149
  GE_BEVEL_JOIN = 3
150
} R_GE_linejoin;
150
} R_GE_linejoin;
151
 
151
 
152
/* 
152
/*
153
 * A structure containing graphical parameters 
153
 * A structure containing graphical parameters
154
 *
154
 *
155
 * This is how graphical parameters are passed from graphics systems
155
 * This is how graphical parameters are passed from graphics systems
156
 * to the graphics engine AND from the graphics engine to graphics
156
 * to the graphics engine AND from the graphics engine to graphics
157
 * devices.
157
 * devices.
158
 *
158
 *
Line 166... Line 166...
166
     * NOTE:  Alpha transparency included in col & fill
166
     * NOTE:  Alpha transparency included in col & fill
167
     */
167
     */
168
    int col;             /* pen colour (lines, text, borders, ...) */
168
    int col;             /* pen colour (lines, text, borders, ...) */
169
    int fill;            /* fill colour (for polygons, circles, rects, ...) */
169
    int fill;            /* fill colour (for polygons, circles, rects, ...) */
170
    double gamma;        /* Gamma correction */
170
    double gamma;        /* Gamma correction */
171
    /* 
171
    /*
172
     * Line characteristics
172
     * Line characteristics
173
     */
173
     */
174
    double lwd;          /* Line width (roughly number of pixels) */
174
    double lwd;          /* Line width (roughly number of pixels) */
175
    int lty;             /* Line type (solid, dashed, dotted, ...) */
175
    int lty;             /* Line type (solid, dashed, dotted, ...) */
176
    R_GE_lineend lend;   /* Line end */
176
    R_GE_lineend lend;   /* Line end */
Line 185... Line 185...
185
    int fontface;        /* Font face (plain, italic, bold, ...) */
185
    int fontface;        /* Font face (plain, italic, bold, ...) */
186
    char fontfamily[201]; /* Font family */
186
    char fontfamily[201]; /* Font family */
187
} R_GE_gcontext;
187
} R_GE_gcontext;
188
 
188
 
189
typedef R_GE_gcontext* pGEcontext;
189
typedef R_GE_gcontext* pGEcontext;
190
    
190
 
191
 
191
 
192
#include <R_ext/GraphicsDevice.h> /* needed for DevDesc */
192
#include <R_ext/GraphicsDevice.h> /* needed for DevDesc */
193
 
193
 
194
typedef struct _GEDevDesc GEDevDesc;
194
typedef struct _GEDevDesc GEDevDesc;
195
 
195
 
196
typedef SEXP (* GEcallback)(GEevent, GEDevDesc *, SEXP);
196
typedef SEXP (* GEcallback)(GEevent, GEDevDesc *, SEXP);
197
 
197
 
198
typedef struct { 
198
typedef struct {
199
    /* An array of information about each graphics system that
199
    /* An array of information about each graphics system that
200
     * has registered with the graphics engine.
200
     * has registered with the graphics engine.
201
     * This is used to store graphics state for each graphics
201
     * This is used to store graphics state for each graphics
202
     * system on each device.
202
     * system on each device.
203
     */
203
     */
204
    void *systemSpecific;
204
    void *systemSpecific;
205
    /* 
205
    /*
206
     * An array of function pointers, one per graphics system that
206
     * An array of function pointers, one per graphics system that
207
     * has registered with the graphics engine.
207
     * has registered with the graphics engine.
208
     *
208
     *
209
     * system_Callback is called when the graphics engine wants
209
     * system_Callback is called when the graphics engine wants
210
     * to give a graphics system the chance to play with its
210
     * to give a graphics system the chance to play with its
Line 217... Line 217...
217
     */
217
     */
218
    GEcallback callback;
218
    GEcallback callback;
219
} GESystemDesc;
219
} GESystemDesc;
220
 
220
 
221
struct _GEDevDesc {
221
struct _GEDevDesc {
222
    /* 
222
    /*
223
     * Stuff that the devices can see (and modify).
223
     * Stuff that the devices can see (and modify).
224
     * All detailed in GraphicsDevice.h
224
     * All detailed in GraphicsDevice.h
225
     */
225
     */
226
    pDevDesc dev;
226
    pDevDesc dev;
227
    /*
227
    /*
Line 238... Line 238...
238
			      */
238
			      */
239
    Rboolean dirty;          /* Has the device received any output? */
239
    Rboolean dirty;          /* Has the device received any output? */
240
    Rboolean recordGraphics; /* Should a graphics call be stored
240
    Rboolean recordGraphics; /* Should a graphics call be stored
241
			      * on the display list?
241
			      * on the display list?
242
			      * Set to FALSE by do_recordGraphics,
242
			      * Set to FALSE by do_recordGraphics,
243
			      * do_dotcallgr, and do_Externalgr 
243
			      * do_dotcallgr, and do_Externalgr
244
			      * so that nested calls are not
244
			      * so that nested calls are not
245
			      * recorded on the display list
245
			      * recorded on the display list
246
			      */
246
			      */
247
    /* 
247
    /*
248
     * Stuff about the device that only graphics systems see.
248
     * Stuff about the device that only graphics systems see.
249
     * The graphics engine has no idea what is in here.
249
     * The graphics engine has no idea what is in here.
250
     * Used by graphics systems to store system state per device.
250
     * Used by graphics systems to store system state per device.
251
     */
251
     */
252
    GESystemDesc *gesd[MAX_GRAPHICS_SYSTEMS];
252
    GESystemDesc *gesd[MAX_GRAPHICS_SYSTEMS];
Line 283... Line 283...
283
#define fromDeviceWidth		GEfromDeviceWidth
283
#define fromDeviceWidth		GEfromDeviceWidth
284
#define toDeviceWidth		GEtoDeviceWidth
284
#define toDeviceWidth		GEtoDeviceWidth
285
#define fromDeviceHeight	GEfromDeviceHeight
285
#define fromDeviceHeight	GEfromDeviceHeight
286
#define toDeviceHeight		GEtoDeviceHeight
286
#define toDeviceHeight		GEtoDeviceHeight
287
 
287
 
288
double fromDeviceX(double value, GEUnit to, pGEDevDesc dd); 
288
double fromDeviceX(double value, GEUnit to, pGEDevDesc dd);
289
double toDeviceX(double value, GEUnit from, pGEDevDesc dd);
289
double toDeviceX(double value, GEUnit from, pGEDevDesc dd);
290
double fromDeviceY(double value, GEUnit to, pGEDevDesc dd); 
290
double fromDeviceY(double value, GEUnit to, pGEDevDesc dd);
291
double toDeviceY(double value, GEUnit from, pGEDevDesc dd);
291
double toDeviceY(double value, GEUnit from, pGEDevDesc dd);
292
double fromDeviceWidth(double value, GEUnit to, pGEDevDesc dd); 
292
double fromDeviceWidth(double value, GEUnit to, pGEDevDesc dd);
293
double toDeviceWidth(double value, GEUnit from, pGEDevDesc dd);
293
double toDeviceWidth(double value, GEUnit from, pGEDevDesc dd);
294
double fromDeviceHeight(double value, GEUnit to, pGEDevDesc dd); 
294
double fromDeviceHeight(double value, GEUnit to, pGEDevDesc dd);
295
double toDeviceHeight(double value, GEUnit from, pGEDevDesc dd);
295
double toDeviceHeight(double value, GEUnit from, pGEDevDesc dd);
296
 
296
 
297
/*-------------------------------------------------------------------
297
/*-------------------------------------------------------------------
298
 *
298
 *
299
 *  COLOUR CODE is concerned with the internals of R colour representation
299
 *  COLOUR CODE is concerned with the internals of R colour representation
Line 371... Line 371...
371
R_GE_linejoin GE_LJOINpar(SEXP value, int ind);
371
R_GE_linejoin GE_LJOINpar(SEXP value, int ind);
372
SEXP GE_LJOINget(R_GE_linejoin ljoin);
372
SEXP GE_LJOINget(R_GE_linejoin ljoin);
373
 
373
 
374
void GESetClip(double x1, double y1, double x2, double y2, pGEDevDesc dd);
374
void GESetClip(double x1, double y1, double x2, double y2, pGEDevDesc dd);
375
void GENewPage(const pGEcontext gc, pGEDevDesc dd);
375
void GENewPage(const pGEcontext gc, pGEDevDesc dd);
376
void GELine(double x1, double y1, double x2, double y2, 
376
void GELine(double x1, double y1, double x2, double y2,
377
	    const pGEcontext gc, pGEDevDesc dd);
377
	    const pGEcontext gc, pGEDevDesc dd);
378
void GEPolyline(int n, double *x, double *y, 
378
void GEPolyline(int n, double *x, double *y,
379
		const pGEcontext gc, pGEDevDesc dd);
379
		const pGEcontext gc, pGEDevDesc dd);
380
void GEPolygon(int n, double *x, double *y, 
380
void GEPolygon(int n, double *x, double *y,
381
	       const pGEcontext gc, pGEDevDesc dd);
381
	       const pGEcontext gc, pGEDevDesc dd);
382
SEXP GEXspline(int n, double *x, double *y, double *s, Rboolean open, 
382
SEXP GEXspline(int n, double *x, double *y, double *s, Rboolean open,
383
	       Rboolean repEnds, Rboolean draw,
383
	       Rboolean repEnds, Rboolean draw,
384
	       const pGEcontext gc, pGEDevDesc dd);
384
	       const pGEcontext gc, pGEDevDesc dd);
385
void GECircle(double x, double y, double radius,
385
void GECircle(double x, double y, double radius,
386
	      const pGEcontext gc, pGEDevDesc dd);
386
	      const pGEcontext gc, pGEDevDesc dd);
387
void GERect(double x0, double y0, double x1, double y1,
387
void GERect(double x0, double y0, double x1, double y1,
388
	    const pGEcontext gc, pGEDevDesc dd);
388
	    const pGEcontext gc, pGEDevDesc dd);
389
void GEPath(double *x, double *y, 
389
void GEPath(double *x, double *y,
390
            int npoly, int *nper,
390
            int npoly, int *nper,
391
            Rboolean winding,
391
            Rboolean winding,
392
            const pGEcontext gc, pGEDevDesc dd);
392
            const pGEcontext gc, pGEDevDesc dd);
393
void GERaster(unsigned int *raster, int w, int h,
393
void GERaster(unsigned int *raster, int w, int h,
394
              double x, double y, double width, double height,
394
              double x, double y, double width, double height,
Line 400... Line 400...
400
	    const pGEcontext gc, pGEDevDesc dd);
400
	    const pGEcontext gc, pGEDevDesc dd);
401
void GEMode(int mode, pGEDevDesc dd);
401
void GEMode(int mode, pGEDevDesc dd);
402
void GESymbol(double x, double y, int pch, double size,
402
void GESymbol(double x, double y, int pch, double size,
403
	      const pGEcontext gc, pGEDevDesc dd);
403
	      const pGEcontext gc, pGEDevDesc dd);
404
void GEPretty(double *lo, double *up, int *ndiv);
404
void GEPretty(double *lo, double *up, int *ndiv);
405
void GEMetricInfo(int c, const pGEcontext gc, 
405
void GEMetricInfo(int c, const pGEcontext gc,
406
		  double *ascent, double *descent, double *width,
406
		  double *ascent, double *descent, double *width,
407
		  pGEDevDesc dd);
407
		  pGEDevDesc dd);
408
double GEStrWidth(const char *str, cetype_t enc, 
408
double GEStrWidth(const char *str, cetype_t enc,
409
		  const pGEcontext gc, pGEDevDesc dd);
409
		  const pGEcontext gc, pGEDevDesc dd);
410
double GEStrHeight(const char *str, cetype_t enc,
410
double GEStrHeight(const char *str, cetype_t enc,
411
		  const pGEcontext gc, pGEDevDesc dd);
411
		  const pGEcontext gc, pGEDevDesc dd);
412
int GEstring_to_pch(SEXP pch);
412
int GEstring_to_pch(SEXP pch);
413
 
413
 
Line 428... Line 428...
428
                            unsigned int *draster, int dw, int dh);
428
                            unsigned int *draster, int dw, int dh);
429
void R_GE_rasterRotatedSize(int w, int h, double angle,
429
void R_GE_rasterRotatedSize(int w, int h, double angle,
430
                            int *wnew, int *hnew);
430
                            int *wnew, int *hnew);
431
void R_GE_rasterRotatedOffset(int w, int h, double angle, int botleft,
431
void R_GE_rasterRotatedOffset(int w, int h, double angle, int botleft,
432
                              double *xoff, double *yoff);
432
                              double *xoff, double *yoff);
433
void R_GE_rasterResizeForRotation(unsigned int *sraster, 
433
void R_GE_rasterResizeForRotation(unsigned int *sraster,
434
                                  int w, int h, 
434
                                  int w, int h,
435
                                  unsigned int *newRaster,
435
                                  unsigned int *newRaster,
436
                                  int wnew, int hnew,
436
                                  int wnew, int hnew,
437
                                  const pGEcontext gc);
437
                                  const pGEcontext gc);
438
void R_GE_rasterRotate(unsigned int *sraster, int w, int h, double angle,
438
void R_GE_rasterRotate(unsigned int *sraster, int w, int h, double angle,
439
                       unsigned int *draster, const pGEcontext gc,
439
                       unsigned int *draster, const pGEcontext gc,
440
                       Rboolean perPixelAlpha);
440
                       Rboolean perPixelAlpha);
441
 
441
 
442
 
442
 
443
/* 
443
/*
444
 * From plotmath.c 
444
 * From plotmath.c
445
 */
445
 */
446
double GEExpressionWidth(SEXP expr, 
446
double GEExpressionWidth(SEXP expr,
447
			 const pGEcontext gc, pGEDevDesc dd);
447
			 const pGEcontext gc, pGEDevDesc dd);
448
double GEExpressionHeight(SEXP expr, 
448
double GEExpressionHeight(SEXP expr,
449
			  const pGEcontext gc, pGEDevDesc dd);
449
			  const pGEcontext gc, pGEDevDesc dd);
450
void GEMathText(double x, double y, SEXP expr,
450
void GEMathText(double x, double y, SEXP expr,
451
		double xc, double yc, double rot, 
451
		double xc, double yc, double rot,
452
		const pGEcontext gc, pGEDevDesc dd);
452
		const pGEcontext gc, pGEDevDesc dd);
453
/* 
453
/*
454
 * (End from plotmath.c)
454
 * (End from plotmath.c)
455
 */
455
 */
456
 
456
 
457
/* 
457
/*
458
 * From plot3d.c : used in package clines
458
 * From plot3d.c : used in package clines
459
 */
459
 */
460
SEXP GEcontourLines(double *x, int nx, double *y, int ny,
460
SEXP GEcontourLines(double *x, int nx, double *y, int ny,
461
		    double *z, double *levels, int nl);
461
		    double *z, double *levels, int nl);
462
/* 
462
/*
463
 * (End from plot3d.c)
463
 * (End from plot3d.c)
464
 */
464
 */
465
 
465
 
466
/* 
466
/*
467
 * From vfonts.c
467
 * From vfonts.c
468
 */
468
 */
469
double R_GE_VStrWidth(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd);
469
double R_GE_VStrWidth(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd);
470
 
470
 
471
double R_GE_VStrHeight(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd);
471
double R_GE_VStrHeight(const char *s, cetype_t enc, const pGEcontext gc, pGEDevDesc dd);
472
void R_GE_VText(double x, double y, const char * const s, cetype_t enc, 
472
void R_GE_VText(double x, double y, const char * const s, cetype_t enc,
473
		double x_justify, double y_justify, double rotation,
473
		double x_justify, double y_justify, double rotation,
474
		const pGEcontext gc, pGEDevDesc dd);
474
		const pGEcontext gc, pGEDevDesc dd);
475
/* 
475
/*
476
 * (End from vfonts.c)
476
 * (End from vfonts.c)
477
 */
477
 */
478
 
478
 
479
/* Also in Graphics.h */
479
/* Also in Graphics.h */
480
#define	DEG2RAD 0.01745329251994329576
480
#define	DEG2RAD 0.01745329251994329576
Line 492... Line 492...
492
void GEplaySnapshot(SEXP snapshot, pGEDevDesc dd);
492
void GEplaySnapshot(SEXP snapshot, pGEDevDesc dd);
493
void GEonExit(void);
493
void GEonExit(void);
494
void GEnullDevice(void);
494
void GEnullDevice(void);
495
 
495
 
496
 
496
 
497
/* From plot.c, used by grid/src/grid.c */
497
// From ../../main/plot.c, used by ../../library/grid/src/grid.c :
498
#define CreateAtVector		Rf_CreateAtVector
498
#define CreateAtVector		Rf_CreateAtVector
499
SEXP CreateAtVector(double*, double*, int, Rboolean);
499
SEXP CreateAtVector(double*, double*, int, Rboolean);
-
 
500
// From ../../main/graphics.c, used by ../../library/grDevices/src/axis_scales.c :
-
 
501
#define GAxisPars 		Rf_GAxisPars
-
 
502
void GAxisPars(double *min, double *max, int *n, Rboolean log, int axis);
500
 
503
 
501
#ifdef __cplusplus
504
#ifdef __cplusplus
502
}
505
}
503
#endif
506
#endif
504
 
507