-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrid.R
41 lines (31 loc) · 1.02 KB
/
grid.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#' @include options.R
#' @import grid
NULL
tryViewport <- function(name, verbose=FALSE){
if( verbose ) message("vp - lookup for ", name)
l <- grid.ls(viewports=TRUE, grobs=FALSE, print=FALSE)
if( name %in% l$name ){
downViewport(name)
}
}
current.vpPath_patched <- local({
.current.vpPath <- NULL
function(){
f_current.vpPath <- .current.vpPath
if( !.use.grid.patch() ) f_current.vpPath <- grid::current.vpPath
else if( is.null(f_current.vpPath) ){ # load patch from installed file
patch <- source(packagePath('scripts', 'grid.R', package = 'KINOMO'), local = TRUE)
.current.vpPath <<- patch$value
f_current.vpPath <- .current.vpPath
}
# call
f_current.vpPath()
}
})
# Add new option to enable/disable grid patch
.OPTIONS$newOptions(grid.patch = FALSE)
#' \code{.use.grid.patch} tells if the user enabled patching grid.
#' @rdname grid
.use.grid.patch <- function(){
!isCHECK() && KINOMO.getOption('grid.patch')
}