[racket] plot3d & canvas question

From: Neil Toronto (neil.toronto at gmail.com)
Date: Mon Feb 6 18:41:08 EST 2012

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 ⊥

Posted on the users mailing list.