[Vegan-commits] r335 - in pkg: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun May 4 17:21:59 CEST 2008
Author: jarioksa
Date: 2008-05-04 17:21:59 +0200 (Sun, 04 May 2008)
New Revision: 335
Modified:
pkg/R/orditkplot.R
pkg/inst/ChangeLog
pkg/man/orditkplot.Rd
Log:
orditkplot zooms
Modified: pkg/R/orditkplot.R
===================================================================
--- pkg/R/orditkplot.R 2008-05-01 05:36:15 UTC (rev 334)
+++ pkg/R/orditkplot.R 2008-05-04 15:21:59 UTC (rev 335)
@@ -213,6 +213,7 @@
y <- (xy0[2] - row[2]) * yincr + mar[3]
c(x,y)
}
+ ## User coordinates of an item
xy2usr <- function(item) {
xy <- as.numeric(tkcoords(can, item))
x <- xy[1]
@@ -221,6 +222,13 @@
y <- yrange[2] - (y - mar[3])/yincr
c(x,y)
}
+ ## Canvas x or y to user coordinates
+ x2usr <- function(xcan) {
+ xrange[1] + (xcan - mar[2])/xincr
+ }
+ y2usr <- function(ycan) {
+ yrange[2] - (ycan - mar[3])/yincr
+ }
## Equal aspect ratio
height <- round((diff(yrange)/diff(xrange)) * xusr)
height <- height + mar[1] + mar[3]
@@ -311,6 +319,7 @@
tkdelete(can, "ptr")
.lastX <<- x
.lastY <<- y
+ ## xadj,yadj: adjust for canvas scrolling
xadj <- as.numeric(tkcanvasx(can, 0))
yadj <- as.numeric(tkcanvasy(can, 0))
conn <- tkcreate(can, "line", .lastX + xadj, .lastY+yadj,
@@ -336,7 +345,36 @@
tkdestroy(tt)
}
tkbind(labEd, "<Return>", isDone)
- }
+ }
+ ## Zooming: draw rectangle and take its user coordinates
+ ## Rectangle: first corner
+ pRect0 <- function(x, y) {
+ x <- as.numeric(x)
+ y <- as.numeric(y)
+ ## yadj here and below adjusts for canvas scrolling
+ yadj <- as.numeric(tkcanvasy(can, 0))
+ .pX <<- x
+ .pY <<- y + yadj
+ }
+ ## Grow rectangle
+ pRect <- function(x, y) {
+ x <- as.numeric(x)
+ y <- as.numeric(y)
+ tkdelete(can, "box")
+ yadj <- as.numeric(tkcanvasy(can, 0))
+ .lastX <<- x
+ .lastY <<- y + yadj
+ rect <- tkcreate(can, "rectangle", .pX, .pY, .lastX, .lastY,
+ outline="blue")
+ tkaddtag(can, "box", "withtag", rect)
+ }
+ ## Redraw ordiktplot with new xlim and ylim
+ ## FIXME: zooming does not pass "..." arguments
+ pZoom <- function() {
+ xlim <- sort(c(x2usr(.pX), x2usr(.lastX)))
+ ylim <- sort(c(y2usr(.pY), y2usr(.lastY)))
+ orditkplot(x, xlim = xlim, ylim = ylim, ...)
+ }
## Dummy location of the mouse
.lastX <- 0
.lastY <- 0
@@ -352,4 +390,7 @@
function() {tkdtag(can, "selected"); tkdelete(can, "ptr")})
tkitembind(can, "label", "<Double-Button-1>", pEdit)
tkbind(can, "<B1-Motion>", pMove)
+ tkbind(can, "<Shift-Button-1>", pRect0)
+ tkbind(can, "<Shift-B1-Motion>", pRect)
+ tkbind(can, "<Shift-ButtonRelease>", pZoom)
}
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2008-05-01 05:36:15 UTC (rev 334)
+++ pkg/inst/ChangeLog 2008-05-04 15:21:59 UTC (rev 335)
@@ -4,7 +4,8 @@
Version 1.12-13 (opened May 1, 2008)
- * orditkplot: labels can be edited with double clicking.
+ * orditkplot: labels can be edited with double clicking, and
+ shift-mouse allows zooming into smaller are in the plot.
Version 1.12-12 (closed May 1, 2008)
Modified: pkg/man/orditkplot.Rd
===================================================================
--- pkg/man/orditkplot.Rd 2008-05-01 05:36:15 UTC (rev 334)
+++ pkg/man/orditkplot.Rd 2008-05-04 15:21:59 UTC (rev 335)
@@ -50,7 +50,10 @@
Tcl/Tk based ordination graphics with points and labels. The function
opens an editable canvas with fixed points, but the labels can be
\strong{dragged with mouse} to better positions. The label can be
- edited with \strong{double clicking} a label. In addition there are buttons
+ edited with \strong{double clicking} a label.
+ \strong{Shift-mousebutton} allows zooming into the plot.
+
+ In addition there are buttons
for the following tasks: \strong{Copy to EPS} copies the current plot
to an encapsulated postscript (eps) file using standard Tcl/Tk
utilities. The faithfullness of this copy is system dependent. Button
More information about the Vegan-commits
mailing list