Re: Issue with Synchronization between Manipulate and functions called
- To: mathgroup at smc.vnet.net
- Subject: [mg79001] Re: Issue with Synchronization between Manipulate and functions called
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sun, 15 Jul 2007 01:10:17 -0400 (EDT)
- Organization: Arcor
- References: <f79rj1$48f$1@smc.vnet.net>
Hi, Manipulate[Dynamic@ process[a], {a, 1, 10, 1}] may help ... Regards Jens Nasser Abbasi wrote: > (Mathematica 6.0, Windows XP, OLD PC) > > Manipulate[expr,{n,1,10}] is supposed to evaluate expr for each value > of 'n'. > > There seems to be a synchronization problem between Manipulate[] and > completing evaluation of expr, when there is a Graphics inside expr. > > I have a simple example below, where expr is a function, which > displays 'n'. > > ---- CODE ----------------- > > process[a_] := Graphics[ {Text[StringJoin["a=", ToString[a]]]}, > ImageSize -> {40} ] > > Manipulate[ process[a], {a, 1, 10, 1} ] > > ---- END CODE ----------------------- > > If you run the above, and click on 'play' and look at the display > inside the Graphics window, you will see that not every integer is > being printed. i.e. NOT each 'n' is being displayed. > > Some values of 'n' are skipped. What is being displayed is something > like 2,4,6... or 1,2,3,5,6,... instead of 1,2,3,4,5,.... i.e. some numbers > do NOT get displayed, while Manipulate itself is of course is > incrementing 'n' correctly. This ofcourse might depend on speed of > the computer itself and other factors, but on my slow PC, I see this > is clearly happening. > > I think this happens because Manipulate is calling expr before the > previous Graphics[] which displays the text is fully flushed out to > display within the function expr. > > Hence, expr returns back, and Manipulate now calls it with n+1 value, > before the previous n value is yet displayed, and so n+1 overwrites > earlier 'n' in some internal Graphics buffer, and what I see is n+1 > and 'n' is missing. > > I need a way to make sure Graphics[] is completed inside expr before > I return back from the function, back to Manipulate, to prevent this > problem. > > To confirm this, when I 'slow' down Manipulate using the 'slow' > control, now I see that each number is being displayed ok. So this > clearly is telling me there is a buffer overrun problem. > > I need to study the documentation more, I just started using > Manipulate, but I noticed this problem. > > Do you think I am interpreting this ok, or am I doing something silly > elsewhere? > > thank you > Nasser > >