[R] rgl: How to position a window during open3d call

Duncan Murdoch murdoch at stats.uwo.ca
Thu Sep 18 17:52:03 CEST 2008


On 18/09/2008 12:08 AM, Yihui Xie wrote:
> Thanks Duncan, I have also been wondering about this problem for a long time.

This is fixed now on R-forge; eventually it will make it into the next 
rgl release on CRAN.  You should be able to download a binary of the 
development version from R-forge sooner.  Make sure you get version 
0.81.706 or newer.

Duncan Murdoch

> 
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
> Mobile: +86-15810805877
> Homepage: http://www.yihui.name
> School of Statistics, Room 1037, Mingde Main Building,
> Renmin University of China, Beijing, 100872, China
> 
> 
> 
> On Thu, Sep 18, 2008 at 1:49 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>> On 9/17/2008 1:13 PM, Koen Stegen wrote:
>>> Dear all,
>>>
>>> The documentation on the function open3d in the rgl package, reads:
>>>
>>>    open3d opens a new rgl device, and sets the parameters as requested.
>>>
>>> I want the new rgl device (window) to be sized and positioned in a
>>> specific
>>> place on my screen. So, I try to set the "windowRect" parameter as
>>> follows:
>>>
>>>    > library("rgl")
>>>    > open3d(windowRect=c(100,100,500,500))
>>>    [1] 1
>>>
>>> Obviously you can't see where the window appears, so I'll ask for the
>>> "windowRect" parameter:
>>>
>>>    > par3d()["windowRect"]
>>>    $windowRect
>>>    [1] 2300  764 2556 1020
>>>
>>> As you can see, the window is not positioned at (100,100) nor is the size
>>> 400x400. The size is the default 256x256 and the position is where the
>>> window
>>> manager would put a new window if its position is unspecified.
>>> [note: I have a dual screen setup so the coordinates are not bogus]
>>>
>>> If, however, I use par3d to set the "windowRect", the window goes where it
>>> is
>>> supposed to go:
>>>
>>>    > par3d(windowRect=c(100,100,500,500))
>>>    > par3d()["windowRect"]
>>>    $windowRect
>>>    [1] 104 125 504 525
>>>
>>> The (4,25) pixels offset are the border and title bar of the window.
>>>
>>> For completeness sake:
>>> This behavior occurs on both Windows+ATI, Linux+ATI, Linux+NVidia.
>>> On Windows  is R version 2.7.2, and rgl version 0.81 (installed today).
>>>
>>> Does anyone know how to set the windowRect parameter during an open3d
>>> call?
>> Looks like a bug.  The open3d function is defined as
>>
>>> open3d
>> function (..., params = get("r3dDefaults", envir = .GlobalEnv))
>> {
>>    rgl.open()
>>    clear3d("material", defaults = params)
>>    params$material <- NULL
>>    if (!is.null(params$bg)) {
>>        do.call("bg3d", params$bg)
>>        params$bg <- NULL
>>    }
>>    do.call("par3d", params)
>>    return(rgl.cur())
>> }
>> <environment: namespace:rgl>
>>
>>
>> and you'll notice that the ... parameters are never used.  Not sure when
>> this error crept in...
>>
>> The workaround is simply to use par3d() after open3d().
>>
>> Duncan Murdoch
>>
>>>
>>> Thanks in advance,
>>>
>>> Koen Stegen
>>> Royal Meteorological Institute of Belgium
>>>
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list