MathGroup Archive 2007

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

Search the Archive

RE: : 6.0 Get Graphics Coordinates...


Of course there was some bug in my GetGraphicsCoordinates palette yesterday.
The relation between the Mathematica ClipboardNotebook[] (not present in the
Mathematica 6 Documentation Center!) and the Windows system clipboard is a
bit complicated, and they sometimes can get out of sync. It seems to me as
if pasting between cells uses the Mathematic Clipboard, while pasting into
the inside of Input cells uses the Windows clipboard. If the clipboards are
out-of-sync, then the result of pasting depends on where you paste. I have
corrected the code to improve the behavior. I have also seen some occasional
errors and instability in the Mathematica 6 behavior, but someone else has
the responsibility for such problems.
You have to move the palette to be able to save it. 
There seems to be some problems also with the palette in the KDE windowing
system. In the new version of the palette, the "Copy locator positions" also
sets the $LocatorPositions variable to the list of locator positions. Then
hopefully that property can be used, even if the copying mechanism does not
work.
As Robert Novak pointed out yesterday, there are some 5.2 graphics left in
the documentation, and there the old GetGraphicsCoordinates mechanism still
works. It also seem to work with bitmap images. But the coordinates you
obtain are not necessarily connected to the coordinate system inside the
graph.

A benefit of this palette is that you might operate on already generated
graphics. You do not have to regenerate them. That is a benefit of the
Mathematica 6 system also: the generated graphics are stored without the
memory losses associated to the PostScript conversion. 

Here is the new code:

CreatePalette[
  Column[{Button["Add LocatorPane", 
     SelectionMove[InputNotebook[], All, CellContents];
     NotebookWrite[
      InputNotebook[], (DynamicModuleBox[{$CellContext`pts$$ = {{0., 
              0.}}}, LocatorPaneBox[Dynamic[$CellContext`pts$$], #, 
           LocatorAutoCreate -> True], DynamicModuleValues :> {}]) &@
       NotebookRead[InputNotebook[]]]], 
    "Use Alt+Click to add or delete locators!", 
    Button["Copy locator positions", 
     SelectionMove[InputNotebook[], All, Cell]; 
     FrontEndExecute[FrontEndToken["Copy"]];
     SelectionMove[InputNotebook[], All, CellContents];
     Module[{b}, b = NotebookRead[InputNotebook[]];
      If[And[Length[b] >= 3, MatchQ[b[[2]], _LocatorPaneBox]], 
       b = b[[1, 1]]; $LocatorPositions = b;
       SelectionMove[ClipboardNotebook[], All, Notebook];
       NotebookWrite[ClipboardNotebook[], ToBoxes[b], All];
       SelectionMove[ClipboardNotebook[], All, Notebook]]]], 
    Button["Remove LocatorPane", 
     SelectionMove[InputNotebook[], All, CellContents];
     Module[{b}, b = NotebookRead[InputNotebook[]];
      If[And[Length[b] >= 3, MatchQ[b[[2]], _LocatorPaneBox]], 
       NotebookWrite[InputNotebook[], b[[2, 2]]]]]], 
    Dynamic[MousePosition["Graphics"]]}], 
  WindowTitle -> "Get Graphics Coordinates"];


Suggestions are welcome
Best regards

Ingolf Dahl

> -----Original Message-----
> From: Ingolf Dahl [mailto:ingolf.dahl at telia.com] 
> Sent: den 20 juni 2007 12:20
> To: mathgroup at smc.vnet.net
> Subject: [mg77971] RE: [mg77817] Re: [mg77755] Re: 6.0 Get 
> Graphics Coordinates...
> 
> Here is my suggestion:
> I have created a Matematica-6 palette with three buttons, 
> intended to mimic the GetGraphicsCoordinates from Mathematica 5.
>  
> Use:
> 1. Select a graphics cell and press the "Add LocatorPane" button.
> 2. Press "Alt" and click the mouse to add or delete point 
> ("locators") to the graphics.
> 3. Press the "Copy locator position" to copy a list of the 
> locator coordinates to the Clipboard. 
> 4. Select a graphics cell and phe "Remove LocatorPane" to 
> reset the graphics to initial conditions (if you want to do that) 
> 
> You get the flexibility that it is possible to adjust the 
> position of the locators. It seems necessary to start with 
> one point present. I have chosen to put this point at {0,0}. 
> 
> Best regards
> 
> Ingolf Dahl




  • Prev by Date: Re: Re: Fast interactive graphics
  • Next by Date: Re: Same Limit: OK in 5.2, fails in 6.0; Packages gone in 6.0 ???
  • Previous by thread: Re: RE: Re: Re: 6.0 Get Graphics Coordinates...
  • Next by thread: Re: RE: : 6.0 Get Graphics Coordinates...