Re: callback problem: figure crashes



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
.



Relevant Pages

  • Re: panning a plot with datetick
    ... Daniel Sternberg wrote: ... When I click on an axes, the callback executes. ... verify whether it truly is executing or not. ...
    (comp.soft-sys.matlab)
  • Re: View an image independently when we double click on one of the subplot’s pane.
    ... so test for 'open' and drop out of the callback if you find anything else ... If you set the ButtonDownFcn against the axes containing the image, ... Once you have newfig available to draw into, ... the proper coordinate system. ...
    (comp.soft-sys.matlab)
  • callback problem: figure crashes
    ... I have a figure that contains two axes, ... WindowButtonUpFcn and WindowButtonMotionFcn callback properties ... I can enter a command at the Matlab ... like "error while executing callback". ...
    (comp.soft-sys.matlab)
  • Re: What happened to (undocumented) hittest()?
    ... ButtonDownFcn Callback for Axes Objects http://bit.ly/lYsprI ... WindowButtonMotionFcn callback it causes some unwanted side effects ... >> I found a few old posts here that talk about hittest() function (which ... >> I presume checks if mouse pointer is over the object). ...
    (comp.soft-sys.matlab)
  • Re: GUI handle user variable updating
    ... problem is not related to the axes. ... % Call subfunction that updates variable ... If I run this code (within the full GUI), ... returned to the callback. ...
    (comp.soft-sys.matlab)