File: hooks.R

package info (click to toggle)
rgl 1.3.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,984 kB
  • sloc: cpp: 23,234; ansic: 7,462; javascript: 6,121; sh: 3,555; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download | duplicates (3)
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
# This file supports auto-printing of RGL scenes in
# RStudio

# Called just after a low level function has been
# called, likely changing an existing display
# Returns the ids that were created by the function,
# which should be passed as the ids arg.

lowlevel <- function(ids = integer()) {
  structure(ids, class = c("rglLowlevel", "rglId", "numeric"))
}

# Called just after a high level function (plot3d
# or persp3d) has been called, if it wasn't
# called with add = TRUE (in which case it would be
# treated as low level).
# Returns the ids that were created by the function,
# which should be passed as the ids arg.

highlevel <- function(ids = integer()) {
  structure(ids, class = c("rglHighlevel", "rglId", "numeric"))
}

rglId <- function(ids = integer()) {
  structure(ids, class = "rglId")
}

print.rglId <- function(x, rglwidget = getOption("rgl.printRglwidget", FALSE),
			...) {
  if (!par3d("skipRedraw")) {
    if (rglwidget)
      # FIXME:  For lowlevel, this should replace the scene, not update the history
      print(rglwidget(...))
    else if (in_pkgdown_example())
      pkgdown::pkgdown_print(x)
  }
  invisible(x)
}