Re: callback problem: figure crashes
- From: "per isakson" <poi3@xxxxxxxxxxxx>
- Date: Wed, 7 Dec 2005 12:56:57 -0500
Jörg Dittmar wrote:
>
>
> Hi,
> I have the following problem:
> I have a figure that contains two axes, one on the left side
> and one on the right. In the left axes I display a surface
> with pcolor, and in the right axes I display a curve depending
> on the position of the mouse cursor in the left axes. The
> points of the curves for the different mouse positions are
> stored in a matrix. The curve in the right axes should only
> be updated (i.e. redrawn) when I click in the left axes
> or when I click in the left axes, hold the mouse button down and
> move the mouse pointer (in the latter case the curve should
> be updated continously). For this, I use the WindowButtonDownFcn,
> WindowButtonUpFcn and WindowButtonMotionFcn callback properties
> of the figure handle. They look basically as follows:
>
> cbWindowButtonDownFcn(src,evt)
> isDown = true;
> - get actual cursor position
> - draw the curve on the right axes corresponding
> mouse cursor position
>
>
> cbWindowButtonUpFcn(src,evt)
> isDown = false;
>
> cbWindowButtonMotionFcn(src,evt)
> if isDown==true
> - get actual cursor position
> - draw the curve on the right axes corresponding
> mouse cursor position
> end
>
> isDown is a global variable that I use to indicate if the mouse
> button is pressed or not. So every time the WindowButtonDown
> callback is executed the plot in the right axes is updated, and
> if I move the mouse around the plot in the right axes is updated
> only while the mouse button is pressed and until it is released.
>
> However, if I move and click very fast in the left axes, after a
> while Matlab crashes. (Actually it doesn't crash completely, but
> the figure crashes somehow. I can enter a command at the Matlab
> prompt, but it doesn't get executed, and when I try to interrupt
> this command using ctrl-c an error message occurs saying something
> like "error while executing callback". Then I have to restart
> Matlab.)
> This occurs when I use the default values for the figure properties
> 'interruptible' ('on') and 'busyaction' ('queue'). It seems that
> because of my fast clicking and/or mouse movement the events
> that cause the execution of my callbacks occur faster than these
> callbacks get executed and maybe the event queue gets too long.
> So I tried interruptible=off and busyaction=cancel. Then Matlab
> doesn't crash but often the callback WindowButtonUp doesn't get
> executed and my isDown flag doesn't work, i.e. it remains
> true even if I have released the mouse button.
>
> So what I need is either
> - prevent Matlab from crashing using interruptible=on and
> busyaction=queue or
> - a direct way to check in cbWindowButtonMotionFcn whether the
> mouse
> button is pressed or not when this callback is executed.
>
> Any help would be appreciated.
>
> Joerg
>
> --
> to mail me, remove the "_nospam4me"
>
Should work. How exactly do you update the curve?
/ per
.
- Follow-Ups:
- Re: callback problem: figure crashes
- From: Jörg Dittmar
- Re: callback problem: figure crashes
- References:
- callback problem: figure crashes
- From: Jörg Dittmar
- callback problem: figure crashes
- Prev by Date: How to display a GUI in Fullsize?
- Next by Date: Re: spaces in variable names
- Previous by thread: callback problem: figure crashes
- Next by thread: Re: callback problem: figure crashes
- Index(es):
Relevant Pages
|