[rkward-cvs] SF.net SVN: rkward:[2973] trunk/rkward/rkward
kapatp at users.sourceforge.net
kapatp at users.sourceforge.net
Sat Aug 28 01:28:32 UTC 2010
Revision: 2973
http://rkward.svn.sourceforge.net/rkward/?rev=2973&view=rev
Author: kapatp
Date: 2010-08-28 01:28:31 +0000 (Sat, 28 Aug 2010)
Log Message:
-----------
Track the previously active device before rk.graph.on is called. See http://www.mail-archive.com/rkward-devel@lists.sourceforge.net/msg00886.html
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
trunk/rkward/rkward/windows/rkwindowcatcher.cpp
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2010-08-27 23:17:30 UTC (rev 2972)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R 2010-08-28 01:28:31 UTC (rev 2973)
@@ -422,3 +422,5 @@
# call separate assignments functions:
if (exists (".rk.fix.assignments.graphics")) eval (body (.rk.fix.assignments.graphics)) # internal_graphics.R
}
+
+.rk.active.device <- 1
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2010-08-27 23:17:30 UTC (rev 2972)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2010-08-28 01:28:31 UTC (rev 2973)
@@ -2,12 +2,14 @@
## These functions are accessible to the user.
# Requests a graph to be written.
-rk.graph.on <- function (device.type=getOption ("rk.graphics.type"), width=getOption ("rk.graphics.width"), height=getOption ("rk.graphics.height"), quality, ...)
+rk.graph.on <- function (device.type=getOption ("rk.graphics.type"), width=getOption ("rk.graphics.width"), height=getOption ("rk.graphics.height"), quality, ..., set.active.device = TRUE)
{
if (!is.numeric (width)) width <- 480
if (!is.numeric (height)) height <- 480
if (is.null (device.type)) device.type <- "PNG" # default behavior is PNG for now
+ if (set.active.device) assign (".rk.active.device", dev.cur (), pos = "package:rkward")
+
ret <- NULL
if (device.type == "PNG") {
filename <- rk.get.tempfile.name(prefix = "graph", extension = ".png")
@@ -44,7 +46,12 @@
"rk.graph.off" <- function(){
.rk.cat.output ("\n") # so the output will be auto-refreshed
- dev.off()
+ ret <- dev.off()
+
+ # dev.off () sets dev.next () as active, which may not have been active before rk.graph.on was called; so reset the correct device as active:
+ i <- get (".rk.active.device", pos = "package:rkward")
+ if ((!is.null (i)) && i > 1) dev.set (i)
+ ret
}
"rk.duplicate.device" <- function (deviceId = dev.cur ())
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-08-27 23:17:30 UTC (rev 2972)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2010-08-28 01:28:31 UTC (rev 2973)
@@ -333,7 +333,7 @@
void RKCaughtX11Window::copyDeviceToOutput () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.copy (device=rk.graph.on)\nrk.graph.off ()", RCommand::App | RCommand::DirectToOutput, i18n ("Copy contents of graphics device number %1 to output", device_number), error_dialog);
+ RKGlobals::rInterface ()->issueCommand ("assign (\".rk.active.device\", dev.cur (), pos=\"package:rkward\")\ndev.set (" + QString::number (device_number) + ")\ndev.copy (device=rk.graph.on, set.active.device = FALSE)\nrk.graph.off ()", RCommand::App | RCommand::DirectToOutput, i18n ("Copy contents of graphics device number %1 to output", device_number), error_dialog);
}
void RKCaughtX11Window::printDevice () {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list