[R-SIG-Mac] Call R framework from my own Cocoa app?
Demitri Muna
thatsanicehatyouhave at mac.com
Tue Jun 28 20:14:56 CEST 2005
Hi Simon,
On 28 Jun 2005, at 15:40, Simon Urbanek wrote:
> you can do that fairly easily just using REngine. I have put
> together a tiny sample project, you can download it from
> http://research.att.com/~urbanek/REngineTest.dmg
That is absolutely brilliant - it's exactly what I was hoping to do.
Thanks for the sample app; it worked perfectly and it's very
illustrative. With that I can experiment with the rest of the API.
Now, the final step for me is to display a plot.
> All you need now is R installed as framework in /Library/
> Frameworks. The demo app above includes REngine that is independent
> of the R.app. Quartz won't work with that, though - you'd have to
> get the Quartz classes from R.app (but it's possible).
I copied the following classes into the REngineTest you gave me:
devQuartz.h/c, RQuartz.h/m, QuartzDevice.h/m, RDeviceView.h/m,
RGUI.h, Preferences.h/m, PreferenceKeys.h, and RQuartz.nib. With a
few minor changes (mainly commenting out "#import "../RController.h"
lines), it compiled successfully.
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. I'm guessing
that it's in QuartzDevice, innerQuartzDevice:, but I'm not sure where
*that* is called from (or at least, how a plot command triggers it).
I copied newQuartzDevice: from RController, but there was no result.
What am I missing to be able to connect the R engine in my app to the
Quartz view?
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. I noted that X11 displays do refresh
when called from R.app - what is the callback that will let me know
when to redraw the window? Do you buffer it or actually resubmit the
plot command(s)?
Thank you very much for all your help. I'm really pleased with the
results!
Cheers,
Demitri
More information about the R-SIG-Mac
mailing list