MathGroup Archive 2007

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

Search the Archive

Re: design question, how to have a set of manipulate controls, but

  • To: mathgroup at
  • Subject: [mg81090] Re: design question, how to have a set of manipulate controls, but
  • From: dh <dh at>
  • Date: Wed, 12 Sep 2007 03:44:19 -0400 (EDT)
  • References: <fc5n1u$qt7$>

HI Nasser,

you could e.g. temporarlily save a copy of the separate graphics as well 

as a flag, indicating if the graphics has changed. If it is time to 

redraw, the flag is questioned and if it has not changed, the old 

graphic is used instead of recalculating it. Here is an example drawing 

2 lines with adjustable slopes.




       If[tx1===x1,g1,g1=Plot[x1 t,{t,-1,1},PlotStyle->Blue]],

       If[tx2===x2,g2,g2=Plot[x2 t,{t,-1,1},PlotStyle->Red]]



hope this helps, Daniel

Nasser Abbasi wrote:

> hi;


> There is a design problem I am trying to solve. Currently with Manipulate, I 

> use the following pattern:


> process[p1_,p2_,......]:=Module[{},...Plot[],...Plot[],....]

> Manipulate[process[p1,p2,....],  {p1,0,1},{p2,0,1},.....]


> So that when I update p1 or p2 or p3,.... then process[] is called with 

> updated p's and it does its work, and makes plots, and life is good.


> The problem with this approach, is that now process[], everytime it is 

> called, will go through all the processing again, and makes all the plots 

> again with the new set of p's it is called with, even though may be only ONE 

> of those p's has changed, and this change may be only will affect one plot 

> inside it, or more generally will affect only part of over all computation, 

> and there would have been no need to repeat everything all over again, and 

> update all the plots again. But poor process[] does not know this when it is 

> called ofcourse.


> So how to solve this? What would be really nice is the following:


> If I can figure how to make each control have associated with it its own 

> method (but still have all the controls inside one manipulate so that they 

> are grouped together.) If this is possible, then when only one control 

> changes, then this specific control method will run, and it will update the 

> specific plot, or plots, it only cares about.


> This will require that each control method will have access to all the 

> 'other' input control variables as well.


> So, I am thinking of this set up:


> p1Method[p1_,p2_,......]:=Module[{}, Plot[]]

> p2Method[p1_,p2_,......]:=Module[{},......Plot[],....]

> p3Method[p1_,p2_,......]:=Module[{},..Plot[]....]

> ...


> Manipulate[Null,

> {{p1,0,1},  p1Method[p1,p2,....]},

> {{p2,0,1},  p2Method[p1,p2,....]},

> {{p3,0,1},  p3Method[p1,p2,....]},

> ....


> Ofcourse, I can already solve this problem, by using a separate manipulate 

> for separate control like this:


> Manipulate[p1Method[p1]}, {p1,0,1}]

> Manipulate[p2Method[p2]}, {p2,0,1}]

> Manipulate[p3Method[p3]}, {p3,0,1}]

> ....

> and somehow have each other be able to access the other parameters, my be 

> make them global or something (not good solution)



> so you might ask, what is the problem then?


> Well, I wanted to have one common display area where all method do the 

> display into. If I use separate manipulate for separate control, then each 

> display will go into its own area, and I will also not have the controls 

> themselves in one area.


> For example, I can use Grid, and use Manipulate inside each grid, like this:


> foo[n_] := Plot[Sin[n*x], {x, -Pi, Pi}]

> foo2[n_] := Plot[Cos[n*x], {x, -Pi, Pi}]

> Grid[{{Manipulate[foo[n], {n, 1, 10}], Manipulate[foo2[n], {n, 1, 10}]}}]


> But you see now the controls are not close to each others, and the display 

> area is not 'common'.


> I want to have one display area, controls in one place, but separate method 

> for each control, and shared parameters.


> I am sure there is a way to do, I hope so.


> I hope I explained this problem.


> thanks,

> Nasser




  • Prev by Date: Re: Problem with inverse laplace transform
  • Next by Date: TrackedSymbols:>Manipulate ???
  • Previous by thread: Re: Problem with inverse laplace transform (FIX)
  • Next by thread: TrackedSymbols:>Manipulate ???