samer@0: function u=construct(s,sizes_in) samer@0: fg=fig(s); figure(fg); samer@0: ax=gca; samer@0: samer@0: current_pos={}; %[nan;nan]; samer@0: btnisup=1; samer@0: samer@0: if ~isempty(s.opts.xlim), xlim(s.opts.xlim); end samer@0: if ~isempty(s.opts.ylim), xlim(s.opts.ylim); end samer@0: if isfield(s.opts,'ylabel'), ylabel(s.opts.ylabel); end samer@0: if isfield(s.opts,'xlabel'), xlabel(s.opts.xlabel); end samer@0: if isfield(s.opts,'box'), box(s.opts.box); end samer@0: samer@0: u=mkunit(s); samer@0: u.process=@proc; samer@0: u.sizes_out = {[2,1]}; samer@0: u.dispose = @dispose; samer@0: u.starting = @starting; samer@0: u.stopping = @stopping; samer@0: samer@0: function starting samer@0: set(ax,'ButtonDownFcn',@btndown); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: samer@0: function stopping samer@0: set(ax,'ButtonDownFcn',[]); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: samer@0: function x=proc, samer@0: x=current_pos; samer@0: if btnisup, current_pos={}; end % [nan;nan]; end samer@0: end samer@0: samer@0: function btndown(a,b), samer@0: set(fg,'WindowButtonMotionFcn',@move,'WindowButtonUpFcn',@btnup); samer@0: btnisup=0; samer@0: move(a,b); samer@0: end samer@0: function btnup(a,b), set(fg,'WindowButtonMotionFcn',[]); btnisup=1; end samer@0: function move(a,b), cp=get(ax,'CurrentPoint'); current_pos={cp(1,1:2)'}; end samer@0: samer@0: function dispose samer@0: set(ax,'ButtonDownFcn',[]); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: end