MathGroup Archive 2010

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

Search the Archive

Re: Enabled in Manipulate ...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112617] Re: Enabled in Manipulate ...
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Thu, 23 Sep 2010 04:21:46 -0400 (EDT)
  • References: <i79htb$ogm$1@smc.vnet.net>

Hi Dave,

This is probably caused by the value of the Enabled option being
evaluated at the start of the Manipulate only. Its value is therefore
not dynamically updated. Somewhat to my surprise, I discovered that
using Dynamic it works as desired. I also included the TrackedSymbols
option so that processor usage doesn't go to 100%.

Manipulate[
 p1 = Switch[l, 1, True, _, False];
 p2 = Switch[l, 2, True, _, False];
 poly1 = {{-2, 1}, {-2, 0}, Sort@u, {2, 0}, {2, 1}};
 poly2 = {{-2, -1}, {-2, 0}, Sort@u, {2, 0}, {2, -1}};
 poly3 = {{-2, -2}, {-2, -1}, {2, -1}, {2, -2}};
 poly1 = {Directive[Red], Polygon[FlattenAt[poly1, 3]]};
 poly2 = {Directive[Lighter@Gray], Polygon[FlattenAt[poly2, 3]]};
 poly3 = {Directive[Blue], Polygon[poly3]};
 Graphics[{poly1, poly2, poly3}, PlotRange -> {All, {-2, 1}},
  Frame -> True, PlotLabel -> l],
 {{l, 1, "Lyr"}, {1, 2}},
 {{u, {{-1, 0}, {1, 0}}}, Locator, LocatorAutoCreate -> {2, 10},
  Enabled -> Dynamic[p1]},
 TrackedSymbols -> {l, u}
 ]

TrackedSymbols -> True would also work.

Cheers -- Sjoerd


On Sep 21, 8:04 am, annetts729 <annetts... at gmail.com> wrote:
> Hi,
>
> I have the following Manipulate[] block.
>
> Manipulate[
>  p1 = Switch[l, 1, True, _, False];
>  p2 = Switch[l, 2, True, _, False];
>  poly1 = {{-2, 1}, {-2, 0}, Sort@u, {2, 0}, {2, 1}};
>  poly2 = {{-2, -1}, {-2, 0}, Sort@u, {2, 0}, {2, -1}};
>  poly3 = {{-2, -2}, {-2, -1}, {2, -1}, {2, -2}};
>  poly1 = {Directive[Red], Polygon[FlattenAt[poly1, 3]]};
>  poly2 = {Directive[Lighter@Gray], Polygon[FlattenAt[poly2, 3]]};
>  poly3 = {Directive[Blue], Polygon[poly3]};
>  Graphics[{poly1, poly2, poly3}, PlotRange -> {All, {-2, 1}},
>   Frame -> True, PlotLabel -> l],
>  {{u, {{-1, 0}, {1, 0}}}, Locator, LocatorAutoCreate -> {2, 10},
>   Enabled -> p1},
>  {{l, 1, "Lyr"}, {1, 2}}]
>
> By moving & adding locators, I can change the boundary between the red
> & gray polygons.
>
> My reading of Enabled says that when I set the button to "2", the
> locators shouldn't work.
>
> But they do, at least under 7.0.1 (Windows).
>
> Assuming (!) my reading is correct, how do I render these locators
> inactive?
>
> It's reasonably obvious that I'd like to put another Locator[] between
> the gray & blue rectangles, and in so doing, be able to change the
> nature of the boundary of the central body, but it seems impossible to
> do this.  Is it possible to have multiple Locators on a Manipulate?
>
> Many thanks,
>
> Dave.



  • Prev by Date: Re: How to localize a symbol when using Manipulate?
  • Next by Date: Re: How to interpret this integral?
  • Previous by thread: Enabled in Manipulate ...
  • Next by thread: getting all interesting sections of 7-d simplex