[R-SIG-Mac] Call R framework from my own Cocoa app?

Simon Urbanek simon.urbanek at r-project.org
Tue Jun 28 22:15:49 CEST 2005


Hi Demitri,

On Jun 28, 2005, at 2:14 PM, Demitri Muna wrote:

> These seemed to be the minimum number of classes needed to include  
> RQuartz, RDeviceView, and QuartzDevice. RQuartz.nib looks like the  
> graphic window containing the custom NSView. I then tried to find  
> where an RQuartz is instantiated (either directly or via  
> loadNibNamed:@"RQuartz"), but I was not able to find it.

In REngine/RCallbacks.m in the REngineTest sources at the bottom of  
the file there are two dummy callbacks for innerQuartzDevice and  
getQuartzParameters - please remove them both, they should come from  
the Quartz classes you copied. I put them there so that the test  
works even without Quartz.

R.app is a document-based application, and if you look in the  
QuartzDevice.m sources you will see:
         newDocument = [[NSDocumentController sharedDocumentController]
                                                  
openUntitledDocumentOfType:@"pdf" display:NO];
So you have either to change that to explicit window creation or  
change the application to be document-based and add a document class  
for the type "pdf".

> It then struck me that I could just as easily use X11 displays, and  
> that worked the first time I tried it. the only problem - the  
> display does not refresh on a resize.

This is the case because you're not running the R event loop. In  
order to run the event loop you must implement the <REPLHandler>  
protocol, especially handleProcessEvents for handling CF events and  
then use runREPL method of REngine to start R's event loop (see  
RController in the R.app, but that file is historically a big mess,  
so you want to pick and choose).

Cheers,
Simon



More information about the R-SIG-Mac mailing list