The R Project SVN R

Rev

Rev 88863 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
29921 ripley 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
88863 ripley 3
 *  Copyright (C) 2001-25 The R Core Team.
29921 ripley 4
 *
71657 plummer 5
 *  This header file is free software; you can redistribute it and/or modify
29921 ripley 6
 *  it under the terms of the GNU Lesser General Public License as published by
7
 *  the Free Software Foundation; either version 2.1 of the License, or
8
 *  (at your option) any later version.
9
 *
71657 plummer 10
 *  This file is part of R. R is distributed under the terms of the
11
 *  GNU General Public License, either Version 2, June 1991 or Version 3,
12
 *  June 2007. See doc/COPYRIGHTS for details of the copyright status of R.
13
 *
29921 ripley 14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Lesser General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Lesser General Public License
42308 ripley 20
 *  along with this program; if not, a copy is available at
68949 ripley 21
 *  https://www.R-project.org/Licenses/
29921 ripley 22
 */
17204 hornik 23
 
44154 ripley 24
/* Used by graphics.c, grid and by third-party graphics devices */
29921 ripley 25
 
34747 ripley 26
#ifndef R_GRAPHICSENGINE_H_
27
#define R_GRAPHICSENGINE_H_
28
 
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
 
32815 murrell 33
/*
34
 * The current graphics engine (including graphics device) API version
35
 * MUST be integer
57122 maechler 36
 *
37
 * This number should be bumped whenever there are changes to
32815 murrell 38
 * GraphicsEngine.h or GraphicsDevice.h so that add-on packages
39
 * that compile against these headers (graphics systems such as
40
 * graphics and grid;  graphics devices such as gtkDevice, RSvgDevice)
41
 * can detect any version mismatch.
42
 *
43
 * Version 1:  Introduction of the version number.
34785 murrell 44
 * Version 2:  GEDevDesc *dd dropped from GEcontourLines().
56854 ripley 45
 * Version 3:  R_GE_str2col() added to API. (r41887)
44308 ripley 46
 * Version 4:  UTF-8 text hooks, useRotatedTextInContour,
44418 ripley 47
 *             add newFrameConfirm() to NewDevDesc.
44412 ripley 48
 *             New API: GEaddDevice[2] GEgetDevice, GEkillDevice,
56854 ripley 49
 *             ndevNumber. (R 2.7.0)
44404 ripley 50
 * Version 5:  Clean up 1.4.0/2.0.0 changes!
44308 ripley 51
 *             Remove newDevStruct from GEDevDesc and NewDevDesc.
44404 ripley 52
 *             Remove asp, dot(), hold(), open() from NewDevDesc.
53
 *             Move displayList, DLlastElt, savedSnapshot from
54
 *             NewDevDesc to GEDevDesc.
56854 ripley 55
 *             Add 'ask' to GEDevDesc. (R 2.8.0)
56
 * Version 6:  Add dev_Raster() and dev_Cap()  (R 2.11.0)
57122 maechler 57
 * Version 7:  Change graphics event handling, adding eventEnv and eventHelper()
56854 ripley 58
 *	       to DevDesc.  (R 2.12.0)
59
 * Version 8:  Add dev_Path() (R 2.12.0)
57122 maechler 60
 * Version 9:  Add dev_HoldFlush(), haveTrans*, haveRaster,
56854 ripley 61
 *             haveCapture, haveLocator.  (R 2.14.0)
61351 ripley 62
 * Version 10: For R 3.0.0.  Typedef and use 'rcolor',
63
 *             Remove name2col (R_GE_str2col does the job).
69314 murrell 64
 * Version 11: For R 3.3.0.
65
 *             Official support for saving/restoring display lists
66
 *             across R sessions (via recordPlot() and replayPlot())
67
 *             - added grid DL to snapshots (used to be NULL)
68
 *             - added this version number to snapshots (as attribute)
69
 *             - added R version number to snapshots (as attribute)
70
 *             - added pkgName to graphics system state info (as attribute)
72261 murrell 71
 * Version 12: For R 3.4.0
72758 ripley 72
 *             Added canGenIdle, doIdle() and doesIdle() to devices.
78760 ripley 73
 * Version 13: For R 4.1.0
78759 murrell 74
 *             Added graphical definitions
75
 *             - linear gradients
76
 *             - radial gradients
77
 *             - patterns
78
 *             - clipping paths
79
 *             - masks
79409 murrell 80
 *             Added deviceVersion
81
 * Version 14: Added deviceClip
81097 murrell 82
 * Version 15: For R 4.2.0
83
 *             Added more graphical definitions
84
 *             - groups
85
 *             - paths
81278 murrell 86
 *             - luminance masks
87
 *             Added capabilities
83684 murrell 88
 * Version 16: For R 4.3.0
89
 *             Added more advanced typesetting
90
 *             - glyphs
88293 murrell 91
 * Version 17: For R 4.6.0
92
 *             - variable fonts
32815 murrell 93
 */
78759 murrell 94
#define R_GE_definitions 13
79409 murrell 95
#define R_GE_deviceClip  14
81097 murrell 96
#define R_GE_group       15
83684 murrell 97
#define R_GE_glyphs      16
88293 murrell 98
#define R_GE_fontVar     17
32815 murrell 99
 
88293 murrell 100
#define R_GE_version R_GE_fontVar
32815 murrell 101
 
44195 ripley 102
int R_GE_getVersion(void);
32815 murrell 103
 
104
void R_GE_checkVersionOrDie(int version);
105
 
57122 maechler 106
/* The graphics engine will only accept locations and dimensions
17204 hornik 107
 * in native device coordinates, but it provides the following functions
57122 maechler 108
 * for converting between a couple of simple alternative coordinate
17204 hornik 109
 * systems and device coordinates:
110
 *    DEVICE = native units of the device
57122 maechler 111
 *    NDC = Normalised device coordinates
17204 hornik 112
 *    INCHES = inches (!)
113
 *    CM = centimetres (!!)
114
 */
115
 
116
typedef enum {
117
 GE_DEVICE	= 0,	/* native device coordinates (rasters) */
118
 GE_NDC	= 1,	/* normalised device coordinates x=(0,1), y=(0,1) */
119
 GE_INCHES = 2,
120
 GE_CM     = 3
121
} GEUnit;
122
 
123
#define MAX_GRAPHICS_SYSTEMS 24
124
 
125
typedef enum {
126
    /* In response to this event, the registered graphics system
127
     * should allocate and initialise the systemSpecific structure
57122 maechler 128
     *
51056 murrell 129
     * Should return R_NilValue on failure so that engine
130
     * can tidy up memory allocation
17204 hornik 131
     */
132
    GE_InitState = 0,
133
    /* This event gives the registered system a chance to undo
134
     * anything done in the initialisation.
135
     */
136
    GE_FinaliseState = 1,
137
    /* This is sent by the graphics engine prior to initialising
138
     * the display list.  It give the graphics system the chance
139
     * to squirrel away information it will need for redrawing the
140
     * the display list
141
     */
142
    GE_SaveState = 2,
143
    /* This is sent by the graphics engine prior to replaying the
144
     * display list.  It gives the graphics system the chance to
145
     * restore any information it saved on the GE_SaveState event
146
     */
147
    GE_RestoreState = 6,
148
    /* Copy system state information to the current device.
149
     * This is used when copying graphics from one device to another
150
     * so all the graphics system needs to do is to copy across
151
     * the bits required for the display list to draw faithfully
152
     * on the new device.
153
     */
154
    GE_CopyState = 3,
155
    /* Create a snapshot of the system state that is sufficient
156
     * for the current "image" to be reproduced
157
     */
158
    GE_SaveSnapshotState = 4,
159
    /* Restore the system state that is saved by GE_SaveSnapshotState
160
     */
161
    GE_RestoreSnapshotState = 5,
57122 maechler 162
    /* When replaying the display list, the graphics engine
163
     * checks, after each replayed action, that the action
17204 hornik 164
     * produced valid output.  This is the graphics system's
165
     * chance to say that the output is crap (in which case the
166
     * graphics engine will abort the display list replay).
167
     */
17270 murrell 168
    GE_CheckPlot = 7,
169
    /* The device wants to scale the current pointsize
170
     * (for scaling an image)
57122 maechler 171
     * This is not a nice general solution, but a quick fix for
17270 murrell 172
     * the Windows device.
173
     */
174
    GE_ScalePS = 8
17204 hornik 175
} GEevent;
176
 
44271 ripley 177
/*
178
 *  Some line end/join constants
179
 */
180
typedef enum {
181
  GE_ROUND_CAP  = 1,
182
  GE_BUTT_CAP   = 2,
183
  GE_SQUARE_CAP = 3
184
} R_GE_lineend;
185
 
186
typedef enum {
187
  GE_ROUND_JOIN = 1,
188
  GE_MITRE_JOIN = 2,
189
  GE_BEVEL_JOIN = 3
190
} R_GE_linejoin;
191
 
57122 maechler 192
/*
193
 * A structure containing graphical parameters
44271 ripley 194
 *
195
 * This is how graphical parameters are passed from graphics systems
196
 * to the graphics engine AND from the graphics engine to graphics
197
 * devices.
198
 *
199
 * Devices are not *required* to honour graphical parameters
200
 * (e.g., alpha transparency is going to be tough for some)
201
 */
202
typedef struct {
203
    /*
204
     * Colours
205
     *
206
     * NOTE:  Alpha transparency included in col & fill
207
     */
208
    int col;             /* pen colour (lines, text, borders, ...) */
209
    int fill;            /* fill colour (for polygons, circles, rects, ...) */
210
    double gamma;        /* Gamma correction */
57122 maechler 211
    /*
44271 ripley 212
     * Line characteristics
213
     */
214
    double lwd;          /* Line width (roughly number of pixels) */
215
    int lty;             /* Line type (solid, dashed, dotted, ...) */
216
    R_GE_lineend lend;   /* Line end */
217
    R_GE_linejoin ljoin; /* line join */
218
    double lmitre;       /* line mitre */
219
    /*
220
     * Text characteristics
221
     */
222
    double cex;          /* Character expansion (font size = fontsize*cex) */
223
    double ps;           /* Font size in points */
224
    double lineheight;   /* Line height (multiply by font size) */
225
    int fontface;        /* Font face (plain, italic, bold, ...) */
226
    char fontfamily[201]; /* Font family */
78759 murrell 227
    /*
228
     * Definitions
229
     */
230
    SEXP patternFill;  /* Reference to a pattern fill */
44271 ripley 231
} R_GE_gcontext;
232
 
44301 ripley 233
typedef R_GE_gcontext* pGEcontext;
234
 
87075 kalibera 235
#ifdef __cplusplus
236
}
237
#endif
57122 maechler 238
 
46180 ripley 239
#include <R_ext/GraphicsDevice.h> /* needed for DevDesc */
44271 ripley 240
 
87075 kalibera 241
#ifdef __cplusplus
242
extern "C" {
243
#endif
244
 
19966 duncan 245
typedef struct _GEDevDesc GEDevDesc;
17204 hornik 246
 
19966 duncan 247
typedef SEXP (* GEcallback)(GEevent, GEDevDesc *, SEXP);
248
 
57122 maechler 249
typedef struct {
17204 hornik 250
    /* An array of information about each graphics system that
251
     * has registered with the graphics engine.
252
     * This is used to store graphics state for each graphics
253
     * system on each device.
254
     */
255
    void *systemSpecific;
57122 maechler 256
    /*
17204 hornik 257
     * An array of function pointers, one per graphics system that
258
     * has registered with the graphics engine.
259
     *
260
     * system_Callback is called when the graphics engine wants
261
     * to give a graphics system the chance to play with its
262
     * device-specific information (stored in systemSpecific)
263
     * There are two parameters:  an "event" to tell the graphics
264
     * system why the graphics engine has called this function,
265
     * and the systemSpecific pointer.  The graphics engine
266
     * has to pass the systemSpecific pointer because only
267
     * the graphics engine will know what array index to use.
268
     */
269
    GEcallback callback;
270
} GESystemDesc;
271
 
19966 duncan 272
struct _GEDevDesc {
57122 maechler 273
    /*
30832 murrell 274
     * Stuff that the devices can see (and modify).
275
     * All detailed in GraphicsDevice.h
276
     */
44364 ripley 277
    pDevDesc dev;
30832 murrell 278
    /*
279
     * Stuff about the device that only the graphics engine sees
280
     * (the devices don't see it).
17204 hornik 281
     */
44352 ripley 282
    Rboolean displayListOn;  /* toggle for display list status */
283
    SEXP displayList;        /* display list */
284
    SEXP DLlastElt;          /* A pointer to the end of the display list
84150 maechler 285
				to avoid traversing pairlists */
44352 ripley 286
    SEXP savedSnapshot;      /* The last element of the display list
287
			      * just prior to when the display list
288
			      * was last initialised
289
			      */
290
    Rboolean dirty;          /* Has the device received any output? */
31938 murrell 291
    Rboolean recordGraphics; /* Should a graphics call be stored
292
			      * on the display list?
293
			      * Set to FALSE by do_recordGraphics,
57122 maechler 294
			      * do_dotcallgr, and do_Externalgr
31938 murrell 295
			      * so that nested calls are not
296
			      * recorded on the display list
297
			      */
88805 murrell 298
    Rboolean lock;           /* The device is locked and unlocked
299
                              * within R_eval_with_gd().
300
                              * When the device is locked, attempts
301
                              * to "kill" the device are ignored.
302
                              */
57122 maechler 303
    /*
30832 murrell 304
     * Stuff about the device that only graphics systems see.
305
     * The graphics engine has no idea what is in here.
306
     * Used by graphics systems to store system state per device.
307
     */
17204 hornik 308
    GESystemDesc *gesd[MAX_GRAPHICS_SYSTEMS];
44458 ripley 309
 
310
    /* per-device setting for 'ask' (use NewFrameConfirm) */
311
    Rboolean ask;
81097 murrell 312
 
313
    /* Is a device appending a path ? */
314
    Rboolean appending;
19966 duncan 315
};
17204 hornik 316
 
44285 ripley 317
typedef GEDevDesc* pGEDevDesc;
318
 
44259 ripley 319
/* functions from devices.c for use by graphics devices */
320
 
321
#define desc2GEDesc		Rf_desc2GEDesc
46180 ripley 322
/* map DevDesc to enclosing GEDevDesc */
44364 ripley 323
pGEDevDesc desc2GEDesc(pDevDesc dd);
44285 ripley 324
int GEdeviceNumber(pGEDevDesc);
44412 ripley 325
pGEDevDesc GEgetDevice(int);
44372 ripley 326
void GEaddDevice(pGEDevDesc);
44376 ripley 327
void GEaddDevice2(pGEDevDesc, const char *);
66109 ripley 328
void GEaddDevice2f(pGEDevDesc, const char *, const char *);
44285 ripley 329
void GEkillDevice(pGEDevDesc);
88863 ripley 330
pDevDesc GEcreateDD(void);
88803 murrell 331
void GEfreeDD(pDevDesc dd);
44364 ripley 332
pGEDevDesc GEcreateDevDesc(pDevDesc dev);
44257 ripley 333
 
44285 ripley 334
void GEdestroyDevDesc(pGEDevDesc dd);
44299 ripley 335
void *GEsystemState(pGEDevDesc dd, int index);
44285 ripley 336
void GEregisterWithDevice(pGEDevDesc dd);
17360 murrell 337
void GEregisterSystem(GEcallback callback, int *systemRegisterIndex);
17204 hornik 338
void GEunregisterSystem(int registerIndex);
44364 ripley 339
SEXP GEhandleEvent(GEevent event, pDevDesc dev, SEXP data);
17204 hornik 340
 
38705 ripley 341
#define fromDeviceX		GEfromDeviceX
342
#define toDeviceX		GEtoDeviceX
343
#define fromDeviceY		GEfromDeviceY
344
#define toDeviceY		GEtoDeviceY
345
#define fromDeviceWidth		GEfromDeviceWidth
346
#define toDeviceWidth		GEtoDeviceWidth
347
#define fromDeviceHeight	GEfromDeviceHeight
348
#define toDeviceHeight		GEtoDeviceHeight
349
 
57122 maechler 350
double fromDeviceX(double value, GEUnit to, pGEDevDesc dd);
44285 ripley 351
double toDeviceX(double value, GEUnit from, pGEDevDesc dd);
57122 maechler 352
double fromDeviceY(double value, GEUnit to, pGEDevDesc dd);
44285 ripley 353
double toDeviceY(double value, GEUnit from, pGEDevDesc dd);
57122 maechler 354
double fromDeviceWidth(double value, GEUnit to, pGEDevDesc dd);
44285 ripley 355
double toDeviceWidth(double value, GEUnit from, pGEDevDesc dd);
57122 maechler 356
double fromDeviceHeight(double value, GEUnit to, pGEDevDesc dd);
44285 ripley 357
double toDeviceHeight(double value, GEUnit from, pGEDevDesc dd);
17204 hornik 358
 
44264 ripley 359
/*-------------------------------------------------------------------
360
 *
361
 *  COLOUR CODE is concerned with the internals of R colour representation
362
 *
363
 *  From colors.c, used in par.c, grid/src/gpar.c
364
 */
365
 
61351 ripley 366
typedef unsigned int rcolor;
367
 
44264 ripley 368
#define RGBpar			Rf_RGBpar
44369 ripley 369
#define RGBpar3			Rf_RGBpar3
44264 ripley 370
#define col2name                Rf_col2name
371
 
44312 ripley 372
/* Convert an element of a R colour specification (which might be a
373
   number or a string) into an internal colour specification. */
61351 ripley 374
rcolor RGBpar(SEXP, int);
375
rcolor RGBpar3(SEXP, int, rcolor);
44357 ripley 376
 
44312 ripley 377
/* Convert an internal colour specification to/from a colour name */
61351 ripley 378
const char *col2name(rcolor col); /* used in par.c, grid */
44357 ripley 379
 
44369 ripley 380
/* Convert either a name or a #RRGGBB[AA] string to internal.
381
   Because people were using it, it also converts "1", "2" ...
382
   to a colour in the palette, and "0" to transparent white.
383
*/
61351 ripley 384
rcolor R_GE_str2col(const char *s);
44264 ripley 385
 
386
 
44312 ripley 387
 
17204 hornik 388
/*
389
 *	Some Notes on Line Textures
390
 *
391
 *	Line textures are stored as an array of 4-bit integers within
392
 *	a single 32-bit word.  These integers contain the lengths of
393
 *	lines to be drawn with the pen alternately down and then up.
394
 *	The device should try to arrange that these values are measured
395
 *	in points if possible, although pixels is ok on most displays.
396
 *
397
 *	If newlty contains a line texture description it is decoded
398
 *	as follows:
399
 *
400
 *		ndash = 0;
401
 *		for(i=0 ; i<8 && newlty & 15 ; i++) {
402
 *			dashlist[ndash++] = newlty & 15;
403
 *			newlty = newlty>>4;
404
 *		}
405
 *		dashlist[0] = length of pen-down segment
406
 *		dashlist[1] = length of pen-up segment
407
 *		etc
408
 *
409
 *	An integer containing a zero terminates the pattern.  Hence
410
 *	ndash in this code fragment gives the length of the texture
411
 *	description.  If a description contains an odd number of
412
 *	elements it is replicated to create a pattern with an
413
 *	even number of elements.  (If this is a pain, do something
414
 *	different its not crucial).
415
 *
416
 */
417
 
418
/*--- The basic numbered & names line types; Here device-independent:
419
  e.g. "dashed" == "44",  "dotdash" == "1343"
420
*/
421
 
44154 ripley 422
/* NB: was also in Rgraphics.h in R < 2.7.0 */
17204 hornik 423
#define LTY_BLANK	-1
424
#define LTY_SOLID	0
425
#define LTY_DASHED	4 + (4<<4)
426
#define LTY_DOTTED	1 + (3<<4)
427
#define LTY_DOTDASH	1 + (3<<4) + (4<<8) + (3<<12)
428
#define LTY_LONGDASH	7 + (3<<4)
429
#define LTY_TWODASH	2 + (2<<4) + (6<<8) + (2<<12)
430
 
44142 ripley 431
R_GE_lineend GE_LENDpar(SEXP value, int ind);
432
SEXP GE_LENDget(R_GE_lineend lend);
433
R_GE_linejoin GE_LJOINpar(SEXP value, int ind);
434
SEXP GE_LJOINget(R_GE_linejoin ljoin);
30925 murrell 435
 
44285 ripley 436
void GESetClip(double x1, double y1, double x2, double y2, pGEDevDesc dd);
44500 ripley 437
void GENewPage(const pGEcontext gc, pGEDevDesc dd);
57122 maechler 438
void GELine(double x1, double y1, double x2, double y2,
44500 ripley 439
	    const pGEcontext gc, pGEDevDesc dd);
57122 maechler 440
void GEPolyline(int n, double *x, double *y,
44500 ripley 441
		const pGEcontext gc, pGEDevDesc dd);
57122 maechler 442
void GEPolygon(int n, double *x, double *y,
44500 ripley 443
	       const pGEcontext gc, pGEDevDesc dd);
57122 maechler 444
SEXP GEXspline(int n, double *x, double *y, double *s, Rboolean open,
36748 murrell 445
	       Rboolean repEnds, Rboolean draw,
44500 ripley 446
	       const pGEcontext gc, pGEDevDesc dd);
17204 hornik 447
void GECircle(double x, double y, double radius,
44500 ripley 448
	      const pGEcontext gc, pGEDevDesc dd);
17204 hornik 449
void GERect(double x0, double y0, double x1, double y1,
44500 ripley 450
	    const pGEcontext gc, pGEDevDesc dd);
57122 maechler 451
void GEPath(double *x, double *y,
52406 murrell 452
            int npoly, int *nper,
453
            Rboolean winding,
454
            const pGEcontext gc, pGEDevDesc dd);
50283 murrell 455
void GERaster(unsigned int *raster, int w, int h,
456
              double x, double y, double width, double height,
457
              double angle, Rboolean interpolate,
458
              const pGEcontext gc, pGEDevDesc dd);
459
SEXP GECap(pGEDevDesc dd);
44986 ripley 460
void GEText(double x, double y, const char * const str, cetype_t enc,
21060 murrell 461
	    double xc, double yc, double rot,
44500 ripley 462
	    const pGEcontext gc, pGEDevDesc dd);
44285 ripley 463
void GEMode(int mode, pGEDevDesc dd);
17204 hornik 464
void GESymbol(double x, double y, int pch, double size,
44500 ripley 465
	      const pGEcontext gc, pGEDevDesc dd);
17204 hornik 466
void GEPretty(double *lo, double *up, int *ndiv);
57122 maechler 467
void GEMetricInfo(int c, const pGEcontext gc,
17204 hornik 468
		  double *ascent, double *descent, double *width,
44285 ripley 469
		  pGEDevDesc dd);
57122 maechler 470
double GEStrWidth(const char *str, cetype_t enc,
44500 ripley 471
		  const pGEcontext gc, pGEDevDesc dd);
44986 ripley 472
double GEStrHeight(const char *str, cetype_t enc,
44500 ripley 473
		  const pGEcontext gc, pGEDevDesc dd);
57567 murrell 474
void GEStrMetric(const char *str, cetype_t enc, const pGEcontext gc,
475
                 double *ascent, double *descent, double *width,
476
                 pGEDevDesc dd);
44142 ripley 477
int GEstring_to_pch(SEXP pch);
17204 hornik 478
 
44142 ripley 479
/*-------------------------------------------------------------------
480
 *
481
 *  LINE TEXTURE CODE is concerned with the internals of R
482
 *  line texture representation.
483
 */
484
unsigned int GE_LTYpar(SEXP, int);
485
SEXP GE_LTYget(unsigned int);
486
 
50488 murrell 487
/*
488
 * Raster operations
489
 */
50554 murrell 490
void R_GE_rasterScale(unsigned int *sraster, int sw, int sh,
491
                      unsigned int *draster, int dw, int dh);
50488 murrell 492
void R_GE_rasterInterpolate(unsigned int *sraster, int sw, int sh,
493
                            unsigned int *draster, int dw, int dh);
50554 murrell 494
void R_GE_rasterRotatedSize(int w, int h, double angle,
495
                            int *wnew, int *hnew);
496
void R_GE_rasterRotatedOffset(int w, int h, double angle, int botleft,
497
                              double *xoff, double *yoff);
57122 maechler 498
void R_GE_rasterResizeForRotation(unsigned int *sraster,
499
                                  int w, int h,
50554 murrell 500
                                  unsigned int *newRaster,
501
                                  int wnew, int hnew,
502
                                  const pGEcontext gc);
503
void R_GE_rasterRotate(unsigned int *sraster, int w, int h, double angle,
50608 murrell 504
                       unsigned int *draster, const pGEcontext gc,
505
                       Rboolean perPixelAlpha);
50488 murrell 506
 
50554 murrell 507
 
57122 maechler 508
/*
509
 * From plotmath.c
19875 murrell 510
 */
57122 maechler 511
double GEExpressionWidth(SEXP expr,
44500 ripley 512
			 const pGEcontext gc, pGEDevDesc dd);
57122 maechler 513
double GEExpressionHeight(SEXP expr,
44500 ripley 514
			  const pGEcontext gc, pGEDevDesc dd);
57567 murrell 515
void GEExpressionMetric(SEXP expr, const pGEcontext gc,
516
                        double *ascent, double *descent, double *width,
517
                        pGEDevDesc dd);
19875 murrell 518
void GEMathText(double x, double y, SEXP expr,
57122 maechler 519
		double xc, double yc, double rot,
44500 ripley 520
		const pGEcontext gc, pGEDevDesc dd);
57122 maechler 521
/*
21060 murrell 522
 * (End from plotmath.c)
19875 murrell 523
 */
524
 
57122 maechler 525
/*
44158 ripley 526
 * From plot3d.c : used in package clines
21060 murrell 527
 */
528
SEXP GEcontourLines(double *x, int nx, double *y, int ny,
34785 murrell 529
		    double *z, double *levels, int nl);
57122 maechler 530
/*
21060 murrell 531
 * (End from plot3d.c)
532
 */
533
 
44154 ripley 534
/* Also in Graphics.h */
17204 hornik 535
#define	DEG2RAD 0.01745329251994329576
536
 
44285 ripley 537
pGEDevDesc GEcurrentDevice(void);
538
Rboolean GEdeviceDirty(pGEDevDesc dd);
539
void GEdirtyDevice(pGEDevDesc dd);
540
Rboolean GEcheckState(pGEDevDesc dd);
541
Rboolean GErecording(SEXP call, pGEDevDesc dd);
542
void GErecordGraphicOperation(SEXP op, SEXP args, pGEDevDesc dd);
543
void GEinitDisplayList(pGEDevDesc dd);
544
void GEplayDisplayList(pGEDevDesc dd);
17204 hornik 545
void GEcopyDisplayList(int fromDevice);
44285 ripley 546
SEXP GEcreateSnapshot(pGEDevDesc dd);
547
void GEplaySnapshot(SEXP snapshot, pGEDevDesc dd);
44195 ripley 548
void GEonExit(void);
34747 ripley 549
 
550
 
59105 maechler 551
/* From ../../main/plot.c, used by ../../library/grid/src/grid.c : */
45051 ripley 552
#define CreateAtVector		Rf_CreateAtVector
80633 maechler 553
SEXP CreateAtVector(double axp[], const double usr[], int nint, Rboolean logflag);
59105 maechler 554
/* From ../../main/graphics.c, used by ../../library/grDevices/src/axis_scales.c : */
57122 maechler 555
#define GAxisPars 		Rf_GAxisPars
556
void GAxisPars(double *min, double *max, int *n, Rboolean log, int axis);
45051 ripley 557
 
88805 murrell 558
SEXP Rf_eval_with_gd(SEXP, SEXP, pGEDevDesc);
559
#define eval_with_gd Rf_eval_with_gd
560
 
78759 murrell 561
/* Patterns - from ../../main/patterns.c */
562
Rboolean R_GE_isPattern(SEXP x);
563
#define R_GE_linearGradientPattern 1
564
#define R_GE_radialGradientPattern 2
565
#define R_GE_tilingPattern         3
566
int R_GE_patternType(SEXP pattern);
567
 
568
double R_GE_linearGradientX1(SEXP pattern);
569
double R_GE_linearGradientY1(SEXP pattern);
570
double R_GE_linearGradientX2(SEXP pattern);
571
double R_GE_linearGradientY2(SEXP pattern);
572
int R_GE_linearGradientNumStops(SEXP pattern);
573
double R_GE_linearGradientStop(SEXP pattern, int i);
574
rcolor R_GE_linearGradientColour(SEXP pattern, int i);
575
/* Must match order in ../library/grDevices/R/patterns.R */
576
#define R_GE_patternExtendPad 1
577
#define R_GE_patternExtendRepeat 2
578
#define R_GE_patternExtendReflect 3
579
#define R_GE_patternExtendNone 4
580
int R_GE_linearGradientExtend(SEXP pattern);
581
 
582
double R_GE_radialGradientCX1(SEXP pattern);
583
double R_GE_radialGradientCY1(SEXP pattern);
584
double R_GE_radialGradientR1(SEXP pattern);
585
double R_GE_radialGradientCX2(SEXP pattern);
586
double R_GE_radialGradientCY2(SEXP pattern);
587
double R_GE_radialGradientR2(SEXP pattern);
588
int R_GE_radialGradientNumStops(SEXP pattern);
589
double R_GE_radialGradientStop(SEXP pattern, int i);
590
rcolor R_GE_radialGradientColour(SEXP pattern, int i);
591
int R_GE_radialGradientExtend(SEXP pattern);
592
 
593
SEXP R_GE_tilingPatternFunction(SEXP pattern);
594
double R_GE_tilingPatternX(SEXP pattern);
595
double R_GE_tilingPatternY(SEXP pattern);
596
double R_GE_tilingPatternWidth(SEXP pattern);
597
double R_GE_tilingPatternHeight(SEXP pattern);
598
int R_GE_tilingPatternExtend(SEXP pattern);
599
 
81097 murrell 600
/* Composition operators */
81278 murrell 601
/* Must match order in ../library/grDevices/R/group.R */
81097 murrell 602
/* Porter-Duff */
603
#define R_GE_compositeClear 1
604
#define R_GE_compositeSource 2
605
#define R_GE_compositeOver 3
606
#define R_GE_compositeIn 4
607
#define R_GE_compositeOut 5
608
#define R_GE_compositeAtop 6
609
#define R_GE_compositeDest 7
610
#define R_GE_compositeDestOver 8
611
#define R_GE_compositeDestIn 9
612
#define R_GE_compositeDestOut 10
613
#define R_GE_compositeDestAtop 11
614
#define R_GE_compositeXor 12
615
/* Additional Porter-Duff */
616
#define R_GE_compositeAdd 13
617
#define R_GE_compositeSaturate 14
618
/* PDF Blend Modes */
619
#define R_GE_compositeMultiply 15
620
#define R_GE_compositeScreen 16
621
#define R_GE_compositeOverlay 17
622
#define R_GE_compositeDarken 18
623
#define R_GE_compositeLighten 19
624
#define R_GE_compositeColorDodge 20
625
#define R_GE_compositeColorBurn 21
626
#define R_GE_compositeHardLight 22
627
#define R_GE_compositeSoftLight 23
628
#define R_GE_compositeDifference 24
629
#define R_GE_compositeExclusion 25
630
 
631
/* Path rules */
81257 murrell 632
/* Must match order in ../library/grDevices/R/path.R */
81097 murrell 633
#define R_GE_nonZeroWindingRule 1
634
#define R_GE_evenOddRule        2
635
 
636
int R_GE_clipPathFillRule(SEXP path);
637
 
638
void GEStroke(SEXP path, const pGEcontext gc, pGEDevDesc dd);
639
void GEFill(SEXP path, int rule, const pGEcontext gc, pGEDevDesc dd);
640
void GEFillStroke(SEXP path, int rule, const pGEcontext gc, pGEDevDesc dd);
641
 
81257 murrell 642
/* Mask types */
643
/* Must match order in ../library/grDevices/R/mask.R */
644
#define R_GE_alphaMask     1
645
#define R_GE_luminanceMask 2
646
 
647
int R_GE_maskType(SEXP mask);
648
 
81278 murrell 649
/* Device capabilities */
650
/* Must match order in ../library/grDevices/R/device.R */
651
#define R_GE_capability_semiTransparency      0
652
#define R_GE_capability_transparentBackground 1
653
#define R_GE_capability_rasterImage           2
654
#define R_GE_capability_capture               3
655
#define R_GE_capability_locator               4
656
#define R_GE_capability_events                5
657
#define R_GE_capability_patterns              6
658
#define R_GE_capability_clippingPaths         7
659
#define R_GE_capability_masks                 8
660
#define R_GE_capability_compositing           9
661
#define R_GE_capability_transformations      10
662
#define R_GE_capability_paths                11 
83684 murrell 663
#define R_GE_capability_glyphs               12 
88293 murrell 664
#define R_GE_capability_variableFonts        13 
81278 murrell 665
 
83684 murrell 666
/* Must match order in ../library/grDevices/R/glyph.R */
667
#define R_GE_text_style_normal  1
668
#define R_GE_text_style_italic  2
669
#define R_GE_text_style_oblique 3
670
 
671
SEXP R_GE_glyphInfoGlyphs(SEXP glyphInfo);
672
SEXP R_GE_glyphInfoFonts(SEXP glyphInfo);
673
 
674
SEXP R_GE_glyphID(SEXP glyphs);
675
SEXP R_GE_glyphX(SEXP glyphs);
676
SEXP R_GE_glyphY(SEXP glyphs);
677
SEXP R_GE_glyphFont(SEXP glyphs);
678
SEXP R_GE_glyphSize(SEXP glyphs);
679
SEXP R_GE_glyphColour(SEXP glyphs);
86937 murrell 680
SEXP R_GE_glyphRotation(SEXP glyphs);
681
Rboolean R_GE_hasGlyphRotation(SEXP glyphs);
83684 murrell 682
 
83689 ripley 683
const char* R_GE_glyphFontFile(SEXP glyphFont);
83684 murrell 684
int R_GE_glyphFontIndex(SEXP glyphFont);
83689 ripley 685
const char* R_GE_glyphFontFamily(SEXP glyphFont);
83684 murrell 686
double R_GE_glyphFontWeight(SEXP glyphFont);
687
int R_GE_glyphFontStyle(SEXP glyphFont);
83689 ripley 688
const char* R_GE_glyphFontPSname(SEXP glyphFont);
88293 murrell 689
int R_GE_glyphFontNumVar(SEXP glyphFont);
690
const char* R_GE_glyphFontVarAxis(SEXP glyphFont, int index);
691
double R_GE_glyphFontVarValue(SEXP glyphFont, int index);
692
const char* R_GE_glyphFontVarFormatted(SEXP glyphFont, int index);
83684 murrell 693
 
694
void GEGlyph(int n, int *glyphs, double *x, double *y, 
695
             SEXP font, double size, 
696
             int colour, double rot, pGEDevDesc dd);
697
 
34747 ripley 698
#ifdef __cplusplus
699
}
700
#endif
701
 
702
#endif /* R_GRAPHICSENGINE_ */