Bug 16951 - getGraphicsEvent does not work for cairo; implementation of onIdle handler for animation
Summary: getGraphicsEvent does not work for cairo; implementation of onIdle handler fo...
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.3.*
Hardware: Other Linux
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-06-14 15:24 UTC by Frederick Eaton
Modified: 2017-02-27 00:33 UTC (History)
4 users (show)

See Also:


Attachments
patch to enable Cairo support for getGraphicsEvent, and implement onIdle (10.46 KB, patch)
2016-06-14 15:24 UTC, Frederick Eaton
Details | Diff
example code for onIdle (2.45 KB, text/plain)
2016-11-14 02:38 UTC, Frederick Eaton
Details
Example of an interactive histogram using getGraphicsEvent (926 bytes, text/plain)
2016-11-19 18:08 UTC, Mark O'Connell
Details
Example of an interactive histogram controlling a scatterplot using getGraphicsEvent (1.59 KB, text/plain)
2016-11-19 18:14 UTC, Mark O'Connell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frederick Eaton 2016-06-14 15:24:48 UTC
Created attachment 2105 [details]
patch to enable Cairo support for getGraphicsEvent, and implement onIdle

Here's a patch for a couple of features as discussed recently on the R-devel list (https://stat.ethz.ch/pipermail/r-devel/2016-June/072811.html).

Problem #1, lack of Cairo support in getGraphicsEvent, was fixed in a patch in bug 14364; strangely enough that bug was closed and the patch was never applied. The bug was fixed by generating an error when Cairo is used with getGrahpicsEvent; the reporter's patch would have just made Cairo *work* with getGraphicsEvent...

I solve Problem #2, the ability to use getGraphicsEvent asynchronously, with the suggestion I made in the follow-up to the above message - via the implementation of an "onIdle" handler in the getGraphicsEvent interface.

The changes for Problem #1 were essentially the same as those in the patch of Hugo's bug 14364, but I also updated the documentation to say that Cairo is now supported.

I have combined both sets of changes into a single patch, since the Cairo changes are dwarfed by the onIdle changes. Let me know if it would be helpful to have them separated out.

This is the largest patch I've submitted to R. Whoever applies it may want to delete some of my comments, or let me know if other changes need to be made. Or whatever. I tested it enough to satisfy myself that it works.

Hope everything is well. Thank you. Clicking "submit" now...
Comment 1 Paul Murrell 2016-09-29 01:46:49 UTC
Hi

Would you be able to send some example test code for your #2 fix ?
i.e., some examples of the use of 'onIdle' (along with a description of expected behaviour)

Thanks!

Paul
Comment 2 Frederick Eaton 2016-11-14 02:38:33 UTC
Created attachment 2181 [details]
example code for onIdle

Examples for onIdle code

I sent this to r-devel but also wanted to post it here since Paul asked for it here. I'm not sure if I'm getting Cc'ed when someone comments on this bug so please bear with me.

Thank you.
Comment 3 Mark O'Connell 2016-11-19 18:08:47 UTC
Created attachment 2182 [details]
Example of an interactive histogram using getGraphicsEvent

I've added a simple example to produce an interactive histogram, where we can click on the bars to highlight them (actually just using the horizontal position of the click --doesn't have to be on the bar).
Comment 4 Mark O'Connell 2016-11-19 18:14:03 UTC
Created attachment 2183 [details]
Example of an interactive histogram controlling a scatterplot using getGraphicsEvent

This second example is similar to the first, but uses the interactive histogram to highlight points in a scatterplot on another device. This is slightly hacky because it relies on the device numbers remaining the same.

I don't really have any useful suggestions for unit testing of the interactive graphics functionality, but these examples might be useful for the help files.
Comment 5 Paul Murrell 2017-02-27 00:33:32 UTC
Patch applied in r-devel r72261