Problem with scrollable panel with clipped axes on it

2 views (last 30 days)
Hello everyone, i have a problem by trying to implement a scrollable panel with axes on it. In my gui i let the user load image files in a linked list. The main image shall be shown on the right side of the figure on the mainpanel. On the leftside of the figure is a scrollabe panel on which the axes are created and the image files are loaded. The Problem ist that the axes on the leftpanel are not on the position they should be. Also the first axes resizes when the panel is scrolled out of the window. As you can see i have tried to set several properties of the axes to manual and also tried to freeze the size with axis ('manual'); I would be very thankfull if somebody could help me, im a poor student that is unexperienced matlab. attached : pics of the leftpanel and the Problem when moved and the commandwindow with fprintf output.
Function that rebuilds the panels when files are loaded or deleted :
function buildGUI(obj)
obj.length_list = lengthList(obj);
node = obj.ldcm{obj.firstListIndx};
%%build mainpanel + axis
obj.mainPan = uipanel('Parent',obj.fig,'Units','normalized','Position',[0.3, 0, 1, 1]);
node.ha = axes('Parent',obj.mainPan,'Position',[-0.15 0 1 1]); %left -0.15 ??
node.data.cur_vars.slice = ceil(node.data.par_vars.sizeimdata(3)/2);
node.hi = imshow( node.data.curImdata(:,:,node.data.cur_vars.slice), ...
[], 'Parent',node.ha,'Border','tight');
hold on
delete(obj.leftPan)
delete(obj.uicScrbar)
%number of objects on second panel
numPan2 = obj.length_list-1;
obj.length_leftPan = numPan2/2 ; %one iamge on leftPan shall be 0.5 'tall'
%redefine scrollbar object
obj.uicScrbar = uicontrol('Parent',obj.mainPan,'Units','normalized', ...
'Position',[0, 0, .02, 1],'Style','Slider','Max',0,...
'Min',-obj.length_leftPan,'Value',0);
addlistener(obj.uicScrbar,'Value','PreSet',@(src,evt)update_imPos(obj));
%redefine scrollbar object
if(obj.ldcm{obj.firstListIndx}.data.cur_vars.sizeimdata(4) > 1)
obj.uicScrbarMain = uicontrol('Parent',obj.mainPan,'Units','normalized', ...
'OuterPosition',[.034, 0, .035, 1],'Style','Slider','Max',-1,...
'Min',-obj.ldcm{obj.firstListIndx}.data.cur_vars.sizeimdata(4),'Value',-1 );
addlistener(obj.uicScrbarMain,'Value','PreSet',@(src,evt)update_main(obj));
end
%%build leftpanel
obj.leftPan = uipanel('Parent',obj.fig,'Units','normalized', ...
'Position',[0, 0, 0.3, obj.length_leftPan],'BackGroundColor','Red');
%%create axis and image on leftpanel
fprintf('obj.length_leftPan=%f \n',obj.length_leftPan);
fprintf('numPan2 = %i \n',numPan2);
for ii=2:obj.length_list
node = node.Next;
delete(node.ha);
delete(node.hi);
node.data.cur_vars.slice = floor(size(node.data.parImdata,3) /2);
node.ha = axes('Parent',obj.leftPan,'units','normalized', ...
'PlotBoxAspectRatioMode','manual','PlotBoxAspectRatio',[1 1 1], ...
'OuterPosition',[0 (ii-2)/numPan2 1 (ii-1)/numPan2 ], ...
'ActivePositionProperty','OuterPosition','ClippingStyle','rectangle' );
axis ('manual')
axis([0 node.data.par_vars.sizeimdata(1) 0 node.data.par_vars.sizeimdata(2)])
hold(node.ha,'on');
fprintf('OuterPosition axes %i =[%f %f %f %f]\n',ii-1,0,(ii-2)/numPan2,1,(ii-1)/numPan2);
end
end

Accepted Answer

Niraj Gadakari
Niraj Gadakari on 26 Sep 2017
I am entirely not sure about what you are trying to achieve. You can align the UI components by using the "align" function. Here is the link to documentation for "align" function.
Could you clarify the following:
1. What is expected when you say axes on the left panel are not on the position they should be? Can you add a screenshot and clarify this?
2. You said that first axis is resized when the panel is scrolled, can you elaborate what is it resized to along with screenshots?
  2 Comments
Sebastian Nowak
Sebastian Nowak on 27 Sep 2017
Thank you for your quick reply, I have found my Problm yesterday. i missunderstood the position property of the axis and the panel. Its [left botton widht height] and bot [left botton right top]. This leaded me to Change the Position(4) property of the left Panel which should be scrollable. And by changing Position(4) i did not relocate the Panel in respect to the parent figure, i resized it and that caused my problem. Again thank you for your reply. Best regards
Sebastian Nowak
Sebastian Nowak on 27 Sep 2017
Screenshots of the initial problem should be added.

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks 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!