Message Boards Message Boards

0
|
4881 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How create a list of interactive locators?

Posted 11 years ago
I can create a list of locators easy enough, but how can I do this using Dynamic[ ] so I can then index in and read the point value after moving one of the locators?
I am having trouble with the syntax.

i.e., I want a list of
Locator[Dynamic[p]]
POSTED BY: William Stewart
4 Replies
Are you looking for something different than what is shown on the help pages?

http://reference.wolfram.com/mathematica/ref/LocatorPane.html

There is an example there showing 3 points and printing the coordinate of the point as you move it. It is half way down the page :
DynamicModule[{pt = {{1, 1}/2, {-1, 1}/2, {1, -1}/2}}, {LocatorPane[
   Dynamic[pt], Graphics[{Gray, Disk[]}]], Dynamic[pt]}]
POSTED BY: Nasser M. Abbasi
I think Nasser provided a good solution for a start. If yo need something else you should clarify it in you original question - especially you should post the code of what you have tried. Otherwise it is hard for other people to see where the problem is at. To read the point values you could do something like this:
Manipulate[
Graphics[Style[Text[#, # + .3], 12, Red] & /@ pt,
  PlotRange -> 2], {{pt, {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {1, -1}}},
  Locator, LocatorAutoCreate -> True}]

POSTED BY: Vitaliy Kaurov
I already have a lot of graphics and even some individual Locators so I was hoping just to be able a list of Locators straight into the Graphics statement. I don't really understand what a LocatorPane is for and when you have to use it. Any words of wisdom greatfully received!
POSTED BY: William Stewart
Thank-you both for your attention to my problem.

The following code snippet isolates the issue:

ppList := Table[{i/4, i/4}, {i, 4}];

locList = Table[ Locator[    ppList [[ i ]]    ] , {i, 4}];

   Graphics [ locList ]


(* should show 4 locators : now move the one in the lower left  then *)

locList[[1]]


(* still shows {1/4,1/4} as location *)
I have tried putting a Dynamic[] in at various points but either this was an error or did not achieve the goal of showing the new location.

I am aware that both the solns given so far would achieve the desired result for this example, but  I need to create the locators conditionally, read programatically altered locations and also reset those locations  programatically. So, if possible would like to work with the simple structure above.  I have everything working fine if I code each locator individually but am getting a bit fed up cutting and pasting code now I'm on my 8th Locator!!

The problem maybe relates to that of, in general, changing the value of an element in a list??
POSTED BY: William Stewart
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract