MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Zoom

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76612] Zoom
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 24 May 2007 06:22:55 -0400 (EDT)


Hello,

unfortunately there is still no Zoom function for 2D graphics in version 

6. Well, I tried to roll my own, here is it, please try it out.

It still needs some improvements. I did not manage to localize the 

dynamic variables p1,p2. As soon as I enclose them in a a Module or 

DynamicModule block, they are no more active. Has anybody an idea?

Further, there is a white highlighted region that disapears as soon as 

the cursor move over it. How to eliminate this region?

The function takes as input either a graphics object or the output from 

NotebookRead. The idea is to create a button by e.g.:

Button["Zoom",Zoom2D[NotebookRead[SelectedNotebook[]]]]

You may e.g. put this button in a palette.

Now, select some 2D graphics like e.g. the output of Plot and click the 

button with the graphics still selected. A new document is now created 

showing two graphics. The first one is the original graphics with two 

movable locators, the second one corresponds to the rectangle defined by 

the two locators in the first pane.

Here is the code:



Zoom2D[g00_]:=

Module[{g,g1,opts},

p1={0,0};p2={1,1};

g=If[Head[g00]=!=Graphics,Replace[g00,head_[x1_,x2___]:>Graphics[{x1},{x2}]]/.{NCache[x_,_]->x,LineBox->Line},g00];



{p1,p2}=FullOptions[g,PlotRange]//Transpose;

opts=FullOptions[g];

Print[{p1,p2}];

g1=Show[g,PlotRange->Dynamic[Transpose[{p1,p2}]],Frame->True ];



CreateDocument[{

LocatorPane[Dynamic[{p1,p2}],g],

g1,

Button["Close",NotebookClose[SelectedNotebook []]]

},WindowSelected->True];



]



have fun, Daniel




  • Prev by Date: Re: Mathematica 6.0 easier for me ... (small review)
  • Next by Date: Re: Re: Dialogs and inheritance
  • Previous by thread: Re: Mathematica 6.0 easier for me ... (small review)
  • Next by thread: Grid