| Line 6... |
Line 6... |
| 6 |
\name{grid.grab}
|
6 |
\name{grid.grab}
|
| 7 |
\alias{grid.grab}
|
7 |
\alias{grid.grab}
|
| 8 |
\alias{grid.grabExpr}
|
8 |
\alias{grid.grabExpr}
|
| 9 |
\title{ Grab the current grid output }
|
9 |
\title{ Grab the current grid output }
|
| 10 |
\description{
|
10 |
\description{
|
| 11 |
Creates a gTree object from the current grid display list
|
11 |
Creates a \I{gTree} object from the current grid display list
|
| 12 |
or from a scene generated by user-specified code.
|
12 |
or from a scene generated by user-specified code.
|
| 13 |
}
|
13 |
}
|
| 14 |
\usage{
|
14 |
\usage{
|
| 15 |
grid.grab(warn = 2, wrap = wrap.grobs, wrap.grobs = FALSE, ...)
|
15 |
grid.grab(warn = 2, wrap = wrap.grobs, wrap.grobs = FALSE, ...)
|
| 16 |
grid.grabExpr(expr, warn = 2, wrap = wrap.grobs, wrap.grobs = FALSE,
|
16 |
grid.grabExpr(expr, warn = 2, wrap = wrap.grobs, wrap.grobs = FALSE,
|
| Line 39... |
Line 39... |
| 39 |
\item{device}{ A function that opens a graphics device for temporary
|
39 |
\item{device}{ A function that opens a graphics device for temporary
|
| 40 |
rendering. By default this is an off-screen, in-memory device
|
40 |
rendering. By default this is an off-screen, in-memory device
|
| 41 |
based on the \code{pdf} device, but this default device may not be
|
41 |
based on the \code{pdf} device, but this default device may not be
|
| 42 |
satisfactory when using custom fonts.
|
42 |
satisfactory when using custom fonts.
|
| 43 |
}
|
43 |
}
|
| 44 |
\item{\dots}{ arguments passed to gTree, for example, a
|
44 |
\item{\dots}{ arguments passed to \I{gTree}, for example, a
|
| 45 |
name and/or class for the gTree that is created.}
|
45 |
name and/or class for the \I{gTree} that is created.}
|
| 46 |
}
|
46 |
}
|
| 47 |
\details{
|
47 |
\details{
|
| 48 |
There are four ways to capture grid output as a gTree.
|
48 |
There are four ways to capture grid output as a \I{gTree}.
|
| 49 |
|
49 |
|
| 50 |
There are two functions for capturing output:
|
50 |
There are two functions for capturing output:
|
| 51 |
use \code{grid.grab} to capture an existing drawing
|
51 |
use \code{grid.grab} to capture an existing drawing
|
| 52 |
and \code{grid.grabExpr} to capture the output from
|
52 |
and \code{grid.grabExpr} to capture the output from
|
| 53 |
an expression (without drawing anything).
|
53 |
an expression (without drawing anything).
|
| 54 |
|
54 |
|
| 55 |
For each of these functions, the output can be captured in
|
55 |
For each of these functions, the output can be captured in
|
| 56 |
two ways. One way tries to be clever and make a
|
56 |
two ways. One way tries to be clever and make a
|
| 57 |
gTree with a \I{childrenvp} slot containing all viewports on
|
57 |
\I{gTree} with a \I{childrenvp} slot containing all viewports on
|
| 58 |
the display list (including those
|
58 |
the display list (including those
|
| 59 |
that are popped) and every
|
59 |
that are popped) and every
|
| 60 |
grob on the display list as a child of the new
|
60 |
grob on the display list as a child of the new
|
| 61 |
gTree; each child has a vpPath in the \I{vp} slot so that it is
|
61 |
\I{gTree}; each child has a \I{vpPath} in the \I{vp} slot so that it is
|
| 62 |
drawn in the appropriate viewport.
|
62 |
drawn in the appropriate viewport.
|
| 63 |
In other words, the gTree contains all elements on the display
|
63 |
In other words, the \I{gTree} contains all elements on the display
|
| 64 |
list, but in a slightly altered form.
|
64 |
list, but in a slightly altered form.
|
| 65 |
|
65 |
|
| 66 |
The other way, \code{wrap=TRUE},
|
66 |
The other way, \code{wrap=TRUE},
|
| 67 |
is to create a grob for every element on the
|
67 |
is to create a grob for every element on the
|
| 68 |
display list (and make all of those grobs children of the
|
68 |
display list (and make all of those grobs children of the
|
| 69 |
gTree). Only viewports are
|
69 |
\I{gTree}). Only viewports are
|
| 70 |
wrapped unless \code{wrap.grobs} is also \code{TRUE}.
|
70 |
wrapped unless \code{wrap.grobs} is also \code{TRUE}.
|
| 71 |
|
71 |
|
| 72 |
The first approach creates a more compact and elegant gTree,
|
72 |
The first approach creates a more compact and elegant \I{gTree},
|
| 73 |
which is more flexible to work with,
|
73 |
which is more flexible to work with,
|
| 74 |
but is not guaranteed to faithfully replicate all possible
|
74 |
but is not guaranteed to faithfully replicate all possible
|
| 75 |
grid output. The second approach is more brute force, and
|
75 |
grid output. The second approach is more brute force, and
|
| 76 |
harder to work with, but is more likely to replicate the original
|
76 |
harder to work with, but is more likely to replicate the original
|
| 77 |
output.
|
77 |
output.
|
| Line 80... |
Line 80... |
| 80 |
with \code{wrap.grobs=TRUE}, is
|
80 |
with \code{wrap.grobs=TRUE}, is
|
| 81 |
a scene where the placement of one grob is dependent on another grob
|
81 |
a scene where the placement of one grob is dependent on another grob
|
| 82 |
(e.g., via \code{grobX} or \code{grobWidth}).
|
82 |
(e.g., via \code{grobX} or \code{grobWidth}).
|
| 83 |
}
|
83 |
}
|
| 84 |
\value{
|
84 |
\value{
|
| 85 |
A gTree object.
|
85 |
A \I{gTree} object.
|
| 86 |
}
|
86 |
}
|
| 87 |
\seealso{ \code{\link{gTree}}
|
87 |
\seealso{ \code{\link{gTree}}
|
| 88 |
}
|
88 |
}
|
| 89 |
\examples{
|
89 |
\examples{
|
| 90 |
pushViewport(viewport(width=.5, height=.5))
|
90 |
pushViewport(viewport(width=.5, height=.5))
|