필터 지우기
필터 지우기

How can I use scrollbars in MATLAB figure windows when viewing large GUIs?

조회 수: 68 (최근 30일)
I have large GUIs and images that I want to look at, but not all at once. I would like to be able to use the window scrollbars to scroll through these figures.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2012년 2월 23일
The ability to use scrollbars in MATLAB figure windows when viewing large GUIs is not available.
As a workaround for this issue:
1) Create a uipanel() on your figure, the size of the viewing area.
2) Create a second uipanel() whose Parent is the first uipanel, and which is big enough to contain all of the data.
3) Draw your images, making sure that their Parent is the second uipanel.
4) Now configure the Callback on your scrollbar so that it changes the Position of the second uipanel. The edges of the first uipanel will "clip" the visibility of the second uipanel so that only the portion of the second uipanel that is behind the "window" that is the size of the first uipanel will be visible.
NOTE: The 'Painters' renderer must be used for clipping to work. Clipping also does not affect UICONTROLS.
Code example:
figure(1)
panel1 = uipanel('Parent',1);
panel2 = uipanel('Parent',panel1);
set(panel1,'Position',[0 0 0.95 1]);
set(panel2,'Position',[0 -1 1 2]);
h = image;
set(gca,'Parent',panel2);
s = uicontrol('Style','Slider','Parent',1,...
'Units','normalized','Position',[0.95 0 0.05 1],...
'Value',1,'Callback',{@slider_callback1,panel2});
Callback function:
function slider_callback1(src,eventdata,arg1)
val = get(src,'Value');
set(arg1,'Position',[0 -val 1 2])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by