From: Eric Wait on
I have two figure windows, one with an image with tracking data overlaid and the other with a timeline graph. I have a line on the timeline figure that is dragable and updates the figure with the image. Everything works well until the user drags too fast.

I am not updating the image if the time between calls is not long enough but it still hangs indefinitely when moved too fast.

Is there a better way to check the time between calls than:

Time = 0;

function WindowButtonMotionFcn(src,evnt)
if (Time == 0)
Time = clock;
end

curtime = clock;
a = curtime(6) - Time(6);
if (abs(a) > .25)
%do some stuff here
Time = 0;
end
end

I have timed how long "do some stuff here" takes and never over .2 sec.

Thanks in advance,

E

P.S. Matlab does not give any errors when then happens, but Matlab has to be forced closed to do anything else.
From: Matthew Whitaker on
"Eric Wait" <ericwait(a)uwm.edu.remove> wrote in message <i17nao$nk5$1(a)fred.mathworks.com>...
> I have two figure windows, one with an image with tracking data overlaid and the other with a timeline graph. I have a line on the timeline figure that is dragable and updates the figure with the image. Everything works well until the user drags too fast.
>
> I am not updating the image if the time between calls is not long enough but it still hangs indefinitely when moved too fast.
>
> Is there a better way to check the time between calls than:
>
> Time = 0;
>
> function WindowButtonMotionFcn(src,evnt)
> if (Time == 0)
> Time = clock;
> end
>
> curtime = clock;
> a = curtime(6) - Time(6);
> if (abs(a) > .25)
> %do some stuff here
> Time = 0;
> end
> end
>
> I have timed how long "do some stuff here" takes and never over .2 sec.
>
> Thanks in advance,
>
> E
>
> P.S. Matlab does not give any errors when then happens, but Matlab has to be forced closed to do anything else.

A couple of things to try
1) After the 'do some things' are you calling drawnow so that the graphics queue gets flushed?

2) A simpler programming pattern to what you are doing might be:

> beingUpdated = false;
>
> function WindowButtonMotionFcn(src,evnt)
> if ~beingUpdated
beingUpdated = true;
> %do some stuff here
> drawnow;
beingUpdated = false;
> end
> end

Hope this helps
Matt W
From: Walter Roberson on
Eric Wait wrote:
> I have two figure windows, one with an image with tracking data overlaid
> and the other with a timeline graph. I have a line on the timeline
> figure that is dragable and updates the figure with the image.
> Everything works well until the user drags too fast.
>
> I am not updating the image if the time between calls is not long enough
> but it still hangs indefinitely when moved too fast.
> Is there a better way to check the time between calls than:
>
> Time = 0;
>
> function WindowButtonMotionFcn(src,evnt)
> if (Time == 0)
> Time = clock;
> end
>
> curtime = clock;
> a = curtime(6) - Time(6);
> if (abs(a) > .25)
> %do some stuff here
> Time = 0;
> end
> end
> I have timed how long "do some stuff here" takes and never over .2 sec.

Why do you reset Time to 0 instead of setting it to curtime ? Not that I think
that would solve your problem, but by resetting it to 0 you miss the next
update no matter how much later it is.
From: Steven Lord on

"Eric Wait" <ericwait(a)uwm.edu.remove> wrote in message
news:i17nao$nk5$1(a)fred.mathworks.com...
>I have two figure windows, one with an image with tracking data overlaid
>and the other with a timeline graph. I have a line on the timeline figure
>that is dragable and updates the figure with the image. Everything works
>well until the user drags too fast.
>
> I am not updating the image if the time between calls is not long enough
> but it still hangs indefinitely when moved too fast.
> Is there a better way to check the time between calls than:

Try setting the BusyAction and Interruptible properties of the figure:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html#BusyAction

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Eric Wait on
Thanks for all the help/suggestion.

To answers some of your questions,
--Yes, draw now was being called in the do stuff here section. However, MATLAB was hanging even with that code commented out.

--Time is set to 0 because I am using it to hold the time since the last "fresh" call was made. Trying to limit the number of calls that are allowed to execute.

The solution consisted of both my convoluted timer and setting the BusyAction to cancel and turning interuptable off while in the WindowButtonMotionFcn. Thanks Steven Lord.

It is working now, it's a little choppy but at least it doesn't hang.

Thanks again,
E