GUI panels moving around upon updating axes

1 view (last 30 days)
I am writing a GUI based program that has several panels and one set of axes. As the primary calculation function runs, the axes are updated to show the physical state of the system (using plot > drawnow). The problem is, each time the axes are updated, all of the panels and objects nested within them scale in size, shift a bit, then shift back to the correct position and size shortly after. Since the axes are updated 50 times per execution, this is pretty irritating and I'd like to find a solution.
  3 Comments
Anthony Mora
Anthony Mora on 22 May 2017
Edited: Anthony Mora on 22 May 2017
Well, I didn't find out why this was occurring, but I figured out what was causing it. I had been using getframe upon each iteration that the plot was supposed to update, and this caused the shifting/resizing problem. I have since found a way around using getframe so this issue is no longer plaguing me, but I would like to see if anyone knows anything more about why getframe would have caused this behavior.
Walter Roberson
Walter Roberson on 23 May 2017
Odd... what is your figure Renderer set to? There is the possibility that getframe might switch Renderer temporarily, and that could lead to changes in output.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 17 May 2017
I think you might be encountering a SizeChangedFcn . Perhaps a ResizeFcn, but that seems less likely to me. See some hints:
and see
If you have multiple property changes, sometimes the way to deal with the situation is to make the object (or container) visible off, make the several changes, and then set visible on again.
My work on HG1 showed that unless you did a drawnow() or pause(), it was common for the old appearance (with the object still visible) to persist for long enough that the changes to effectively happen as a batch, everything updating at once -- just as one might hope would happen. But this was not something that could be counted on: if you did "enough" computation before making the object visible again, then it would update "by itself".
Another way of putting this is that using drawnow() or pause() to flush the event queue would typically (but not always) trigger an update that would have the object go invisible while you were working on it, but that if you do not signal that you want the event queue flushed, then typically the graphics would not update until you so signaled. But this is not foolproof: the event queue can end up getting acted upon even outside of the conditions specifically defined as giving an opportunity for it to be paid attention to.
  1 Comment
Anthony Mora
Anthony Mora on 18 May 2017
Reading about SizeChangedFcn and ResizeFcn makes me think that it is the same thing. However, I don't think that your proposed solution worked. Unfortunately, I cannot share the actual code since it is proprietary and confidential. Essentially what I tried to do was:
set(container/object,'visible','off')
[insert calculations/operations]
set(container/object,'visible','on')
I tried the above with and without drawnow, and all I got from this was objects disappearing, reappearing, resizing incorrectly, then resizing correctly, then repeating. Perhaps I did not properly implement what you suggested?

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!