MathGroup Archive 2009

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

Search the Archive

Re: Manipulate[] eval hold until all controls are changed?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101708] Re: [mg101667] Manipulate[] eval hold until all controls are changed?
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 15 Jul 2009 07:07:24 -0400 (EDT)
  • References: <10357881.1247564194896.JavaMail.root@n11>

Roger,

Maybe someone can show how to adjust a Manipulate statement to do what you
want. But I find this a natural case of writing a custom dynamic. With a
custom dynamic you can easily control, through the second argument of
Dynamic, precisely what each control does and you can precisely control what
display items are dynamically updated. You also have much more control of
the layout of the entire display.

Here is a custom dynamic presentation along the lines you suggest. The
DensityPlot takes a longer time so it is only updated when the Run button is
pressed. The advisory message, however, is updated each time a parameter is
changed.

DynamicModule[
 {a = 1, b = 0, c = 0, current = True, f, plotf, plot},
 
 f[a_, b_, c_][x_, y_] := a Sin[x y] + b Cos[x] + c Cos[y];
 plotf[a_, b_, c_] := 
  DensityPlot[f[a, b, c][x, y], {x, 0, 4 \[Pi]}, {y, 0, 4 \[Pi]},
   ColorFunction -> ColorData["ThermometerColors"],
   MaxRecursion -> 4,
   ImageMargins -> 20,
   ImageSize -> 300];
 plot = plotf[a, b, c];
 
 Column[{
   (* PopUp and Run Controls *)
   Row[{Spacer[20], "a", Spacer[37], "b", Spacer[35], "c"}],
   Row[
    {PopupMenu[
      Dynamic[a, (a = #; current = False) &], {0, 1, 2, 3, 4}],
     PopupMenu[
      Dynamic[b, (b = #; current = False) &], {0, 1, 2, 3, 4}],
     PopupMenu[
      Dynamic[c, (c = #; current = False) &], {0, 1, 2, 3, 4}],
     (* Update the plot *)
     Button["Run", plot = plotf[a, b, c]; current = True]
     }] (* Popups *),
   (* Indicator that the plot is current *)
   Dynamic@
    If[current, "Plot is current", Style["Plot is not current", Red]],
   (* The plot *)
   Dynamic@plot
   }](* Main Column *)
 ]

If you look into the PlaneGeometry section of your copy of Presentations you
will find a rather extensive tutorial on writing custom dynamic
presentations.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  



From: divisor [mailto:congruentialuminaire at yahoo.com] 

Hello MathGroup:

I have 3 drop-down list boxes to set parameters in my Manipulate[]
application. After the user changes any one of these, Manipulate
evaluates the first argument. It is a semi-long running application,
so it you want to change 3, the usability is compromised.

Is it possible to make Manipulate[] delay evaluation until all of
these boxes have their value set?

I assume I need some other control to tell Manipulate[] to "do it
now".

Any assistance with this is greatly appreciated.

Regards..

Roger Williams
Franklin Laboratory




  • Prev by Date: Re: Add syntax highlighting to own command
  • Next by Date: Re: CityData seems to be dead.
  • Previous by thread: Manipulate[] eval hold until all controls are changed?
  • Next by thread: Re: Manipulate[] eval hold until all controls are changed?