[Rd] Re: [R] using graphapp.h
Wed, 28 Jun 2000 15:57:38 +0200
On Wed, Jun 28, 2000 at 08:28:45AM -0400, Vadim Kutsyy wrote:
> What I need to do as to plot a few tens thousands squares of different
> colors. As David mention, it can be done with polygon(), but it still be
> slow. So I am trying to do it from c code.
> As a result, I open the window with plot(), and then I want to plot in to
> that window from c code (in S it is done using "graphics.h"). The only
> thing I could think about, is to use "graphapp.h". "graphapp.h" defines a
> lot of function for that (fillrect(rect r) for example), but I can not
> figure out how to make it grow in that window, which is already open by
I move to r-devel.
I am not sure that plotting directly on a graphics device is a
safe idea. I see it as a little adventure. Anyway,
since I not against adventures, my 0.01Euro on what I know.
A possibility is to call do_polygon - the C front end of the
R 'polygon' function - directly from your C code.
Another portable alternative is clone do_polygon and friends.
You need to get a pointer to the current device driver and then you
must use the device operation functions.
DevDesc *dd = CurrentDevice() /* or GetDevice(number of device) */
(a) using GPolygon or similar function (in main/graphics.c )
you can draw to the device (difference between (a) e (b) is that
(b) calls directly the device).
Essentially, (a) is what do_polygon does.
Alternatively, if you want, you can also call graphapp directly
(but this isn't portable).
A pointer to the graphapp window is hided in the DeviceSpecific part
of DevDesc. So, you need to copy the definition of 'gadesc' from devga.c.
window w = ((gadesc *) dd->DeviceSpecific)->gawin;
will give you the pointer.
Keep in mind that, if I remember well Graphics.h is not
a part of the R API. Surely, the details
of the DeviceSpecific part of a DevDesc are subject to changes.
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: email@example.com