Re: Basic Locator question in a Manipulate...
- To: mathgroup at smc.vnet.net
- Subject: [mg83330] Re: Basic Locator question in a Manipulate...
- From: Albert <awnl at arcor.net>
- Date: Sat, 17 Nov 2007 05:32:59 -0500 (EST)
- References: <fhjsc2$517$1@smc.vnet.net>
David Reiss wrote:
> I have an example like the following:
>
> Manipulate[Column[
> {Graphics[Locator[Dynamic[p]], PlotRange -> 2],
> Graphics[Locator[Dynamic[q]], PlotRange -> 2],
> Dynamic[p],
> Dynamic[q]}],
> {{p, {0.5, 0.5}}, Locator},
> {{q, {0.5, 0.5}}, Locator}]
>
> I find that there actually are 3 Locators or, more precisely, 3
> locator cross hairs: one which corresponds to the first locator (for
> p) and appears in the top graphic, and two others that are linked and
> correspond to the second parameter, q. In the latter case one is in
> the top graphic and the other in the corresponding position in the
> bottom graphic.
>
> Actually, the first (single) Locator may actually be two overlaid that
> move in concert. The color of that one is a darker Grey than the
> other two...
>
> So, is there something very basic that I am not understanding here?
Yes, you don't need explicit Locators within the graphics at all when
using Manipulate, the following will already have two of them in the
first graphic:
Manipulate[Column[
{Graphics[{}, PlotRange -> 2],
Graphics[{}, PlotRange -> 2],
Dynamic[p],
Dynamic[q]}],
{{p, {0.5, 0.5}}, Locator},
{{q, {0.5, 0.5}}, Locator}]
If you want one in the upper and one in the lower graphics, I don't know
how to do that with Manipulate and would recommend to build something
from scratch with DynamicModule and LocatorPane. It looks as if
Manipulate would automatically position all locators in the first
graphics, but if this is true and can be controlled, I would need to
check the docs, so probably it makes more sense if you have a look
yourself...
This lets you control the points in the lower graphics with the locators
in the upper graphics:
Manipulate[Column[
{Graphics[{}, PlotRange -> 2],
Graphics[{Point[p],Point[q]}, PlotRange -> 2],
Dynamic[p],
Dynamic[q]}],
{{p, {0.5, 0.5}}, Locator},
{{q, {0.5, 0.5}}, Locator}]
hth,
albert