Skip to content

Commit

Permalink
fix ggobi#2
Browse files Browse the repository at this point in the history
  • Loading branch information
stlagsk committed Jun 3, 2017
1 parent a449626 commit 800df87
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions R/display.r
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# View displays
# See methods for details
#
# @keyword internal
#
# @keyword internal
displays <- function(x) UseMethod("displays", x)

# Get GGobi displays
# Gets list of displays in the specified GGobi instance
#
#
# A display basically corresponds to a window in GGobi. A display
# may contain mutliple plots within it. For example, the scatterplot
# matrix contains $p * p$ plots.
#
# Use this function to obtain a reference to a display (they are
#
# Use this function to obtain a reference to a display (they are
# numbered in the order they are created) so you can change
# display mode, set variables (\code{\link{variables<-.GGobiDisplay}}),
# or save a static image to disk.
#
# @seealso \code{\link{display}} to create displays
#
# @seealso \code{\link{display}} to create displays
# @alias displays.GGobi
# @arguments GGobi object
# @keyword dynamic
Expand All @@ -30,12 +30,12 @@ displays.GGobi <- function(x) {

# Get display dataset
# Returns a link to the GGobiData (dataset) object associated with this display.
#
# See \code{\link{[.GGobi}} for more information on
#
#
# See \code{\link{[.GGobi}} for more information on
#
# @arguments GGobiDisplay object
# @arguments ggobi reference
# @keyword manip
# @keyword manip
#X g <- ggobi(mtcars)
#X d <- displays(g)[[1]]
#X dataset(d)
Expand All @@ -45,7 +45,7 @@ dataset.GGobiDisplay <- function(x, .gobi=ggobi(x)) {

# Get display GGobi
# Returns a link to the GGobi object associated with this display
#
#
# @arguments GGobiDisplay object
# @keyword internal
ggobi.GGobiDisplay <- function(data, ...) {
Expand All @@ -54,18 +54,18 @@ ggobi.GGobiDisplay <- function(data, ...) {

# Print method for GGobiDisplay
# Shows display type (first element in class vector)
#
#
# @arguments GGobiDisplay object
# @keyword internal
# @keyword internal
print.GGobiDisplay <- function(x, ...) {
print(class(x)[1])
}

# Close display
# Closes the referenced display. The R variable will be invalid after this call.
#
#
# @arguments GGobiDisplay object to close
# @keyword internal
# @keyword internal
#X g <- ggobi(mtcars)
#X displays(g)
#X close(displays(g)[[1]])
Expand All @@ -76,49 +76,49 @@ close.GGobiDisplay <- function(con, ...) {

# Length method for GGobiDisplay
# Returns the number of plots within a given display
#
#
# @arguments GGobiDisplay object from which to retrieve the number of plots
# @keyword internal
# @keyword internal
length.GGobiDisplay <- function(x) {
.GGobiCall("getNumPlotsInDisplay", x)
}


# Save picture of plot (and window) to disk
# This allows you to make a static copy of a GGobiDisplay.
#
#
# If you want to make publicaiton quality graphics, you should
# probably use the DescribeDisplay plugin and package. This
# will recreate a GGobiDisplay in R, and so can produce high-quality
# vector (eg. pdf) output. See \url{http://www.ggobi.org/describe-display}
# for more information
#
#
# @arguments GGobiDisplay to save
# @arguments path to save to
# @arguments type of file to save
# @arguments if TRUE, save only plot, otherwise save surrounding GUI elements as well
# @keyword hplot
# @keyword hplot
#X g <- ggobi(mtcars)
#X ggobi_display_save_picture(displays(g)[[1]], "test.png")
ggobi_display_save_picture <- function(display=displays(ggobi_get())[[1]], path="ggobi_display.png", filetype="png", plot.only = FALSE) {
display_widget <- .ggobi_display_get_widget(as.RGtkObject(display))
if (plot.only) {
if (inherits(display, "GGobiScatmatDisplay"))
display_widget <- display_widget[[2]][[1]]
display_widget <- display_widget[[2]][[3]][["widget"]]
else display_widget <- display_widget[[2]][[3]][["widget"]]
}
if (boundGTKVersion() >= "2.14.0")
drawable <- display_widget$getSnapshot()
else drawable <- display_widget[["window"]]

widget_size <- drawable$getSize()

pixbuf <- gdkPixbufGetFromDrawable(src = drawable, cmap = NULL,
pixbuf <- gdkPixbufGetFromDrawable(src = drawable, cmap = NULL,
src.x = 0, src.y = 0,
dest.x = 0, dest.y = 0,
dest.x = 0, dest.y = 0,
width = widget_size$width,
height = widget_size$height)

pixbuf$save(path, filetype)
invisible(path)
}
Expand All @@ -134,7 +134,7 @@ ggobi_display_save_picture <- function(display=displays(ggobi_get())[[1]], path=

# GGobiDisplay types
# Get list of GGobiDisplay types. An instance of GGobi must be open
#
#
# @arguments GGobi reference
# @seealso \code{\link{ggobi_display_make_type}}
# @keyword internal
Expand All @@ -144,8 +144,8 @@ ggobi_display_types <- function() {

# Convert plot name to GGobi plot type
# Used to convert between friendly plot name and internal GGobi name.
#
# @keyword internal
#
# @keyword internal
ggobi_display_make_type <- function(type) {
if(!inherits(type, "GType")) {
types <- ggobi_display_types()
Expand Down

0 comments on commit 800df87

Please sign in to comment.