[racket] plot3d & canvas question

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Feb 6 21:55:44 EST 2012

Yes, because a plot is a snip%. It's easy to do something quick and dirty.

But doing it right takes more than just a few object creations and 
method calls. You also need to disable edit operations, hide the caret, 
etc., without disabling the editor itself. If it's disabled entirely, it 
won't receive mouse events.

So it's... easy, but not entirely straightforward? That's probably the 
best description, and also why it might be a good idea for me to add 
`plot-canvas' and `plot3d-canvas' functions, or a plot-canvas% class.

Neil ⊥

On 02/06/2012 06:48 PM, Robby Findler wrote:
> Just to be sure I'm understanding: you can put this into any GUI where
> you can put an editor-canvas% object, right? So it should just be a
> couple of object creations and method calls to get this going?
>
> Robby
>
> On Mon, Feb 6, 2012 at 5:41 PM, Neil Toronto<neil.toronto at gmail.com>  wrote:
>> On 02/06/2012 04:14 AM, Nikolaus Klepp wrote:
>>>
>>> Hi!
>>>
>>> When I create a 3D plot in DrRacket, I can rotate the plot by clicking on
>>> it
>>> and dragging the mouse. Now I would like to embed the same plot with the
>>> same
>>> ability in my GUI. Is there an easy way to do that?
>>
>>
>> Great idea!
>>
>> Unfortunately, I didn't think of making an easy way to do it. Fortunately,
>> `plot' already does something similar: if you set (plot-new-window? #t),
>> plots appear on a canvas in a new frame. You just need to do that without
>> the frame.
>>
>> The relevant code is in "<racket-dir>/collects/plot/common/gui.rkt",
>> specifically the `make-snip-frame' function.
>>
>> The basic idea is to make a canvas containing a single read-only-text% that
>> is initially writable, insert the snip (which you get from `plot-snip' or
>> `plot3d-snip'), and then set the text to read-only. If you want to change
>> the plot, set the text writable, delete the snip, insert the new one, and
>> set it read-only again.
>>
>> If you don't mind my asking, what are you plotting in your gui?
>>
>> Neil ⊥
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users


Posted on the users mailing list.