[racket] plot pixel position

From: John Clements (clements at brinckerhoff.org)
Date: Tue Apr 15 16:48:02 EDT 2014

On Apr 15, 2014, at 11:59 AM, David Vanderson <david.vanderson at gmail.com> wrote:

> Sorry for the delay.  I hacked together something that lets you drag points around on a plot (attached).
> 
> Is there a way to access area's plot->dc?  For this example I wanted to ask if the mouse was within 2 pixels of any point.
> 
> When dragging the point around on the plot, it looks like I'm seeing multiple repaints queueing up.  It's especially bad on Linux where I can move the mouse a bunch and then watch all the repaints happen over the next few seconds.  I'm trying to figure out if this can be improved.
> 
> Question for GUI experts: Is there a reason why multiple repaint requests in the queue should not be coalesced into a single paint?

I had this problem recently, and it turned out that the problem was that I was calling “printf” as part of the handling of the redraw request. Removing this allowed coalescing to occur.

Probably unrelated, but maybe worth a try.

John Clements

> 
> Thanks,
> Dave
> 
> On 04/01/2014 05:41 PM, Neil Toronto wrote:
>> On 04/01/2014 02:17 PM, David Vanderson wrote:
>>> Plot is fantastic - thanks so much!
>>> 
>>> Is there a way to hook into the interactive features of plot so, for
>>> instance, the user could click to add data or drag data points around?
>>> 
>>> I'm using plot/dc to draw onto a canvas, and I'd be more than happy just
>>> to be able to ask a plot to translate a pixel position to the
>>> corresponding axes' positions.  I know that plot does this for the
>>> zooming feature, but is there a way for external code to do it?
>> 
>> There's not an easy way right now.
>> 
>> If you don't mind copying code, you can take some from `plot/dc' here:
>> 
>>    pkgs/plot-pkgs/plot-lib/plot/private/no-gui/plot2d.rkt
>> 
>> The main thing you need is access to the `area' object, which has a public `dc->plot' method that translates device context coordinates into plot coordinates. I'm sorry it's not easier. :/
>> 
>> It will be someday, I promise! I've lately decided that "2D and 3D games that use Plot to render scenes" will be two of my main test cases. Games are the most interactive uses I can think of, and they need to be fast, so that should cover pretty much everyone's interactivity needs.
>> 
>> Neil ⊥
>> 
>> 
> 
> <graph_ui.rkt>____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.