| Line 19... |
Line 19... |
| 19 |
*/
|
19 |
*/
|
| 20 |
|
20 |
|
| 21 |
#ifndef RGRAPHICS_H_
|
21 |
#ifndef RGRAPHICS_H_
|
| 22 |
#define RGRAPHICS_H_
|
22 |
#define RGRAPHICS_H_
|
| 23 |
|
23 |
|
| 24 |
/* This is a public header */
|
24 |
/* This was a public header in R < 2.8.0, but no longer */
|
| 25 |
|
25 |
|
| 26 |
#ifdef __cplusplus
|
26 |
#ifdef __cplusplus
|
| 27 |
extern "C" {
|
27 |
extern "C" {
|
| 28 |
#endif
|
28 |
#endif
|
| 29 |
|
29 |
|
| 30 |
/* Color handling is in colors.c: at least R_OPAQUE and R_ALPHA are
|
- |
|
| 31 |
used by devices.
|
- |
|
| 32 |
|
- |
|
| 33 |
Line textures are in engine.c, used in graphics.c, plot3d.c,
|
- |
|
| 34 |
plotmath.c and in devices.
|
- |
|
| 35 |
*/
|
- |
|
| 36 |
|
- |
|
| 37 |
/* possible coordinate systems (for specifying locations) */
|
30 |
/* possible coordinate systems (for specifying locations) */
|
| 38 |
typedef enum {
|
31 |
typedef enum {
|
| 39 |
DEVICE = 0, /* native device coordinates (rasters) */
|
32 |
DEVICE = 0, /* native device coordinates (rasters) */
|
| 40 |
NDC = 1, /* normalised device coordinates x=(0,1), y=(0,1) */
|
33 |
NDC = 1, /* normalised device coordinates x=(0,1), y=(0,1) */
|
| 41 |
INCHES = 13, /* inches x=(0,width), y=(0,height) */
|
34 |
INCHES = 13, /* inches x=(0,width), y=(0,height) */
|
| Line 59... |
Line 52... |
| 59 |
LINES = 14, /* multiples of a line in the margin (mex) */
|
52 |
LINES = 14, /* multiples of a line in the margin (mex) */
|
| 60 |
CHARS = 15 /* multiples of text height (cex) */
|
53 |
CHARS = 15 /* multiples of text height (cex) */
|
| 61 |
} GUnit;
|
54 |
} GUnit;
|
| 62 |
|
55 |
|
| 63 |
|
56 |
|
| 64 |
#ifdef R_GRAPHICS
|
- |
|
| 65 |
/* Foe use inside R: point to the real structure */
|
- |
|
| 66 |
# define pGEDev pGEDevDesc
|
- |
|
| 67 |
# define DevDesc GEDevDesc
|
- |
|
| 68 |
#else
|
- |
|
| 69 |
/* Use opaque structure for back compatibility */
|
- |
|
| 70 |
typedef struct {
|
- |
|
| 71 |
/* opaque structure */
|
- |
|
| 72 |
int dummy;
|
- |
|
| 73 |
} DevDesc;
|
- |
|
| 74 |
typedef DevDesc * pGEDev;
|
- |
|
| 75 |
#endif
|
- |
|
| 76 |
|
- |
|
| 77 |
#define CreateAtVector Rf_CreateAtVector
|
- |
|
| 78 |
#define CurrentDevice Rf_CurrentDevice
|
- |
|
| 79 |
#define currentFigureLocation Rf_currentFigureLocation
|
57 |
#define currentFigureLocation Rf_currentFigureLocation
|
| 80 |
#define GArrow Rf_GArrow
|
58 |
#define GArrow Rf_GArrow
|
| 81 |
#define GBox Rf_GBox
|
59 |
#define GBox Rf_GBox
|
| 82 |
#define GCheckState Rf_GCheckState
|
60 |
#define GCheckState Rf_GCheckState
|
| 83 |
#define GCircle Rf_GCircle
|
61 |
#define GCircle Rf_GCircle
|
| Line 131... |
Line 109... |
| 131 |
#define yDevtoNPC Rf_yDevtoNPC
|
109 |
#define yDevtoNPC Rf_yDevtoNPC
|
| 132 |
#define yDevtoUsr Rf_yDevtoUsr
|
110 |
#define yDevtoUsr Rf_yDevtoUsr
|
| 133 |
#define yNPCtoUsr Rf_yNPCtoUsr
|
111 |
#define yNPCtoUsr Rf_yNPCtoUsr
|
| 134 |
|
112 |
|
| 135 |
|
113 |
|
| 136 |
/* User Callable Functions */
|
- |
|
| 137 |
|
- |
|
| 138 |
|
- |
|
| 139 |
/*-------------------------------------------------------------------
|
114 |
/*-------------------------------------------------------------------
|
| 140 |
*
|
115 |
*
|
| 141 |
* GPAR FUNCTIONS are concerned with operations on the
|
116 |
* GPAR FUNCTIONS are concerned with operations on the
|
| 142 |
* entire set of graphics parameters for a device
|
117 |
* entire set of graphics parameters for a device
|
| 143 |
* (e.g., initialisation, saving, and restoring)
|
118 |
* (e.g., initialisation, saving, and restoring)
|
| 144 |
*
|
119 |
*
|
| 145 |
* From graphics.c, used in plot.c.
|
120 |
* From graphics.c, used in plot.c.
|
| 146 |
*/
|
121 |
*/
|
| 147 |
|
122 |
|
| 148 |
/* Reset the current graphical parameters from the default ones: */
|
123 |
/* Reset the current graphical parameters from the default ones: */
|
| 149 |
void GRestore(pGEDev);
|
124 |
void GRestore(pGEDevDesc);
|
| 150 |
/* Make a temporary copy of the current parameters */
|
125 |
/* Make a temporary copy of the current parameters */
|
| 151 |
void GSavePars(pGEDev);
|
126 |
void GSavePars(pGEDevDesc);
|
| 152 |
/* Restore the temporary copy saved by GSavePars */
|
127 |
/* Restore the temporary copy saved by GSavePars */
|
| 153 |
void GRestorePars(pGEDev);
|
128 |
void GRestorePars(pGEDevDesc);
|
| 154 |
|
129 |
|
| 155 |
|
130 |
|
| 156 |
/*-------------------------------------------------------------------
|
131 |
/*-------------------------------------------------------------------
|
| 157 |
*
|
132 |
*
|
| 158 |
* DEVICE STATE FUNCTIONS are concerned with getting and setting
|
133 |
* DEVICE STATE FUNCTIONS are concerned with getting and setting
|
| Line 160... |
Line 135... |
| 160 |
*
|
135 |
*
|
| 161 |
* From graphics.c, used in plot.c.
|
136 |
* From graphics.c, used in plot.c.
|
| 162 |
*/
|
137 |
*/
|
| 163 |
|
138 |
|
| 164 |
/* has plot.new been called yet? */
|
139 |
/* has plot.new been called yet? */
|
| 165 |
void GCheckState(pGEDev);
|
140 |
void GCheckState(pGEDevDesc);
|
| 166 |
/* Set to 1 when plot.new succeeds
|
141 |
/* Set to 1 when plot.new succeeds
|
| 167 |
* Set to 0 when don't want drawing to go ahead */
|
142 |
* Set to 0 when don't want drawing to go ahead */
|
| 168 |
void GSetState(int, pGEDev);
|
143 |
void GSetState(int, pGEDevDesc);
|
| 169 |
|
144 |
|
| 170 |
|
145 |
|
| 171 |
|
146 |
|
| 172 |
/*-------------------------------------------------------------------
|
147 |
/*-------------------------------------------------------------------
|
| 173 |
*
|
148 |
*
|
| Line 183... |
Line 158... |
| 183 |
* From graphics.c, used in plot.c.
|
158 |
* From graphics.c, used in plot.c.
|
| 184 |
*/
|
159 |
*/
|
| 185 |
|
160 |
|
| 186 |
|
161 |
|
| 187 |
/* Draw a circle, centred on (x,y) with radius r (in inches). */
|
162 |
/* Draw a circle, centred on (x,y) with radius r (in inches). */
|
| 188 |
void GCircle(double, double, int, double, int, int, pGEDev);
|
163 |
void GCircle(double, double, int, double, int, int, pGEDevDesc);
|
| 189 |
/* Set clipping region (based on current setting of dd->gp.xpd).
|
164 |
/* Set clipping region (based on current setting of dd->gp.xpd).
|
| 190 |
* Only clip if new clipping region is different from the current one */
|
165 |
* Only clip if new clipping region is different from the current one */
|
| 191 |
void GClip(pGEDev);
|
166 |
void GClip(pGEDevDesc);
|
| 192 |
/* Polygon clipping: */
|
167 |
/* Polygon clipping: */
|
| 193 |
int GClipPolygon(double *, double *, int, int, int,
|
168 |
int GClipPolygon(double *, double *, int, int, int,
|
| 194 |
double *, double *, pGEDev);
|
169 |
double *, double *, pGEDevDesc);
|
| 195 |
/* Always clips */
|
170 |
/* Always clips */
|
| 196 |
void GForceClip(pGEDev);
|
171 |
void GForceClip(pGEDevDesc);
|
| 197 |
/* Draw a line from (x1,y1) to (x2,y2): */
|
172 |
/* Draw a line from (x1,y1) to (x2,y2): */
|
| 198 |
void GLine(double, double, double, double, int, pGEDev);
|
173 |
void GLine(double, double, double, double, int, pGEDevDesc);
|
| 199 |
/* Return the location of the next mouse click: */
|
174 |
/* Return the location of the next mouse click: */
|
| 200 |
Rboolean GLocator(double*, double*, int, pGEDev);
|
175 |
Rboolean GLocator(double*, double*, int, pGEDevDesc);
|
| 201 |
/* Return the height, depth, and width of the specified
|
176 |
/* Return the height, depth, and width of the specified
|
| 202 |
* character in the specified units: */
|
177 |
* character in the specified units: */
|
| 203 |
void GMetricInfo(int, double*, double*, double*, GUnit, pGEDev);
|
178 |
void GMetricInfo(int, double*, double*, double*, GUnit, pGEDevDesc);
|
| 204 |
/* Set device "mode" (drawing or not drawing) here for windows and mac drivers.
|
179 |
/* Set device "mode" (drawing or not drawing) here for windows and mac drivers.
|
| 205 |
*/
|
180 |
*/
|
| 206 |
void GMode(int, pGEDev);
|
181 |
void GMode(int, pGEDevDesc);
|
| 207 |
/* Draw a polygon using the specified lists of x and y values: */
|
182 |
/* Draw a polygon using the specified lists of x and y values: */
|
| 208 |
void GPolygon(int, double*, double*, int, int, int, pGEDev);
|
183 |
void GPolygon(int, double*, double*, int, int, int, pGEDevDesc);
|
| 209 |
/* Draw series of straight lines using the specified lists of x and y values: */
|
184 |
/* Draw series of straight lines using the specified lists of x and y values: */
|
| 210 |
void GPolyline(int, double*, double*, int, pGEDev);
|
185 |
void GPolyline(int, double*, double*, int, pGEDevDesc);
|
| 211 |
/* Draw a rectangle given two opposite corners: */
|
186 |
/* Draw a rectangle given two opposite corners: */
|
| 212 |
void GRect(double, double, double, double, int, int, int, pGEDev);
|
187 |
void GRect(double, double, double, double, int, int, int, pGEDevDesc);
|
| 213 |
/* Return the height of the specified string in the specified units: */
|
188 |
/* Return the height of the specified string in the specified units: */
|
| 214 |
double GStrHeight(const char *, cetype_t, GUnit, pGEDev);
|
189 |
double GStrHeight(const char *, cetype_t, GUnit, pGEDevDesc);
|
| 215 |
/* Return the width of the specified string in the specified units */
|
190 |
/* Return the width of the specified string in the specified units */
|
| 216 |
double GStrWidth(const char *, cetype_t, GUnit, pGEDev);
|
191 |
double GStrWidth(const char *, cetype_t, GUnit, pGEDevDesc);
|
| 217 |
/* Draw the specified text at location (x,y) with the specified
|
192 |
/* Draw the specified text at location (x,y) with the specified
|
| 218 |
* rotation and justification: */
|
193 |
* rotation and justification: */
|
| 219 |
void GText(double, double, int, const char *, cetype_t, double, double, double,
|
194 |
void GText(double, double, int, const char *, cetype_t, double, double, double,
|
| 220 |
pGEDev);
|
195 |
pGEDevDesc);
|
| 221 |
|
- |
|
| 222 |
/* No longer exist
|
- |
|
| 223 |
void GStartPath(pGEDev);
|
- |
|
| 224 |
void GEndPath(pGEDev);
|
- |
|
| 225 |
*/
|
- |
|
| 226 |
|
196 |
|
| 227 |
/* From plotmath.c, used in plot.c */
|
197 |
/* From plotmath.c, used in plot.c */
|
| 228 |
void GMathText(double, double, int, SEXP, double, double, double, pGEDev);
|
198 |
void GMathText(double, double, int, SEXP, double, double, double, pGEDevDesc);
|
| 229 |
void GMMathText(SEXP, int, double, int, double, int, double, pGEDev);
|
199 |
void GMMathText(SEXP, int, double, int, double, int, double, pGEDevDesc);
|
| 230 |
|
200 |
|
| 231 |
|
201 |
|
| 232 |
/*-------------------------------------------------------------------
|
202 |
/*-------------------------------------------------------------------
|
| 233 |
*
|
203 |
*
|
| 234 |
* GRAPHICAL UTILITIES are functions that produce graphical output
|
204 |
* GRAPHICAL UTILITIES are functions that produce graphical output
|
| Line 238... |
Line 208... |
| 238 |
* From graphics.c, used in plot.c.
|
208 |
* From graphics.c, used in plot.c.
|
| 239 |
*/
|
209 |
*/
|
| 240 |
|
210 |
|
| 241 |
/* Draw a line from (x1,y1) to (x2,y2) with an arrow head
|
211 |
/* Draw a line from (x1,y1) to (x2,y2) with an arrow head
|
| 242 |
* at either or both ends. */
|
212 |
* at either or both ends. */
|
| 243 |
void GArrow(double, double, double, double, int, double, double, int, pGEDev);
|
213 |
void GArrow(double, double, double, double, int, double, double, int, pGEDevDesc);
|
| 244 |
/* Draw a box around specified region:
|
214 |
/* Draw a box around specified region:
|
| 245 |
* 1=plot region, 2=figure region, 3=inner region, 4=device. */
|
215 |
* 1=plot region, 2=figure region, 3=inner region, 4=device. */
|
| 246 |
void GBox(int, pGEDev);
|
216 |
void GBox(int, pGEDevDesc);
|
| 247 |
/* Return a "nice" min, max and number of intervals for a given
|
217 |
/* Return a "nice" min, max and number of intervals for a given
|
| 248 |
* range on a linear or _log_ scale, respectively: */
|
218 |
* range on a linear or _log_ scale, respectively: */
|
| 249 |
void GPretty(double*, double*, int*); /* used in plot3d.c */
|
219 |
void GPretty(double*, double*, int*); /* used in plot3d.c */
|
| 250 |
void GLPretty(double*, double*, int*);
|
220 |
void GLPretty(double*, double*, int*);
|
| 251 |
/* Draw text in margins. */
|
221 |
/* Draw text in margins. */
|
| 252 |
void GMtext(const char *, cetype_t, int, double, int, double, int, double, pGEDev);
|
222 |
void GMtext(const char *, cetype_t, int, double, int, double, int, double, pGEDevDesc);
|
| 253 |
/* Draw one of the predefined symbols (circle, square, diamond, ...) */
|
223 |
/* Draw one of the predefined symbols (circle, square, diamond, ...) */
|
| 254 |
void GSymbol(double, double, int, int, pGEDev);
|
224 |
void GSymbol(double, double, int, int, pGEDevDesc);
|
| 255 |
|
225 |
|
| 256 |
/* From plotmath.c, used in plot.c */
|
226 |
/* From plotmath.c, used in plot.c */
|
| 257 |
double GExpressionHeight(SEXP, GUnit, pGEDev);
|
227 |
double GExpressionHeight(SEXP, GUnit, pGEDevDesc);
|
| 258 |
double GExpressionWidth(SEXP, GUnit, pGEDev);
|
228 |
double GExpressionWidth(SEXP, GUnit, pGEDevDesc);
|
| 259 |
|
229 |
|
| 260 |
|
230 |
|
| 261 |
|
231 |
|
| 262 |
/*----------------------------------------------------------------------
|
232 |
/*----------------------------------------------------------------------
|
| 263 |
*
|
233 |
*
|
| Line 268... |
Line 238... |
| 268 |
*/
|
238 |
*/
|
| 269 |
|
239 |
|
| 270 |
/* Convert an R unit (e.g., "user") into an internal unit (e.g., USER)> */
|
240 |
/* Convert an R unit (e.g., "user") into an internal unit (e.g., USER)> */
|
| 271 |
GUnit GMapUnits(int);
|
241 |
GUnit GMapUnits(int);
|
| 272 |
/* Convert a LOCATION from one coordinate system to another: */
|
242 |
/* Convert a LOCATION from one coordinate system to another: */
|
| 273 |
void GConvert(double*, double*, GUnit, GUnit, pGEDev);
|
243 |
void GConvert(double*, double*, GUnit, GUnit, pGEDevDesc);
|
| 274 |
double GConvertX(double, GUnit, GUnit, pGEDev);
|
244 |
double GConvertX(double, GUnit, GUnit, pGEDevDesc);
|
| 275 |
double GConvertY(double, GUnit, GUnit, pGEDev);
|
245 |
double GConvertY(double, GUnit, GUnit, pGEDevDesc);
|
| 276 |
/* Convert an x/y-dimension from one set of units to another: */
|
246 |
/* Convert an x/y-dimension from one set of units to another: */
|
| 277 |
double GConvertXUnits(double, GUnit, GUnit, pGEDev);
|
247 |
double GConvertXUnits(double, GUnit, GUnit, pGEDevDesc);
|
| 278 |
double GConvertYUnits(double, GUnit, GUnit, pGEDev);
|
248 |
double GConvertYUnits(double, GUnit, GUnit, pGEDevDesc);
|
| 279 |
|
249 |
|
| 280 |
/* Set up the different regions on a device (i.e., inner region,
|
250 |
/* Set up the different regions on a device (i.e., inner region,
|
| 281 |
* figure region, plot region) and transformations for associated
|
251 |
* figure region, plot region) and transformations for associated
|
| 282 |
* coordinate systems (called whenever anything that affects the
|
252 |
* coordinate systems (called whenever anything that affects the
|
| 283 |
* coordinate transformations changes):
|
253 |
* coordinate transformations changes):
|
| 284 |
*/
|
254 |
*/
|
| 285 |
void GReset(pGEDev);
|
255 |
void GReset(pGEDevDesc);
|
| 286 |
|
256 |
|
| 287 |
/* Set up the user coordinate transformations: */
|
257 |
/* Set up the user coordinate transformations: */
|
| 288 |
void GMapWin2Fig(pGEDev);
|
258 |
void GMapWin2Fig(pGEDevDesc);
|
| 289 |
/* Set up the device for a new plot by Resetting graphics parameters
|
259 |
/* Set up the device for a new plot by Resetting graphics parameters
|
| 290 |
* and Resetting the regions and coordinate Systems */
|
260 |
* and Resetting the regions and coordinate Systems */
|
| 291 |
pGEDev GNewPlot(Rboolean);
|
261 |
pGEDevDesc GNewPlot(Rboolean);
|
| 292 |
/* Set up the user coordinates based on the axis limits */
|
262 |
/* Set up the user coordinates based on the axis limits */
|
| 293 |
void GScale(double, double, int, pGEDev);
|
263 |
void GScale(double, double, int, pGEDevDesc);
|
| 294 |
/* Set up the axis limits based on the user coordinates */
|
264 |
/* Set up the axis limits based on the user coordinates */
|
| 295 |
void GSetupAxis(int, pGEDev);
|
265 |
void GSetupAxis(int, pGEDevDesc);
|
| 296 |
/* Return row and column of current figure in the layout matrix */
|
266 |
/* Return row and column of current figure in the layout matrix */
|
| 297 |
void currentFigureLocation(int*, int*, pGEDev);
|
267 |
void currentFigureLocation(int*, int*, pGEDevDesc);
|
| 298 |
|
268 |
|
| 299 |
/* which of these conversions should be public? maybe all? [NO_REMAP] */
|
269 |
/* which of these conversions should be public? maybe all? [NO_REMAP] */
|
| 300 |
double xDevtoNDC(double, pGEDev);
|
270 |
double xDevtoNDC(double, pGEDevDesc);
|
| 301 |
double yDevtoNDC(double, pGEDev);
|
271 |
double yDevtoNDC(double, pGEDevDesc);
|
| 302 |
double xDevtoNFC(double, pGEDev);
|
272 |
double xDevtoNFC(double, pGEDevDesc);
|
| 303 |
double yDevtoNFC(double, pGEDev);
|
273 |
double yDevtoNFC(double, pGEDevDesc);
|
| 304 |
double xDevtoNPC(double, pGEDev);
|
274 |
double xDevtoNPC(double, pGEDevDesc);
|
| 305 |
double yDevtoNPC(double, pGEDev);
|
275 |
double yDevtoNPC(double, pGEDevDesc);
|
| 306 |
double xDevtoUsr(double, pGEDev);
|
276 |
double xDevtoUsr(double, pGEDevDesc);
|
| 307 |
double yDevtoUsr(double, pGEDev);
|
277 |
double yDevtoUsr(double, pGEDevDesc);
|
| 308 |
double xNPCtoUsr(double, pGEDev);
|
278 |
double xNPCtoUsr(double, pGEDevDesc);
|
| 309 |
double yNPCtoUsr(double, pGEDev);
|
279 |
double yNPCtoUsr(double, pGEDevDesc);
|
| 310 |
|
- |
|
| 311 |
|
- |
|
| 312 |
/* Devices: from devices.c */
|
- |
|
| 313 |
|
- |
|
| 314 |
/* Return a pointer to the current device. */
|
- |
|
| 315 |
pGEDev CurrentDevice(void); /* used in colors, graphics, par, plot, plot3d */
|
- |
|
| 316 |
|
- |
|
| 317 |
/* From plot.c, used by grid/src/grid.c */
|
- |
|
| 318 |
SEXP CreateAtVector(double*, double*, int, Rboolean);
|
- |
|
| 319 |
|
280 |
|
| 320 |
#ifdef __cplusplus
|
281 |
#ifdef __cplusplus
|
| 321 |
}
|
282 |
}
|
| 322 |
#endif
|
283 |
#endif
|
| 323 |
|
284 |
|