<br><br><div class="gmail_quote">On Tue, Aug 31, 2010 at 10:11 PM, Yihui Xie <span dir="ltr">&lt;<a href="mailto:xie@yihui.name">xie@yihui.name</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi all,<br>
<br>
I&#39;m wondering if there are any approaches to completely show the<br>
graphical elements on the boundaries under a layout containing several<br>
layers. This is like the functionality par(xpd=NA) in base R graphics.<br>
See the example below that the texts for the origin (0,0) on the axes<br>
are partially hidden.<br>
<br>
My another problem is, I don&#39;t really understand the layout approach,<br>
although I&#39;ve been reading the qtpaint vignette and digging the Nokia<br>
Qt documentations.</blockquote><div><br>Me neither. I&#39;ll try to find some time to look into it. The QGraphicsLayout stuff is even worse than QLayout. You&#39;re correct that stretch factory set to zero does not work. I inferred that from the QGridLayout, but it must be different for QGraphicsGridLayout. <br>
<br>I&#39;d like to move to an approach where each layer has a size and sizing policy, rather than doing things by rows and columns in the grid layout. I haven&#39;t figured out that yet though either.<br><br>Michael<br> <br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> Specifically, how should we define the coordinate<br>
system in each layer in a layout? (I experimented with mouse clicking<br>
to get locations but got even more confused) With a single layer, I<br>
can plot the data using its range to define the limits and everything<br>
is fine. Besides, does anyone have a working demo to draw a simplest<br>
plot with the layout approach? I struggled with<br>
set(Column|Row)(Maximum|Minimum|Preferred)(Width|Height) and<br>
set(Column|Row)StretchFactor, but they do not behave as we expect them<br>
to, e.g. the stretch factor being 0 will not restrict the height/width<br>
of a layer to be a fixed value -- they change as we resize the window.<br>
<br>
Below is the R code:<br>
<br>
# I need hints on how to split the root layer into several regions<br>
# and what are their coordinate systems<br>
library(qtpaint)<br>
scene = qscene()<br>
figLayer = qlayer(scene,limits=qrect(0,0,675,550))<br>
titlePainter = function(item, painter) {<br>
    qdrawText(painter, &#39;The Useless Title&#39;, 300, 0,&#39;center&#39;,&#39;bottom&#39;)<br>
    tmp=as.matrix(titleLayer$boundingRect())<br>
    qdrawRect(painter, tmp[1,1],tmp[1,2],tmp[2,1],tmp[2,2])<br>
}<br>
yAxisPainter = function(item, painter) {<br>
    qdrawText(painter, as.character(pretty(1:400)), 37.5, pretty(1:400))<br>
}<br>
plotPainter = function(item, painter) {<br>
    qdrawPoint(painter, runif(1000, 0, 600), runif(1000, 0, 400))<br>
    qdrawRect(painter, 1, 1, 600-1, 400-1)<br>
}<br>
xAxisPainter = function(item, painter) {<br>
    qdrawText(painter, as.character(pretty(1:600)), pretty(1:600), 37.5)<br>
}<br>
mouseLocator = function(item, event){<br>
    print(as.numeric(event$pos()))<br>
}<br>
titleLayer = qlayer(figLayer, titlePainter,<br>
mousePressFun=mouseLocator, row=2,col=1)<br>
yaxis = qlayer(figLayer, yAxisPainter,mousePressFun=mouseLocator,row = 1,col=0)<br>
plotLayer = qlayer(figLayer, plotPainter,<br>
mousePressFun=mouseLocator,row = 1, col = 1)<br>
xaxis = qlayer(figLayer, xAxisPainter, mousePressFun=mouseLocator,row<br>
= 0, col = 1)<br>
<br>
layout = figLayer$gridLayout()<br>
<br>
layout$setRowMaximumHeight(0, 75)<br>
layout$setRowMinimumHeight(0, 60)<br>
# main plot region: 400x600<br>
layout$setRowPreferredHeight(1, 400)<br>
layout$setRowMaximumHeight(2, 75)<br>
layout$setRowMinimumHeight(2, 60)<br>
<br>
layout$setColumnMaximumWidth(0, 75)<br>
layout$setColumnMinimumWidth(0, 60)<br>
layout$setColumnPreferredWidth(1, 600)<br>
layout$setRowStretchFactor(0, 0)<br>
layout$setRowStretchFactor(1, 1)<br>
layout$setRowStretchFactor(2, 0)<br>
layout$setColumnStretchFactor(0, 0)<br>
layout$setColumnStretchFactor(1, 1)<br>
<br>
print(view&lt;-qplotView(scene = scene))<br>
<br>
<br>
#################################################<br>
<br>
&gt; sessionInfo()<br>
R version 2.11.1 (2010-05-31)<br>
x86_64-pc-linux-gnu<br>
<br>
locale:<br>
[1] en_US.utf8<br>
<br>
attached base packages:<br>
[1] stats     graphics  grDevices utils     datasets  methods   base<br>
<br>
other attached packages:<br>
[1] qtpaint_0.7.9<br>
<br>
loaded via a namespace (and not attached):<br>
[1] qtbase_0.8-4 tools_2.11.1<br>
<br>
<br>
Thanks a lot!<br>
<br>
Regards,<br>
Yihui<br>
--<br>
<font color="#888888">Yihui Xie &lt;<a href="mailto:xieyihui@gmail.com">xieyihui@gmail.com</a>&gt;<br>
Phone: 515-294-6609 Web: <a href="http://yihui.name" target="_blank">http://yihui.name</a><br>
Department of Statistics, Iowa State University<br>
3211 Snedecor Hall, Ames, IA<br>
_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
</font></blockquote></div><br>