1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| function testgui
fig = figure('Numbertitle', 'Off', 'Name', 'Simulateur du systéme VOR ');
movegui(fig, 'center')
% Bouton page precedente
handles.buttonprev = uicontrol('style','pushbutton', 'units', 'normalized', 'position', [0.05 0.05 0.1 0.05], ...
'string', 'Retour', 'callback', {@changepage -1}, 'visible', 'off');
% Bouton page suivante
handles.buttonnext = uicontrol('style','pushbutton', 'units', 'normalized', 'position', [0.85 0.05 0.1 0.05], ...
'string', 'OK', 'callback', {@changepage +1}, 'visible', 'on');
% Objet sur la page 1
handles.object(2) = uibuttongroup('position',[.1 .1 .5 .5]);
uicontrol('style', 'radio', 'parent', p, 'position', [10 50 50 20])
uicontrol('style', 'radio', 'parent', p, 'position', [10 10 50 20])
handles.objectvisibiliy(1) = 1;
% Objet sur la page 2
handles.object(2) = uipanel('title', 'Page 2', 'units', 'normalized', 'position', [0.2 0.2 0.7 0.7], ...
'visible', 'off');
handles.objectvisibiliy(2) = 2;
% Objet sur la page 3
handles.object(3) = uicontrol('style', 'text', 'units', 'normalized', 'position', [0.3 0.3 0.6 0.4], ...
'string', 'Page 3', 'visible', 'off');
handles.objectvisibiliy(3) = 3;
% Objet sur la page 4
handles.object(4) = subplot(2, 2, 1, 'visible', 'off');
handles.object(5) = subplot(2, 2, 2, 'visible', 'off');
handles.object(6) = subplot(2, 2, 3, 'visible', 'off');
handles.object(7) = subplot(2, 2, 4, 'visible', 'off');
handles.objectvisibiliy(4:7) = 4;
% Numero de page courante
handles.currentpage = 1;
% Nombre maxi de pages
handles.maxpage = 4;
guidata(fig, handles);
function changepage(obj, event, incr)
fig = get(obj, 'parent');
handles = guidata(fig);
% Changement de page + ou -
handles.currentpage = handles.currentpage+incr;
% Ne rien faire si on se trouve sur la page 1 ou la page max
if handles.currentpage<1 || handles.currentpage>handles.maxpage
return
end
set(fig, 'Name', sprintf('Simulateur du système VOR', handles.currentpage));
% Visibilite du bouton page precedente
if handles.currentpage == 1
set(handles.buttonprev, 'visible', 'off');
else
set(handles.buttonprev, 'visible', 'on');
end
% Visibilite du bouton page suivante
if handles.currentpage == handles.maxpage
set(handles.buttonnext, 'visible', 'off');
else
set(handles.buttonnext, 'visible', 'on');
end
% Recherche des indices des objets presents sur la page courante
idx = handles.objectvisibiliy == handles.currentpage;
% Objets presents sur la page courante => visible
set(handles.object(idx), 'visible', 'on');
% Objets non presents sur la page courante => invisible
set(handles.object(~idx), 'visible', 'off');
guidata(fig, handles); |
Partager