[RQt-devel] Layers and layout
Deepayan Sarkar
deepayan.sarkar at gmail.com
Tue Sep 21 13:14:10 CEST 2010
Hi,
In my efforts to resurrect mosaiq, I have managed to put two "panel"
layers on the root layer as follows:
-----------
library(qtpaint)
scene <- qscene()
root <- qlayer(scene)
scatterplotLayer <-
function(x = runif(10), y = runif(10),
fill = "black", row, col)
{
force(x)
force(y)
paintFun <- function(item, painter, exposed)
{
qdrawGlyph(painter, qglyphCircle(), x, y, fill = qcolor(fill))
}
qlayer(root, paintFun = paintFun, cache = TRUE,
limits = qrect(c(0, 1), c(0, 1)),
row = row, col = col)
}
panel1 <- scatterplotLayer(row = 0, col = 0, fill = "red")
panel2 <- scatterplotLayer(row = 1, col = 1, fill = "green")
(view <- qplotView(scene = scene, opengl = FALSE))
-----------
However, this requires that I specify the position in the layout at
the time of creating the layer. The old mosaiq created parent-less
layers first and then put them in the root layer's layout. I have
tried this in two ways, both have failed:
-----------
library(qtpaint)
scene <- qscene()
root <- qlayer(scene)
scatterplotLayer <- function(x = runif(10), y = runif(10), fill = "black")
{
force(x)
force(y)
paintFun <- function(item, painter, exposed)
{
qdrawGlyph(painter, qglyphCircle(), x, y, fill = qcolor(fill))
}
qlayer(NULL, paintFun = paintFun, cache = TRUE,
limits = qrect(c(0, 1), c(0, 1)))
}
panel1 <- scatterplotLayer()
panel2 <- scatterplotLayer()
## This gives an error: Wrong number or types of arguments passed to
## 'Qanviz::RLayer::addLayer'
root[0, 0] <- panel1
root[1, 1] <- panel2
## This crashes
layout <- root$gridLayout()
layout$addItem(panel1, 0, 0)
layout$addItem(panel2, 1, 1)
-----------
Is there a way to achieve this? How is addLayer supposed to work?
-Deepayan
More information about the Qtinterfaces-devel
mailing list