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