134
134
return(structure(c(unclass(object), unclass(lay)),
135
135
class = c("layer", "trellis")))
137
panel <- if (toString(object$call[[1]]) == "splom")
137
panel <- if ("panel" %in% names(object$panel.args.common))
138
138
object$panel.args.common$panel
139
139
else object$panel
140
140
panel <- if (is.function(panel)) panel
149
149
## a flag to indicate this panel function has layers
150
150
## (used by flattenPanel and undoLayer)
151
151
.is.a.layer <- TRUE
152
newpanel <- function(..., subscripts = TRUE) {
152
newpanel <- function(...) {
153
153
.UNDER <- unlist(lapply(lay, attr, "under"))
155
drawLayer(lay[.UNDER])
154
## underlaying items only
155
drawLayer(lay[.UNDER], list(...))
156
156
## original panel function:
157
panel(..., subscripts = subscripts)
159
drawLayer(lay[.UNDER == FALSE])
158
## overlaying items only
159
drawLayer(lay[.UNDER == FALSE], list(...))
161
object <- update(object, panel = newpanel)
161
if ("panel" %in% names(object$panel.args.common))
162
object$panel.args.common$panel <- newpanel
163
else object$panel <- newpanel
162
164
## need this to allow further calls to update() to insert arguments:
163
165
object$call <- call("update", ocall)
167
drawLayer <- function(lay)
169
drawLayer <- function(lay, panelArgs = trellis.panelArgs())
169
171
lay <- as.layer(lay)
170
172
.UNDER <- unlist(lapply(lay, attr, "under"))
171
173
## underlayers, in reverse order
172
174
for (.ITEM in rev(lay[.UNDER]))
175
drawLayerItem(.ITEM, panelArgs)
175
177
for (.ITEM in lay[.UNDER == FALSE])
178
drawLayerItem(.ITEM, panelArgs)
180
drawLayerItem <- function(layer.item)
182
drawLayerItem <- function(layer.item, panelArgs)
182
184
stopifnot(is.expression(layer.item))
183
185
## check that any restrictions on packets/rows/columns are met
240
242
## call panel.superpose for group layers
241
243
if (isTRUE(attr(layer.item, "superpose"))) {
242
244
do.call("panel.superpose",
243
modifyList(trellis.panelArgs(),
245
modifyList(panelArgs,
244
246
list(panel.groups = drawLayerItemPerGroup)))
246
do.call("drawLayerItemPerGroup", trellis.panelArgs())
248
do.call("drawLayerItemPerGroup", panelArgs)