The R Project SVN R

Rev

Rev 59039 | Rev 63721 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11506 ripley 1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1995, 1996  Robert Gentleman and Ross Ihaka
59039 ripley 4
 *  Copyright (C) 1998--2008  R Core Team
11506 ripley 5
 *
6
 *  This program is free software; you can redistribute it and/or modify
12778 pd 7
 *  it under the terms of the GNU Lesser General Public License as published by
8
 *  the Free Software Foundation; either version 2.1 of the License, or
11506 ripley 9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12778 pd 14
 *  GNU Lesser General Public License for more details.
11506 ripley 15
 *
12778 pd 16
 *  You should have received a copy of the GNU Lesser General Public License
42308 ripley 17
 *  along with this program; if not, a copy is available at
18
 *  http://www.r-project.org/Licenses/
11506 ripley 19
 */
20
 
11509 ripley 21
#ifndef RGRAPHICS_H_
22
#define RGRAPHICS_H_
11506 ripley 23
 
45051 ripley 24
/* This was a public header in R < 2.8.0, but no longer */
44154 ripley 25
 
11506 ripley 26
#ifdef  __cplusplus
27
extern "C" {
28
#endif
29
 
30
	/* possible coordinate systems (for specifying locations) */
31
typedef enum {
32
 DEVICE	= 0,	/* native device coordinates (rasters) */
33
 NDC	= 1,	/* normalised device coordinates x=(0,1), y=(0,1) */
34
 INCHES = 13,	/* inches x=(0,width), y=(0,height) */
35
 NIC	= 6,	/* normalised inner region coordinates (0,1) */
36
 OMA1	= 2,	/* outer margin 1 (bottom) x=NIC, y=LINES */
37
 OMA2	= 3,	/* outer margin 2 (left) */
38
 OMA3	= 4,	/* outer margin 3 (top) */
39
 OMA4	= 5,	/* outer margin 4 (right) */
40
 NFC	= 7,	/* normalised figure region coordinates (0,1) */
41
 NPC	= 16,	/* normalised plot region coordinates (0,1) */
11510 ripley 42
 USER	= 12,	/* user/data/world coordinates;
11506 ripley 43
		 * x,=(xmin,xmax), y=(ymin,ymax) */
44
 MAR1	= 8,	/* figure margin 1 (bottom) x=USER(x), y=LINES */
45
 MAR2	= 9,	/* figure margin 2 (left)   x=USER(y), y=LINES */
46
 MAR3	= 10,	/* figure margin 3 (top)    x=USER(x), y=LINES */
47
 MAR4	= 11,	/* figure margin 4 (right)  x=USER(y), y=LINES */
48
 
49
	/* possible, units (for specifying dimensions) */
50
	/* all of the above, plus ... */
51
 
52
 LINES = 14,	/* multiples of a line in the margin (mex) */
53
 CHARS = 15	/* multiples of text height (cex) */
54
} GUnit;
55
 
56
 
57
#define currentFigureLocation	Rf_currentFigureLocation
58
#define GArrow			Rf_GArrow
59
#define GBox			Rf_GBox
60
#define GCheckState		Rf_GCheckState
61
#define GCircle			Rf_GCircle
62
#define GClip			Rf_GClip
63
#define GClipPolygon		Rf_GClipPolygon
64
#define GConvert		Rf_GConvert
65
#define GConvertX		Rf_GConvertX
66
#define GConvertXUnits		Rf_GConvertXUnits
67
#define GConvertY		Rf_GConvertY
68
#define GConvertYUnits		Rf_GConvertYUnits
69
#define GExpressionHeight	Rf_GExpressionHeight
70
#define GExpressionWidth	Rf_GExpressionWidth
71
#define GForceClip		Rf_GForceClip
72
#define GLine			Rf_GLine
73
#define GLocator		Rf_GLocator
74
#define GMapUnits		Rf_GMapUnits
75
#define GMapWin2Fig		Rf_GMapWin2Fig
76
#define GMathText		Rf_GMathText
77
#define GMetricInfo		Rf_GMetricInfo
78
#define GMMathText		Rf_GMMathText
79
#define GMode			Rf_GMode
80
#define GMtext			Rf_GMtext
81
#define GNewPlot		Rf_GNewPlot
52406 murrell 82
#define GPath   		Rf_GPath
11506 ripley 83
#define GPolygon		Rf_GPolygon
84
#define GPolyline		Rf_GPolyline
85
#define GPretty			Rf_GPretty
86
#define GRect			Rf_GRect
51121 murrell 87
#define GRaster			Rf_GRaster
11506 ripley 88
#define GReset			Rf_GReset
89
#define GRestore		Rf_GRestore
90
#define GRestorePars		Rf_GRestorePars
91
#define GSavePars		Rf_GSavePars
92
#define GScale			Rf_GScale
93
#define GSetState		Rf_GSetState
94
#define GSetupAxis		Rf_GSetupAxis
95
#define GStrHeight		Rf_GStrHeight
96
#define GStrWidth		Rf_GStrWidth
97
#define GSymbol			Rf_GSymbol
98
#define GText			Rf_GText
99
#define GVStrHeight		Rf_GVStrHeight
100
#define GVStrWidth		Rf_GVStrWidth
101
#define GVText			Rf_GVText
44369 ripley 102
 
11506 ripley 103
#define xDevtoNDC		Rf_xDevtoNDC
104
#define xDevtoNFC		Rf_xDevtoNFC
105
#define xDevtoNPC		Rf_xDevtoNPC
106
#define xDevtoUsr		Rf_xDevtoUsr
107
#define xNPCtoUsr		Rf_xNPCtoUsr
108
#define yDevtoNDC		Rf_yDevtoNDC
109
#define yDevtoNFC		Rf_yDevtoNFC
110
#define yDevtoNPC		Rf_yDevtoNPC
111
#define yDevtoUsr		Rf_yDevtoUsr
112
#define yNPCtoUsr		Rf_yNPCtoUsr
113
 
114
 
115
/*-------------------------------------------------------------------
116
 *
117
 *  GPAR FUNCTIONS are concerned with operations on the
118
 *  entire set of graphics parameters for a device
119
 *  (e.g., initialisation, saving, and restoring)
44154 ripley 120
 *
121
 *  From graphics.c, used in plot.c.
11506 ripley 122
 */
123
 
124
/* Reset the current graphical parameters from the default ones: */
45051 ripley 125
void GRestore(pGEDevDesc);
11506 ripley 126
/* Make a temporary copy of the current parameters */
45051 ripley 127
void GSavePars(pGEDevDesc);
11506 ripley 128
/* Restore the temporary copy saved by GSavePars */
45051 ripley 129
void GRestorePars(pGEDevDesc);
11506 ripley 130
 
131
 
132
/*-------------------------------------------------------------------
133
 *
134
 *  DEVICE STATE FUNCTIONS are concerned with getting and setting
135
 *  the current state of the device;  is it ready to be drawn into?
44154 ripley 136
 *
137
 *  From graphics.c, used in plot.c.
11506 ripley 138
 */
139
 
140
/* has plot.new been called yet? */
45051 ripley 141
void GCheckState(pGEDevDesc);
11506 ripley 142
/* Set to 1 when plot.new succeeds
143
 * Set to 0 when don't want drawing to go ahead */
45051 ripley 144
void GSetState(int, pGEDevDesc);
11506 ripley 145
 
146
 
147
 
148
/*-------------------------------------------------------------------
149
 *
150
 *  GRAPHICAL PRIMITIVES are the generic front-end for the functions
151
 *  that every device driver must provide.
152
 *
153
 *  NOTE that locations supplied to these functions may be in any
154
 *  of the valid coordinate systems (each function takes a "coords"
155
 *  parameter to indicate the coordinate system);  the device-specific
156
 *  version of the function is responsible for calling GConvert to get
157
 *  the location into device coordinates.
158
 *
44154 ripley 159
 *  From graphics.c, used in plot.c.
11506 ripley 160
 */
161
 
162
 
163
/* Draw a circle, centred on (x,y) with radius r (in inches). */
45051 ripley 164
void GCircle(double, double, int, double, int, int, pGEDevDesc);
11506 ripley 165
/* Set clipping region (based on current setting of dd->gp.xpd).
166
 * Only clip if new clipping region is different from the current one */
45051 ripley 167
void GClip(pGEDevDesc);
11506 ripley 168
/* Polygon clipping: */
169
int GClipPolygon(double *, double *, int, int, int,
45051 ripley 170
		 double *, double *, pGEDevDesc);
11506 ripley 171
/* Always clips */
45051 ripley 172
void GForceClip(pGEDevDesc);
11506 ripley 173
/* Draw a line from (x1,y1) to (x2,y2): */
45051 ripley 174
void GLine(double, double, double, double, int, pGEDevDesc);
11506 ripley 175
/* Return the location of the next mouse click: */
45051 ripley 176
Rboolean GLocator(double*, double*, int, pGEDevDesc);
11506 ripley 177
/* Return the height, depth, and width of the specified
178
 * character in the specified units: */
45051 ripley 179
void GMetricInfo(int, double*, double*, double*, GUnit, pGEDevDesc);
11506 ripley 180
/* Set device "mode" (drawing or not drawing) here for windows and mac drivers.
181
 */
45051 ripley 182
void GMode(int, pGEDevDesc);
52406 murrell 183
/* Draw a path using the specified lists of x and y values: */
184
void GPath(double*, double*, int, int*, Rboolean, int, int, pGEDevDesc);
11506 ripley 185
/* Draw a polygon using the specified lists of x and y values: */
45051 ripley 186
void GPolygon(int, double*, double*, int, int, int, pGEDevDesc);
11506 ripley 187
/* Draw series of straight lines using the specified lists of x and y values: */
45051 ripley 188
void GPolyline(int, double*, double*, int, pGEDevDesc);
11506 ripley 189
/* Draw a rectangle given two opposite corners: */
45051 ripley 190
void GRect(double, double, double, double, int, int, int, pGEDevDesc);
51121 murrell 191
/* Draw a raster image given two opposite corners: */
192
void GRaster(unsigned int*, int, int,
57123 maechler 193
             double, double, double, double,
51121 murrell 194
             double, Rboolean, pGEDevDesc);
11506 ripley 195
/* Return the height of the specified string in the specified units: */
45051 ripley 196
double GStrHeight(const char *, cetype_t, GUnit, pGEDevDesc);
11506 ripley 197
/* Return the width of the specified string in the specified units */
45051 ripley 198
double GStrWidth(const char *, cetype_t, GUnit, pGEDevDesc);
11506 ripley 199
/* Draw the specified text at location (x,y) with the specified
200
 * rotation and justification: */
44986 ripley 201
void GText(double, double, int, const char *, cetype_t, double, double, double,
45051 ripley 202
	   pGEDevDesc);
11506 ripley 203
 
44154 ripley 204
/* From plotmath.c, used in plot.c */
45051 ripley 205
void GMathText(double, double, int, SEXP, double, double, double, pGEDevDesc);
206
void GMMathText(SEXP, int, double, int, double, int, double, pGEDevDesc);
11506 ripley 207
 
14945 duncan 208
 
11506 ripley 209
/*-------------------------------------------------------------------
210
 *
211
 *  GRAPHICAL UTILITIES are functions that produce graphical output
212
 *  using the graphical primitives (i.e., they are generic - NOT
213
 *  device-specific).
214
 *
44154 ripley 215
 *  From graphics.c, used in plot.c.
11506 ripley 216
 */
217
 
218
/* Draw a line from (x1,y1) to (x2,y2) with an arrow head
219
 * at either or both ends. */
45051 ripley 220
void GArrow(double, double, double, double, int, double, double, int, pGEDevDesc);
11506 ripley 221
/* Draw a box around specified region:
222
 *  1=plot region, 2=figure region, 3=inner region, 4=device. */
45051 ripley 223
void GBox(int, pGEDevDesc);
11506 ripley 224
/* Return a "nice" min, max and number of intervals for a given
225
 * range on a linear or _log_ scale, respectively: */
44154 ripley 226
void GPretty(double*, double*, int*); /* used in plot3d.c */
11506 ripley 227
/* Draw text in margins. */
45051 ripley 228
void GMtext(const char *, cetype_t, int, double, int, double, int, double, pGEDevDesc);
11506 ripley 229
/* Draw one of the predefined symbols (circle, square, diamond, ...) */
45051 ripley 230
void GSymbol(double, double, int, int, pGEDevDesc);
11506 ripley 231
 
44154 ripley 232
/* From plotmath.c, used in plot.c */
45051 ripley 233
double GExpressionHeight(SEXP, GUnit, pGEDevDesc);
234
double GExpressionWidth(SEXP, GUnit, pGEDevDesc);
11506 ripley 235
 
236
 
237
 
238
/*----------------------------------------------------------------------
239
 *
240
 *  TRANSFORMATIONS are concerned with converting locations between
241
 *  coordinate systems and dimensions between different units.
44154 ripley 242
 *
44309 ripley 243
 *  From graphics.c, used in par.c, plot.c, plot3d.c
11506 ripley 244
 */
245
 
246
/* Convert an R unit (e.g., "user") into an internal unit (e.g., USER)> */
247
GUnit GMapUnits(int);
248
/* Convert a LOCATION from one coordinate system to another: */
45051 ripley 249
void GConvert(double*, double*, GUnit, GUnit, pGEDevDesc);
250
double GConvertX(double, GUnit, GUnit, pGEDevDesc);
251
double GConvertY(double, GUnit, GUnit, pGEDevDesc);
11506 ripley 252
/* Convert an x/y-dimension from one set of units to another: */
45051 ripley 253
double GConvertXUnits(double, GUnit, GUnit, pGEDevDesc);
254
double GConvertYUnits(double, GUnit, GUnit, pGEDevDesc);
11506 ripley 255
 
256
/* Set up the different regions on a device (i.e., inner region,
257
 * figure region, plot region) and transformations for associated
258
 * coordinate systems (called whenever anything that affects the
259
 * coordinate transformations changes):
260
 */
45051 ripley 261
void GReset(pGEDevDesc);
11506 ripley 262
 
263
/* Set up the user coordinate transformations: */
45051 ripley 264
void GMapWin2Fig(pGEDevDesc);
11506 ripley 265
/* Set up the device for a new plot by Resetting graphics parameters
266
 * and Resetting the regions and coordinate Systems */
45051 ripley 267
pGEDevDesc GNewPlot(Rboolean);
11506 ripley 268
/* Set up the user coordinates based on the axis limits */
45051 ripley 269
void GScale(double, double, int, pGEDevDesc);
11506 ripley 270
/* Set up the axis limits based on the user coordinates */
45051 ripley 271
void GSetupAxis(int, pGEDevDesc);
11506 ripley 272
/* Return row and column of current figure in the layout matrix */
45051 ripley 273
void currentFigureLocation(int*, int*, pGEDevDesc);
11506 ripley 274
 
275
/* which of these conversions should be public? maybe all? [NO_REMAP] */
45051 ripley 276
double xDevtoNDC(double, pGEDevDesc);
277
double yDevtoNDC(double, pGEDevDesc);
278
double xDevtoNFC(double, pGEDevDesc);
279
double yDevtoNFC(double, pGEDevDesc);
280
double xDevtoNPC(double, pGEDevDesc);
281
double yDevtoNPC(double, pGEDevDesc);
282
double xDevtoUsr(double, pGEDevDesc);
283
double yDevtoUsr(double, pGEDevDesc);
284
double xNPCtoUsr(double, pGEDevDesc);
285
double yNPCtoUsr(double, pGEDevDesc);
11506 ripley 286
 
287
#ifdef  __cplusplus
288
}
289
#endif
290
 
11509 ripley 291
#endif /* RGRAPHICS_H_ */