l.bize@wanadoo.fr
2003-Oct-23 19:22 UTC
[Rd] Ask for information about device architecture
Hello. I'm looking for documentation about the graphic device model in R. I would understand it in the details, but it seems a bit complex :) Thanks for any documents which will help me. Laurent
Hi l.bize@wanadoo.fr wrote:> Hello. > I'm looking for documentation about the graphic device model in R. > I would understand it in the details, but it seems a bit complex :) > Thanks for any documents which will help me.I'm assuming you want to write a new device ... Here are a couple of places to look: The API for graphics devices (such as it is) is in R/src/include/R_ext/graphicsDevice.h There's a reasonable amount of documentation in the code; you should probably ingore the first set of "NOTES" and look at all of the comments in the NewDevDesc structure, plus the stuff at the end of the file. The file R/src/modules/X11/devX11.c provides a "template" for how a device should be implemented. It also has a reasonable amount of documentation in the code. Most of the device functions should be fairly straightforward -- depending on what sort of device you want to implement, dev_MetricInfo can be challenging, but returning 0 for all values is a valid option at least initially. Probably the trickiest part is writing the device initialisation and making sure that you allocate/deallocate structures in the correct places -- here the X11 template can be particularly useful. There are a couple of examples of add-on devices for R, so the source code for these (particularly the stuff for initialising the device) might be useful; see the gtkDevice package and the RSvgDevice package (both on CRAN). There is a document describing a reorganisation of R's graphics code (started a couple of years ago, but still ongoing -- see below) at http://www.stat.auckland.ac.nz/~paul/R/graphicsChanges.html Some of this is relevant to graphics device structures and includes a section on what should happen when a device is started and when it is killed. Note that my current plan is to make some changes to this stuff in the near future (e.g., the graphical primitive functions dev_line, etc will be getting a graphical-parameter-structure rather than individual graphical parameters col, lwd, ...), so if you go ahead with anything, please keep in touch so that I can let you know when these changes (are about to) happen. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/