Reputation: 190
i want to display photo above the panel , i see the documentation here : http://www.mathworks.com/help/matlab/ref/uistack.html but it only mention how to use this function (uistack) only in figure
my program till now :
my code :
function varargout = panel(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @panel_OpeningFcn, ...
'gui_OutputFcn', @panel_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
handles.output = hObject;
guidata(hObject, handles);
function varargout = panel_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
k = 1;
[filename pathname] = uigetfile({'*.*'},'File Selector','MultiSelect', 'on')
iscellstr(filename)
celldata1 = cellstr(pathname)
celldata2 = cellstr(filename)
celldata3 = strcat(celldata1,celldata2)
subplot(3,4,1),imshow(celldata3{1})
subplot(3,4,2),imshow(celldata3{2})
subplot(3,4,3),imshow(celldata3{3})
subplot(3,4,4),imshow(celldata3{4})
subplot(3,4,5),imshow(celldata3{5})
subplot(3,4,6),imshow(celldata3{6})
Upvotes: 2
Views: 397
Reputation: 5175
I'm not sure I've correctly undestood what you need, nevertheless ...
you can first create the panel (uipanel
) specifying its position (which includes size), then create as many axes as you need (consider the number of imagery you want to add) in order to crate a sort of chessboard (you can do this by properly setting their position and size).
You can now load the images over the axis by specifying the parent
property.
In the following example I create a uipanel which contains three images, notice the coupling "axes-handle - parent property" in the calls to imshow.
In the "pushbutton1_Callback
" of your code, you can "automate" this procedure.
uipanel ('position', [0 0 0.33 0.95],'title','PLOK');
a1=axes('position',[0 0 .3 .3])
a2=axes('position',[0 0.3 .3 .3])
a3=axes('position',[0 0.6 .3 .3])
imshow('curva_con_linee_verticali.jpg','parent',a1)
imshow('grafico_3d_assi_cartesiani.jpg','parent',a2)
imshow('prod_punt.jpg','parent',a3)
This is how the Figure looks like (the three graphs are actually three jpg images):
Hope this helps.
Upvotes: 0
Reputation: 5672
The reason I asked for the version was that if you were using an older version (than R2014b) you could set the BackgroundColor
property of the uipanel
to be 'none' which would make it transparent. This "feature" doesn't work in R2014b onwards...
%% Only HG1 (pre R2014b)
f = figure;
subplot ( 3, 3, 4 )
uipanel ( 'parent', f, 'Position', [0. 0. 0.6 0.6], 'BackgroundColor', 'none' );
Im afraid other options will require more knowledge of how GUI's work - specifically creating GUI's from the commandline (and not in GUIDE):
% Create a figure
f = figure;
% Create a uicontainer (this is a way of grouping controls together
uic = uicontainer ( 'parent', f, 'position', [0.1 0.1 0.5 0.5] );
% Create an axes -> which is a child of the UICONTAINER
ax = axes ( 'parent', uic, 'position', [0 0 1 1] );
% Create a uipanel -> which is a chilf of the FIGURE
uipanel ( 'parent', f, 'position', [0 0 0.4 0.7] );
% Some data to plot
image(rand(100)*255,'parent',ax)
% Note at this point the axes is underneath the uipanel
%%
% Hey presto we can move the uicontainer to the top and the axes appears! :)
uistack ( uic, 'top' )
Note: If you create the uicontainer
after creating the uipanel
then you dont need to use uistack
- I put it in that order to show that uistack will move the 'axes' in the stack order...
Upvotes: 1