Re: Re: Rotable Graphics and ViewPoint
- To: mathgroup at smc.vnet.net
- Subject: [mg78633] Re: [mg78501] Re: Rotable Graphics and ViewPoint
- From: Selwyn Hollis <sh2.7183 at earthlink.net>
- Date: Thu, 5 Jul 2007 05:52:52 -0400 (EDT)
- References: <f67mco$2vu$1@smc.vnet.net> <f6alrr$hpg$1@smc.vnet.net> <200707030929.FAA18224@smc.vnet.net>
Helen, Here's a button that pastes ViewPoint and ViewVertical values into the input cell. Just select the entire cell group that contains the input cell and resulting graphic, and click the button. Perhaps it will be a reasonably convenient solution, once put on a palette that your students can access. Button["Get 3D ViewPoint", Module[{vops, vp, vv, vpstr, vvstr, a, b, c, nb = InputNotebook[]}, If[MatchQ[NotebookRead[nb], Cell[CellGroupData[{Cell[___], Cell[BoxData[Graphics3DBox[___]], ___]}, _]] ], SelectionMove[nb, After, CellContents]; SelectionMove[nb, All, CellContents]; vops = {ViewPoint, ViewVertical} /. Cases[NotebookRead[nb], _Rule]; {vp, vv} = vops; If[Not[VectorQ[vp]], vp = {1.3, -2.4, 2}]; If[Not[VectorQ[vv]], vv = {0, 0, 1}]; SelectionMove[nb, Previous, Cell]; SetOptions[NotebookSelection[nb], ShowCursorTracker -> False]; NotebookWrite[nb, NotebookRead[nb] //. { RowBox[{a___, ",", RowBox[{"ViewPoint", ___}], c___}] -> RowBox[{a, c}], RowBox[{a___, ",", RowBox[{"ViewVertical", ___}], c___}] -> RowBox[{a, c}]}]; SelectionMove[nb, Previous, CellContents]; SelectionMove[nb, After, CellContents] ; SelectionMove[nb, Previous, Character] ; vpstr = StringReplace[ "," <> If[VectorQ[vp], ToString[ViewPoint -> vp], ""], {" " -> "", "->" -> "=E2=86=92"}]; vvstr = StringReplace[ If[VectorQ[vv], "," <> ToString[ViewVertical -> vv], ""], {" " -= > "", "->" -> "=E2=86=92"}]; NotebookWrite[nb, vpstr, After]; NotebookWrite[nb, vvstr]; SelectionMove[nb, All, Cell]; SetOptions[NotebookSelection[nb], ShowCursorTracker -> Automatic] ] ] ] Regards, Selwyn Hollis On Jul 3, 2007, at 5:29 AM, Helen Read wrote: > Albert wrote: >> Helen Read wrote: >> >>> So here's what I would really like. >>> >>> 1. Re-executing a 3D graphic would return it to the original >>> ViewPoint >>> and ViewVertical settings. >>> >>> 2. An easy way to make a copy of a graphic with the current >>> ViewPoint >>> and ViewVertical settings pasted into the input, sort of like the = >>> way >>> Paste Snapshot works for Manipulate, so that I can delete all output >>> before quitting, come back later and recreate the graphic in the >>> state >>> that I had it. >> >> I don't know if this helps (that is whether or not you would let your >> students do it :-), but have you tried to just copy the Graphics >> in the >> state you want it into the empty brackets of the code below: >> >> {ViewPoint,ViewVertical} /. FullOptions[] >> >> end execute the Cell? Once getting used to being able to use any >> graphics output as input this is rather obvious. Note that you >> even can >> continue to rotate in this input-cell, reevaluate and get the new >> viewpoint/viewvertical settings (which is more fun if you increase = >> the >> graphics size by selecting it and drag the (orange?) frame that >> appears). > > While this works, I'm not sure I'll suggest it to my students. Part of > my reason for wanting an easy way to extract the viewpoint settings is > so that we can delete all the output before saving the file, in > order to > make the files smaller for transferring via e-mail or web. Pasting 3D > graphics into an input cells rather defeats the purpose, unless you = > then > remember to copy/paste the viewpoint info into the original graphic > input (or a copy of it), then delete the input cell into which you > have > pasted the graphic, and finally, delete all the output from the file. > I'm not sure it's worth this much effort. > > We'll deal, one way or another, but I do think it would not be much > trouble for WRI to add an easy way to make a "snapshot" copy after > rotating a 3D graphic that would retain all of the viewpoint settings, > similar to the Paste Snapshot for Manipulate. > >> Of course one could construct a Palette that reads this >> information from >> the currently selected graphics object (there was code for a 2D zoom >> tool which could serve as a start), but that would again mean to >> provide >> code to your students that is not part of mathematica, which I >> remember >> is something that you rather try to avoid... > > Indeed, I would rather avoid providing a palette that they would > have to > install. > > -- > Helen Read > University of Vermont >
- References:
- Re: Rotable Graphics and ViewPoint
- From: Helen Read <hpr@together.net>
- Re: Rotable Graphics and ViewPoint