[racket] plot3d & canvas question

From: Neil Toronto (neil.toronto at gmail.com)
Date: Wed Feb 8 12:59:49 EST 2012

On 02/08/2012 09:42 AM, Neil Toronto wrote:
> On 02/07/2012 03:56 PM, Nikolaus Klepp wrote:
>> Am Dienstag, 7. Februar 2012 schrieb Neil Toronto:
>>> 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.
>> Hi!
>> Ok, that worked quite straight forward, thank you.
>> Now my next problem is how to change the size of the sniplet...
> Unfortunately, you can't. You'll have to delete the old one from the
> read-only-text% and insert a new one.
> If this is for resizing, you have another problem: creating a new plot
> will reset the viewing angles. I was going to describe how to save and
> restore them, but it would require copying much larger sections of
> private `plot' code. You're better off letting the viewing angles reset
> for now, and waiting for 3d-plot-canvas%, which I'll start on tonight.

Well, that was dumb. 3d-plot-snip% has the fields `angle' and 
`altitude', which you can get the values of using `get-field'.

I'm still making 3d-plot-canvas% and 2d-plot-canvas%, though. :)

Be aware that, if you get these fields from a snip that is evaluated in 
the REPL, you'll get old values because the REPL displays *copies* of 
snips. But the values you get from a snip that you insert into a text% 
will be current.

Neil ⊥

Posted on the users mailing list.