| 11507 |
ripley |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
|
|
3 |
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
|
| 59177 |
ripley |
4 |
* Copyright (C) 1998--2012 R Core Team
|
| 11507 |
ripley |
5 |
*
|
|
|
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
|
|
|
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
|
|
|
14 |
* GNU General Public License for more details.
|
|
|
15 |
*
|
|
|
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
|
|
|
18 |
* http://www.r-project.org/Licenses/
|
| 11507 |
ripley |
19 |
*/
|
|
|
20 |
|
|
|
21 |
#ifndef GRAPHICS_H_
|
|
|
22 |
#define GRAPHICS_H_
|
|
|
23 |
|
| 44142 |
ripley |
24 |
/* This is a private header */
|
|
|
25 |
|
| 11509 |
ripley |
26 |
#include <R_ext/Boolean.h>
|
| 11507 |
ripley |
27 |
|
| 30956 |
murrell |
28 |
#include <R_ext/GraphicsEngine.h>
|
| 44197 |
ripley |
29 |
/* needed for R_GE_lineend/join, R_GE_gcontext */
|
| 44312 |
ripley |
30 |
|
| 44348 |
ripley |
31 |
#define R_GRAPHICS 1
|
|
|
32 |
#include <Rgraphics.h> /* RUnit */
|
| 30956 |
murrell |
33 |
|
| 61351 |
ripley |
34 |
//typedef unsigned int rcolor;
|
| 44342 |
ripley |
35 |
|
| 44154 |
ripley |
36 |
/* base.c, graphics.c, par.c */
|
| 59084 |
maechler |
37 |
#define MAX_LAYOUT_ROWS 200
|
|
|
38 |
#define MAX_LAYOUT_COLS 200
|
|
|
39 |
#define MAX_LAYOUT_CELLS 10007 /* must be less than 65535,
|
| 32449 |
ripley |
40 |
3 copies, 3bytes each */
|
| 11507 |
ripley |
41 |
|
|
|
42 |
typedef struct {
|
|
|
43 |
double ax;
|
|
|
44 |
double bx;
|
|
|
45 |
double ay;
|
|
|
46 |
double by;
|
|
|
47 |
} GTrans;
|
|
|
48 |
|
|
|
49 |
typedef struct {
|
|
|
50 |
/* Plot State */
|
| 59084 |
maechler |
51 |
/*
|
| 44342 |
ripley |
52 |
When the device driver is started this is 0
|
|
|
53 |
After the first call to plot.new/perps it is 1
|
|
|
54 |
Every graphics operation except plot.new/persp
|
| 59084 |
maechler |
55 |
should fail if state = 0
|
| 44342 |
ripley |
56 |
This is checked at the highest internal function
|
| 59084 |
maechler |
57 |
level (e.g., do_lines, do_axis, do_plot_xy, ...)
|
| 44342 |
ripley |
58 |
*/
|
| 11507 |
ripley |
59 |
|
| 59084 |
maechler |
60 |
int state; /* plot state: 1 if GNewPlot has been called
|
| 44343 |
ripley |
61 |
(by plot.new or persp) */
|
|
|
62 |
Rboolean valid; /* valid layout ? Used in GCheckState & do_playDL */
|
| 11507 |
ripley |
63 |
|
|
|
64 |
/* GRZ-like Graphics Parameters */
|
|
|
65 |
/* ``The horror, the horror ... '' */
|
|
|
66 |
/* Marlon Brando - Appocalypse Now */
|
|
|
67 |
|
|
|
68 |
/* General Parameters -- set and interrogated directly */
|
|
|
69 |
|
|
|
70 |
double adj; /* String adjustment */
|
|
|
71 |
Rboolean ann; /* Should annotation take place */
|
|
|
72 |
rcolor bg; /* **R ONLY** Background color */
|
| 59177 |
ripley |
73 |
char bty; /* Box type */
|
| 11507 |
ripley |
74 |
double cex; /* Character expansion */
|
| 30956 |
murrell |
75 |
double lheight; /* Line height
|
|
|
76 |
The height of a line of text is:
|
|
|
77 |
ps * cex * lheight */
|
| 11507 |
ripley |
78 |
rcolor col; /* Plotting Color */
|
|
|
79 |
double crt; /* Character/string rotation */
|
|
|
80 |
double din[2]; /* device size in inches */
|
|
|
81 |
int err; /* Error repporting level */
|
|
|
82 |
rcolor fg; /* **R ONLY** Foreground Color */
|
| 59084 |
maechler |
83 |
char family[201]; /* **R ONLY** Font family
|
| 30956 |
murrell |
84 |
Simple name which is mapped by device-specific
|
|
|
85 |
font database to device-specific name.
|
|
|
86 |
Only used if not "".
|
|
|
87 |
Default is "".
|
|
|
88 |
Ignored by some devices. */
|
| 11507 |
ripley |
89 |
int font; /* Text font */
|
|
|
90 |
double gamma; /* Device Gamma Correction */
|
|
|
91 |
int lab[3]; /* Axis labelling */
|
|
|
92 |
/* [0] = # ticks on x-axis */
|
|
|
93 |
/* [1] = # ticks on y-axis */
|
|
|
94 |
/* [2] = length of axis labels */
|
|
|
95 |
int las; /* Label style (rotation) */
|
|
|
96 |
int lty; /* Line texture */
|
|
|
97 |
double lwd; /* Line width */
|
| 30956 |
murrell |
98 |
R_GE_lineend lend; /* **R ONLY** Line end style */
|
|
|
99 |
R_GE_linejoin ljoin;/* **R ONLY** Line join style */
|
|
|
100 |
double lmitre; /* **R ONLY** Line mitre limit */
|
| 11507 |
ripley |
101 |
double mgp[3]; /* Annotation location */
|
|
|
102 |
/* [0] = location of axis title */
|
|
|
103 |
/* [1] = location of axis label */
|
|
|
104 |
/* [2] = location of axis line */
|
|
|
105 |
double mkh; /* Mark size in inches */
|
|
|
106 |
int pch; /* Plotting character */
|
| 44343 |
ripley |
107 |
/* Note that ps is never changed, so always the same as dev->startps.
|
|
|
108 |
However, the ps in the graphics context is changed */
|
| 44645 |
ripley |
109 |
double ps; /* Text & symbol pointsize */
|
| 20446 |
maechler |
110 |
int smo; /* Curve smoothness */
|
| 11507 |
ripley |
111 |
double srt; /* String Rotation */
|
|
|
112 |
double tck; /* Tick size as in S */
|
|
|
113 |
double tcl; /* Tick size in "lines" */
|
|
|
114 |
double xaxp[3]; /* X Axis annotation */
|
|
|
115 |
/* [0] = coordinate of lower tick */
|
|
|
116 |
/* [1] = coordinate of upper tick */
|
|
|
117 |
/* [2] = num tick intervals */
|
|
|
118 |
/* almost always used internally */
|
| 59177 |
ripley |
119 |
char xaxs; /* X Axis style */
|
|
|
120 |
char xaxt; /* X Axis type */
|
| 44343 |
ripley |
121 |
Rboolean xlog; /* Log Axis for X */
|
| 11507 |
ripley |
122 |
int xpd; /* Clip to plot region indicator */
|
|
|
123 |
int oldxpd;
|
|
|
124 |
double yaxp[3]; /* Y Axis annotation */
|
| 59177 |
ripley |
125 |
char yaxs; /* Y Axis style */
|
|
|
126 |
char yaxt; /* Y Axis type */
|
| 11507 |
ripley |
127 |
Rboolean ylog; /* Log Axis for Y */
|
|
|
128 |
|
|
|
129 |
/* Annotation Parameters */
|
|
|
130 |
|
| 59177 |
ripley |
131 |
double cexbase; /* Base character size */
|
|
|
132 |
double cexmain; /* Main title size */
|
|
|
133 |
double cexlab; /* xlab and ylab size */
|
|
|
134 |
double cexsub; /* Sub title size */
|
|
|
135 |
double cexaxis; /* Axis label size */
|
| 11507 |
ripley |
136 |
|
|
|
137 |
int fontmain; /* Main title font */
|
|
|
138 |
int fontlab; /* Xlab and ylab font */
|
|
|
139 |
int fontsub; /* Subtitle font */
|
|
|
140 |
int fontaxis; /* Axis label fonts */
|
|
|
141 |
|
| 44369 |
ripley |
142 |
rcolor colmain; /* Main title color */
|
|
|
143 |
rcolor collab; /* Xlab and ylab color */
|
|
|
144 |
rcolor colsub; /* Subtitle color */
|
|
|
145 |
rcolor colaxis; /* Axis label color */
|
| 11507 |
ripley |
146 |
|
|
|
147 |
/* Layout Parameters */
|
|
|
148 |
|
|
|
149 |
Rboolean layout; /* has a layout been specified */
|
|
|
150 |
|
|
|
151 |
int numrows;
|
|
|
152 |
int numcols;
|
|
|
153 |
int currentFigure;
|
|
|
154 |
int lastFigure;
|
|
|
155 |
double heights[MAX_LAYOUT_ROWS];
|
|
|
156 |
double widths[MAX_LAYOUT_COLS];
|
|
|
157 |
int cmHeights[MAX_LAYOUT_ROWS];
|
|
|
158 |
int cmWidths[MAX_LAYOUT_COLS];
|
| 32449 |
ripley |
159 |
unsigned short order[MAX_LAYOUT_CELLS];
|
| 11507 |
ripley |
160 |
int rspct; /* 0 = none, 1 = full, 2 = see respect */
|
| 32449 |
ripley |
161 |
unsigned char respect[MAX_LAYOUT_CELLS];
|
| 11507 |
ripley |
162 |
|
|
|
163 |
int mfind; /* By row/col indicator */
|
|
|
164 |
|
|
|
165 |
/* Layout parameters which can be set directly by the */
|
|
|
166 |
/* user (e.g., par(fig=c(.5,1,0,1))) or otherwise are */
|
|
|
167 |
/* calculated automatically */
|
|
|
168 |
/* NOTE that *Units parameters are for internal use only */
|
|
|
169 |
|
|
|
170 |
double fig[4]; /* (current) Figure size (proportion) */
|
|
|
171 |
/* [0] = left, [1] = right */
|
|
|
172 |
/* [2] = bottom, [3] = top */
|
|
|
173 |
double fin[2]; /* (current) Figure size (inches) */
|
|
|
174 |
/* [0] = width, [1] = height */
|
|
|
175 |
GUnit fUnits; /* (current) figure size units */
|
|
|
176 |
double plt[4]; /* (current) Plot size (proportions) */
|
|
|
177 |
/* [0] = left, [1] = right */
|
|
|
178 |
/* [2] = bottom, [3] = top */
|
|
|
179 |
double pin[2]; /* (current) plot size (inches) */
|
|
|
180 |
/* [0] = width, [1] = height */
|
|
|
181 |
GUnit pUnits; /* (current) plot size units */
|
|
|
182 |
Rboolean defaultFigure; /* calculate figure from layout ? */
|
|
|
183 |
Rboolean defaultPlot; /* calculate plot from figure - margins ? */
|
|
|
184 |
|
|
|
185 |
/* Layout parameters which are set directly by the user */
|
|
|
186 |
|
|
|
187 |
double mar[4]; /* Plot margins in lines */
|
|
|
188 |
double mai[4]; /* Plot margins in inches */
|
|
|
189 |
/* [0] = bottom, [1] = left */
|
|
|
190 |
/* [2] = top, [3] = right */
|
|
|
191 |
GUnit mUnits; /* plot margin units */
|
|
|
192 |
double mex; /* Margin expansion factor */
|
|
|
193 |
double oma[4]; /* Outer margins in lines */
|
|
|
194 |
double omi[4]; /* outer margins in inches */
|
|
|
195 |
double omd[4]; /* outer margins in NDC */
|
|
|
196 |
/* [0] = bottom, [1] = left */
|
|
|
197 |
/* [2] = top, [3] = right */
|
|
|
198 |
GUnit oUnits; /* outer margin units */
|
| 59177 |
ripley |
199 |
char pty; /* Plot type */
|
| 11507 |
ripley |
200 |
|
|
|
201 |
/* Layout parameters which can be set by the user, but */
|
|
|
202 |
/* almost always get automatically calculated anyway */
|
|
|
203 |
|
|
|
204 |
double usr[4]; /* Graphics window */
|
|
|
205 |
/* [0] = xmin, [1] = xmax */
|
|
|
206 |
/* [2] = ymin, [3] = ymax */
|
|
|
207 |
|
|
|
208 |
/* The logged usr parameter; if xlog, use logusr[0:1] */
|
|
|
209 |
/* if ylog, use logusr[2:3] */
|
|
|
210 |
|
|
|
211 |
double logusr[4];
|
|
|
212 |
|
|
|
213 |
/* Layout parameter: Internal flags */
|
|
|
214 |
|
|
|
215 |
Rboolean new; /* Clean plot ? */
|
|
|
216 |
int devmode; /* creating new image or adding to existing one */
|
|
|
217 |
|
|
|
218 |
/* Coordinate System Mappings */
|
|
|
219 |
/* These are only used internally (i.e., cannot be */
|
|
|
220 |
/* set directly by the user) */
|
|
|
221 |
|
|
|
222 |
/* The reliability of these parameters relies on */
|
|
|
223 |
/* the fact that plot.new is the */
|
|
|
224 |
/* first graphics operation called in the creation */
|
| 44343 |
ripley |
225 |
/* of a graph (unless it is a call to persp) */
|
| 11507 |
ripley |
226 |
|
|
|
227 |
/* udpated per plot.new */
|
|
|
228 |
|
|
|
229 |
double xNDCPerChar; /* Nominal character width (NDC) */
|
|
|
230 |
double yNDCPerChar; /* Nominal character height (NDC) */
|
|
|
231 |
double xNDCPerLine; /* Nominal line width (NDC) */
|
|
|
232 |
double yNDCPerLine; /* Nominal line height (NDC) */
|
|
|
233 |
double xNDCPerInch; /* xNDC -> Inches */
|
|
|
234 |
double yNDCPerInch; /* yNDC -> Inches */
|
|
|
235 |
|
|
|
236 |
/* updated per plot.new and if inner2dev changes */
|
|
|
237 |
|
|
|
238 |
GTrans fig2dev; /* Figure to device */
|
|
|
239 |
|
|
|
240 |
/* udpated per DevNewPlot and if ndc2dev changes */
|
|
|
241 |
|
|
|
242 |
GTrans inner2dev; /* Inner region to device */
|
|
|
243 |
|
|
|
244 |
/* udpated per device resize */
|
|
|
245 |
|
|
|
246 |
GTrans ndc2dev; /* NDC to raw device */
|
|
|
247 |
|
|
|
248 |
/* updated per plot.new and per plot.window */
|
|
|
249 |
|
|
|
250 |
GTrans win2fig; /* Window to figure mapping */
|
|
|
251 |
|
|
|
252 |
/* NOTE: if user has not set fig and/or plt then */
|
|
|
253 |
/* they need to be updated per plot.new too */
|
|
|
254 |
|
| 34613 |
murrell |
255 |
double scale; /* An internal "zoom" factor to apply to ps and lwd */
|
|
|
256 |
/* (for fit-to-window resizing in Windows) */
|
| 11507 |
ripley |
257 |
} GPar;
|
|
|
258 |
|
| 11510 |
ripley |
259 |
/* always remap private functions */
|
|
|
260 |
#define copyGPar Rf_copyGPar
|
| 37012 |
ripley |
261 |
#define FixupCol Rf_FixupCol
|
|
|
262 |
#define FixupLty Rf_FixupLty
|
|
|
263 |
#define FixupLwd Rf_FixupLwd
|
|
|
264 |
#define FixupVFont Rf_FixupVFont
|
| 11510 |
ripley |
265 |
#define GInit Rf_GInit
|
| 44154 |
ripley |
266 |
#define labelformat Rf_labelformat
|
| 37012 |
ripley |
267 |
#define ProcessInlinePars Rf_ProcessInlinePars
|
| 44154 |
ripley |
268 |
#define recordGraphicOperation Rf_recordGraphicOperation
|
| 11507 |
ripley |
269 |
|
| 31938 |
murrell |
270 |
/* NOTE: during replays, call == R_NilValue;
|
|
|
271 |
---- the following adds readability: */
|
| 44348 |
ripley |
272 |
Rboolean GRecording(SEXP, pGEDevDesc);
|
| 31938 |
murrell |
273 |
|
| 11507 |
ripley |
274 |
/* Default the settings for general graphical parameters
|
|
|
275 |
* (i.e., defaults that do not depend on the device type: */
|
|
|
276 |
void GInit(GPar*);
|
|
|
277 |
|
| 11510 |
ripley |
278 |
void copyGPar(GPar *, GPar *);
|
|
|
279 |
|
| 44312 |
ripley |
280 |
/* from graphics.c, used in par.c */
|
|
|
281 |
double R_Log10(double);
|
| 11510 |
ripley |
282 |
|
| 44312 |
ripley |
283 |
/* from par.c, called in plot.c, plot3d.c */
|
| 59261 |
ripley |
284 |
void ProcessInlinePars(SEXP, pGEDevDesc);
|
| 37012 |
ripley |
285 |
|
| 44154 |
ripley |
286 |
/* from device.c */
|
| 44348 |
ripley |
287 |
void recordGraphicOperation(SEXP, SEXP, pGEDevDesc);
|
| 44154 |
ripley |
288 |
|
|
|
289 |
/* some functions that plot.c needs to share with plot3d.c */
|
| 44312 |
ripley |
290 |
SEXP FixupCol(SEXP, unsigned int);
|
| 37012 |
ripley |
291 |
SEXP FixupLty(SEXP, int);
|
|
|
292 |
SEXP FixupLwd(SEXP, double);
|
|
|
293 |
SEXP FixupVFont(SEXP);
|
| 44154 |
ripley |
294 |
SEXP labelformat(SEXP);
|
| 37012 |
ripley |
295 |
|
| 59084 |
maechler |
296 |
/*
|
| 27237 |
murrell |
297 |
* Function to generate an R_GE_gcontext from Rf_gpptr info
|
| 44154 |
ripley |
298 |
*
|
|
|
299 |
* from graphics.c, used in plot.c, plotmath.c
|
| 27237 |
murrell |
300 |
*/
|
| 44348 |
ripley |
301 |
void gcontextFromGP(pGEcontext gc, pGEDevDesc dd);
|
| 27237 |
murrell |
302 |
|
| 44154 |
ripley |
303 |
/* From base.c */
|
| 44343 |
ripley |
304 |
#define gpptr Rf_gpptr
|
|
|
305 |
#define dpptr Rf_dpptr
|
| 44348 |
ripley |
306 |
GPar* Rf_gpptr(pGEDevDesc dd);
|
|
|
307 |
GPar* Rf_dpptr(pGEDevDesc dd);
|
| 16880 |
murrell |
308 |
|
| 11507 |
ripley |
309 |
#endif /* GRAPHICS_H_ */
|