Message Boards Message Boards

4 Replies
2 Total Likes
View groups...
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
POSTED BY: William Stewart
4 Replies
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 *)


(* 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
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:
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
Are you looking for something different than what is shown on the help pages?

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 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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract