Mercurial > hg > ishara
view general/algo/iterate_gui.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | beb8a3f4a345 |
children |
line wrap: on
line source
function iterate_gui(stfn,S0,varargin) % iterate_gui - iterate state transformer under GUI control % % iterate_gui :: % (A->A,handle) ~'state transformer function', % A ~'initial state' % -> gui. % % The idea is that the state transformer returns a handle to a % GUI element to be used for advancing the sequence. You click % on that element to move to the next element of the sequence. % Button 2 rewinds to the beginning of the sequence. % to do: user configurable keys to allow multiple plotseqs % in same figure, each watching different keys. opts=options('keyctl','set',varargin{:}); [S,h]=stfn(S0); set(h,'ButtonDownFcn',@btndn); switch opts.keyctl case 'set', addkbcallback(gcf), addkbcallback(gcf,@keypress); case 'add', addkbcallback(gcf,@keypress); end function next() if isempty(S), beep; else [S,h]=stfn(S); set(h,'ButtonDownFcn',@btndn); end end function rewind(), [S,h]=stfn(S0); set(h,'ButtonDownFcn',@btndn); end function btndn(a,b) if strcmp(get(gcf,'SelectionType'),'alt'), rewind(); else next(); end end function keypress(b) switch b.Character case {'b','r'}, rewind(); case {' ','n'}, next(); end end end % of main function