Rendering problem with axes in nested uipanels

조회 수: 5 (최근 30일)
Jochen Smolka
Jochen Smolka 2014년 5월 19일
답변: Thomas 2015년 12월 1일
Hi,
I'm encountering a problem with uipanel and graphics objects inside it. Basically, I have a gui with one main uipanel, and a number of smaller uipanels that are children of this "super"-panel. Each of the small panels contains a few buttons and an axes object with an image in it. I then want to move the superpanel and all its children programmatically (the aim is to use a slider to scroll through it, but that is not really important). However, when I do that, the axes object does not move properly. It stays in the spot where it was last drawn (e.g. after drawnow or a pause in the program). How can I fix this behaviour? Solutions I've tried so far:
i) using just one panel instead of two nested panels. This seems to solve the problem, everything is drawn correctly, but this is not practical in my program.
ii) using different renderer's. This seems to make the problem worse; all sorts of other clipping problems occur.
iii) Calling drawnow does not help.
iv) Saving the figure or calling print resolves the problem. If I step through print, I can see that the call that resolves the problem is
line 276 pj = render(pj,pj.Handles{i});
However, I can't call the private function render from outside (and this doesn't seem like a very elegant or practical solution). Is there any other way I can force a rendering update?
Any help would be appreciated. Sample code to reproduce the problem and a screenshot of the result can be found below.
Thanks!
P.S.: I'm working in 2014a on Windows 7
I = imread('ngc6543a.jpg'); %read image
fh = figure(1); %create figure
clf;
sp = uipanel('parent', fh, 'position', [.2 .3 .4 .4]); %create superpanel
ph = uipanel('parent', sp, 'position', [.1 .1 .8 .8]); %create sub-panel
ah = axes('parent', ph, 'position', [0 0 1 1]); %create axes object
image(I, 'parent', ah); %draw image
drawnow
set(sp, 'position', [.1 .1 .4 .4]) %move superpanel
  댓글 수: 1
sejo
sejo 2014년 11월 25일
have the same problem. did you find a solution?

댓글을 달려면 로그인하십시오.

답변 (1개)

Thomas
Thomas 2015년 12월 1일
I ran into the same issue in 2012b (axes in nested panel doesn't move with parent), while trying to make backward compatible a programmatic GUI that works fine in 2015a. What a brain buster! Knowing that this issue is still unresolved, I guess I'll just have to ask them to upgrade... Moving forward it would be nice if sliders could be inserted automatically as an option (for parent figures, tabs, panels) when object positions extend beyond their parents.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by